You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by ad...@apache.org on 2006/02/28 17:05:47 UTC
svn commit: r381686 [31/40] - in /incubator/ode/scratch/bpe: ./ bpelTests/
bpelTests/probeService/ bpelTests/test1/ bpelTests/test10/
bpelTests/test12/ bpelTests/test13/ bpelTests/test14/ bpelTests/test15/
bpelTests/test16/ bpelTests/test17/ bpelTests/...
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/SimpleRequestMessageEvent.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/SimpleRequestMessageEvent.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/SimpleRequestMessageEvent.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/SimpleRequestMessageEvent.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,51 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.event;
+
+import com.sybase.bpe.util.BPException;
+
+public class SimpleRequestMessageEvent
+ extends SimpleMessage
+ implements IRequestMessageEvent
+{
+
+ static final long serialVersionUID = -1669122486254031924L;
+
+
+ private IStaticKey m_staticKey = null;
+
+ public void setStaticKey( IStaticKey iKey )
+ {
+ m_staticKey = iKey;
+ }
+
+ public IStaticKey getStaticKey() throws BPException
+ {
+ return m_staticKey;
+ }
+
+ public IResponseMessage createResponseMessage() throws BPException
+ {
+ return new SimpleResponseMessage();
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/SimpleResponseMessage.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/SimpleResponseMessage.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/SimpleResponseMessage.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/SimpleResponseMessage.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,75 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.event;
+
+import java.util.Iterator;
+
+
+public class SimpleResponseMessage extends SimpleMessage implements IResponseMessage
+{
+
+ static final long serialVersionUID = 8801756730504584727L;
+
+ private Fault m_fault;
+
+ public boolean hasFault()
+ {
+ if ( getFault() == null )
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public Fault getFault()
+ {
+ return m_fault;
+ }
+
+ public void setFault( Fault iFault )
+ {
+ m_fault = iFault;
+ }
+
+ public String toString() {
+ StringBuffer buf =
+ new StringBuffer("Fault Message:" + this.getFault() + "\n");
+ Iterator it = this.getPartMap().keySet().iterator();
+ while (it.hasNext()) {
+ String name = it.next().toString();
+ try {
+ buf.append(
+ "Part \""
+ + name
+ + "\" value: "
+ + this.getPart(name).toString()
+ + "\n");
+ } catch (Exception e) {
+ buf.append(
+ "Part \"" + name + "\" value: " + e.getLocalizedMessage());
+ }
+
+ }
+ return buf.toString();
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/StateEvent.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/StateEvent.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/StateEvent.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/StateEvent.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,125 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.event;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+import com.sybase.bpe.engine.IEvaluationContext;
+import com.sybase.bpe.engine.IProcessCallBack;
+import com.sybase.bpe.engine.ProcessInstance;
+import com.sybase.bpe.engine.StateEnum;
+import com.sybase.bpe.util.BPException;
+
+
+/**
+ * @author waterman
+ *
+ * The StateEvent changes the state of a business process. This is an internal
+ * event and will not be exposed to external clients.
+ *
+ * It is used by the BPEE to start a parallel thread of execution. The
+ * BPEE passes a StateEvent on the BPED callback interface when it needs to
+ * start a process.
+ *
+ */
+public class StateEvent extends ProcessInstanceEvent implements Serializable {
+
+ static final long serialVersionUID = -538982297121415925L;
+
+ public static String PROCESS_STATE_NAME = "ProcessState";
+ private StateEnum state;
+
+ /**
+ * Constructor for StateEvent.
+ *
+ * @param pKey - the process instance on which a state change is being
+ * requested
+ * @param state - the state being applied to the pKey
+ */
+ public StateEvent(String rootKey, String pKey, StateEnum state) {
+ super(rootKey, pKey);
+ this.state = state;
+ }
+
+ public StateEvent() {
+ super();
+ state = null;
+ }
+
+ /** @param properties */
+ public void init(java.util.Properties attributes) throws EventException {
+ super.init(attributes);
+
+ Object obj = attributes.get(PROCESS_STATE_NAME);
+
+ if ( obj instanceof StateEnum ) {
+ state = (StateEnum)obj;
+ } else {
+ throw new EventException("INVALID_PROCESS_STATE",new Object[] {obj});
+ }
+
+ }
+
+ public void apply(ProcessInstance processInstance, IEvaluationContext ec, IProcessCallBack pcb) throws BPException {
+ // make sure the process matches it's intended target
+ super.apply(processInstance,ec, pcb);
+
+ processInstance.setState(state);
+
+ if ( state.equals(StateEnum.TERMINATED)) {
+ processInstance.terminate(ec,pcb);
+// mark the process for clean up
+ ec.getProcessService().getInstanceService().
+ getInstance(
+ processInstance.getRootKey(),
+ processInstance.getRootKey()).setMarkedForCleanUp(true);
+ }
+
+ }
+
+ /**
+ * @see com.sybase.bpe.event.Event#getAttributes()
+ */
+ public Properties getAttributes() {
+ Properties retVal = super.getAttributes();
+ retVal.put(PROCESS_STATE_NAME,state);
+ return retVal;
+ }
+
+ /**
+ * Returns the state.
+ * @return StateEnum
+ */
+ public StateEnum getState() {
+ return state;
+ }
+
+ /**
+ * Set the state
+ */
+ public void setState(StateEnum state) {
+ this.state = state;
+ }
+
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/TimerEvent.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/TimerEvent.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/TimerEvent.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/TimerEvent.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,100 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Aug 25, 2003
+ *
+ */
+package com.sybase.bpe.event;
+
+/**
+ * @author charper
+ *
+ */
+public class TimerEvent implements ITimerEvent {
+
+ static final long serialVersionUID = -4310489553355459222L;
+
+ String rootId;
+ String procId;
+ String defId;
+ String rootDefId;
+
+ /**
+ * @return Returns the rootDefId.
+ */
+ public String getRootDefId() {
+ return rootDefId;
+ }
+ /**
+ * @param rootDefId The rootDefId to set.
+ */
+ public void setRootDefId(String rootDefId) {
+ this.rootDefId = rootDefId;
+ }
+ /**
+ * @return Returns the defId.
+ */
+ public String getDefId() {
+ return defId;
+ }
+ /**
+ * @param defId The defId to set.
+ */
+ public void setDefId(String defId) {
+ this.defId = defId;
+ }
+ public TimerEvent ( String rootId, String procId, String rootDefId, String defId ) {
+ this.rootId = rootId;
+ this.procId = procId;
+ this.rootDefId = rootDefId;
+ this.defId = defId;
+ }
+
+ /**
+ * @return
+ */
+ public String getProcId() {
+ return procId;
+ }
+
+ /**
+ * @return
+ */
+ public String getRootId() {
+ return rootId;
+ }
+
+ /**
+ * @param string
+ */
+ public void setProcId(String string) {
+ procId = string;
+ }
+
+ /**
+ * @param string
+ */
+ public void setRootId(String string) {
+ rootId = string;
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/UnsupportedInteractionTypeException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/UnsupportedInteractionTypeException.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/UnsupportedInteractionTypeException.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/event/UnsupportedInteractionTypeException.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,31 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.event;
+public class UnsupportedInteractionTypeException extends EventException
+{
+ static final long serialVersionUID = 2282121520764580017L;
+
+
+ public UnsupportedInteractionTypeException() {
+ super("UNSUPPORTED_INTERACTION_TYPE",null);
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/info/PackageInfoBean.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/info/PackageInfoBean.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/info/PackageInfoBean.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/info/PackageInfoBean.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,96 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.info;
+
+import java.util.Properties;
+//import java.util.logging.Logger;
+
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+import javax.naming.Binding;
+import javax.naming.InitialContext;
+import javax.naming.NamingEnumeration;
+
+/**
+ * This bean holds properties about the package.
+ * @ejb:bean
+ * type="Stateless"
+ * name="PackageInfo"
+ * jndi-name="BPE/PackageInfo"
+ * view-type="both"
+ * local-jndi-name="BPE/PackageInfoLocal"
+ *
+ * @ejb.transaction type="Supports"
+ *
+ * @ejb.env-entry
+ * name="PACKAGE_NAME"
+ * value="BPE"
+ * @ejb.env-entry
+ * name="PACKAGE_EAR_NAME"
+ * value="BPE.ear"
+ * @ejb.env-entry
+ * name="TABLE_PREFIX"
+ * value="BPE"
+ *
+ *
+ *
+ */
+public class PackageInfoBean implements SessionBean {
+
+ static final long serialVersionUID = -2575868371338788524L;
+
+// private static Logger logger = Logger.getLogger(PackageInfoBean.class
+// .getName());
+ /**
+ * @ejb:interface-method
+ */
+ public Properties getProperties() {
+ Properties props = new Properties();
+ try {
+ InitialContext ic = new InitialContext();
+ NamingEnumeration e = ic.listBindings("java:comp/env");
+ while (e.hasMore()) {
+ Binding b = (Binding) e.next();
+ props.put(b.getName(), b.getObject().toString());
+ }
+
+ } catch (Exception ex) {
+ throw new EJBException(ex.getLocalizedMessage(), ex);
+ }
+ return props;
+ }
+ public void ejbCreate() {
+ }
+ public void setSessionContext(SessionContext ctx) {
+ }
+ public void ejbRemove() {
+ }
+ public void ejbActivate() {
+ }
+ public void ejbPassivate() {
+ }
+ public void ejbLoad() {
+ }
+ public void ejbStore() {
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/inmemory/jndi/IMContext.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/inmemory/jndi/IMContext.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/inmemory/jndi/IMContext.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/inmemory/jndi/IMContext.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,471 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Sep 23, 2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package com.sybase.bpe.inmemory.jndi;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.text.DateFormat;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.zip.DataFormatException;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.OperationNotSupportedException;
+import javax.naming.directory.InvalidAttributesException;
+import javax.resource.spi.ManagedConnectionFactory;
+
+/**
+ * @author jjin
+ *
+ * This class is used to overload the initialContext call, and right now
+ * it is only overload the initialContext call for RAs
+ */
+public class IMContext implements Context {
+
+ private static final String PROPERTY_FILE_NAME_PART = ".properties";
+ private static final String RA_MANAGED_CONNECTION_FACTORY_NAME = "RAManagedConnectionFactoryName";
+ private static final String RA_PROPERTY_SET_METHOD_PART = "set";
+ private static final String RA_CREATE_CONNECTION_FACTORY_METHOD_NAME = "createConnectionFactory";
+ private static final String FILE_SEPERATER1 = "\\";
+ private static final String FILE_SEPERATER2 = "/";
+ private static final String PROPERTY_VALUE_TYPE_PART = "_PROPERTY_VALUE_TYPE";
+
+ private static Logger logger =
+ Logger.getLogger(IMContext.class.getName());
+
+ private static Map managedConnectionFactoryCache = Collections.synchronizedMap(new HashMap());
+
+ public IMContext() {
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#lookup(javax.naming.Name)
+ */
+ public Object lookup(Name name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#lookup(java.lang.String)
+ */
+ public Object lookup(String name) throws NamingException {
+
+ // charper 11-03-03
+ // cache the managed connection factories
+ Object retValue = managedConnectionFactoryCache.get(name);
+ if ( retValue != null ) {
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Got cached object for ->" + name);
+ }
+ return retValue;
+ }
+
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("Calling IMContext for look up->" + name);
+ }
+
+
+
+ // get file seperator
+ String fileSeperator = System.getProperty("file.separator");
+ // find file seperator
+ int pos = name.lastIndexOf(fileSeperator);
+ // get ra info file name part
+ // for all ra look up in format java:comp/env/...., only the
+ // last part after last "/" will be used as property file
+ // name part
+ String raInfoFileName = name;
+ if (pos != -1) {
+ // found "/" or "\"
+ if (pos + fileSeperator.length() < name.length()) {
+ // has valid part after file seperator
+ // get the part after file seperator
+ raInfoFileName = name.substring(pos + fileSeperator.length());
+ }
+ } else {
+ // not find "/" or "\"
+ if (fileSeperator.equals(FILE_SEPERATER1) == true) {
+ // not find "\", try to find "/"
+ pos = name.lastIndexOf(FILE_SEPERATER2);
+ if (pos != -1) {
+ // found "/"
+ if (pos + FILE_SEPERATER2.length() < name.length()) {
+ raInfoFileName = name.substring(pos + FILE_SEPERATER2.length());
+ }
+ }
+ } else {
+ // not find "/", try to find "\"
+ pos = name.lastIndexOf(FILE_SEPERATER1);
+ if (pos != -1) {
+ if (pos + FILE_SEPERATER1.length() < name.length()) {
+ raInfoFileName = name.substring(pos + FILE_SEPERATER1.length());
+ }
+ }
+ }
+ }
+ // append name with ".properties"
+ raInfoFileName += PROPERTY_FILE_NAME_PART;
+
+ try {
+ // load ra property file
+
+ Properties props = new Properties();
+ getProperties(props,raInfoFileName);
+
+ // get managed connection factory name
+ String managedConnectionFactoryName = props.getProperty(RA_MANAGED_CONNECTION_FACTORY_NAME);
+ if (managedConnectionFactoryName == null) {
+ // managed connection factory name is required for overload
+ // initialContext for RAs, since right now we only overload
+ // initialContext for RAs, so we throw exception here. If
+ // later on we decide to overload initialContext for EJBs too,
+ // we will need to change this part of code
+ throw new InvalidAttributesException();
+ }
+ // remove processed property
+ props.remove(RA_MANAGED_CONNECTION_FACTORY_NAME);
+ try {
+ // get class for managed connection factory
+ Class managedConnectionFactoryClass = Class.forName(managedConnectionFactoryName);
+ // get an instance of managed connection factory
+ ManagedConnectionFactory managedConnectionFactory = (ManagedConnectionFactory)(managedConnectionFactoryClass.newInstance());
+
+ // get properties
+ while (props.size() > 0) {
+ Set keys = props.keySet();
+ Iterator iter = keys.iterator();
+
+ while (iter.hasNext()) {
+ // get property key
+ String key = (String)(iter.next());
+ int propertyValueTypePartIndex = key.indexOf(PROPERTY_VALUE_TYPE_PART);
+ if (propertyValueTypePartIndex != -1
+ && propertyValueTypePartIndex + PROPERTY_VALUE_TYPE_PART.length() == key.length()) {
+ continue;
+ }
+ // get property value
+ String value = (String)(props.getProperty(key));
+ // remove processed property
+ props.remove(key);
+
+ // check for property key type, if not find, using
+ // string
+ String typeKey = key + PROPERTY_VALUE_TYPE_PART;
+ String typeValue = "java.lang.String";
+ if (props.containsKey(typeKey) == true) {
+ typeValue = props.getProperty(typeKey);
+ props.remove(typeKey);
+ }
+
+ // construct method name, it should be "set" +
+ // key
+ String methodName = RA_PROPERTY_SET_METHOD_PART + key;
+
+ // method parameters' class
+ Class[] paramsCls = new Class[1];
+ paramsCls[0] = Class.forName(typeValue);
+ // parameters
+ Object[] params = new Object[1];
+
+ // handling property type
+ if (typeValue.equals("java.lang.String")) {
+ params[0] = value;
+ } else if (typeValue.equals("java.lang.Boolean")) {
+ params[0] = new Boolean(value);
+ } else if (typeValue.equals("java.lang.Byte")) {
+ params[0] = new Byte(Byte.parseByte(value));
+ } else if (typeValue.equals("java.lang.Character")) {
+ if (value.length() != 0) {
+ params[0] = new Character(value.charAt(0));
+ } else {
+ params[0] = null;
+ }
+ } else if (typeValue.equals("java.lang.Short")) {
+ params[0] = new Short(Short.parseShort(value));
+ } else if (typeValue.equals("java.lang.Integer")) {
+ params[0] = new Integer(Integer.parseInt(value));
+ } else if (typeValue.equals("java.lang.Long")) {
+ params[0] = new Long(Long.parseLong(value));
+ } else if (typeValue.equals("java.lang.Float")) {
+ params[0] = new Float(Float.parseFloat(value));
+ } else if (typeValue.equals("java.lang.Double")) {
+ params[0] = new Double(Double.parseDouble(value));
+ } else if (typeValue.equals("java.util.Calendar")) {
+ DateFormat df = DateFormat.getTimeInstance();
+ params[0] = df.parse(value);
+ } else {
+ throw new DataFormatException(String.class.getName() + "->" + typeValue);
+ }
+
+ // get the method
+ Method method = managedConnectionFactoryClass.getMethod(methodName, paramsCls);
+ // call the method to the RA managed connection factory instance
+ method.invoke(managedConnectionFactory, params);
+ break;
+ }
+ }
+ // call createConnectionFactory
+ Class[] paramsCls = new Class[0];
+ Method method = managedConnectionFactoryClass.getMethod(RA_CREATE_CONNECTION_FACTORY_METHOD_NAME, paramsCls);
+ Object[] params = new Object[0];
+ retValue = method.invoke(managedConnectionFactory, params);
+ } catch (Exception e) {
+ throw new NamingException(e.getClass().getName() + "->" + e.getLocalizedMessage());
+ }
+
+ } catch (IOException e) {
+ throw new NamingException(e.getClass().getName() + "->" + e.getLocalizedMessage());
+ }
+
+ // charper 11-03-03
+ // stick this in the cache
+ managedConnectionFactoryCache.put(name,retValue);
+
+ return retValue;
+ }
+
+ public static void getProperties(Properties props, String fileName) throws IOException {
+
+ String path = System.getProperty("java.naming.provider.url");
+ String resource;
+ if (path == null ) {
+ resource = fileName;
+ } else {
+ resource = path+"/"+fileName;
+ }
+ InputStream strm =
+ Thread.currentThread().getContextClassLoader().
+ getResourceAsStream(resource);
+ if ( strm == null ) {
+ strm = new FileInputStream(fileName);
+ }
+ props.load(strm);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#bind(javax.naming.Name, java.lang.Object)
+ */
+ public void bind(Name name, Object obj) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#bind(java.lang.String, java.lang.Object)
+ */
+ public void bind(String name, Object obj) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#rebind(javax.naming.Name, java.lang.Object)
+ */
+ public void rebind(Name name, Object obj) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#rebind(java.lang.String, java.lang.Object)
+ */
+ public void rebind(String name, Object obj) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#unbind(javax.naming.Name)
+ */
+ public void unbind(Name name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#unbind(java.lang.String)
+ */
+ public void unbind(String name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#rename(javax.naming.Name, javax.naming.Name)
+ */
+ public void rename(Name oldName, Name newName) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#rename(java.lang.String, java.lang.String)
+ */
+ public void rename(String oldName, String newName) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#list(javax.naming.Name)
+ */
+ public NamingEnumeration list(Name name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#list(java.lang.String)
+ */
+ public NamingEnumeration list(String name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#listBindings(javax.naming.Name)
+ */
+ public NamingEnumeration listBindings(Name name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#listBindings(java.lang.String)
+ */
+ public NamingEnumeration listBindings(String name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#destroySubcontext(javax.naming.Name)
+ */
+ public void destroySubcontext(Name name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#destroySubcontext(java.lang.String)
+ */
+ public void destroySubcontext(String name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#createSubcontext(javax.naming.Name)
+ */
+ public Context createSubcontext(Name name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#createSubcontext(java.lang.String)
+ */
+ public Context createSubcontext(String name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#lookupLink(javax.naming.Name)
+ */
+ public Object lookupLink(Name name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#lookupLink(java.lang.String)
+ */
+ public Object lookupLink(String name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#getNameParser(javax.naming.Name)
+ */
+ public NameParser getNameParser(Name name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#getNameParser(java.lang.String)
+ */
+ public NameParser getNameParser(String name) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#composeName(javax.naming.Name, javax.naming.Name)
+ */
+ public Name composeName(Name name, Name prefix) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#composeName(java.lang.String, java.lang.String)
+ */
+ public String composeName(String name, String prefix) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#addToEnvironment(java.lang.String, java.lang.Object)
+ */
+ public Object addToEnvironment(String propName, Object propVal) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#removeFromEnvironment(java.lang.String)
+ */
+ public Object removeFromEnvironment(String propName) throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#getEnvironment()
+ */
+ public Hashtable getEnvironment() throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#close()
+ */
+ public void close() throws NamingException {
+ }
+
+ /* (non-Javadoc)
+ * @see javax.naming.Context#getNameInNamespace()
+ */
+ public String getNameInNamespace() throws NamingException {
+ throw new OperationNotSupportedException();
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/inmemory/jndi/IMContextFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/inmemory/jndi/IMContextFactory.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/inmemory/jndi/IMContextFactory.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/inmemory/jndi/IMContextFactory.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,52 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Sep 23, 2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package com.sybase.bpe.inmemory.jndi;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.spi.InitialContextFactory;
+
+/**
+ * @author jjin
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class IMContextFactory implements InitialContextFactory {
+
+ public IMContextFactory() {
+ }
+ /* (non-Javadoc)
+ * @see javax.naming.spi.InitialContextFactory#getInitialContext(java.util.Hashtable)
+ */
+ public Context getInitialContext(Hashtable environment) {
+ return new IMContext();
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/inmemory/jndi/java/javaURLContextFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/inmemory/jndi/java/javaURLContextFactory.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/inmemory/jndi/java/javaURLContextFactory.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/inmemory/jndi/java/javaURLContextFactory.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,55 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Sep 24, 2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package com.sybase.bpe.inmemory.jndi.java;
+
+import java.util.Hashtable;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.spi.ObjectFactory;
+
+import com.sybase.bpe.inmemory.jndi.IMContext;
+
+/**
+ * @author jjin
+ *
+ * This class is needed because j2ee.jar has a jndi.properties which has
+ * "java.naming.factory.url.pkgs" defined. If we don't define this class,
+ * JNDI will go to j2ee's javaURLContextFactory to create a URL context
+ * for look up
+ */
+public class javaURLContextFactory implements ObjectFactory {
+ public javaURLContextFactory() {
+ }
+ public Object getObjectInstance(Object urlInfo,
+ Name name,
+ Context nameCtx,
+ Hashtable environment) {
+ return new IMContext();
+ }
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/IPMIProcess.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/IPMIProcess.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/IPMIProcess.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/IPMIProcess.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,116 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/***********************************************************************
+ * Module: IPMIProcess.java
+ * Author: waterman
+ * Purpose: Defines the Interface IPMIProcess
+ ***********************************************************************/
+
+package com.sybase.bpe.instance;
+
+import com.sybase.bpe.definition.IPMDProcess;
+import com.sybase.bpe.instance.service.InstanceService;
+import com.sybase.bpe.instance.service.InstanceServiceException;
+import com.sybase.bpe.scope.service.ScopePath;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * The interface defines attributes of process instance state. Process instances
+ * are managed by the InstanceService.
+ *
+ * @see InstanceService
+ * @author waterman
+ */
+public interface IPMIProcess
+{
+ /**
+ * A unique reference key of the process instance
+ * @return a unique reference key of the process instance
+ */
+ String getKey();
+ /**
+ * A unique reference key of the root process instance. Each process instance
+ * executes under the context of a root process instance.
+ * @return a unique reference key of the root process instance
+ */
+ String getRootKey();
+ /** the current state of a process instance.
+ *
+ * @see StateEnum
+ * @return
+ */
+ int getState();
+ void setState(int state);
+
+ /**
+ * identifies process instances that can be garbage collected
+ * @return true idicates it is safe to garbage collect
+ */
+ public boolean isMarkedForCleanUp();
+ public void setMarkedForCleanUp(boolean mark);
+
+ /**
+ * identifies process instances that require persistence
+ * @return true indicates a process instance does not require persistence
+ */
+ public boolean isStateless();
+
+ /**
+ * Returns the process definition object which holds metadata describing
+ * the process instance.
+ *
+ * @return the process definition object
+ * @throws DefinitionServiceException
+ * @throws InstanceServiceException
+ */
+ IPMDProcess getDefinition() throws BPException;
+
+ /**
+ * Creates a child process instance
+ *
+ * @param definition the process definition metadata that describes the child process
+ * @return a new process instance
+ * @throws InstanceServiceException
+ */
+ IPMIProcess createSubProcess(IPMDProcess definition) throws BPException;
+
+ /**
+ * Delete this process instance. This is really an indirect call to the instance service.
+ * @throws InstanceServiceException
+ */
+ void remove() throws BPException;
+
+ public boolean isPaused();
+
+ ScopePath getScopePath();
+ void setScopePath(ScopePath scopePath);
+
+ String getContextContainerId();
+ void setContextContaionerId(String id);
+
+ // need to track the context of the process
+ // executing in fault handler, compensation handler
+ // process etc.
+ String getExecutionContext();
+ void setExecutionContext(String executionCtx);
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/nonpersistent/PMIProcessTransientImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/nonpersistent/PMIProcessTransientImpl.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/nonpersistent/PMIProcessTransientImpl.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/nonpersistent/PMIProcessTransientImpl.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,222 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.instance.nonpersistent;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.sybase.bpe.definition.IPMDProcess;
+import com.sybase.bpe.definition.service.DefinitionService;
+import com.sybase.bpe.definition.service.DefinitionServiceException;
+import com.sybase.bpe.engine.ProcessDefinitionKey;
+import com.sybase.bpe.engine.StateEnum;
+import com.sybase.bpe.instance.IPMIProcess;
+import com.sybase.bpe.instance.service.InstanceServiceException;
+import com.sybase.bpe.instance.service.nonpersistent.InstanceServiceTransientImpl;
+import com.sybase.bpe.scope.service.IFCScopeInstance;
+import com.sybase.bpe.scope.service.ScopePath;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * Implements a stateless process instance node.
+ *
+ * @author waterman
+ */
+public class PMIProcessTransientImpl implements IPMIProcess {
+
+ private static Logger logger =
+ Logger.getLogger(PMIProcessTransientImpl.class.getName());
+
+ private String root;
+ private String key;
+ private String contextContainerId;
+ private String executionCtx = IFCScopeInstance.PROCESS;
+ private int state = StateEnum.UNSTARTED.getIntValue();
+ private ScopePath scopePath = new ScopePath();
+ private boolean markedForCleanUp;
+ private boolean isStateless;
+
+ private IPMDProcess pDefinition;
+ private InstanceServiceTransientImpl service;
+
+
+ public PMIProcessTransientImpl(String defKey, DefinitionService ds, InstanceServiceTransientImpl is)
+ {
+ ProcessDefinitionKey pdk = new ProcessDefinitionKey(defKey);
+ try {
+ pDefinition = ds.getProcessDefintion(pdk,pdk);
+ isStateless = ds.getRootDefinition(pdk).getIsStateless();
+ } catch (BPException e) {
+ }
+ root = String.valueOf(this.hashCode());
+ this.key = root;
+ this.contextContainerId = root;
+
+ service = is;
+ }
+
+
+ private PMIProcessTransientImpl(IPMDProcess pDef, String root,
+ InstanceServiceTransientImpl is, ScopePath scopePath, String ctxtid,
+ String executionCtx) {
+ pDefinition = pDef;
+ this.root = root;
+ this.service = is;
+ this.key = String.valueOf(this.hashCode());
+ this.scopePath = scopePath;
+ this.contextContainerId = ctxtid;
+ this.executionCtx = executionCtx;
+ }
+
+
+
+ public IPMIProcess createSubProcess(IPMDProcess definition)
+ throws BPException {
+
+ PMIProcessTransientImpl ret;
+ try {
+ ret = new PMIProcessTransientImpl(definition,root,service,
+ (ScopePath)scopePath.clone(), contextContainerId,
+ executionCtx);
+ } catch (CloneNotSupportedException e) {
+ throw new BPException("NATIVE_EXCEPTION",
+ new Object[] {"CloneNotSupportedException"},e);
+ }
+ // running a stateful business process in a stateless manager is
+ // for testing only.
+ if ( !isStateless && service != null ) {
+ service.addInstance(root,ret);
+ }
+
+ if ( logger.isLoggable(Level.FINE)) {
+ logger.fine("New instance:"+ret.getKey()+"(Parent:"+this.key+")");
+ }
+
+ return ret;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.IPMIProcess#remove()
+ */
+ public void remove() throws InstanceServiceException {
+ }
+
+ public boolean isMarkedForCleanUp() {
+ return markedForCleanUp;
+ }
+ public void setMarkedForCleanUp(boolean b) {
+ markedForCleanUp = b;
+ }
+
+ public String getRootKey() {
+ return root;
+ }
+
+ public int getState() {
+ return state;
+ }
+
+ public void setState(int i) {
+ state = i;
+ }
+
+
+ /**
+ * @see com.sybase.bpe.instance.IPMIProcess#getDefinition()
+ */
+ public IPMDProcess getDefinition() throws InstanceServiceException,
+ DefinitionServiceException {
+ return pDefinition;
+ }
+
+ /**
+ * @return
+ */
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * @see com.sybase.bpe.instance.IPMIProcess#isStateless()
+ */
+ public boolean isStateless() {
+ return true;
+ }
+
+
+
+ public boolean isPaused()
+ {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.IPMIProcess#getScopePath()
+ */
+ public ScopePath getScopePath(){
+ return scopePath;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.IPMIProcess#setScopePath(java.lang.String)
+ */
+ public void setScopePath(ScopePath scopePath){
+ this.scopePath = scopePath;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.IPMIProcess#getContextContainerId()
+ */
+ public String getContextContainerId() {
+ return contextContainerId;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.IPMIProcess#setContextContaionerId()
+ */
+ public void setContextContaionerId(String id) {
+ contextContainerId = id;
+
+
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.IPMIProcess#getExecutionContext()
+ */
+ public String getExecutionContext() {
+ return this.executionCtx;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.IPMIProcess#setExecutionContext(java.lang.String)
+ */
+ public void setExecutionContext(String executionCtx) {
+ this.executionCtx = executionCtx;
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/persistent/PMIProcessPersistentImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/persistent/PMIProcessPersistentImpl.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/persistent/PMIProcessPersistentImpl.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/persistent/PMIProcessPersistentImpl.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,267 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.instance.persistent;
+
+import java.io.Serializable;
+//import java.util.logging.Logger;
+
+import com.sybase.bpe.definition.IPMDProcess;
+import com.sybase.bpe.engine.ProcessDefinitionKey;
+import com.sybase.bpe.engine.StateEnum;
+import com.sybase.bpe.instance.IPMIProcess;
+import com.sybase.bpe.instance.service.persistent.InstanceServicePersistentImpl;
+import com.sybase.bpe.scope.service.IFCScopeInstance;
+import com.sybase.bpe.scope.service.ScopePath;
+import com.sybase.bpe.util.BPException;
+
+/**
+ * The persistent implementation of a business process activity
+ *
+ * @author waterman
+ */
+public class PMIProcessPersistentImpl implements IPMIProcess, Serializable {
+
+ static final long serialVersionUID = 4013280109638724771L;
+
+// private static Logger logger =
+// Logger.getLogger(PMIProcessPersistentImpl.class.getName());
+
+ // The persistent state of a business process node
+ private String key;
+ private String rootKey;
+ private String defKey;
+ private String contextContainerId;
+ private String executionCtx = IFCScopeInstance.PROCESS;
+ private int state = StateEnum.UNSTARTED.getIntValue();
+ private ScopePath scopePath = new ScopePath();
+
+ // transient cached services used by the business process node
+ private transient boolean markedForCleanUp;
+ private transient InstanceServicePersistentImpl service;
+ private transient IPMDProcess pDefinition;
+
+ public PMIProcessPersistentImpl () {
+ }
+
+
+ public PMIProcessPersistentImpl(String rootKey, String defKey,
+ InstanceServicePersistentImpl service)
+ {
+ key = service.getUUIDService().getUUID();
+ this.defKey = defKey;
+ // if this is the root use the same key
+ if ( rootKey == null ) {
+ this.contextContainerId = key;
+ this.rootKey = key;
+ ProcessDefinitionKey pdk = new ProcessDefinitionKey(defKey);
+ try {
+ pDefinition = service.getDefinitionService().getProcessDefintion(pdk,pdk);
+ } catch (BPException e) {
+ }
+ } else {
+ this.rootKey = rootKey;
+ }
+ this.service = service;
+ }
+
+ private PMIProcessPersistentImpl(String rootKey, IPMDProcess pDefKey,
+ InstanceServicePersistentImpl service, ScopePath scopePath, String ctxid,
+ String execCtx)
+ {
+ this(rootKey,pDefKey.getKey().getValue(),service);
+ pDefinition = pDefKey;
+ this.scopePath = scopePath;
+ this.contextContainerId = ctxid;
+ this.executionCtx = execCtx;
+ }
+
+
+ public IPMIProcess createSubProcess(IPMDProcess definition)
+ throws BPException {
+
+ PMIProcessPersistentImpl ret;
+ try {
+ ret = new PMIProcessPersistentImpl(this.getRootKey(),definition, service,
+ (ScopePath)scopePath.clone(), contextContainerId, executionCtx);
+ } catch (CloneNotSupportedException e) {
+ throw new BPException("NATIVE_EXCEPTION",
+ new Object[] {"CloneNotSupportedException"},e);
+ }
+ service.addInstance(this.getRootKey(),ret);
+ return ret;
+ }
+
+ /**
+ * Sets the callback interface to the instance service
+ *
+ * @param service
+ */
+ public void setProcessService(InstanceServicePersistentImpl service){
+ this.service = service;
+ }
+
+
+ /**
+ * @see com.sybase.bpe.instance.IPMIProcess#remove()
+ */
+ public void remove() throws BPException {
+ if (!rootKey.equals(key)) {
+ service.remove(rootKey,key);
+ }
+ }
+
+
+ public boolean isMarkedForCleanUp() {
+ return markedForCleanUp;
+ }
+ public void setMarkedForCleanUp(boolean b) {
+ markedForCleanUp = b;
+ }
+
+ /**
+ * @see com.sybase.bpe.instance.IPMIProcess#getDefinition()
+ */
+ public IPMDProcess getDefinition() throws BPException {
+
+ if ( pDefinition == null ) {
+ // For a stateful business process that went into event
+ // receive mode, the instance will need to reaquire a reference to
+ // its definition metadata.
+ PMIProcessPersistentImpl rootproc = (PMIProcessPersistentImpl)service.getInstance(this.rootKey,this.rootKey);
+
+ ProcessDefinitionKey pdk = new ProcessDefinitionKey(this.defKey);
+ ProcessDefinitionKey rpdk = new ProcessDefinitionKey(rootproc.defKey);
+ pDefinition = service.getDefinitionService().getProcessDefintion(pdk,rpdk);
+ }
+ return pDefinition;
+
+ }
+
+ /**
+ * @see com.sybase.bpe.instance.IPMIProcess#isStateless()
+ */
+ public boolean isStateless() {
+ return false;
+ }
+
+
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String string) {
+ key = string;
+ }
+
+ public String getRootKey() {
+ return rootKey;
+ }
+
+ public void setRootKey(String string) {
+ rootKey = string;
+ }
+
+ public String getDefKey() {
+ return defKey;
+ }
+
+ public void setDefKey(String string) {
+ defKey = string;
+ }
+
+ public int getState() {
+ return state;
+ }
+
+ public void setState(int i) {
+ state = i;
+ }
+
+ public boolean isPaused()
+ {
+ if ( getState() == StateEnum.PAUSED.getIntValue())
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.IPMIProcess#getScopePath()
+ */
+ public ScopePath getScopePath(){
+ return scopePath;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.IPMIProcess#setScopePath(java.lang.String)
+ */
+ public void setScopePath(ScopePath scopePath){
+ this.scopePath = scopePath;
+
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.IPMIProcess#getContextContainerId()
+ */
+ public String getContextContainerId() {
+ return contextContainerId;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.IPMIProcess#setContextContaionerId(java.lang.String)
+ */
+ public void setContextContaionerId(String id) {
+ contextContainerId = id;
+
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.IPMIProcess#getExecutionContext()
+ */
+ public String getExecutionContext() {
+ return executionCtx;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.IPMIProcess#setExecutionContext()
+ */
+ public void setExecutionContext(String executionCtx) {
+ this.executionCtx = executionCtx;
+
+ }
+
+
+
+
+
+
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/InstanceService.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/InstanceService.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/InstanceService.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/InstanceService.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,114 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/***********************************************************************
+ * Module: InstanceService.java
+ * Author: waterman
+ * Purpose: Defines the Interface InstanceService
+ ***********************************************************************/
+
+package com.sybase.bpe.instance.service;
+
+import java.util.Collection;
+
+import com.sybase.bpe.definition.IPMDRoot;
+import com.sybase.bpe.definition.service.DefinitionService;
+import com.sybase.bpe.engine.IEvaluationContext;
+import com.sybase.bpe.engine.IProcessCallBack;
+import com.sybase.bpe.engine.ProcessService;
+import com.sybase.bpe.instance.IPMIProcess;
+import com.sybase.bpe.util.BPException;
+import com.sybase.bpe.uuid.UUIDService;
+
+
+/**
+ * Manages IPMIProcess instances. The instance service manager creates and manages
+ * business process instances. It is dependent on the defintion service to acquire
+ * the metadata definition of a business process instance.
+ *
+ * @see IPMIProcess
+ * @see DefinitionService
+ * @author waterman
+ */
+public interface InstanceService
+{
+ /**
+ * process instances are reacquired from a definition reference key
+ *
+ * @param defkey the key for the requested definition
+ * @return a collection of IPMIProcess instances
+ * @throws BPException
+ */
+ public Collection getRootInstances(String defid) throws BPException;
+
+ /**
+ * A process instance is reacquired from a process reference key
+ *
+ * @param rootkey the root instance node of a business process
+ * @param key the current instance node of a business process
+ * @return a process node instance
+ * @throws BPException
+ */
+ public IPMIProcess getRootInstance(String rootkey) throws BPException;
+ public IPMIProcess getInstance(String rootkey, String key) throws BPException;
+ public IPMIProcess getInstanceForContext(String rootkey, String key) throws BPException;
+
+ public void pauseRootInstance(String rootkey) throws BPException;
+ public void resumeRootInstance(String rootkey) throws BPException;
+
+ /**
+ * Creates a business process root instance from a business process definition
+ *
+ * @param rootDefinition the root metadata node of a business process definition
+ * @return a process node instance
+ * @throws BPException
+ */
+ public IPMIProcess createRootInstance(IPMDRoot rootDefinition) throws BPException ;
+ /**
+ * The instance service holds a definition service which it uses to create
+ * new business process instance nodes.
+ *
+ * @return a reference to the definition service being used by the instance service
+ */
+ public DefinitionService getDefinitionService();
+ /**
+ * Initializes the instance service. The service is not available until it has
+ * been initialized.
+ *
+ * @param ds the business process definition service
+ * @param us the uuid service
+ */
+ public void init(DefinitionService ds, UUIDService us, ProcessService ps) throws BPException;
+ /**
+ * Called by the engine to let the service know a unit of work is being commited
+ *
+ * @param rootkey the reference key of a business process root instance
+ * @param ec
+ * @param pcb
+ * @throws BPException
+ */
+ public void update(String rootkey,IEvaluationContext ec, IProcessCallBack pcb) throws BPException;
+ /**
+ * Flush
+ *
+ */
+ public void init();
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/InstanceServiceException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/InstanceServiceException.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/InstanceServiceException.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/InstanceServiceException.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,57 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.instance.service;
+
+import com.sybase.bpe.util.BPException;
+
+/**
+ * @author waterman
+ *
+ *
+ *
+ */
+public class InstanceServiceException extends BPException {
+
+ static final long serialVersionUID = -1635622011915042931L;
+
+
+ /**
+ * @param message_id
+ * @param msgParams
+ */
+ public InstanceServiceException(String message_id, Object[] msgParams) {
+ super(message_id, msgParams);
+ }
+
+ /**
+ * @param message_id
+ * @param msgParams
+ * @param cause
+ */
+ public InstanceServiceException(
+ String message_id,
+ Object[] msgParams,
+ Throwable cause) {
+ super(message_id, msgParams, cause);
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/InstanceServiceFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/InstanceServiceFactory.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/InstanceServiceFactory.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/InstanceServiceFactory.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,84 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.instance.service;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.sybase.bpe.definition.service.DefinitionService;
+import com.sybase.bpe.definition.service.DefinitionServiceException;
+import com.sybase.bpe.definition.service.DefinitionServiceFactory;
+import com.sybase.bpe.engine.ProcessService;
+import com.sybase.bpe.util.BPEProperties;
+import com.sybase.bpe.util.BPException;
+import com.sybase.bpe.uuid.UUIDService;
+import com.sybase.bpe.uuid.UUIDServiceException;
+
+public class InstanceServiceFactory
+{
+
+ private static Logger logger =
+ Logger.getLogger(InstanceServiceFactory.class.getName());
+
+ /** @param properties */
+ public static InstanceService createInstanceService(BPEProperties props,
+ UUIDService us, ProcessService ps) throws InstanceServiceException, DefinitionServiceException, UUIDServiceException
+ {
+
+ DefinitionService ds = DefinitionServiceFactory.createDefinitionService(props,us);
+ return createInstanceService(props,ds,us,ps);
+ }
+
+ private static InstanceService createInstanceService(BPEProperties props,
+ DefinitionService ds, UUIDService us, ProcessService ps) throws InstanceServiceException, DefinitionServiceException, UUIDServiceException {
+
+ InstanceService is = null;
+
+ try {
+ // load the implementation
+ Class instClass = java.lang.Class.forName(props.getInstanceServiceClass());
+ // try to instantiate the subclass
+ is = (InstanceService) instClass.newInstance();
+ is.init(ds,us, ps);
+
+ } catch (ClassNotFoundException e) {
+ InstanceServiceException bpx = new InstanceServiceException("CLASS_NOT_FOUND",new Object[] {props.getEventDirectorClass()});
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ } catch (InstantiationException e) {
+ InstanceServiceException bpx = new InstanceServiceException("NATIVE_EXCEPTION",new Object[] {"InstantiationException"},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ } catch (IllegalAccessException e) {
+ InstanceServiceException bpx = new InstanceServiceException("NATIVE_EXCEPTION",new Object[] {"IllegalAccessException"},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ } catch (BPException e) {
+ InstanceServiceException bpx = new InstanceServiceException("BP_EXCEPTION",new Object[] {},e);
+ bpx.log(logger,Level.SEVERE);
+ throw bpx;
+ }
+
+ return is;
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/nonpersistent/InstanceServiceTransientImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/nonpersistent/InstanceServiceTransientImpl.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/nonpersistent/InstanceServiceTransientImpl.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/nonpersistent/InstanceServiceTransientImpl.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,221 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+/*
+ * Created on Oct 23, 2003
+ */
+package com.sybase.bpe.instance.service.nonpersistent;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.sybase.bpe.definition.IPMDRoot;
+import com.sybase.bpe.definition.service.DefinitionService;
+import com.sybase.bpe.engine.IEvaluationContext;
+import com.sybase.bpe.engine.IProcessCallBack;
+import com.sybase.bpe.engine.ProcessService;
+import com.sybase.bpe.instance.IPMIProcess;
+import com.sybase.bpe.instance.nonpersistent.PMIProcessTransientImpl;
+import com.sybase.bpe.instance.service.InstanceService;
+import com.sybase.bpe.instance.service.InstanceServiceException;
+import com.sybase.bpe.util.BPException;
+import com.sybase.bpe.uuid.UUIDService;
+
+/**
+ * @author waterman
+ */
+public class InstanceServiceTransientImpl implements InstanceService {
+
+ private static Logger logger =
+ Logger.getLogger(InstanceServiceTransientImpl.class.getName());
+
+ private DefinitionService definitionService;
+// private UUIDService uuidService;
+
+
+ // The collection of business process root instances
+ // each root instance will have one or more current process node instances
+ private HashMap rootInstances = new HashMap();
+
+ public InstanceServiceTransientImpl() {
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.InstanceService#getRootInstances(java.lang.String)
+ */
+ public Collection getRootInstances(String defkey) throws BPException {
+ ArrayList rootInstForDef = new ArrayList();
+ Iterator ri = rootInstances.keySet().iterator();
+
+ while (ri.hasNext()) {
+ IPMIProcess inst = getRootInstance((String) ri.next());
+
+ if (inst.getDefinition().getKey().equals(defkey)) {
+ rootInstForDef.add(inst);
+ }
+ }
+
+ return rootInstForDef;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.InstanceService#getRootInstance(java.lang.String)
+ */
+ public IPMIProcess getRootInstance(String rootkey) throws BPException {
+ IPMIProcess p = null;
+ HashMap instances = (HashMap) rootInstances.get(rootkey);
+
+ if (instances != null) {
+ p = (IPMIProcess) instances.get(rootkey);
+ }
+
+ if (p == null) {
+ InstanceServiceException ise = new InstanceServiceException("IS_IMPL_PNF",new Object[] { rootkey });
+ ise.log(logger,Level.SEVERE);
+ throw ise;
+ }
+
+ return p;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.InstanceService#getInstance(java.lang.String, java.lang.String)
+ */
+ public IPMIProcess getInstance(String rootkey, String key)
+ throws BPException {
+ // get the collection of current process node instances executing
+ // under the root process node instance
+ HashMap instances = (HashMap)rootInstances.get(rootkey);
+ if (instances == null) {
+ BPException bp = new InstanceServiceException("IS_IMPL_PNF",new Object[] { key });
+ bp.log(logger,Level.SEVERE);
+ throw bp;
+ }
+
+ // get the specific process node instance executing under the root
+ // process node instance
+ IPMIProcess p = (IPMIProcess) instances.get(key);
+ // throw an exception if a process intance is not found
+ if (p == null) {
+ BPException bp = new InstanceServiceException("IS_IMPL_PNF",new Object[] { key });
+ bp.log(logger,Level.SEVERE);
+ throw bp;
+ }
+ return p;
+ }
+
+
+ /**
+ * @see com.sybase.bpe.instance.service.InstanceService#createRootInstance(com.sybase.bpe.definition.IPMDRoot)
+ */
+ public IPMIProcess createRootInstance(IPMDRoot rootDefinition)
+ throws BPException {
+ // a stateless business process instance
+ IPMIProcess inst = new PMIProcessTransientImpl(rootDefinition.getProcess().getKey().getValue(),definitionService,this);
+
+ // add the root process instance into the managed cache
+ rootInstances.put(inst.getKey(), new HashMap());
+ addInstance(inst.getKey(), inst);
+
+ return inst;
+ }
+
+ /**
+ * @see com.sybase.bpe.instance.service.InstanceService#getDefinitionService()
+ */
+ public DefinitionService getDefinitionService() {
+ return definitionService;
+ }
+
+ /**
+ * @see com.sybase.bpe.instance.service.InstanceService#init(com.sybase.bpe.util.BPEProperties, com.sybase.bpe.definition.service.DefinitionService, com.sybase.bpe.uuid.UUIDService)
+ */
+ public void init(
+ DefinitionService ds,
+ UUIDService us, ProcessService ps) {
+ definitionService = ds;
+// uuidService = us;
+ }
+
+ /**
+ * @see com.sybase.bpe.instance.service.InstanceService#update(java.lang.String, com.sybase.bpe.engine.IEvaluationContext, com.sybase.bpe.engine.IProcessCallBack)
+ */
+ public void update(
+ String rootkey,
+ IEvaluationContext ec,
+ IProcessCallBack pcb)
+ throws BPException {
+
+ if ( getInstance(rootkey,rootkey).isMarkedForCleanUp() ) {
+ // The business process has completed - clean up its state
+
+ // remove the process context
+ ec.getProcessService().getContextService(rootkey).getRoot().removeChild(rootkey);
+
+ // remove the cached process tree
+ rootInstances.remove(rootkey);
+ }
+
+ }
+
+ /**
+ * @see com.sybase.bpe.instance.service.InstanceService#init()
+ */
+ public void init() {
+ // There is no persistent backing store so do nothing
+ }
+
+ /**
+ * A callback interface on which process instances can register themselves
+ * with the instance manager.
+ *
+ * @param rootkey the root process reference key
+ * @param instance the process instance to register
+ * @throws InstanceServiceException
+ */
+ public void addInstance(String rootkey, IPMIProcess instance)
+ throws InstanceServiceException {
+ HashMap instances = (HashMap)rootInstances.get(rootkey);
+ instances.put(instance.getKey(), instance);
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.InstanceService#getInstanceForContext(java.lang.String, java.lang.String)
+ */
+ public IPMIProcess getInstanceForContext(String rootkey, String key) throws BPException {
+ return getInstance(rootkey,key);
+ }
+
+ public void pauseRootInstance(String rootkey) throws BPException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void resumeRootInstance(String rootkey) throws BPException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+}
Added: incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/persistent/InstanceServicePersistentImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/persistent/InstanceServicePersistentImpl.java?rev=381686&view=auto
==============================================================================
--- incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/persistent/InstanceServicePersistentImpl.java (added)
+++ incubator/ode/scratch/bpe/src/main/java/com/sybase/bpe/instance/service/persistent/InstanceServicePersistentImpl.java Tue Feb 28 08:02:48 2006
@@ -0,0 +1,424 @@
+/*
+* Confidential property of Sybase, Inc.
+*
+* Copyright 1987 - 2006.
+*
+* Sybase, Inc. All rights reserved.
+*
+* Unpublished rights reserved under U.S. copyright laws.
+*
+* This software contains confidential and trade secret information
+* of Sybase, Inc. Use, duplication or disclosure of the software and
+* documentation by the U.S. Government is subject to restrictions
+* set forth in a license agreement between the Government and Sybase,
+* Inc. or other written agreement specifying the Government's rights
+* to use the software and any applicable FAR provisions, for example,
+* FAR 52.227-19.
+*
+* Sybase, Inc. One Sybase Drive, Dublin, CA 94568, USA
+*
+* http://www.sybase.com
+*/
+package com.sybase.bpe.instance.service.persistent;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.sybase.bpe.context.IContainer;
+import com.sybase.bpe.context.IContextService;
+import com.sybase.bpe.context.IPart;
+import com.sybase.bpe.context.ejb.BPE_ObjectLocal;
+import com.sybase.bpe.context.ejb.BPE_ObjectLocalHome;
+import com.sybase.bpe.context.persistent.PersistentContextService;
+import com.sybase.bpe.definition.IPMDRoot;
+import com.sybase.bpe.definition.service.DefinitionService;
+import com.sybase.bpe.engine.IEvaluationContext;
+import com.sybase.bpe.engine.IProcessCallBack;
+import com.sybase.bpe.engine.ProcessService;
+import com.sybase.bpe.engine.StateEnum;
+import com.sybase.bpe.instance.IPMIProcess;
+import com.sybase.bpe.instance.nonpersistent.PMIProcessTransientImpl;
+import com.sybase.bpe.instance.persistent.PMIProcessPersistentImpl;
+import com.sybase.bpe.instance.service.InstanceService;
+import com.sybase.bpe.instance.service.InstanceServiceException;
+import com.sybase.bpe.util.BPEProperties;
+import com.sybase.bpe.util.BPException;
+import com.sybase.bpe.uuid.UUIDService;
+
+/**
+ * An implementation of InstanceService that provides Entity bean persistence
+ * capabilities for process state instances. The impl will only persist the current activity node upon
+ * transaction commit. The runtime repository does not retain a history of
+ * activity node state.
+ *
+ * This implementation should only be invoked within a J2EE container
+ * server; it should not be overloaded to handle the standalone
+ * case. - bkl
+ *
+ * @see PMIProcessPersistentImpl
+ *
+ * @author waterman
+ *
+ */
+public class InstanceServicePersistentImpl implements InstanceService {
+
+ private static Logger logger =
+ Logger.getLogger(InstanceServicePersistentImpl.class.getName());
+
+ private DefinitionService definitionService;
+ private UUIDService uuidService;
+ private ProcessService processService;
+// private static final String JNDI_BLOB_NAME =
+// "java:comp/env/theBMPObjectBean";
+
+// private static final String PS_STATE = "process_state";
+ private static final String PS_STATE_HASH = "process_state_hash";
+ BPE_ObjectLocalHome blobHome;
+ BPE_ObjectLocal blobProxy;
+
+ // The collection of business process root instances
+ // each root instance will have one or more current process node instances
+ private HashMap rootInstances = new HashMap();
+
+
+ public InstanceServicePersistentImpl() {
+ }
+
+ public void update(String rootkey, IEvaluationContext ec, IProcessCallBack pcb) throws BPException {
+
+ //getBlobProxyHome();
+
+ // acquire the root process instance
+ IPMIProcess inst = getInstance(rootkey, rootkey);
+ IContextService cs = ec.getProcessService().getContextService(rootkey);
+
+ if (inst.isMarkedForCleanUp()) {
+ // The business process has completed - clean up its state
+
+ // remove the process context
+
+ IContainer rootCont = cs.getRoot();
+
+ rootCont.removeChild(rootkey);
+
+ // remove the cached process tree
+ rootInstances.remove(rootkey);
+
+ } else if (!inst.isStateless()) {
+
+ HashMap instances = getInstances(rootkey);
+ if ( logger.isLoggable(Level.FINE)) {
+ String s = "State in context to context: root:" + rootkey +
+ " ";
+ Iterator it = instances.values().iterator();
+ while ( it.hasNext() ) {
+ PMIProcessPersistentImpl proc = (PMIProcessPersistentImpl)it.next();
+ proc.setProcessService(this);
+ s += "(" + proc.getKey() + ":"+ proc.getState() + ") ";
+ }
+ logger.fine(s);
+ }
+// IPart hashPart = getStateHash(rootkey);
+// hashPart.setObject(instances);
+ rootInstances.remove(rootkey);
+
+ // Since we may be invoking other business
+ // processes in the same transaction it's important
+ // to flush cached data to the persistent store
+ // before completing the engine crank.
+ if ( cs instanceof PersistentContextService )
+ {
+ flushPersistentContext( (PersistentContextService )cs);
+ }
+ }
+
+ /*
+ CorrelationService correlationService = pcb.getCorrelationService();
+ if ( correlationService instanceof CorrelationServiceEjbImpl )
+ {
+ CorrelationServiceEjbImpl csei = ( CorrelationServiceEjbImpl)
+ ( correlationService );
+ csei.persistRegistrationChanges();
+ }
+ */
+ }
+
+ private void flushPersistentContext( PersistentContextService
+ iService ) throws BPException
+ {
+ iService.flush();
+
+ }
+
+ /**
+ * @see com.sybase.bpe.instance.service.InstanceService#getRootInstances(java.lang.String)
+ */
+ public Collection getRootInstances(String rootDefinitionKey) throws BPException
+ {
+
+ if ( BPEProperties.IsRunningStandAlone())
+ {
+ //This instance service implementation
+ //should never be invoked in a stand alone
+ //environment since it relies on entity bean
+ //persistence.
+ throw new UnsupportedOperationException();
+ }
+ else
+ {
+ LinkedList returnCollection = new LinkedList();
+ RegistrationUtil ru = new RegistrationUtil();
+ Collection rootProcessInstanceIDs =
+ ru.getRegisteredRootInstanceIDs(rootDefinitionKey);
+ Iterator iter = rootProcessInstanceIDs.iterator();
+ while( iter.hasNext() )
+ {
+ String rootProcessInstanceID =
+ ( String )( iter.next() );
+ if ( rootProcessInstanceID != null )
+ {
+ IPMIProcess ipmiprocess =
+ getRootInstance( rootProcessInstanceID );
+ returnCollection.add( ipmiprocess );
+ }
+ }
+ return returnCollection;
+ }
+ }
+
+
+ /**
+ * @see com.sybase.bpe.instance.service.InstanceService#getRootInstance(java.lang.String)
+ */
+ public IPMIProcess getRootInstance(String rootkey) throws BPException
+ {
+ return getInstance( rootkey, rootkey);
+ }
+
+ /**
+ * @see com.sybase.bpe.instance.service.InstanceService#getInstance(com.sybase.bpe.engine.ProcessInstanceKey)
+ */
+ public IPMIProcess getInstance(String rootkey, String key)
+ throws BPException {
+
+ // get the collection of current process node instances executing
+ // under the root process node instance
+ HashMap instances = getInstances(rootkey);
+ if (instances == null) {
+ InstanceServiceException ise = new InstanceServiceException("IS_IMPL_PNF",new Object[] { key });
+ ise.log(logger,Level.SEVERE);
+ throw ise;
+ }
+
+ // get the specific process node instance executing under the root
+ // process node instance
+ IPMIProcess p = (IPMIProcess) instances.get(key);
+ // throw an exception if a process intance is not found
+ if (p == null) {
+ InstanceServiceException ise = new InstanceServiceException("IS_IMPL_PNF",new Object[] { key });
+ ise.log(logger,Level.SEVERE);
+ throw ise;
+ }
+ return p;
+ }
+
+ /**
+ * @see com.sybase.bpe.instance.service.InstanceService#createRootInstance(com.sybase.bpe.definition.IPMDRoot)
+ */
+ public IPMIProcess createRootInstance(IPMDRoot rootDefinition)
+ throws BPException {
+ logger.fine(
+ "Creating root instance for def:"
+ + rootDefinition.getProcess().getKey().getValue());
+ IPMIProcess inst = null;
+ HashMap hm = new HashMap();
+ if ( rootDefinition.getIsStateless()) {
+ // a stateless business process instance executing within
+ // a persistent context
+ inst = new PMIProcessTransientImpl(rootDefinition.getProcess().getKey().getValue(),definitionService, null);
+ } else {
+ // a stateful business process instance executing within
+ // a persistent context
+ inst = new PMIProcessPersistentImpl(
+ null,
+ rootDefinition.getProcess().getKey().getValue(),
+ this);
+ // add to context
+ IPart hashPart = getStateHash(inst.getKey());
+ hashPart.setObject(hm);
+ }
+ // add the root process instance into the managed cache
+ rootInstances.put(inst.getKey(), hm);
+ addInstance(inst.getKey(), inst);
+
+ return inst;
+ }
+
+ /**
+ * @see com.sybase.bpe.instance.service.InstanceService#getDefinitionService()
+ */
+ public DefinitionService getDefinitionService() {
+ return definitionService;
+ }
+
+ /**
+ * @see com.sybase.bpe.instance.service.InstanceService#init(com.sybase.bpe.util.BPEProperties, com.sybase.bpe.definition.service.DefinitionService, com.sybase.bpe.uuid.UUIDService)
+ */
+ public void init(
+ DefinitionService ds,
+ UUIDService us,
+ ProcessService ps) {
+ definitionService = ds;
+ uuidService = us;
+ processService = ps;
+ }
+
+ /**
+ * A cache manager helper function. Will populate the cache from entity bean.
+ *
+ * @param rootkey
+ * @return
+ * @throws InstanceServiceException
+ */
+ private HashMap getInstances(String rootkey)
+ throws BPException {
+
+ if ( logger.isLoggable(Level.FINEST)){
+ logger.fine("Getting instances for root proc:"+rootkey);
+ }
+
+ HashMap instances = (HashMap) rootInstances.get(rootkey);
+
+ // if this is true the process must be stateful, or the proc doesn't exist
+ if (instances == null ) {
+ IPart hashPart = getStateHash(rootkey);
+ instances = (HashMap)hashPart.getObjectForReadWrite();
+ // set the process service and def service on each
+ Iterator it = instances.values().iterator();
+ while ( it.hasNext() ) {
+ PMIProcessPersistentImpl proc = (PMIProcessPersistentImpl)it.next();
+
+ //Doh! We're really setting the instance service here.
+ //TODO: Change this to setInstanceService!
+ proc.setProcessService(this);
+ }
+ if ( logger.isLoggable(Level.FINE)) {
+ String s = "Getting state from context: root:" + rootkey +
+ " ";
+ it = instances.values().iterator();
+ while ( it.hasNext() ) {
+ PMIProcessPersistentImpl proc = (PMIProcessPersistentImpl)it.next();
+ proc.setProcessService(this);
+ s += "(" + proc.getKey() + ":"+ proc.getState() + ") ";
+ }
+ logger.fine(s);
+ }
+ rootInstances.put(rootkey, instances);
+ }
+
+ return instances;
+
+ }
+
+ public UUIDService getUUIDService() {
+ return uuidService;
+ }
+
+ /**
+ * A callback interface on which process instances can register themselves
+ * with the instance manager.
+ *
+ * @param rootkey the root process reference key
+ * @param instance the process instance to register
+ * @throws InstanceServiceException
+ */
+ public void addInstance(String rootkey, IPMIProcess instance)
+ throws BPException {
+ HashMap instances = getInstances(rootkey);
+ instances.put(instance.getKey(), instance);
+ }
+
+ /**
+ * A callback interface on which process isntances can unregister themselves
+ * with the instance manager.
+ *
+ * @param rootkey the root process reference key
+ * @param key the process instance reference key to unregister
+ * @return the process instance that has was unregistered
+ * @throws InstanceServiceException
+ */
+ public IPMIProcess remove(String rootkey, String key)
+ throws BPException {
+ HashMap instances = getInstances(rootkey);
+ return (IPMIProcess) instances.remove(key);
+ }
+
+ /**
+ * @see com.sybase.bpe.instance.service.InstanceService#init()
+ */
+ public void init() {
+ rootInstances.clear();
+ }
+
+ private IPart getStateHash (String rootkey) throws BPException {
+
+ IContextService cs = processService.getContextService(rootkey);
+ IContainer root = cs.getRoot();
+ IContainer procroot = (IContainer)root.findChild(rootkey);
+ if ( procroot == null ) {
+ procroot = root.createContainer(rootkey);
+ }
+ IPart hashPart = (IPart) procroot.findChild(PS_STATE_HASH);
+ if (hashPart == null) {
+ hashPart = procroot.createPart(PS_STATE_HASH);
+ }
+ return hashPart;
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sybase.bpe.instance.service.InstanceService#getInstanceForContext(java.lang.String, java.lang.String)
+ */
+ public IPMIProcess getInstanceForContext(String rootkey, String key)
+ throws BPException {
+
+ if ( logger.isLoggable(Level.FINEST)){
+ logger.fine("Getting instances for root proc:"+rootkey);
+ }
+ HashMap instances = (HashMap) rootInstances.get(rootkey);
+ if (instances == null) {
+ return null;
+ }
+ IPMIProcess p = (IPMIProcess) instances.get(key);
+ if (p == null) {
+ return null;
+ }
+ return p;
+ }
+
+
+ private void setRootInstanceState(String rootKey, int state)
+ throws BPException
+ {
+ IPart statePart = getStateHash(rootKey);
+ HashMap instances = ( HashMap ) statePart.getObjectForReadWrite();
+ IPMIProcess process = ( IPMIProcess ) instances.get(rootKey);
+ process.setState( state );
+ }
+
+ public void pauseRootInstance(String rootKey) throws BPException
+ {
+ setRootInstanceState( rootKey, StateEnum.PAUSED.getIntValue() );
+ }
+
+ public void resumeRootInstance(String rootKey) throws BPException
+ {
+ setRootInstanceState( rootKey, StateEnum.RUNNING.getIntValue());
+ }
+
+
+}