You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2009/01/07 03:00:49 UTC

svn commit: r732195 [1/2] - in /ode/branches/APACHE_ODE_1.X: axis2/src/main/java/org/apache/ode/axis2/ bpel-api/src/main/java/org/apache/ode/bpel/common/ bpel-api/src/main/java/org/apache/ode/bpel/iapi/ bpel-dao/src/main/java/org/apache/ode/bpel/dao/ b...

Author: mriou
Date: Tue Jan  6 18:00:47 2009
New Revision: 732195

URL: http://svn.apache.org/viewvc?rev=732195&view=rev
Log:
Migration to using names in place of omodel ids in correlation and partner link references from both the database and the runtime. Problem was that omodel ids tend to change a lot as soon as the process gets even slightly updated. And then past instances can't complete anymore.

Modified:
    ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
    ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/CorrelationKey.java
    ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/CorrelationKeySet.java
    ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/OptionalCorrelationKey.java
    ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java
    ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnection.java
    ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnectionFactory.java
    ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/CorrelationSetDAO.java
    ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/CorrelatorDAO.java
    ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/MessageRouteDAO.java
    ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java
    ode/branches/APACHE_ODE_1.X/bpel-epr/src/main/java/org/apache/ode/il/MockScheduler.java
    ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OEventHandler.java
    ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OPartnerLink.java
    ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OPickReceive.java
    ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OProcess.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelDatabase.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/OutstandingRequestManager.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerLinkMyRoleImpl.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ReplacementMapImpl.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionFactoryImpl.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelationSetDaoImpl.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelatorDaoImpl.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageRouteDaoImpl.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/BpelJacobRunnable.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/EH_EVENT.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/PICK.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/Selector.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java
    ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java
    ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java
    ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/CorrelationSetDaoImpl.java
    ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/CorrelatorDaoImpl.java
    ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/MessageRouteDaoImpl.java
    ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ProcessDaoImpl.java
    ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HCorrelationSet.java
    ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/hobj/HProcessInstance.java
    ode/branches/APACHE_ODE_1.X/dao-jpa-ojpa-derby/src/test/java/org/apache/ode/dao/jpa/test/InsertObjectTest.java
    ode/branches/APACHE_ODE_1.X/dao-jpa-ojpa-derby/src/test/java/org/apache/ode/dao/jpa/test/SelectObjectTest.java
    ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionFactoryImpl.java
    ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/BPELDAOConnectionImpl.java
    ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelationSetDAOImpl.java
    ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/CorrelatorDAOImpl.java
    ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageExchangeDAOImpl.java
    ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/MessageRouteDAOImpl.java
    ode/branches/APACHE_ODE_1.X/dao-jpa/src/main/java/org/apache/ode/dao/jpa/ProcessDAOImpl.java
    ode/branches/APACHE_ODE_1.X/jacob/src/main/java/org/apache/ode/jacob/vpu/ExecutionQueueImpl.java
    ode/branches/APACHE_ODE_1.X/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java
    ode/branches/APACHE_ODE_1.X/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/SimpleScheduler.java

Modified: ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java (original)
+++ ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java Tue Jan  6 18:00:47 2009
@@ -181,6 +181,8 @@
 
             registerExternalVariableModules();
 
