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:35:26 UTC

svn commit: r381694 [30/38] - in /incubator/ode/scratch: bpe/ ode/ ode/bpelTests/ ode/bpelTests/probeService/ ode/bpelTests/test1/ ode/bpelTests/test10/ ode/bpelTests/test12/ ode/bpelTests/test13/ ode/bpelTests/test14/ ode/bpelTests/test15/ ode/bpelTes...

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/persistent/PMIProcessPersistentImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/persistent/PMIProcessPersistentImpl.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/persistent/PMIProcessPersistentImpl.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/persistent/PMIProcessPersistentImpl.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,261 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.instance.persistent;
+
+import java.io.Serializable;
+//import java.util.logging.Logger;
+
+import org.apache.ode.definition.IPMDProcess;
+import org.apache.ode.engine.ProcessDefinitionKey;
+import org.apache.ode.engine.StateEnum;
+import org.apache.ode.instance.IPMIProcess;
+import org.apache.ode.instance.service.persistent.InstanceServicePersistentImpl;
+import org.apache.ode.scope.service.IFCScopeInstance;
+import org.apache.ode.scope.service.ScopePath;
+import org.apache.ode.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 org.apache.ode.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 org.apache.ode.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 org.apache.ode.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 org.apache.ode.instance.service.IPMIProcess#getScopePath()
+	 */
+	public ScopePath getScopePath(){
+		return scopePath;
+	}
+
+
+	/* (non-Javadoc)
+	 * @see org.apache.ode.instance.service.IPMIProcess#setScopePath(java.lang.String)
+	 */
+	public void setScopePath(ScopePath scopePath){
+		this.scopePath = scopePath;
+		
+	}
+
+
+	/* (non-Javadoc)
+	 * @see org.apache.ode.instance.service.IPMIProcess#getContextContainerId()
+	 */
+	public String getContextContainerId() {
+		return contextContainerId;
+	}
+
+
+	/* (non-Javadoc)
+	 * @see org.apache.ode.instance.service.IPMIProcess#setContextContaionerId(java.lang.String)
+	 */
+	public void setContextContaionerId(String id) {
+		contextContainerId = id;
+		
+	}
+
+
+	/* (non-Javadoc)
+	 * @see org.apache.ode.instance.service.IPMIProcess#getExecutionContext()
+	 */
+	public String getExecutionContext() {
+		return executionCtx;
+	}
+
+
+	/* (non-Javadoc)
+	 * @see org.apache.ode.instance.service.IPMIProcess#setExecutionContext()
+	 */
+	public void setExecutionContext(String executionCtx) {
+		this.executionCtx = executionCtx;
+		
+	}
+
+
+
+	
+
+
+
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/InstanceService.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/InstanceService.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/InstanceService.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/InstanceService.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/***********************************************************************
+ * Module:  InstanceService.java
+ * Author:  waterman
+ * Purpose: Defines the Interface InstanceService
+ ***********************************************************************/
+
+package org.apache.ode.instance.service;
+
+import java.util.Collection;
+
+import org.apache.ode.definition.IPMDRoot;
+import org.apache.ode.definition.service.DefinitionService;
+import org.apache.ode.engine.IEvaluationContext;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.engine.ProcessService;
+import org.apache.ode.instance.IPMIProcess;
+import org.apache.ode.util.BPException;
+import org.apache.ode.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/ode/src/main/java/org/apache/ode/instance/service/InstanceServiceException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/InstanceServiceException.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/InstanceServiceException.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/InstanceServiceException.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.instance.service;
+
+import org.apache.ode.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/ode/src/main/java/org/apache/ode/instance/service/InstanceServiceFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/InstanceServiceFactory.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/InstanceServiceFactory.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/InstanceServiceFactory.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.instance.service;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.ode.definition.service.DefinitionService;
+import org.apache.ode.definition.service.DefinitionServiceException;
+import org.apache.ode.definition.service.DefinitionServiceFactory;
+import org.apache.ode.engine.ProcessService;
+import org.apache.ode.util.BPEProperties;
+import org.apache.ode.util.BPException;
+import org.apache.ode.uuid.UUIDService;
+import org.apache.ode.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/ode/src/main/java/org/apache/ode/instance/service/nonpersistent/InstanceServiceTransientImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/nonpersistent/InstanceServiceTransientImpl.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/nonpersistent/InstanceServiceTransientImpl.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/nonpersistent/InstanceServiceTransientImpl.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,215 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Oct 23, 2003
+ */
+package org.apache.ode.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 org.apache.ode.definition.IPMDRoot;
+import org.apache.ode.definition.service.DefinitionService;
+import org.apache.ode.engine.IEvaluationContext;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.engine.ProcessService;
+import org.apache.ode.instance.IPMIProcess;
+import org.apache.ode.instance.nonpersistent.PMIProcessTransientImpl;
+import org.apache.ode.instance.service.InstanceService;
+import org.apache.ode.instance.service.InstanceServiceException;
+import org.apache.ode.util.BPException;
+import org.apache.ode.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 org.apache.ode.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 org.apache.ode.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 org.apache.ode.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 org.apache.ode.instance.service.InstanceService#createRootInstance(org.apache.ode.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 org.apache.ode.instance.service.InstanceService#getDefinitionService()
+	 */
+	public DefinitionService getDefinitionService() {
+		return definitionService;
+	}
+
+	/**
+	 * @see org.apache.ode.instance.service.InstanceService#init(org.apache.ode.util.BPEProperties, org.apache.ode.definition.service.DefinitionService, org.apache.ode.uuid.UUIDService)
+	 */
+	public void init(
+		DefinitionService ds,
+		UUIDService us, ProcessService ps) {
+			definitionService = ds;
+//			uuidService = us;
+	}
+
+	/**
+	 * @see org.apache.ode.instance.service.InstanceService#update(java.lang.String, org.apache.ode.engine.IEvaluationContext, org.apache.ode.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 org.apache.ode.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 org.apache.ode.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/ode/src/main/java/org/apache/ode/instance/service/persistent/InstanceServicePersistentImpl.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/persistent/InstanceServicePersistentImpl.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/persistent/InstanceServicePersistentImpl.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/persistent/InstanceServicePersistentImpl.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,418 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.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 org.apache.ode.context.IContainer;
+import org.apache.ode.context.IContextService;
+import org.apache.ode.context.IPart;
+import org.apache.ode.context.ejb.BPE_ObjectLocal;
+import org.apache.ode.context.ejb.BPE_ObjectLocalHome;
+import org.apache.ode.context.persistent.PersistentContextService;
+import org.apache.ode.definition.IPMDRoot;
+import org.apache.ode.definition.service.DefinitionService;
+import org.apache.ode.engine.IEvaluationContext;
+import org.apache.ode.engine.IProcessCallBack;
+import org.apache.ode.engine.ProcessService;
+import org.apache.ode.engine.StateEnum;
+import org.apache.ode.instance.IPMIProcess;
+import org.apache.ode.instance.nonpersistent.PMIProcessTransientImpl;
+import org.apache.ode.instance.persistent.PMIProcessPersistentImpl;
+import org.apache.ode.instance.service.InstanceService;
+import org.apache.ode.instance.service.InstanceServiceException;
+import org.apache.ode.util.BPEProperties;
+import org.apache.ode.util.BPException;
+import org.apache.ode.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 org.apache.ode.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 org.apache.ode.instance.service.InstanceService#getRootInstance(java.lang.String)
+	 */
+	public IPMIProcess getRootInstance(String rootkey) throws BPException 
+	{
+		return getInstance( rootkey, rootkey);
+	}
+	
+	/**
+	 * @see org.apache.ode.instance.service.InstanceService#getInstance(org.apache.ode.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 org.apache.ode.instance.service.InstanceService#createRootInstance(org.apache.ode.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 org.apache.ode.instance.service.InstanceService#getDefinitionService()
+	 */
+	public DefinitionService getDefinitionService() {
+		return definitionService;
+	}
+
+	/**
+	 * @see org.apache.ode.instance.service.InstanceService#init(org.apache.ode.util.BPEProperties, org.apache.ode.definition.service.DefinitionService, org.apache.ode.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 org.apache.ode.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 org.apache.ode.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());      
+    }
+	
+
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/persistent/RegistrationUtil.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/persistent/RegistrationUtil.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/persistent/RegistrationUtil.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/instance/service/persistent/RegistrationUtil.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.ode.instance.service.persistent;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.ejb.FinderException;
+import javax.naming.InitialContext;
+
+import org.apache.ode.correlation.managed.RegistrationEntityLocal;
+import org.apache.ode.correlation.managed.RegistrationEntityLocalHome;
+import org.apache.ode.correlation.managed.CorrelationServiceEjbImpl;
+
+
+public class RegistrationUtil
+{
+    private RegistrationEntityLocalHome relh;
+    
+    public RegistrationUtil()
+    {
+        try
+        {
+	        InitialContext ic = new InitialContext();
+	        relh = (RegistrationEntityLocalHome) ic.lookup(
+		    CorrelationServiceEjbImpl.JNDI_RELH_NAME);
+        }
+        catch ( Exception e )
+        {
+            throw new RuntimeException(e);
+        }
+    }
+    
+    public Collection getRegisteredRootInstanceIDs(String definitionID)
+    {
+        Set returnCollection = new HashSet();
+        try
+        {
+            
+            RegistrationEntityLocal bean;
+            
+            Collection beans = relh.findByRootDefId(definitionID);
+            Iterator iter = beans.iterator();
+            while( iter.hasNext() )
+            {
+                bean = ( RegistrationEntityLocal )( iter.next());
+                returnCollection.add( bean.getRootProcId());   
+            }
+                  
+        } catch (FinderException e)
+        {
+            
+        }
+        
+        return returnCollection;
+    }
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/AmbiguousNodeException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/AmbiguousNodeException.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/AmbiguousNodeException.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/AmbiguousNodeException.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+public class AmbiguousNodeException 
+  extends InteractionException
+{
+	
+	static final long serialVersionUID = -1409491860380784018L;
+	
+	public AmbiguousNodeException(Object[] obj) {
+		super("AMBIGUOUS_NODE",obj);
+	}
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/BaseInteraction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/BaseInteraction.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/BaseInteraction.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/BaseInteraction.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+
+import org.apache.ode.context.IAccessControl;
+import org.apache.ode.context.ICloneable;
+
+public abstract class BaseInteraction implements IInteraction, IAccessControl, ICloneable
+{
+
+	public BaseInteraction()
+	{
+		super();
+	}
+	public Object invoke(IInvocation iInvocation, Object iInput) 
+	  throws InteractionException
+	{	  
+			if( iInvocation == null)
+			{
+				throw new NullInvocationException();
+			}
+			try
+			{
+				if ( iInvocation.isMutator() )	
+				{
+					setDirty(true);		
+				}
+				Object resultObject = iInvocation.execute(this, iInput);				
+				return resultObject;
+			}
+			catch( InteractionException ie )
+			{
+				 throw ie;
+			}
+			catch (Exception e)
+			{
+				InteractionException bpx = new InteractionException("NATIVE_EXCEPTION",new Object[] {"Exception"},e);
+				throw bpx;
+			}
+	}
+	public boolean getReadOnly()
+	{
+		return m_isReadOnly;
+	}
+	
+	public void setReadOnly( boolean isReadOnly )
+	{
+		m_isReadOnly = isReadOnly;		
+	}
+	
+	protected boolean getDirty()
+	{
+		return m_isDirty;
+	}
+	
+	protected void setDirty( boolean iIsDirty )
+	{
+		m_isDirty = iIsDirty;
+	}
+	
+	public Object invoke( IInvocation iInvocation)
+	 throws InteractionException
+	{
+		return invoke( iInvocation, null );
+	}
+	
+	private transient boolean m_isReadOnly = false;
+	private transient boolean m_isDirty = false;
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/BaseInvocation.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/BaseInvocation.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/BaseInvocation.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/BaseInvocation.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+
+public abstract class BaseInvocation implements IInvocation
+{
+	protected BaseInvocation()
+	{
+		super();
+	}
+
+	public Object getResult()
+	{
+		return m_object;
+	}
+	
+	protected void setResult( Object iResult )
+	{
+		m_object = iResult;
+	}
+	
+	protected transient Object m_object;
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/BufferInteraction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/BufferInteraction.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/BufferInteraction.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/BufferInteraction.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+
+import java.io.IOException;
+
+public abstract class BufferInteraction extends BaseInteraction
+{
+
+	public BufferInteraction()
+	{
+		super();
+	}
+	
+	public void setBuffer( byte[] iBuffer )
+	{
+		m_buffer = iBuffer;
+	}
+	
+	public byte[] getBuffer() throws IOException
+	{
+		return m_buffer;
+	}
+	
+	protected final void clearBuffer()
+	{
+		m_buffer = null;
+	}	
+	
+	/////////////////////
+	// JJ 10-29-03
+	//
+	protected final byte[] cloneBuffer() 
+	{
+		if ( m_buffer == null )
+		{
+			return null;
+		}
+		
+		byte[] retValue = new byte[m_buffer.length];
+		for (int i = 0; i < m_buffer.length; i ++) {
+			retValue[i] = m_buffer[i];
+		}
+		return retValue;
+	}
+	//
+	/////////////////////
+	
+	private transient byte[] m_buffer = null;
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IDocumentAccessible.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IDocumentAccessible.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IDocumentAccessible.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IDocumentAccessible.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+
+import org.w3c.dom.Document;
+
+public interface IDocumentAccessible
+{
+	Document getDocument() throws Exception;
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IDocumentMutable.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IDocumentMutable.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IDocumentMutable.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IDocumentMutable.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+
+import org.w3c.dom.Document;
+
+public interface IDocumentMutable
+{
+	public void setDocument( Document iDocument ) throws Exception;
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IFieldAccessible.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IFieldAccessible.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IFieldAccessible.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IFieldAccessible.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Nov 7, 2003
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+package org.apache.ode.interaction;
+
+/**
+ * @author jjin
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public interface IFieldAccessible {
+	// this call expects the field is not repeatable
+	public String getField(String fieldName) throws Exception;
+	// this call expects the filed is repeatable
+	public String getField(String fieldName, int instanceNumber) throws Exception;
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInteraction.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInteraction.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInteraction.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInteraction.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+
+
+public interface IInteraction
+{
+	public static final String OBJECT_TYPE = "obj";
+	public static final String BUFFER_TYPE = "buf";
+	public static final String INTERACTION_TYPE = "interaction";
+	public static final String FORMATTABLE_VALUE_TYPE = "formattableValue";
+		
+	public Object invoke(IInvocation iInvocation) 
+	  throws InteractionException;
+	  
+	public Object invoke(IInvocation iInvocation, 
+	  Object iInput) throws InteractionException;
+	  
+	public void releaseResources() throws InteractionException;
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInvocation.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInvocation.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInvocation.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInvocation.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+
+import org.apache.ode.interaction.query.IQuery;
+
+public interface IInvocation
+{
+	public boolean isMutator();
+	public Object execute( IInteraction iTarget, Object iParameters) throws Exception;
+	public int getType();
+	public IQuery getQuery();
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInvocationDefinition.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInvocationDefinition.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInvocationDefinition.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInvocationDefinition.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+
+public interface IInvocationDefinition
+{
+
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInvocationFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInvocationFactory.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInvocationFactory.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInvocationFactory.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+
+import java.util.HashMap;
+
+public interface IInvocationFactory
+{
+	/**
+	 * Query a document for an element and return the text
+	 * value associated with that element.
+	 * 
+	 * @param iXPathExpression
+	 * XPath locator for the queried node.
+	 * 
+	 * @param iNamespaceMap
+	 * @return
+	 * @throws InteractionException
+	 */
+	public IInvocation createXPathQueryNodeValueInvocation(
+		String iXPathExpression,
+		HashMap iNamespaceMap)
+		throws InteractionException;
+
+	/**
+	 * Query a document for an element and set the text value
+	 * associated with that element.
+	 * 
+	 * @param iXPathExpression
+	 * XPath locator for the queried node. 
+	 * 
+	 * @param iNamespaceMap
+	 * @return
+	 * @throws InteractionException
+	 */
+	public IInvocation createXPathSetNodeValueInvocation(
+		String iXPathExpression,
+		HashMap iNamespaceMap)
+		throws InteractionException;
+
+	/**
+	 * Query a document for a subtree ( the subtree may be 
+	 * a leaf ).
+	 * 
+	 * @param iXPathExpression
+	 * XPath locator for the root node of the selected
+	 * subtree.
+	 * 
+	 * @param iNamespaceMap
+	 * @return
+	 * @throws InteractionException
+	 */
+	public IInvocation createXPathSelectTreeInvocation(
+		String iXPathExpression,
+		HashMap iNamespaceMap)
+		throws InteractionException;
+
+	/**
+	 * Copy a subtree to a specified location in a document.
+	 * 
+	 * @param iXPathExpression
+	 * XPath locator for the parent node under which the
+	 * subtree should be copied.
+	 * 
+	 * @param iNamespaceMap
+	 * @return
+	 * @throws InteractionException
+	 */
+	public IInvocation createXPathCopyTreeInvocation(
+		String iXPathExpression,
+		HashMap iNamespaceMap)
+		throws InteractionException;
+		
+	/**
+	 * Remove the children from the target parent and 
+	 * then copy the children from source parent node under
+	 * the target parent node.
+	 * 
+	 * @param iXPathExpression
+	 * XPath locator for the parent node under which the
+	 * subtree should be copied.
+	 * 
+	 * @param iNamespaceMap
+	 * @return
+	 * @throws InteractionException
+	 */
+	public IInvocation createXPathCopyChildrenWithOverwriteInvocation(
+		String iXPathExpression,
+		HashMap iNamespaceMap)
+		throws InteractionException;
+	
+	/**
+	 * Copy the children from source parent node under
+	 * the target parent node.
+	 * 
+	 * @param iXPathExpression
+	 * XPath locator for the parent node under which the
+	 * subtree should be copied.
+	 * 
+	 * @param iNamespaceMap
+	 * @return
+	 * @throws InteractionException
+	 */
+	public IInvocation createXPathCopyChildrenInvocation(
+		String iXPathExpression,
+		HashMap iNamespaceMap)
+		throws InteractionException;
+
+	/**
+	 * Prune the specified subtree from the document.
+	 * 
+	 * @param iXPathExpression
+	 * XPath locator for the node to prune.
+	 * 
+	 * @param iNamespaceMap
+	 * @return
+	 * @throws InteractionException
+	 */
+	public IInvocation createXPathPruneTreeInvocation(
+		String iXPathExpression,
+		HashMap iNamespaceMap)
+		throws InteractionException;
+
+	/**
+	 * Set the object encapsulated by the interaction.
+	 * 
+	 * @return
+	 * @throws InteractionException
+	 */
+	public IInvocation createSetObjectInvocation() throws InteractionException;
+
+	/**
+	* Get the object encapsulated by the interaction.
+	* 
+	* @return
+	* @throws InteractionException
+	*/
+	public IInvocation createGetObjectInvocation() throws InteractionException;
+
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInvocationTypes.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInvocationTypes.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInvocationTypes.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IInvocationTypes.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.ode.interaction;
+
+
+public class IInvocationTypes
+{
+	public static final int GET_SIMPLE_VALUE = 1;
+	public static final int SET_SIMPLE_VALUE = 2;
+	public static final int GET_COMPLEX_VALUE = 3;
+	public static final int SET_COMPLEX_VALUE = 4;
+	public static final int REMOVE_VALUE = 5;
+	public static final int COPY_SUB_ELEMENTS = 6;
+	public static final int SET_OBJECT = 7;
+	public static final int GET_OBJECT = 8;
+
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IObjectAccessible.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IObjectAccessible.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IObjectAccessible.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IObjectAccessible.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+public interface IObjectAccessible
+{
+	public Object getObject()
+	  throws InteractionException;
+	
+	public Object getObject( 
+	  String iPreference ) 
+	  throws InteractionException;
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IObjectMutable.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IObjectMutable.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IObjectMutable.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/IObjectMutable.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+public interface IObjectMutable
+{
+	public void setObject( Object iObject ) 
+	  throws InteractionException;
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InteractionException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InteractionException.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InteractionException.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InteractionException.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+/*
+ * Created on Apr 16, 2003
+ *
+ */
+package org.apache.ode.interaction;
+
+import org.apache.ode.util.BPException;
+
+/**
+ * @author waterman
+ *
+ */
+public class InteractionException extends BPException {
+	
+	static final long serialVersionUID = 1534737082941167523L;
+
+	/**
+	 * @param message_id
+	 * @param msgParams
+	 */
+	public InteractionException(String message_id, Object[] msgParams) {
+		super(message_id, msgParams);
+	}
+
+	/**
+	 * @param message_id
+	 * @param msgParams
+	 * @param cause
+	 */
+	public InteractionException(
+		String message_id,
+		Object[] msgParams,
+		Throwable cause) {
+		super(message_id, msgParams, cause);
+	}
+
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InteractionFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InteractionFactory.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InteractionFactory.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InteractionFactory.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+
+import java.util.Properties;
+
+import org.w3c.dom.Document;
+
+import org.apache.ode.interaction.spiadapter.SPIAdapterInteractionFactory;
+
+public class InteractionFactory
+{
+
+	protected InteractionFactory()
+	{
+		super();
+	}
+
+	public static InteractionFactory newInstance()
+	{
+		//return new InteractionFactory();
+		return new SPIAdapterInteractionFactory();
+	}
+
+	public IInteraction createXMLInteraction(byte[] iBuffer) throws InteractionException
+	{
+		XMLInteractionObject xmio = new XMLInteractionObject();
+		xmio.setBuffer(iBuffer);
+		return xmio;
+	}
+	
+	////////////////////////
+	// JJ 10-30-03
+	// Cory 02-28-05, we don't use this anymore
+/*	public IInteraction createWireFormatInteraction(byte[] buffer,
+													String codeSet,
+													String locale,
+													String formatName) throws InteractionException {
+		WireFormatInteractionObject retValue = new WireFormatInteractionObject();
+		
+		retValue.setBuffer(buffer);
+		retValue.setCodeSet(codeSet);
+		retValue.setLocale(locale);
+		retValue.setFormatName(formatName);
+		
+		return retValue;
+	}
+	public IInteraction createWireFormatInteraction(byte[] buffer,
+													String formatName) throws InteractionException {
+		WireFormatInteractionObject retValue = new WireFormatInteractionObject();
+		
+		retValue.setBuffer(buffer);
+		retValue.setFormatName(formatName);
+		
+		return retValue;
+	}*/
+															
+
+
+	public IInteraction createPropertiesInteraction(Properties iProperties) throws InteractionException
+	{
+		return new PropertiesInteractionObject(iProperties);
+	}
+
+	public IInteraction createDocumentInteraction(Document iDocument) throws InteractionException
+	{
+		XMLInteractionObject xmio = new XMLInteractionObject();
+		xmio.setDocument( iDocument );
+		return xmio;
+	}
+	
+	public IInteraction createDocumentInteraction() throws InteractionException
+	{
+		XMLInteractionObject xmio = new XMLInteractionObject();
+		//This appears to be an expensive call. In particular where we
+		//want an empty XMLInteractionObject on which the buffer is
+		//set sometime after object creation. Note: this method is being
+		//called from XMLInteractionBuilder.createInteraction() which does
+		//not take any type of initialization data.
+		//xmio.setEmptyDocument();
+		return xmio;
+	}
+	
+	public IInteraction createObjectInteraction( Object iObject )
+	{
+		ObjectInteraction objectInteraction = new ObjectInteraction();
+		objectInteraction.setObject( iObject );
+		
+		return objectInteraction;
+	}
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InvalidInputParameterException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InvalidInputParameterException.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InvalidInputParameterException.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InvalidInputParameterException.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+public class InvalidInputParameterException extends InteractionException
+{
+	
+	static final long serialVersionUID = -7735211549759558497L;
+
+	
+	public InvalidInputParameterException() {
+		super("INVALID_INPUT_PARAM",null);
+	}
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InvalidTypeException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InvalidTypeException.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InvalidTypeException.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InvalidTypeException.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+public class InvalidTypeException extends InteractionException
+{
+	
+	static final long serialVersionUID = 6557666627691798540L;
+
+	public InvalidTypeException()
+	{
+		super(null, null);
+		
+	}
+
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/Invocation.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/Invocation.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/Invocation.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/Invocation.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+
+import java.io.Serializable;
+
+import org.apache.ode.interaction.operations.IOperation;
+import org.apache.ode.interaction.query.IQuery;
+
+public class Invocation implements IInvocation, Serializable
+{
+    static final long serialVersionUID = 7295384248109086989L;
+    
+	public Invocation()
+	{
+		super();
+	}
+	
+	public Invocation( IQuery iQuery, IOperation iOperation, int type )
+	{
+		setQuery( iQuery );
+		setOperation( iOperation );
+		setType( type );
+	}
+
+	public boolean isMutator()
+	{
+		return m_operation.isMutator();
+	}
+	
+	public void setOperation( IOperation iOperation )
+	{
+		m_operation = iOperation;
+	}
+	
+	public IOperation getOperation()
+	{
+		return m_operation;
+	}
+	
+	public void setQuery( IQuery iQuery )
+	{
+		m_query = iQuery;
+	}
+	
+	public IQuery getQuery()
+	{
+		return m_query;
+	}
+	
+	public int getType()
+	{
+		return m_type;
+	}
+	
+	public void setType( int type )
+	{
+		m_type = type;
+	}
+	
+	
+	public Object execute(
+			IInteraction iTarget, 
+			Object iParameters) throws Exception
+	{
+		Object result = m_operation.execute( iTarget, m_query, iParameters, null );
+		return result;
+	}
+	
+	
+	private IOperation m_operation = null;
+	private IQuery m_query = null;
+	private int m_type;
+	
+
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InvocationFactory.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InvocationFactory.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InvocationFactory.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InvocationFactory.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,172 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+
+import java.util.HashMap;
+
+import org.apache.ode.interaction.operations.CopyChildrenOperation;
+import org.apache.ode.interaction.operations.CopyChildrenWithOverwriteOperation;
+import org.apache.ode.interaction.operations.CopyTreeOperation;
+import org.apache.ode.interaction.operations.GetObjectOperation;
+import org.apache.ode.interaction.operations.GetTextValueOperation;
+import org.apache.ode.interaction.operations.IOperation;
+import org.apache.ode.interaction.operations.PruneOperation;
+import org.apache.ode.interaction.operations.SelectTreeOperation;
+import org.apache.ode.interaction.operations.SetObjectOperation;
+import org.apache.ode.interaction.operations.SetTextValueOperation;
+import org.apache.ode.interaction.query.IQuery;
+import org.apache.ode.interaction.query.JaxenXPathSingleNodeQuery;
+
+public class InvocationFactory implements IInvocationFactory
+{
+
+	
+	public InvocationFactory()
+	{
+	}
+
+	public static IInvocationFactory newInstance()
+	{
+		return new InvocationFactory();
+	}
+
+	public IInvocation createXPathQueryNodeValueInvocation(
+		String iExpression,
+		HashMap iNamespaceMap)
+		throws InteractionException
+	{
+		IOperation operation = new GetTextValueOperation();
+		IInvocation invocation =
+			createCommonInvocation(
+					iExpression, iNamespaceMap, operation,
+					IInvocationTypes.GET_SIMPLE_VALUE);
+
+		return invocation;
+	}
+
+	public IInvocation createXPathSetNodeValueInvocation(
+		String iXPathExpression,
+		HashMap iNamespaceMap)
+		throws InteractionException
+	{
+
+		IOperation operation = new SetTextValueOperation();
+		IInvocation invocation =
+			createCommonInvocation(iXPathExpression, iNamespaceMap, operation,
+					IInvocationTypes.SET_SIMPLE_VALUE);
+
+		return invocation;
+	}
+
+	public IInvocation createXPathSelectTreeInvocation(
+		String iXPathExpression,
+		HashMap iNamespaceMap)
+		throws InteractionException
+	{
+		IOperation operation = new SelectTreeOperation();
+		IInvocation invocation =
+			createCommonInvocation(iXPathExpression, iNamespaceMap, 
+					operation, IInvocationTypes.GET_COMPLEX_VALUE);
+		
+
+		return invocation;
+	}
+
+	public IInvocation createXPathCopyTreeInvocation(
+		String iXPathExpression,
+		HashMap iNamespaceMap)
+		throws InteractionException
+	{
+		IOperation operation = new CopyTreeOperation();
+		IInvocation invocation =
+			createCommonInvocation(iXPathExpression, 
+					iNamespaceMap, operation, 
+					IInvocationTypes.SET_COMPLEX_VALUE);
+
+		return invocation;
+	}
+
+	public IInvocation createXPathPruneTreeInvocation(
+		String iXPathExpression,
+		HashMap iNamespaceMap)
+		throws InteractionException
+	{
+		IOperation operation = new PruneOperation();
+		IInvocation invocation =
+			createCommonInvocation(iXPathExpression, iNamespaceMap, operation,
+					IInvocationTypes.REMOVE_VALUE);
+
+		return invocation;
+	}
+
+	public IInvocation createSetObjectInvocation()
+	{
+		IOperation operation = new SetObjectOperation();
+		Invocation invocation = new Invocation(null, operation, 
+				IInvocationTypes.SET_OBJECT);
+		return invocation;
+	}
+	public IInvocation createGetObjectInvocation()
+	{
+		IOperation operation = new GetObjectOperation();
+		Invocation invocation = new Invocation(null, operation, 
+				IInvocationTypes.GET_OBJECT);
+		return invocation;
+	}
+
+	private IInvocation createCommonInvocation(
+		String iXPathExpression,
+		HashMap iNamespaceMap,
+		IOperation iOperation, 
+		int type)
+		throws InteractionException
+	{
+		try
+		{
+			IQuery query =
+				new JaxenXPathSingleNodeQuery(iXPathExpression, iNamespaceMap);
+			Invocation invocation = new Invocation(query, iOperation, type);
+
+			return invocation;
+
+		} catch (Exception e)
+		{
+			InteractionException bpx = new InteractionException("NATIVE_EXCEPTION",new Object[] {"Exception"},e);
+			throw bpx;
+		}
+	}
+
+	public IInvocation createXPathCopyChildrenWithOverwriteInvocation(String iXPathExpression, HashMap iNamespaceMap) throws InteractionException
+	{
+		IOperation operation = new CopyChildrenWithOverwriteOperation();
+		IInvocation invocation =
+			createCommonInvocation(iXPathExpression, iNamespaceMap, operation,
+					IInvocationTypes.COPY_SUB_ELEMENTS);
+
+		return invocation;
+	}
+	
+	public IInvocation createXPathCopyChildrenInvocation(String iXPathExpression, HashMap iNamespaceMap) throws InteractionException
+	{
+		IOperation operation = new CopyChildrenOperation();
+		IInvocation invocation =
+			createCommonInvocation(iXPathExpression, iNamespaceMap, operation,
+					IInvocationTypes.COPY_SUB_ELEMENTS);
+
+		return invocation;
+	}
+
+}

Added: incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InvocationMismatchException.java
URL: http://svn.apache.org/viewcvs/incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InvocationMismatchException.java?rev=381694&view=auto
==============================================================================
--- incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InvocationMismatchException.java (added)
+++ incubator/ode/scratch/ode/src/main/java/org/apache/ode/interaction/InvocationMismatchException.java Tue Feb 28 08:31:48 2006
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.ode.interaction;
+public class InvocationMismatchException extends InteractionException
+{
+	static final long serialVersionUID = 194986460468526233L;
+	
+	public InvocationMismatchException() {
+		super("INVOCATION_MISMATCH",null);
+	}
+}