+            _store.loadAll();
+
             try {
                 _server.start();
             } catch (Exception ex) {
@@ -197,7 +199,8 @@
             new DeploymentWebService().enableService(_axisConfig, _server, _store, _poller, _appRoot.getAbsolutePath(), _workRoot
                     .getAbsolutePath());
 
-            _store.loadAll();
+            __log.debug("Starting scheduler");
+            _scheduler.start();
 
             __log.debug("Initializing JCA adapter.");
             initConnector();

Modified: ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/CorrelationKey.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/CorrelationKey.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/CorrelationKey.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/CorrelationKey.java Tue Jan  6 18:00:47 2009
@@ -18,7 +18,7 @@
  */
 package org.apache.ode.bpel.common;
 
-import java.io.Serializable;
+import java.io.*;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -48,28 +48,27 @@
 
     private static final long serialVersionUID = 1L;
 
-    /** CorrelationSet identifier. */
-    private int _csetId;
-
+    /** CorrelationSet name. */
+    private String _csetName;
     /** Key values. */
-    private final String _keyValues[];
+    private String _keyValues[];
 
     /**
      * Constructor.
      * 
-     * @param csetId
+     * @param csetName
      *            correlation set identifier
      * @param keyValues
      *            correlation key values
      */
-    public CorrelationKey(int csetId, String[] keyValues) {
-        _csetId = csetId;
+    public CorrelationKey(String csetName, String[] keyValues) {
+        _csetName = csetName;
         _keyValues = keyValues;
     }
 
     public CorrelationKey(String canonicalForm) {
         int firstTilde = canonicalForm.indexOf('~');
-        _csetId = Integer.parseInt(canonicalForm.substring(0, firstTilde == -1 ? canonicalForm.length() : firstTilde));
+        _csetName = canonicalForm.substring(0, firstTilde == -1 ? canonicalForm.length() : firstTilde);
 
         if (firstTilde != -1) {
             List<String> keys = new ArrayList<String>();
@@ -95,8 +94,8 @@
     }
 
     /** Return the OCorrelation id for the correlation set */
-    public int getCSetId() {
-        return _csetId;
+    public String getCorrelationSetName() {
+        return _csetName;
     }
 
     /** Return the values for the correlation set */
@@ -134,7 +133,7 @@
     public boolean equals(Object o) {
         CorrelationKey okey = (CorrelationKey) o;
 
-        if (okey == null || okey._csetId != _csetId || okey._keyValues.length != _keyValues.length)
+        if (okey == null || !okey._csetName.equals(_csetName) || okey._keyValues.length != _keyValues.length)
             return false;
 
         for (int i = 0; i < _keyValues.length; ++i)
@@ -151,7 +150,7 @@
      * @see Object#hashCode
      */
     public int hashCode() {
-        int hashCode = _csetId;
+        int hashCode = _csetName.hashCode();
         for (String _keyValue : _keyValues)
             hashCode ^= _keyValue.hashCode();
         return hashCode;
@@ -163,7 +162,7 @@
     public String toString() {
         StringBuffer buf = new StringBuffer("{CorrelationKey ");
         buf.append("setId=");
-        buf.append(_csetId);
+        buf.append(_csetName);
         buf.append(", values=");
         buf.append(CollectionUtils.makeCollection(ArrayList.class, _keyValues));
         buf.append('}');
@@ -173,7 +172,7 @@
 
     public String toCanonicalString() {
         StringBuffer buf = new StringBuffer();
-        buf.append(this.getCSetId());
+        buf.append(_csetName);
         buf.append('~');
         for (int i = 0; i < getValues().length; ++i) {
             if (i != 0)

Modified: ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/CorrelationKeySet.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/CorrelationKeySet.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/CorrelationKeySet.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/CorrelationKeySet.java Tue Jan  6 18:00:47 2009
@@ -60,7 +60,7 @@
 	 */
 	public CorrelationKeySet add(CorrelationKey ck) {
 		for( CorrelationKey key : correlationKeys ) {
-			if( key.getCSetId() == ck.getCSetId() ) {
+			if( key.getCorrelationSetName() == ck.getCorrelationSetName() ) {
 				correlationKeys.remove(ck);
 				break;
 			}
@@ -77,7 +77,7 @@
 	 * @return returns true if the correlation key set is opaque
 	 */
 	public boolean isOpaque() {
-		return correlationKeys.size() == 1 && correlationKeys.iterator().next().getCSetId() == -1;
+		return correlationKeys.size() == 1 && correlationKeys.iterator().next().getCorrelationSetName().equals("-1");
 	}
 
 	/**
@@ -186,7 +186,7 @@
     	CorrelationKeySet explicitKeySet = new CorrelationKeySet();
     	for( CorrelationKey ckey : correlationKeys ) {
     		// assumes only ONE opaque key if there is
-    		if( ckey.getCSetId() == -1 ) {
+    		if( ckey.getCorrelationSetName().equals("-1") ) {
     			opaqueKey = ckey;
     		} else {
     			containsNonOpaque = true;
@@ -280,7 +280,7 @@
 	}
 
 	private static enum ParserState {
-		INITIAL, MET_ALPHA, MET_LEFT_BRACKET, MET_RIGHT_BRACKET, MET_QUESTION, MET_COMMA
+		INITIAL, MET_ALPHA, MET_LEFT_BRACKET, MET_RIGHT_BRACKET, MET_COMMA
 	}
 
 	// parses a canonical form of correlation key set through an automata subsystem(FSM)
@@ -328,10 +328,6 @@
 					buf.setLength(0);
 					state = ParserState.MET_COMMA;
 				}
-			} else if( state == ParserState.MET_QUESTION ) {
-				if( ch == ',' ) {
-					state = ParserState.MET_COMMA;
-				}
 			} else if( state == ParserState.MET_COMMA ) {
 				if( ch == '[' ) {
 					state = ParserState.MET_LEFT_BRACKET;
@@ -354,9 +350,8 @@
 			if( o1 == null || o2 == null ) {
 				return 0;
 			}
-			
 			// used only in sorting the correlation keys in the CorrelationKeySet; does not matter with the values
-			return o1.getCSetId() - o2.getCSetId();
+			return o1.getCorrelationSetName().compareTo(o2.getCorrelationSetName());
 		}
     }    
 }
\ No newline at end of file

Modified: ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/OptionalCorrelationKey.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/OptionalCorrelationKey.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/OptionalCorrelationKey.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/common/OptionalCorrelationKey.java Tue Jan  6 18:00:47 2009
@@ -17,8 +17,8 @@
 public class OptionalCorrelationKey extends CorrelationKey implements Serializable {
     private static final long serialVersionUID = 1L;
 
-    public OptionalCorrelationKey(int csetId, String[] keyValues) {
-    	super(csetId, keyValues);
+    public OptionalCorrelationKey(String csetName, String[] keyValues) {
+    	super(csetName, keyValues);
     }
 
     public OptionalCorrelationKey(String canonicalForm) {
@@ -30,8 +30,8 @@
      */
     public String toString() {
         StringBuffer buf = new StringBuffer("{OptionalCorrelationKey ");
-        buf.append("setId=");
-        buf.append(getCSetId());
+        buf.append("setName=");
+        buf.append(getCorrelationSetName());
         buf.append(", values=");
         buf.append(CollectionUtils.makeCollection(ArrayList.class, getValues()));
         buf.append('}');

Modified: ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-api/src/main/java/org/apache/ode/bpel/iapi/Scheduler.java Tue Jan  6 18:00:47 2009
@@ -76,6 +76,8 @@
     <T> T execTransaction(Callable<T> transaction)
             throws Exception, ContextException;
 
+    void setRollbackOnly() throws Exception;
+
     /**
      * Same as execTransaction but executes in a different thread to guarantee
      * isolation from the main execution thread.

Modified: ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnection.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnection.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnection.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnection.java Tue Jan  6 18:00:47 2009
@@ -94,10 +94,11 @@
   List<BpelEvent> bpelEventQuery(InstanceFilter ifilter, BpelEventFilter efilter);
 
   void close();
-  
-  
+
   Map<Long, Collection<CorrelationSetDAO>> getCorrelationSets(Collection<ProcessInstanceDAO> instances);
 
+  Collection<CorrelationSetDAO> getActiveCorrelationSets();
+
   ProcessDAO createProcess(QName pid, QName type, String guid, long version);
 
   /**

Modified: ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnectionFactory.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnectionFactory.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnectionFactory.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/BpelDAOConnectionFactory.java Tue Jan  6 18:00:47 2009
@@ -19,6 +19,7 @@
 package org.apache.ode.bpel.dao;
 
 
+import javax.sql.DataSource;
 import java.util.Properties;
 
 public interface BpelDAOConnectionFactory {
@@ -43,4 +44,6 @@
   
   public void shutdown();
 
+    public DataSource getDataSource();
+
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/CorrelationSetDAO.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/CorrelationSetDAO.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/CorrelationSetDAO.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/CorrelationSetDAO.java Tue Jan  6 18:00:47 2009
@@ -68,4 +68,12 @@
    */
   public Map<QName, String> getProperties();
 
+    /**
+     * @return the process this correlation is related to, gives a chance of optimization to the underlying impl
+     */
+    ProcessDAO getProcess();
+    /**
+     * @return the instance this correlation is related to, gives a chance of optimization to the underlying impl
+     */
+    ProcessInstanceDAO getInstance();
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/CorrelatorDAO.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/CorrelatorDAO.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/CorrelatorDAO.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/CorrelatorDAO.java Tue Jan  6 18:00:47 2009
@@ -22,6 +22,8 @@
 
 import org.apache.ode.bpel.common.CorrelationKeySet;
 
+import java.util.Collection;
+
 /**
  * <p>
  * Data access object representing a <em>correlator</em>. A correlator
@@ -54,6 +56,8 @@
    */
   String getCorrelatorId();
 
+    void setCorrelatorId(String newId);
+
   /**
    * Enqueue a message exchange to the queue with a set of correlation keys.
    *
@@ -72,6 +76,11 @@
    */
   MessageExchangeDAO dequeueMessage(CorrelationKeySet correlationKeySet);
 
+    /**
+     * @return all messages waiting on this correlator, use with care as it can potentially return a lot of values
+     */
+    Collection<CorrelatorMessageDAO> getAllMessages();
+
   /**
    * Find a route matching the given correlation key.
    * @param correlationKey correlation key
@@ -93,4 +102,9 @@
    * @param routeGroupId
    */
   void removeRoutes(String routeGroupId, ProcessInstanceDAO target);
+
+    /**
+     * @return all routes registered on this correlator, use with care as it can potentially return a lot of values
+     */
+    Collection<MessageRouteDAO> getAllRoutes();
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/MessageRouteDAO.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/MessageRouteDAO.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/MessageRouteDAO.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/MessageRouteDAO.java Tue Jan  6 18:00:47 2009
@@ -20,6 +20,8 @@
 
 import org.apache.ode.bpel.common.CorrelationKeySet;
 
+import org.apache.ode.bpel.common.CorrelationKey;
+
 /**
  * Data access object representing a message consumer. A message consumer
  * represents an unsatisfied BPEL <code>pick</code> or <code>receive</code>
@@ -27,22 +29,27 @@
  */
 public interface MessageRouteDAO  {
 
-  /**
-   * Get the BPEL process instance to which this consumer belongs.
-   *
-   * @return the process instance to which this consumer belongs
-   */
-  ProcessInstanceDAO getTargetInstance();
-
-  String getGroupId();
-
-  int getIndex();
-  
-  String getRoute();
-  
-  /**
-   * Returns a correlation key set for the message route
-   * @return
-   */
-  public CorrelationKeySet getCorrelationKeySet();
+    /**
+     * Get the BPEL process instance to which this consumer belongs.
+     *
+     * @return the process instance to which this consumer belongs
+     */
+    ProcessInstanceDAO getTargetInstance();
+
+    String getGroupId();
+
+    int getIndex();
+
+    String getRoute();
+
+    /**
+     * Returns a correlation key set for the message route
+     * @return
+     */
+    public CorrelationKeySet getCorrelationKeySet();
+
+    void setCorrelationKey(CorrelationKey key);
+
+    CorrelationKey getCorrelationKey();
+
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-dao/src/main/java/org/apache/ode/bpel/dao/ProcessDAO.java Tue Jan  6 18:00:47 2009
@@ -111,4 +111,9 @@
     String getGuid();
 
     int getNumInstances();
+
+    /**
+     * @return all instances that haven't completed, use with care as there could be a lot of them 
+     */
+    Collection<ProcessInstanceDAO> getActiveInstances();
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-epr/src/main/java/org/apache/ode/il/MockScheduler.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-epr/src/main/java/org/apache/ode/il/MockScheduler.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-epr/src/main/java/org/apache/ode/il/MockScheduler.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-epr/src/main/java/org/apache/ode/il/MockScheduler.java Tue Jan  6 18:00:47 2009
@@ -141,6 +141,10 @@
         }
     }
 
+    public void setRollbackOnly() throws Exception {
+        if (_txm != null) _txm.setRollbackOnly();
+    }
+
     public <T> Future<T> execIsolatedTransaction(final Callable<T> transaction) throws Exception, ContextException {
         return _executorSvc.submit(new Callable<T>() {
             public T call() throws Exception {

Modified: ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OEventHandler.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OEventHandler.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OEventHandler.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OEventHandler.java Tue Jan  6 18:00:47 2009
@@ -59,7 +59,7 @@
         public final List <OScope.CorrelationSet> initCorrelations = new ArrayList<OScope.CorrelationSet>();
 
         /** Correlation set to match on. */
-        public final List <OScope.CorrelationSet> matchCorrelations = new ArrayList<OScope.CorrelationSet>();
+        public List <OScope.CorrelationSet> matchCorrelations = new ArrayList<OScope.CorrelationSet>();
         private OScope.CorrelationSet matchCorrelation;
 
         /** Correlation set to join on. */
@@ -87,6 +87,7 @@
         	in.defaultReadObject();
 
         	// backward compatibility; matchCorrelation could have a value if read from old definition
+            if (matchCorrelations == null) matchCorrelations = new ArrayList<OScope.CorrelationSet>();
         	if( matchCorrelation != null ) {
         		matchCorrelations.add(matchCorrelation);
         	}

Modified: ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OPartnerLink.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OPartnerLink.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OPartnerLink.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OPartnerLink.java Tue Jan  6 18:00:47 2009
@@ -134,6 +134,8 @@
      */
     @SuppressWarnings("unchecked")
     public Set<OScope.CorrelationSet> getJoinningCorrelationSetsForOperation(Operation operation) {
+        if (_joiningCorrelationSets == null) return new HashSet();
+        
         Set<OScope.CorrelationSet> ret = _joiningCorrelationSets.get(operation.getName());
         if (ret == null) {
             return Collections.EMPTY_SET;
@@ -156,4 +158,16 @@
                 return op;
         return null;
     }
+
+    @Override
+    public int hashCode() {
+        return name.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if(!(obj instanceof OPartnerLink)) return false;
+        OPartnerLink other = (OPartnerLink) obj;
+        return (name == null && other.name == null && super.equals(obj)) || name.equals(other.name);        
+    }
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OPickReceive.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OPickReceive.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OPickReceive.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OPickReceive.java Tue Jan  6 18:00:47 2009
@@ -61,7 +61,7 @@
         public final List<OScope.CorrelationSet> initCorrelations = new ArrayList<OScope.CorrelationSet>();
 
         /** Correlations to match on. */
-        public final List<OScope.CorrelationSet> matchCorrelations = new ArrayList<OScope.CorrelationSet>();
+        public List<OScope.CorrelationSet> matchCorrelations = new ArrayList<OScope.CorrelationSet>();
         // left out for backward-compatibility, java serialization is lenient about scope
         private OScope.CorrelationSet matchCorrelation;
         
@@ -92,6 +92,7 @@
         	in.defaultReadObject();
 
         	// backward compatibility; matchCorrelation could have a value if read from old definition
+            if (matchCorrelations == null) matchCorrelations = new ArrayList<OScope.CorrelationSet>();
         	if( matchCorrelation != null ) {
         		matchCorrelations.add(matchCorrelation);
         	}

Modified: ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OProcess.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OProcess.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OProcess.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-obj/src/main/java/org/apache/ode/bpel/o/OProcess.java Tue Jan  6 18:00:47 2009
@@ -128,7 +128,7 @@
             if (plink.hasMyRole()) {
                 for (Iterator opI = plink.myRolePortType.getOperations().iterator(); opI.hasNext();) {
                     Operation op = (Operation)opI.next();
-                    correlators.add(plink.getId() + "." + op.getName());
+                    correlators.add(plink.getName() + "." + op.getName());
                 }
             }
         }

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelDatabase.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelDatabase.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelDatabase.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelDatabase.java Tue Jan  6 18:00:47 2009
@@ -32,7 +32,7 @@
 /**
  * Encapsulates transactional access to the BPEL database.
  */
-class BpelDatabase {
+public class BpelDatabase {
   static Log __log = LogFactory.getLog(BpelDatabase.class);
 
   protected BpelDAOConnectionFactory _sscf;
@@ -70,7 +70,7 @@
    * @return
    * @throws DConnectionException
    */
-  <T> T exec(final Callable<T> callable) throws Exception {
+  public <T> T exec(final Callable<T> callable) throws Exception {
     return _scheduler.execTransaction(new java.util.concurrent.Callable<T>() {
       public T call() throws Exception {
         return callable.run(_sscf.getConnection());
@@ -78,7 +78,7 @@
     });
   }
 
-  interface Callable<T> {
+  public interface Callable<T> {
      public T run(BpelDAOConnection conn) throws Exception;
   }
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java Tue Jan  6 18:00:47 2009
@@ -70,7 +70,7 @@
 
 /**
  * Entry point into the runtime of a BPEL process.
- * 
+ *
  * @author mszefler
  * @author Matthieu Riou <mriou at apache dot org>
  */
@@ -87,9 +87,9 @@
      * it's important to note that the same process with the same endpoint can have 2 different myroles. */
     private volatile Map<PartnerLinkMyRoleImpl, Endpoint> _endpointToMyRoleMap;
 
-    /** Mapping from a potentially shared endpoint to its EPR */ 
+    /** Mapping from a potentially shared endpoint to its EPR */
     private SharedEndpoints _sharedEps;
-    
+
     // Backup hashmaps to keep initial endpoints handy after dehydration
     private Map<Endpoint, EndpointReference> _myEprs = new HashMap<Endpoint, EndpointReference>();
     private Map<Endpoint, EndpointReference> _partnerEprs = new HashMap<Endpoint, EndpointReference>();
@@ -116,9 +116,9 @@
 
     /** Deploy-time configuraton for external variables. */
     private ExternalVariableConf _extVarConf;
-    
+
     private ExternalVariableManager _evm;
-    
+
     public BpelProcess(ProcessConf conf) {
         _pid = conf.getProcessId();
         _pconf = conf;
@@ -127,33 +127,33 @@
 
     /**
      * Retrives the base URI to use for local resource resolution.
-     * 
+     *
      * @return URI - instance representing the absolute file path to the physical location of the process definition folder.
      */
     public URI getBaseResourceURI() {
-    	return this._pconf.getBaseURI();
+        return this._pconf.getBaseURI();
     }
-    
+
     /**
      * Intiialize the external variable configuration/engine manager. This is called from hydration logic, so it 
      * is possible to change the external variable configuration at runtime.
-     * 
+     *
      */
     void initExternalVariables() {
         List<Element> conf = _pconf.getExtensionElement(ExternalVariableConf.EXTVARCONF_ELEMENT);
         _extVarConf = new ExternalVariableConf(conf);
         _evm = new ExternalVariableManager(_pid, _extVarConf, _engine._contexts.externalVariableEngines, _oprocess);
     }
-    
+
 
     public String toString() {
         return "BpelProcess[" + _pid + "]";
     }
- 
+
     public ExternalVariableManager getEVM() {
         return _evm;
     }
-   
+
     public void recoverActivity(ProcessInstanceDAO instanceDAO, String channel, long activityId, String action, FaultData fault) {
         if (__log.isDebugEnabled())
             __log.debug("Recovering activity in process " + instanceDAO.getInstanceId() + " with action " + action);
@@ -171,7 +171,7 @@
 
     /**
      * Entry point for message exchanges aimed at the my role.
-     * 
+     *
      * @param mex
      */
     void invokeProcess(MyRoleMessageExchangeImpl mex) {
@@ -204,20 +204,20 @@
                 boolean createInstance = target.isCreateInstance(mex);
 
                 if (mex.getStatus() != MessageExchange.Status.FAILURE) {
-                	for (PartnerLinkMyRoleImpl.RoutingInfo routing : routings) {
-	                    if (routing.messageRoute == null && createInstance) {
-	                        // No route but we can create a new instance
-	                        target.invokeNewInstance(mex, routing);
-	                        routed = true; 
-	                    } else if (routing.messageRoute != null) {
-	                        // Found a route, hitting it
-	                        target.invokeInstance(mex, routing);
-	                        routed = true; 
-	                    }
-                	}
+                    for (PartnerLinkMyRoleImpl.RoutingInfo routing : routings) {
+                        if (routing.messageRoute == null && createInstance) {
+                            // No route but we can create a new instance
+                            target.invokeNewInstance(mex, routing);
+                            routed = true;
+                        } else if (routing.messageRoute != null) {
+                            // Found a route, hitting it
+                            target.invokeInstance(mex, routing);
+                            routed = true;
+                        }
+                    }
                 }
                 if (routed) {
-                	break;
+                    break;
                 }
             }
 
@@ -279,7 +279,7 @@
 
     /**
      * Extract the value of a BPEL property from a BPEL messsage variable.
-     * 
+     *
      * @param msgData
      *            message variable data
      * @param alias
@@ -330,7 +330,7 @@
     /**
      * Get the element name for a given WSDL part. If the part is an <em>element</em> part, the name of that element is returned.
      * If the part is an XML schema typed part, then the name of the part is returned in the null namespace.
-     * 
+     *
      * @param part
      *            WSDL {@link javax.wsdl.Part}
      * @return name of element containing said part
@@ -341,7 +341,7 @@
 
     /**
      * Process the message-exchange interceptors.
-     * 
+     *
      * @param mex
      *            message exchange
      * @return <code>true</code> if execution should continue, <code>false</code> otherwise
@@ -393,30 +393,30 @@
 
                 BpelRuntimeContextImpl processInstance = createRuntimeContext(procInstance, null, null);
                 switch (we.getType()) {
-                case TIMER:
-                    if (__log.isDebugEnabled()) {
-                        __log.debug("handleWorkEvent: TimerWork event for process instance " + processInstance);
-                    }
-                    processInstance.timerEvent(we.getChannel());
-                    break;
-                case RESUME:
-                    if (__log.isDebugEnabled()) {
-                        __log.debug("handleWorkEvent: ResumeWork event for iid " + we.getIID());
-                    }
-                    processInstance.execute();
-                    break;
-                case INVOKE_RESPONSE:
-                    if (__log.isDebugEnabled()) {
-                        __log.debug("InvokeResponse event for iid " + we.getIID());
-                    }
-                    processInstance.invocationResponse(we.getMexId(), we.getChannel());
-                    processInstance.execute();
-                    break;
-                case MATCHER:
-                    if (__log.isDebugEnabled()) {
-                        __log.debug("Matcher event for iid " + we.getIID());
-                    }
-                    processInstance.matcherEvent(we.getCorrelatorId(), we.getCorrelationKeySet());
+                    case TIMER:
+                        if (__log.isDebugEnabled()) {
+                            __log.debug("handleWorkEvent: TimerWork event for process instance " + processInstance);
+                        }
+                        processInstance.timerEvent(we.getChannel());
+                        break;
+                    case RESUME:
+                        if (__log.isDebugEnabled()) {
+                            __log.debug("handleWorkEvent: ResumeWork event for iid " + we.getIID());
+                        }
+                        processInstance.execute();
+                        break;
+                    case INVOKE_RESPONSE:
+                        if (__log.isDebugEnabled()) {
+                            __log.debug("InvokeResponse event for iid " + we.getIID());
+                        }
+                        processInstance.invocationResponse(we.getMexId(), we.getChannel());
+                        processInstance.execute();
+                        break;
+                    case MATCHER:
+                        if (__log.isDebugEnabled()) {
+                            __log.debug("Matcher event for iid " + we.getIID());
+                        }
+                        processInstance.matcherEvent(we.getCorrelatorId(), we.getCorrelationKeySet());
                 }
             }
         } finally {
@@ -466,7 +466,7 @@
             }
 
             if (pl.hasPartnerRole()) {
-            	Endpoint endpoint = _pconf.getInvokeEndpoints().get(pl.getName());
+                Endpoint endpoint = _pconf.getInvokeEndpoints().get(pl.getName());
                 if (endpoint == null && pl.initializePartnerRole)
                     throw new IllegalArgumentException(pl.getName() + " must be bound to an endpoint in deploy.xml");
                 PartnerLinkPartnerRoleImpl partnerRole = new PartnerLinkPartnerRoleImpl(this, pl, endpoint);
@@ -481,12 +481,12 @@
     }
 
     static String genCorrelatorId(OPartnerLink plink, String opName) {
-        return plink.getId() + "." + opName;
+        return plink.getName() + "." + opName;
     }
 
     /**
      * De-serialize the compiled process representation from a stream.
-     * 
+     *
      * @param is
      *            input stream
      * @return process information from configuration database
@@ -500,7 +500,7 @@
 
     /**
      * Get all the services that are implemented by this process.
-     * 
+     *
      * @return list of qualified names corresponding to the myroles.
      */
     public Set<Endpoint> getServiceNames() {
@@ -519,24 +519,24 @@
         __log.debug("Activating " + _pid);
         // Activate all the my-role endpoints.
         for (Map.Entry<String, Endpoint> entry : _pconf.getProvideEndpoints().entrySet()) {
-        	Endpoint endpoint = entry.getValue();
-        	EndpointReference initialEPR = null;
-        	if (isShareable(endpoint)) {
-	        	// Check if the EPR already exists for the given endpoint
-	        	initialEPR = _sharedEps.getEndpointReference(endpoint); 
-	        	if (initialEPR == null) {
-	        		// Create an EPR by physically activating the endpoint 
-	                initialEPR = _engine._contexts.bindingContext.activateMyRoleEndpoint(_pid, entry.getValue());
-	                _sharedEps.addEndpoint(endpoint, initialEPR);
-	                __log.debug("Activated " + _pid + " myrole " + entry.getKey() + ": EPR is " + initialEPR);
-	        	}
-	            // Increment the reference count on the endpoint  
-	            _sharedEps.incrementReferenceCount(endpoint);
-        	} else {
-        		// Create an EPR by physically activating the endpoint 
+            Endpoint endpoint = entry.getValue();
+            EndpointReference initialEPR = null;
+            if (isShareable(endpoint)) {
+                // Check if the EPR already exists for the given endpoint
+                initialEPR = _sharedEps.getEndpointReference(endpoint);
+                if (initialEPR == null) {
+                    // Create an EPR by physically activating the endpoint
+                    initialEPR = _engine._contexts.bindingContext.activateMyRoleEndpoint(_pid, entry.getValue());
+                    _sharedEps.addEndpoint(endpoint, initialEPR);
+                    __log.debug("Activated " + _pid + " myrole " + entry.getKey() + ": EPR is " + initialEPR);
+                }
+                // Increment the reference count on the endpoint
+                _sharedEps.incrementReferenceCount(endpoint);
+            } else {
+                // Create an EPR by physically activating the endpoint
                 initialEPR = _engine._contexts.bindingContext.activateMyRoleEndpoint(_pid, entry.getValue());
                 __log.debug("Activated " + _pid + " myrole " + entry.getKey() + ": EPR is " + initialEPR);
-        	}
+            }
             _myEprs.put(endpoint, initialEPR);
         }
         __log.debug("Activated " + _pid);
@@ -547,46 +547,26 @@
     void deactivate() {
         // Deactivate all the my-role endpoints.
         for (Endpoint endpoint : _myEprs.keySet()) {
-        	// Deactivate the EPR only if there are no more references 
-        	// to this endpoint from any (active) BPEL process.
-        	if (isShareable(endpoint)) {
-	        	__log.debug("deactivating shared endpoint " + endpoint);
-	        	if (!_sharedEps.decrementReferenceCount(endpoint)) {
-		            _engine._contexts.bindingContext.deactivateMyRoleEndpoint(endpoint);
-		            _sharedEps.removeEndpoint(endpoint);
-	        	}
-        	} else {
-	        	__log.debug("deactivating non-shared endpoint " + endpoint);
-	            _engine._contexts.bindingContext.deactivateMyRoleEndpoint(endpoint);
-        	}
+            // Deactivate the EPR only if there are no more references
+            // to this endpoint from any (active) BPEL process.
+            if (isShareable(endpoint)) {
+                __log.debug("deactivating shared endpoint " + endpoint);
+                if (!_sharedEps.decrementReferenceCount(endpoint)) {
+                    _engine._contexts.bindingContext.deactivateMyRoleEndpoint(endpoint);
+                    _sharedEps.removeEndpoint(endpoint);
+                }
+            } else {
+                __log.debug("deactivating non-shared endpoint " + endpoint);
+                _engine._contexts.bindingContext.deactivateMyRoleEndpoint(endpoint);
+            }
         }
         // TODO Deactivate all the partner-role channels
     }
 
     private boolean isShareable(Endpoint endpoint) {
-    	return _pconf.isSharedService(endpoint.serviceName);
-
-// 		Can't use the logic below since it assumes process is loaded.
-//
-//    	if (!_pconf.isSharedService(endpoint.serviceName)) {
-//    		return false;
-//    	}
-//    	PartnerLinkMyRoleImpl partnerLink = null;
-//    	if (_endpointToMyRoleMap == null) {
-//    		return false;
-//    	}
-//    	for (Map.Entry<PartnerLinkMyRoleImpl, Endpoint> entry : _endpointToMyRoleMap.entrySet()) {
-//    		if (entry.getValue().equals(endpoint)) {
-//    			partnerLink = entry.getKey();
-//    			break;
-//    		}
-//    	}
-//    	if (partnerLink == null) {
-//    		return false;    	
-//    	}
-//    	return partnerLink.isOneWayOnly();
+        return _pconf.isSharedService(endpoint.serviceName);
     }
-    
+
     EndpointReference getInitialPartnerRoleEPR(OPartnerLink link) {
         try {
             _hydrationLatch.latch(1);
@@ -679,8 +659,8 @@
             _hydrationLatch.release(1);
         }
     }
-    
-    OProcess getOProcess() {
+
+    public OProcess getOProcess() {
         try {
             _hydrationLatch.latch(1);
             return _oprocess;
@@ -732,10 +712,10 @@
     public long getLastUsed() {
         return _lastUsed;
     }
-    
+
     QName getProcessType() {
-    	return _pconf.getType();
-    }    	 
+        return _pconf.getType();
+    }
 
     /**
      * Get a hint as to whether this process is hydrated. Note this is only a hint, since things could change.
@@ -751,7 +731,7 @@
 
     /** Create a version-appropriate runtime context. */
     BpelRuntimeContextImpl createRuntimeContext(ProcessInstanceDAO dao, PROCESS template,
-            MyRoleMessageExchangeImpl instantiatingMessageExchange) {
+                                                MyRoleMessageExchangeImpl instantiatingMessageExchange) {
         return new BpelRuntimeContextImpl(this, dao, template, instantiatingMessageExchange);
 
     }
@@ -839,8 +819,8 @@
             registerExprLang(_oprocess);
 
             setRoles(_oprocess);
-    		initExternalVariables();
-    
+            initExternalVariables();
+
             if (!_hydratedOnce) {
                 for (PartnerLinkPartnerRoleImpl prole : _partnerRoles.values()) {
                     // Null for initializePartnerRole = false
@@ -908,20 +888,25 @@
             }
         }
     }
-    
+
     public boolean isCleanupCategoryEnabled(boolean instanceSucceeded, CLEANUP_CATEGORY category) {
-    	return _pconf.isCleanupCategoryEnabled(instanceSucceeded, category);
+        return _pconf.isCleanupCategoryEnabled(instanceSucceeded, category);
     }
 
     public Set<CLEANUP_CATEGORY> getCleanupCategories(boolean instanceSucceeded) {
-    	return _pconf.getCleanupCategories(instanceSucceeded);
+        return _pconf.getCleanupCategories(instanceSucceeded);
     }
-    
+
     public Node getProcessProperty(QName propertyName) {
-    	Map<QName, Node> properties = _pconf.getProcessProperties();
-    	if (properties != null) {
-    		return properties.get(propertyName);
-    	}
-    	return null;
+        Map<QName, Node> properties = _pconf.getProcessProperties();
+        if (properties != null) {
+            return properties.get(propertyName);
+        }
+        return null;
     }
+
+    public ProcessConf getConf() {
+        return _pconf;
+    }
+
 }
\ No newline at end of file

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java Tue Jan  6 18:00:47 2009
@@ -557,11 +557,9 @@
     public void writeCorrelation(CorrelationSetInstance cset, CorrelationKey correlation) {
         ScopeDAO scopeDAO = _dao.getScope(cset.scopeInstance);
         CorrelationSetDAO cs = scopeDAO.getCorrelationSet(cset.declaration.name);
-        OScope.CorrelationSet csetdef = (OScope.CorrelationSet) _bpelProcess.getOProcess()
-                .getChild(correlation.getCSetId());
-        QName[] propNames = new QName[csetdef.properties.size()];
-        for (int m = 0; m < csetdef.properties.size(); m++) {
-            OProcess.OProperty oProperty = csetdef.properties.get(m);
+        QName[] propNames = new QName[cset.declaration.properties.size()];
+        for (int m = 0; m < cset.declaration.properties.size(); m++) {
+            OProcess.OProperty oProperty = cset.declaration.properties.get(m);
             propNames[m] = oProperty.name;
         }
         cs.setValue(propNames, correlation);
@@ -606,7 +604,7 @@
             propNames[i] = property.name.toString();
         }
 
-        CorrelationKey ckeyVal = new CorrelationKey(cset.declaration.getId(), propValues);
+        CorrelationKey ckeyVal = new CorrelationKey(cset.declaration.name, propValues);
         writeCorrelation(cset, ckeyVal);
     }
 

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelServerImpl.java Tue Jan  6 18:00:47 2009
@@ -52,6 +52,7 @@
 import org.apache.ode.utils.stl.CollectionsX;
 import org.apache.ode.utils.stl.MemberOfFunction;
 import org.apache.ode.bpel.evar.ExternalVariableModule;
+import org.apache.ode.bpel.engine.migration.MigrationHandler;
 
 /**
  * <p>
@@ -84,7 +85,6 @@
      */
     private final Set<BpelProcess> _registeredProcesses = new HashSet<BpelProcess>();
 
-
     private State _state = State.SHUTDOWN;
     private Contexts _contexts = new Contexts();
     private DehydrationPolicy _dehydrationPolicy;
@@ -131,10 +131,11 @@
                 __log.debug("start() ignored -- already started");
                 return;
             }
-
             __log.debug("BPEL SERVER starting.");
 
-            _contexts.scheduler.start();
+            // Eventually running some migrations before starting
+            new MigrationHandler(_contexts).migrate(_registeredProcesses);
+
             _state = State.RUNNING;
             __log.info(__msgs.msgServerStarted());
             if (_dehydrationPolicy != null) new Thread(new ProcessDefReaper()).start();

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/Contexts.java Tue Jan  6 18:00:47 2009
@@ -38,17 +38,17 @@
  * Aggregation of all the contexts provided to the BPEL engine by the
  * integration layer.
  */
-class Contexts {
+public class Contexts {
 
     MessageExchangeContext mexContext;
 
-    Scheduler scheduler;
+    public Scheduler scheduler;
 
     EndpointReferenceContext eprContext;
 
     BindingContext bindingContext;
 
-    BpelDAOConnectionFactory dao;
+    public BpelDAOConnectionFactory dao;
     BpelDAOConnectionFactory inMemDao;
 
     /** Global Message-Exchange interceptors. Must be copy-on-write!!! */ 

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/OutstandingRequestManager.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/OutstandingRequestManager.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/OutstandingRequestManager.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/OutstandingRequestManager.java Tue Jan  6 18:00:47 2009
@@ -43,13 +43,13 @@
  * for asynchronous messages. 
  * </p> 
  */
-class OutstandingRequestManager implements Serializable {
+public class OutstandingRequestManager implements Serializable {
   private static final long serialVersionUID = -5556374398943757951L;
 
   private static final Log __log = LogFactory.getLog(OutstandingRequestManager.class);
 
-  private final Map<RequestIdTuple, Entry> _byRid = new HashMap<RequestIdTuple, Entry>();
-  private final Map<String, Entry> _byChannel = new HashMap<String, Entry>();
+  public final Map<RequestIdTuple, Entry> _byRid = new HashMap<RequestIdTuple, Entry>();
+  public final Map<String, Entry> _byChannel = new HashMap<String, Entry>();
 
   int findConflict(Selector selectors[]) {
     if (__log.isTraceEnabled()) {
@@ -252,10 +252,10 @@
     }
   }
 
-  private class Entry implements Serializable {
+  public class Entry implements Serializable {
     private static final long serialVersionUID = -583743124656582887L;
     final String pickResponseChannel;
-    final Selector[] selectors;
+    public Object[] selectors;
     String mexRef;
 
     private Entry(String pickResponseChannel, Selector[] selectors) {

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerLinkMyRoleImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerLinkMyRoleImpl.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerLinkMyRoleImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/PartnerLinkMyRoleImpl.java Tue Jan  6 18:00:47 2009
@@ -305,7 +305,7 @@
         // Let's creata a key based on the sessionId
         String mySessionId = mex.getProperty(MessageExchange.PROPERTY_SEP_MYROLE_SESSIONID);
         if (mySessionId != null)
-            keySet.add(new CorrelationKey(-1, new String[] { mySessionId }));
+            keySet.add(new CorrelationKey("-1", new String[] { mySessionId }));
 
         return keySet;
     }
@@ -341,9 +341,9 @@
         }
 
         if( cset.hasJoinUseCases ) {
-        	key = new OptionalCorrelationKey(cset.getId(), values);
+        	key = new OptionalCorrelationKey(cset.name, values);
         } else {
-        	key = new CorrelationKey(cset.getId(), values);
+        	key = new CorrelationKey(cset.name, values);
         }
         
         return key;

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ReplacementMapImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ReplacementMapImpl.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ReplacementMapImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ReplacementMapImpl.java Tue Jan  6 18:00:47 2009
@@ -31,10 +31,10 @@
  * A JACOB {@link ReplacementMap} implementation that eliminates unnecessary serialization
  * of the (constant) compiled process model.
  */
-class ReplacementMapImpl implements ReplacementMap {
+public class ReplacementMapImpl implements ReplacementMap {
     private OProcess _oprocess;
 
-    ReplacementMapImpl(OProcess oprocess) {
+    public ReplacementMapImpl(OProcess oprocess) {
         _oprocess = oprocess;
     }
 

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionFactoryImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionFactoryImpl.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionFactoryImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionFactoryImpl.java Tue Jan  6 18:00:47 2009
@@ -23,6 +23,7 @@
 import org.apache.ode.bpel.iapi.Scheduler;
 
 import javax.xml.namespace.QName;
+import javax.sql.DataSource;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
@@ -57,4 +58,7 @@
     public void shutdown() {
     }
 
+    public DataSource getDataSource() {
+        return null;
+    }
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java Tue Jan  6 18:00:47 2009
@@ -366,6 +366,10 @@
         return map;
     }
 
+    public Collection<CorrelationSetDAO> getActiveCorrelationSets() {
+        throw new UnsupportedOperationException();
+    }
+
     public ProcessManagementDaoImpl getProcessManagement() {
         return new ProcessManagementDaoImpl();
     }

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelationSetDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelationSetDaoImpl.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelationSetDaoImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelationSetDaoImpl.java Tue Jan  6 18:00:47 2009
@@ -21,6 +21,8 @@
 import org.apache.ode.bpel.common.CorrelationKey;
 import org.apache.ode.bpel.dao.CorrelationSetDAO;
 import org.apache.ode.bpel.dao.ScopeDAO;
+import org.apache.ode.bpel.dao.ProcessDAO;
+import org.apache.ode.bpel.dao.ProcessInstanceDAO;
 
 import javax.xml.namespace.QName;
 import java.util.HashMap;
@@ -66,14 +68,15 @@
     return _scope;
   }
 
-  public void setValue(QName[] names, CorrelationKey values) {
-    _key = values;
-    _corrValues = new HashMap<QName, String>();
-    for (int m = 0; m < names.length; m++) {
-      _corrValues.put(names[m], values.getValues()[m]);
+    public void setValue(QName[] names, CorrelationKey values) {
+        _key = values;
+        if (names != null) {
+            _corrValues = new HashMap<QName, String>();
+            for (int m = 0; m < names.length; m++) {
+                _corrValues.put(names[m], values.getValues()[m]);
+            }
+        }
     }
-  }
-
 
   public CorrelationKey getValue() {
     return _key;
@@ -82,4 +85,12 @@
   public Map<QName, String> getProperties() {
     return _corrValues;
   }
+
+    public ProcessDAO getProcess() {
+        return getScope().getProcessInstance().getProcess();
+    }
+
+    public ProcessInstanceDAO getInstance() {
+        return getScope().getProcessInstance();
+    }
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelatorDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelatorDaoImpl.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelatorDaoImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/CorrelatorDaoImpl.java Tue Jan  6 18:00:47 2009
@@ -22,14 +22,12 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.ode.bpel.common.CorrelationKey;
 import org.apache.ode.bpel.common.CorrelationKeySet;
-import org.apache.ode.bpel.dao.CorrelatorDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.MessageRouteDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+import org.apache.ode.bpel.dao.*;
 
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Collection;
 
 /**
  * A very simple, in-memory implementation of the {@link CorrelatorDAO} interface.
@@ -68,23 +66,23 @@
     }
 
     public List<MessageRouteDAO> findRoute(CorrelationKeySet keySet) {
-    	List<MessageRouteDAO> routes = new ArrayList<MessageRouteDAO>();
+        List<MessageRouteDAO> routes = new ArrayList<MessageRouteDAO>();
+
+        assert keySet != null;
 
-    	assert keySet != null;
-    	
         if (__log.isDebugEnabled()) {
             __log.debug("findRoute: keySet=" + keySet);
         }
         List<ProcessInstanceDAO> targets = new ArrayList<ProcessInstanceDAO>();
         for (MessageRouteDaoImpl we : _routes) {
-    		assert we._ckeySet != null;
+            assert we._ckeySet != null;
 
-    		if( keySet.isRoutableTo(we._ckeySet, "all".equals(we.getRoute())) ) {
+            if( keySet.isRoutableTo(we._ckeySet, "all".equals(we.getRoute())) ) {
                 routes.add(we);
                 targets.add(we.getTargetInstance());
-    		}
+            }
         }
-        
+
         return routes;
     }
 
@@ -92,10 +90,22 @@
         return _correlatorId;
     }
 
+    public void setCorrelatorId(String newId) {
+        _correlatorId = newId;
+    }
+
     public void removeRoutes(String routeGroupId, ProcessInstanceDAO target) {
         ((ProcessInstanceDaoImpl)target).removeRoutes(routeGroupId);
     }
 
+    public Collection<MessageRouteDAO> getAllRoutes() {
+        return new ArrayList<MessageRouteDAO>(_routes);
+    }
+
+    public Collection<CorrelatorMessageDAO> getAllMessages() {
+        return new ArrayList<CorrelatorMessageDAO>(_messages);
+    }
+
     public void enqueueMessage(MessageExchangeDAO mex, CorrelationKeySet keySet) {
         if (__log.isDebugEnabled()) {
             __log.debug("enqueueProcessInvocation: data=" + mex + " keys=" + keySet);
@@ -147,14 +157,24 @@
         return buf.toString();
     }
 
-    private class MsgQueueEntry {
-        public final MessageExchangeDAO message;
-        public final CorrelationKeySet keySet;
+    private class MsgQueueEntry implements CorrelatorMessageDAO {
+        public MessageExchangeDAO message;
+        public CorrelationKeySet keySet;
 
         private MsgQueueEntry(MessageExchangeDAO mex,
                               CorrelationKeySet keySet) {
             this.message = mex;
             this.keySet = keySet;
         }
+
+        public CorrelationKey getCorrelationKey() {
+            return keySet.iterator().next();
+        }
+
+        public void setCorrelationKey(CorrelationKey ckey) {
+            keySet = new CorrelationKeySet();
+            keySet.add(ckey);
+        }
     }
+
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageRouteDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageRouteDaoImpl.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageRouteDaoImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageRouteDaoImpl.java Tue Jan  6 18:00:47 2009
@@ -19,6 +19,7 @@
 package org.apache.ode.bpel.memdao;
 
 import org.apache.ode.bpel.common.CorrelationKeySet;
+import org.apache.ode.bpel.common.CorrelationKey;
 import org.apache.ode.bpel.dao.MessageRouteDAO;
 import org.apache.ode.bpel.dao.ProcessInstanceDAO;
 
@@ -27,37 +28,46 @@
  * A very simple, in-memory implementation of the {@link MessageRouteDAO} interface.
  */
 class MessageRouteDaoImpl extends DaoBaseImpl implements MessageRouteDAO {
-  ProcessInstanceDaoImpl _instance;
-  String _groupId;
-  CorrelationKeySet _ckeySet;
-  int _idx;
-  String _route;
-
-  MessageRouteDaoImpl(ProcessInstanceDaoImpl owner, String groupId, CorrelationKeySet ckeySet, int idx, String routePolicy) {
-    _instance = owner;
-    _groupId = groupId;
-    _ckeySet = ckeySet;
-    _idx = idx;
-    _route = routePolicy;
-  }
-
-  public ProcessInstanceDAO getTargetInstance() {
-    return _instance;
-  }
-
-  public String getGroupId() {
-    return _groupId;
-  }
-
-  public int getIndex() {
-    return _idx;
-  }
-  
-  public String getRoute() {
-	  return _route;
-  }
-  
-  public CorrelationKeySet getCorrelationKeySet() {
-	  return _ckeySet;
-  }
+    ProcessInstanceDaoImpl _instance;
+    String _groupId;
+    CorrelationKeySet _ckeySet;
+    int _idx;
+    String _route;
+
+    MessageRouteDaoImpl(ProcessInstanceDaoImpl owner, String groupId, CorrelationKeySet ckeySet, int idx, String routePolicy) {
+        _instance = owner;
+        _groupId = groupId;
+        _ckeySet = ckeySet;
+        _idx = idx;
+        _route = routePolicy;
+    }
+
+    public ProcessInstanceDAO getTargetInstance() {
+        return _instance;
+    }
+
+    public String getGroupId() {
+        return _groupId;
+    }
+
+    public int getIndex() {
+        return _idx;
+    }
+
+    public String getRoute() {
+        return _route;
+    }
+
+    public CorrelationKeySet getCorrelationKeySet() {
+        return _ckeySet;
+    }
+
+    public void setCorrelationKey(CorrelationKey key) {
+        _ckeySet = new CorrelationKeySet();
+        _ckeySet.add(key);
+    }
+
+    public CorrelationKey getCorrelationKey() {
+        return _ckeySet.iterator().next();
+    }
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java Tue Jan  6 18:00:47 2009
@@ -31,6 +31,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ode.bpel.common.CorrelationKey;
+import org.apache.ode.bpel.common.ProcessState;
 import org.apache.ode.bpel.dao.CorrelationSetDAO;
 import org.apache.ode.bpel.dao.CorrelatorDAO;
 import org.apache.ode.bpel.dao.PartnerLinkDAO;
@@ -215,6 +216,15 @@
         _guid = guid;
     }
 
+    public Collection<ProcessInstanceDAO> getActiveInstances() {
+        ArrayList<ProcessInstanceDAO> pis = new ArrayList<ProcessInstanceDAO>();
+        for (ProcessInstanceDAO processInstanceDAO : _instances.values()) {
+            if (processInstanceDAO.getState() == ProcessState.STATE_ACTIVE)
+                pis.add(processInstanceDAO);
+        }
+        return pis;
+    }
+
     /**
      * Discard in-memory instances that exceeded their time-to-live to prevent memory leaks
      */

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/BpelJacobRunnable.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/BpelJacobRunnable.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/BpelJacobRunnable.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/BpelJacobRunnable.java Tue Jan  6 18:00:47 2009
@@ -97,7 +97,7 @@
               __log.debug("Setting correlation property " + propNames[i] + "=" + propValues[i]);
         }
 
-        CorrelationKey ckeyVal = new CorrelationKey(cset.declaration.getId(), propValues);
+        CorrelationKey ckeyVal = new CorrelationKey(cset.declaration.name, propValues);
         getBpelRuntimeContext().writeCorrelation(cset,ckeyVal);
     }
     

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/EH_EVENT.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/EH_EVENT.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/EH_EVENT.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/EH_EVENT.java Tue Jan  6 18:00:47 2009
@@ -130,7 +130,7 @@
                 if( keySet.isEmpty() ) {
                     // Adding a route for opaque correlation. In this case correlation is done on "out-of-band" session id.
                     String sessionId = getBpelRuntimeContext().fetchMySessionId(pLinkInstance);
-                    keySet.add(new CorrelationKey(-1, new String[] {sessionId}));
+                    keySet.add(new CorrelationKey("-1", new String[] {sessionId}));
                 }
 
                 selector =  new Selector(0,pLinkInstance,_oevent.operation.getName(), _oevent.operation.getOutput() == null, _oevent.messageExchangeId, keySet, _oevent.route);

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/PICK.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/PICK.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/PICK.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/PICK.java Tue Jan  6 18:00:47 2009
@@ -135,7 +135,7 @@
      * already initialized join correlation).
      * 
      * @param pLinkInstance the partner link instance
-     * @param matchCorrelation the match type correlation
+     * @param matchCorrelations the match type correlation
      * @return returns the resolved CorrelationKey
      * @throws FaultException thrown when the correlation is not initialized and createInstance flag is not set
      */
@@ -146,7 +146,7 @@
             // Adding a route for opaque correlation. In this case,
             // correlation is on "out-of-band" session-id
             String sessionId = getBpelRuntimeContext().fetchMySessionId(pLinkInstance);
-            keySet.add(new CorrelationKey(-1, new String[] { sessionId }));
+            keySet.add(new CorrelationKey("-1", new String[] { sessionId }));
         } else if (!matchCorrelations.isEmpty()) {
     		for( OScope.CorrelationSet cset : matchCorrelations ) {
     			CorrelationKey key = null;

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/Selector.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/Selector.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/Selector.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/Selector.java Tue Jan  6 18:00:47 2009
@@ -25,38 +25,38 @@
 import java.io.Serializable;
 
 public class Selector implements Serializable {
-	private static final long serialVersionUID = 1L;
+    private static final long serialVersionUID = 1L;
 
-	public final PartnerLinkInstance plinkInstance;
-	// here for the backward compatibility
-	@SuppressWarnings("unused")
-	private final CorrelationKey correlationKey = null;
-  public final CorrelationKeySet correlationKeySet;
-  public final String opName;
-  public final String messageExchangeId;
-  public final int idx;
-  public final boolean oneWay;
-  public final String route;
+    public final PartnerLinkInstance plinkInstance;
+    // here for the backward compatibility
+    @SuppressWarnings("unused")
+    public Object correlationKey = null;
+    public CorrelationKeySet correlationKeySet;
+    public final String opName;
+    public final String messageExchangeId;
+    public final int idx;
+    public final boolean oneWay;
+    public final String route;
 
-  Selector(int idx, PartnerLinkInstance plinkInstance, String opName, boolean oneWay, String mexId, CorrelationKeySet keySet, String route) {
-    this.idx = idx;
-    this.plinkInstance = plinkInstance;
-    this.correlationKeySet = keySet;
-    this.opName = opName;
-    this.messageExchangeId = mexId;
-    this.oneWay = oneWay;
-    this.route = route;
-  }
+    public Selector(int idx, PartnerLinkInstance plinkInstance, String opName, boolean oneWay, String mexId, CorrelationKeySet keySet, String route) {
+        this.idx = idx;
+        this.plinkInstance = plinkInstance;
+        this.correlationKeySet = keySet;
+        this.opName = opName;
+        this.messageExchangeId = mexId;
+        this.oneWay = oneWay;
+        this.route = route;
+    }
 
-  public String toString() {
-    return ObjectPrinter.toString(this, new Object[] {
-      "plinkInstnace", plinkInstance,
-      "ckeySet", correlationKeySet,
-      "opName" ,opName,
-      "oneWay", oneWay ? "yes" : "no",
-      "mexId", messageExchangeId,
-      "idx", Integer.valueOf(idx),
-      "route", route
-    });
-  }
+    public String toString() {
+        return ObjectPrinter.toString(this, new Object[] {
+                "plinkInstnace", plinkInstance,
+                "ckeySet", correlationKeySet,
+                "opName" ,opName,
+                "oneWay", oneWay ? "yes" : "no",
+                "mexId", messageExchangeId,
+                "idx", Integer.valueOf(idx),
+                "route", route
+        });
+    }
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java Tue Jan  6 18:00:47 2009
@@ -301,6 +301,10 @@
             return _scheduler.execTransaction(transaction);
         }
 
+        public void setRollbackOnly() throws Exception {
+            _scheduler.setRollbackOnly();
+        }
+
         public <T> Future<T> execIsolatedTransaction(Callable<T> transaction) throws Exception, ContextException {
             return _scheduler.execIsolatedTransaction(transaction);
         }

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java Tue Jan  6 18:00:47 2009
@@ -206,9 +206,12 @@
         _ds = ds;
     }
 
+    public DataSource getDataSource() {
+        return _ds;
+    }
+
     public void setTransactionManager(Object tm) {
         _tm = (TransactionManager) tm;
-
     }
 
     public void setUnmanagedDataSource(DataSource ds) {

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java Tue Jan  6 18:00:47 2009
@@ -36,6 +36,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.ode.bpel.common.BpelEventFilter;
 import org.apache.ode.bpel.common.InstanceFilter;
+import org.apache.ode.bpel.common.ProcessState;
 import org.apache.ode.bpel.dao.BpelDAOConnection;
 import org.apache.ode.bpel.dao.CorrelationSetDAO;
 import org.apache.ode.bpel.dao.MessageExchangeDAO;
@@ -108,7 +109,7 @@
         _session.save(process);
         return new ProcessDaoImpl(_sm, process);
     }
-    
+
     public ProcessDAO getProcess(QName processId) {
 
         try {
@@ -177,7 +178,7 @@
 
     /**
      * Helper method for inserting bpel events into the database.
-     * 
+     *
      * @param sess
      * @param event
      * @param process
@@ -278,7 +279,7 @@
             iids[i] = dao.getInstanceId();
             i++;
         }
-        Collection<HCorrelationSet> csets = _session.getNamedQuery(HCorrelationSet.SELECT_CORSETS_BY_INSTANCES).setParameterList("instances", iids).list();        
+        Collection<HCorrelationSet> csets = _session.getNamedQuery(HCorrelationSet.SELECT_CORSETS_BY_INSTANCES).setParameterList("instances", iids).list();
         Map<Long, Collection<CorrelationSetDAO>> map = new HashMap<Long, Collection<CorrelationSetDAO>>();
         for (HCorrelationSet cset: csets) {
             Long id = cset.getInstance().getId();
@@ -292,6 +293,15 @@
         return map;
     }
 
+    public Collection<CorrelationSetDAO> getActiveCorrelationSets() {
+        ArrayList<CorrelationSetDAO> csetDaos = new ArrayList<CorrelationSetDAO>();
+        Collection<HCorrelationSet> csets = _session.getNamedQuery(HCorrelationSet.SELECT_ACTIVE_CORSETS).setParameter("state", ProcessState.STATE_ACTIVE).list();
+        for (HCorrelationSet cset : csets)
+            csetDaos.add(new CorrelationSetDaoImpl(_sm, cset));
+        return csetDaos;
+    }
+
+
     public ProcessManagementDAO getProcessManagement() {
         return new ProcessManagementDaoImpl(_sm);
     }

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/CorrelationSetDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/CorrelationSetDaoImpl.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/CorrelationSetDaoImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/CorrelationSetDaoImpl.java Tue Jan  6 18:00:47 2009
@@ -20,6 +20,8 @@
 
 import org.apache.ode.bpel.dao.CorrelationSetDAO;
 import org.apache.ode.bpel.dao.ScopeDAO;
+import org.apache.ode.bpel.dao.ProcessDAO;
+import org.apache.ode.bpel.dao.ProcessInstanceDAO;
 import org.apache.ode.bpel.common.CorrelationKey;
 import org.apache.ode.daohib.SessionManager;
 import org.apache.ode.daohib.bpel.hobj.HCorrelationSet;
@@ -56,25 +58,27 @@
     return new ScopeDaoImpl(_sm, _correlationSet.getScope());
   }
 
-  public void setValue(QName[] names, CorrelationKey values) {
-      entering("CorrelationSetDaoImpl.setValue");
-    _correlationSet.setValue(values.toCanonicalString());
-    if (_correlationSet.getProperties() == null || _correlationSet.getProperties().size() == 0) {
-      for (int m = 0; m < names.length; m++) {
-        HCorrelationProperty prop =
-                new HCorrelationProperty(names[m], values.getValues()[m], _correlationSet);
-        getSession().save(prop);
-      }
-    } else {
-      for (int m = 0; m < names.length; m++) {
-        HCorrelationProperty prop = getProperty(names[m]);
-        if (prop == null) prop = new HCorrelationProperty(names[m], values.getValues()[m], _correlationSet);
-        else prop.setValue(values.getValues()[m]);
-        getSession().save(prop);
-      }
+    public void setValue(QName[] names, CorrelationKey values) {
+        entering("CorrelationSetDaoImpl.setValue");
+        _correlationSet.setValue(values.toCanonicalString());
+        if (names != null) {
+            if (_correlationSet.getProperties() == null || _correlationSet.getProperties().size() == 0) {
+                for (int m = 0; m < names.length; m++) {
+                    HCorrelationProperty prop =
+                            new HCorrelationProperty(names[m], values.getValues()[m], _correlationSet);
+                    getSession().save(prop);
+                }
+            } else {
+                for (int m = 0; m < names.length; m++) {
+                    HCorrelationProperty prop = getProperty(names[m]);
+                    if (prop == null) prop = new HCorrelationProperty(names[m], values.getValues()[m], _correlationSet);
+                    else prop.setValue(values.getValues()[m]);
+                    getSession().save(prop);
+                }
+            }
+        }
+        getSession().update(_correlationSet);
     }
-    getSession().update(_correlationSet);
-  }
 
   public CorrelationKey getValue() {
       entering("CorrelationSetDaoImpl.getValue");
@@ -91,7 +95,15 @@
     return result;
   }
 
-  private HCorrelationProperty getProperty(QName qName) {
+    public ProcessDAO getProcess() {
+        return new ProcessDaoImpl(_sm, _correlationSet.getProcess());
+    }
+
+    public ProcessInstanceDAO getInstance() {
+        return new ProcessInstanceDaoImpl(_sm, _correlationSet.getInstance());
+    }
+
+    private HCorrelationProperty getProperty(QName qName) {
       entering("CorrelationSetDaoImpl.getProperty");
     for (HCorrelationProperty property : _correlationSet.getProperties()) {
       if (qName.getLocalPart().equals(property.getName())

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/CorrelatorDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/CorrelatorDaoImpl.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/CorrelatorDaoImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/CorrelatorDaoImpl.java Tue Jan  6 18:00:47 2009
@@ -18,19 +18,13 @@
  */
 package org.apache.ode.daohib.bpel;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
+import java.util.*;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ode.bpel.common.CorrelationKey;
 import org.apache.ode.bpel.common.CorrelationKeySet;
-import org.apache.ode.bpel.dao.CorrelatorDAO;
-import org.apache.ode.bpel.dao.MessageExchangeDAO;
-import org.apache.ode.bpel.dao.MessageRouteDAO;
-import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+import org.apache.ode.bpel.dao.*;
 import org.apache.ode.daohib.SessionManager;
 import org.apache.ode.daohib.bpel.hobj.HCorrelator;
 import org.apache.ode.daohib.bpel.hobj.HCorrelatorMessage;
@@ -138,7 +132,7 @@
             	while (selectors.hasNext()) {
                     selector = (HCorrelatorSelector) selectors.next();
                     if (selector != null) {
-                    	if ("all".equals(selector.getRoute()) || 
+                    	if ("all".equals(selector.getRoute()) ||
                     			("one".equals(selector.getRoute()) && !targets.contains(selector.getInstance()))) {
                         	routes.add(new MessageRouteDaoImpl(_sm, selector));
                         	targets.add(selector.getInstance());
@@ -250,10 +244,15 @@
         return lockQry.list().isEmpty();
         
     }
+
     public String getCorrelatorId() {
         return _hobj.getCorrelatorId();
     }
 
+    public void setCorrelatorId(String newId) {
+        _hobj.setCorrelatorId(newId);
+    }
+
     public void removeRoutes(String routeGroupId, ProcessInstanceDAO target) {
         entering("CorrelatorDaoImpl.removeRoutes");
         String hdr = "removeRoutes(" + routeGroupId + ", iid=" + target.getInstanceId() + "): ";
@@ -264,4 +263,19 @@
         int updates = q.executeUpdate();
         __log.debug(hdr + "deleted " + updates + " rows");
     }
+
+     public Collection<CorrelatorMessageDAO> getAllMessages() {
+         Collection<CorrelatorMessageDAO> msgs = new ArrayList<CorrelatorMessageDAO>();
+         for (HCorrelatorMessage correlatorMessage : _hobj.getMessageCorrelations())
+             msgs.add(new CorrelatorMessageDaoImpl(_sm, correlatorMessage));
+         return msgs;
+     }
+
+     public Collection<MessageRouteDAO> getAllRoutes() {
+         Collection<MessageRouteDAO> routes = new ArrayList<MessageRouteDAO>();
+         for (HCorrelatorSelector selector : _hobj.getSelectors())
+             routes.add(new MessageRouteDaoImpl(_sm, selector));
+         return routes;
+     }
+
 }
\ No newline at end of file

Modified: ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/MessageRouteDaoImpl.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/MessageRouteDaoImpl.java?rev=732195&r1=732194&r2=732195&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/MessageRouteDaoImpl.java (original)
+++ ode/branches/APACHE_ODE_1.X/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/MessageRouteDaoImpl.java Tue Jan  6 18:00:47 2009
@@ -21,6 +21,7 @@
 import org.apache.ode.bpel.common.CorrelationKeySet;
 import org.apache.ode.bpel.dao.MessageRouteDAO;
 import org.apache.ode.bpel.dao.ProcessInstanceDAO;
+import org.apache.ode.bpel.common.CorrelationKey;
 import org.apache.ode.daohib.SessionManager;
 import org.apache.ode.daohib.bpel.hobj.HCorrelatorSelector;
 import org.apache.ode.daohib.bpel.hobj.HProcessInstance;
@@ -78,4 +79,13 @@
 	public CorrelationKeySet getCorrelationKeySet() {
 		return new CorrelationKeySet(_selector.getCorrelationKey());
 	}
+
+     public void setCorrelationKey(CorrelationKey key) {
+         _selector.setCorrelationKey(key.toCanonicalString());
+     }
+
+     public CorrelationKey getCorrelationKey() {
+         return new CorrelationKey(_selector.getCorrelationKey());
+     }
+
 }