bart merge, rounded up some missing files...


git-svn-id: https://svn.apache.org/repos/asf/ode/branches/bart@573151 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bpel-api/src/main/java/org/apache/ode/bpel/explang/EvaluationContext.java b/bpel-api/src/main/java/org/apache/ode/bpel/explang/EvaluationContext.java
index f617124..2624c49 100644
--- a/bpel-api/src/main/java/org/apache/ode/bpel/explang/EvaluationContext.java
+++ b/bpel-api/src/main/java/org/apache/ode/bpel/explang/EvaluationContext.java
@@ -31,6 +31,9 @@
  * Context for evaluating expressions. Implementations of the
  * {@link ExpressionLanguageRuntime} interface use this interface to access BPEL
  * variables, property sets and link statuses.
+ * 
+ * FIXME: this is the only thing that uses bpel.o objects in this module... smells fishy,
+ * FIXME: prob should change this interface to not use these. -mbs
  */
 public interface EvaluationContext {
 
diff --git a/bpel-epr/src/main/java/org/apache/ode/il/MockScheduler.java b/bpel-epr/src/main/java/org/apache/ode/il/MockScheduler.java
index 21d6fab..b37413f 100644
--- a/bpel-epr/src/main/java/org/apache/ode/il/MockScheduler.java
+++ b/bpel-epr/src/main/java/org/apache/ode/il/MockScheduler.java
@@ -19,22 +19,24 @@
 
 package org.apache.ode.il;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Timer;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-import javax.transaction.Status;
 import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
 import javax.transaction.TransactionManager;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.iapi.ContextException;
+import org.apache.ode.bpel.iapi.Scheduler;
+
 /**
  * 
  * @author Matthieu Riou <mriou at apache dot org>
@@ -78,18 +80,6 @@
                     }
                 }, delay, TimeUnit.MILLISECONDS);
             }
-                                });
-                            } catch (Exception e) {
-                                throw new ContextException("Failure when scheduling a new volatile job.", e);
-                            }
-                        }
-                    }, date);
-                public void beforeCompletion() { }
-            });
-            return null;
-        } else {
-    }
-                if (!success) return;
 
             public void beforeCompletion() {
             }
diff --git a/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelDatabase.java b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelDatabase.java
index 0f36405..afb5346 100644
--- a/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelDatabase.java
+++ b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelDatabase.java
@@ -22,7 +22,6 @@
 
 import org.apache.ode.bpel.dao.BpelDAOConnection;
 import org.apache.ode.bpel.dao.BpelDAOConnectionFactory;
-import org.apache.ode.bpel.iapi.Scheduler;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
diff --git a/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
index 2826e72..f1c83a8 100644
--- a/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
+++ b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelProcess.java
@@ -79,7 +79,6 @@
 import org.apache.ode.jacob.soup.ReplacementMap;
 import org.apache.ode.utils.GUID;
 import org.apache.ode.utils.ObjectPrinter;
-import org.apache.ode.utils.DOMUtils;
 import org.apache.ode.utils.msg.MessageBundle;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -203,7 +202,8 @@
     void invokeProcess(final MessageExchangeDAO mexdao) {
         InvocationStyle istyle = mexdao.getInvocationStyle();
 
-            _hydrationLatch.latch(1);
+        _hydrationLatch.latch(1);
+        try {
             // The following check is mostly for sanity purposes. MexImpls should prevent this from
             // happening.
             PartnerLinkMyRoleImpl target = getMyRoleForService(mexdao.getCallee());
@@ -433,13 +433,12 @@
         PropertyAliasEvaluationContext ectx = new PropertyAliasEvaluationContext(msgData, alias);
         Node lValue = ectx.getRootNode();
 
-        if (alias.location != null) {
+        if (alias.location != null)
             try {
                 lValue = _expLangRuntimeRegistry.evaluateNode(alias.location, ectx);
             } catch (EvaluationException ec) {
                 throw new FaultException(getOProcess().constants.qnSelectionFailure, alias.getDescription());
             }
-        }
 
         if (lValue == null) {
             String errmsg = __msgs.msgPropertyAliasReturnedNullSet(alias.getDescription(), target);
@@ -452,7 +451,8 @@
         if (lValue.getNodeType() == Node.ELEMENT_NODE) {
             // This is a bit hokey, we concatenate all the children's values; we
             // really should be checking to make sure that we are only dealing
-            // with text and attribute nodes.
+            // with
+            // text and attribute nodes.
             StringBuffer val = new StringBuffer();
             NodeList nl = lValue.getChildNodes();
             for (int i = 0; i < nl.getLength(); ++i) {
@@ -503,7 +503,6 @@
     void handleWorkEvent(final JobInfo jobInfo) throws JobProcessorException {
         assert !_contexts.isTransacted() : "work events must be received outside of a transaction";
 
-            _hydrationLatch.latch(1);
         markused();
 
         final WorkEvent we = new WorkEvent(jobInfo.jobDetail);
@@ -683,8 +682,8 @@
     }
 
     EndpointReference getInitialPartnerRoleEPR(OPartnerLink link) {
+        _hydrationLatch.latch(1);
         try {
-            _hydrationLatch.latch(1);
             PartnerLinkPartnerRoleImpl prole = _partnerRoles.get(link);
             if (prole == null)
                 throw new IllegalStateException("Unknown partner link " + link);
@@ -695,8 +694,8 @@
     }
 
     Endpoint getInitialPartnerRoleEndpoint(OPartnerLink link) {
+        _hydrationLatch.latch(1);
         try {
-            _hydrationLatch.latch(1);
             PartnerLinkPartnerRoleImpl prole = _partnerRoles.get(link);
             if (prole == null)
                 throw new IllegalStateException("Unknown partner link " + link);
@@ -707,8 +706,8 @@
     }
 
     EndpointReference getInitialMyRoleEPR(OPartnerLink link) {
+        _hydrationLatch.latch(1);
         try {
-            _hydrationLatch.latch(1);
             PartnerLinkMyRoleImpl myRole = _myRoles.get(link);
             if (myRole == null)
                 throw new IllegalStateException("Unknown partner link " + link);
@@ -723,8 +722,8 @@
     }
 
     PartnerRoleChannel getPartnerRoleChannel(OPartnerLink partnerLink) {
+        _hydrationLatch.latch(1);
         try {
-            _hydrationLatch.latch(1);
             PartnerLinkPartnerRoleImpl prole = _partnerRoles.get(partnerLink);
             if (prole == null)
                 throw new IllegalStateException("Unknown partner link " + partnerLink);
@@ -758,8 +757,9 @@
      * Ask the process to dehydrate.
      */
     void dehydrate() {
+        _hydrationLatch.latch(0);
+
         try {
-            _hydrationLatch.latch(0);
             // We don't actually need to do anything, the latch will run the doDehydrate method
             // when necessary..
         } finally {
@@ -769,8 +769,9 @@
     }
 
     void hydrate() {
+        _hydrationLatch.latch(1);
+
         try {
-            _hydrationLatch.latch(1);
             // We don't actually need to do anything, the latch will run the doHydrate method
             // when necessary..
         } finally {
@@ -779,8 +780,8 @@
     }
 
     OProcess getOProcess() {
+        _hydrationLatch.latch(1);
         try {
-            _hydrationLatch.latch(1);
             return _oprocess;
         } finally {
             _hydrationLatch.release(1);
@@ -830,7 +831,8 @@
     MyRoleMessageExchangeImpl recreateMyRoleMex(MessageExchangeDAO mexdao) {
         InvocationStyle istyle = mexdao.getInvocationStyle();
 
-            _hydrationLatch.latch(1);
+        _hydrationLatch.latch(1);
+        try {
             OPartnerLink plink = (OPartnerLink) _oprocess.getChild(mexdao.getPartnerLinkModelId());
             if (plink == null) {
                 String errmsg = __msgs.msgDbConsistencyError("MexDao #" + mexdao.getMessageExchangeId()
@@ -866,7 +868,8 @@
 
     PartnerRoleMessageExchangeImpl createPartnerRoleMex(MessageExchangeDAO mexdao) {
 
-            _hydrationLatch.latch(1);
+        _hydrationLatch.latch(1);
+        try {
             OPartnerLink plink = (OPartnerLink) _oprocess.getChild(mexdao.getPartnerLinkModelId());
             PartnerLinkPartnerRoleImpl prole = _partnerRoles.get(plink);
             return prole.createPartnerRoleMex(mexdao);
@@ -1213,7 +1216,7 @@
                             bounceProcessDAO(_contexts.dao.getConnection(), _pid, _pconf.getVersion(), _oprocess);
                             return null;
                         }
-                    }).get(); // needs to be synchronous
+                    });
                 } catch (Exception ex) {
                     String errmsg = "DbError";
                     __log.error(errmsg, ex);
diff --git a/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java
index 8864096..a9d805f 100644
--- a/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java
+++ b/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java
@@ -53,6 +53,8 @@
 import org.apache.ode.bpel.iapi.MessageExchange.FailureType;
 import org.apache.ode.bpel.iapi.MessageExchange.MessageExchangePattern;
 import org.apache.ode.bpel.iapi.MessageExchange.Status;
+import org.apache.ode.bpel.o.OElementVarType;
+import org.apache.ode.bpel.o.OMessageVarType;
 import org.apache.ode.bpel.o.OPartnerLink;
 import org.apache.ode.bpel.o.OProcess;
 import org.apache.ode.bpel.o.OScope;
diff --git a/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java b/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java
index e42b6c4..412101c 100644
--- a/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java
+++ b/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/BpelDAOConnectionImpl.java
@@ -18,6 +18,22 @@
  */
 package org.apache.ode.bpel.memdao;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.TransactionManager;
+import javax.xml.namespace.QName;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ode.bpel.common.BpelEventFilter;
@@ -30,28 +46,10 @@
 import org.apache.ode.bpel.dao.ProcessInstanceDAO;
 import org.apache.ode.bpel.dao.ScopeDAO;
 import org.apache.ode.bpel.evt.BpelEvent;
-import org.apache.ode.bpel.iapi.Scheduler;
 import org.apache.ode.utils.ISO8601DateParser;
 import org.apache.ode.utils.stl.CollectionsX;
 import org.apache.ode.utils.stl.UnaryFunction;
 
-import javax.transaction.RollbackException;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.TransactionManager;
-import javax.xml.namespace.QName;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.ConcurrentHashMap;
-
 /**
  * A very simple, in-memory implementation of the {@link BpelDAOConnection} interface.
  */
@@ -65,8 +63,8 @@
 
     private List<BpelEvent> _events = new LinkedList<BpelEvent>();
 
-    private static Map<String, MessageExchangeDAO> _mexStore = Collections
-            .synchronizedMap(new HashMap<String, MessageExchangeDAO>());
+    private final List<MessageExchangeDAOImpl> _mexList = new LinkedList<MessageExchangeDAOImpl>();
+    private final Map<String, MessageExchangeDAOImpl> _mexStore = new HashMap<String, MessageExchangeDAOImpl>();
 
     private static AtomicLong counter = new AtomicLong(Long.MAX_VALUE / 2);
     private static volatile long _lastRemoval = 0;
@@ -184,36 +182,65 @@
         throw new UnsupportedOperationException("Can't query process configuration using a transient DAO.");
     }
 
-    public MessageExchangeDAO createMessageExchange(String mexId, char dir) {
-        MessageExchangeDAO mex = new MessageExchangeDAOImpl(dir, mexId);
-        _mexStore.put(mexId, mex);
-        long now = System.currentTimeMillis();
-        _mexAge.put(id, now);
-
-        if (now > _lastRemoval + (TIME_TO_LIVE/10)) {
-            _lastRemoval = now;
-            Object[] oldMexs = _mexAge.keySet().toArray();
-            for (int i=oldMexs.length-1; i>0; i--) {
-                String oldMex = (String) oldMexs[i];
-                Long age = _mexAge.get(oldMex);
-                if (age != null && now-age > TIME_TO_LIVE) {
-                    removeMessageExchange(oldMex);
-                    _mexAge.remove(oldMex);
-                }
-            }
+    public MessageExchangeDAO createMessageExchange(final String mexId, char dir) {
+        MessageExchangeDAOImpl mex = new MessageExchangeDAOImpl(dir, mexId);
+        mex.createTime  = new Date();
+        
+        // FIXME: Why is this necessary? We should explicitly remove these thigs -mbs
+        
+        synchronized (_mexStore) {
+            _mexStore.put(mexId, mex);
+            _mexList.add(mex);
         }
 
+
+        cleanupDeadWood();
+        
         // Removing right away on rollback
         onRollback(new Runnable() {
             public void run() {
-                removeMessageExchange(id);
-                _mexAge.remove(id);
+                synchronized (_mexStore) {
+                    MessageExchangeDAOImpl mexdao = _mexStore.remove(mexId);
+                    
+                    if (mexdao != null) 
+                        _mexList.remove(mexdao);
+                }
             }
         });
 
         return mex;
     }
 
+
+    
+    /**
+     * Remove old message exchanges from the Mex store.
+     * 
+     */
+    private void cleanupDeadWood() {
+        long now = System.currentTimeMillis();
+        
+        if (now  > _lastRemoval + (TIME_TO_LIVE/10)) {
+            _lastRemoval = now;
+            
+            synchronized (_mexStore) {
+                LinkedList trash = new LinkedList<MessageExchangeDAOImpl>();
+                for (MessageExchangeDAOImpl mexdao : _mexList) {
+                    long createtime = mexdao._createTime.getTime();
+                    if (now-createtime> TIME_TO_LIVE) {
+                        trash.add(mexdao);
+                    } else 
+                        break;
+                }
+                
+                _mexList.removeAll(trash);
+                _mexStore.values().removeAll(trash);
+            }
+        }
+
+        
+    }
+
     public MessageExchangeDAO getMessageExchange(String mexid) {
         return _mexStore.get(mexid);
     }
@@ -337,15 +364,6 @@
         throw new UnsupportedOperationException();
     }
 
-    static void removeMessageExchange(String mexId) {
-        // Cleaning up mex
-        if (__log.isDebugEnabled()) __log.debug("Removing mex " + mexId + " from memory store.");
-        MessageExchangeDAO mex = _mexStore.remove(mexId);
-        if (mex == null)
-            __log.warn("Couldn't find mex " + mexId + " for cleanup.");
-        _mexAge.remove(mexId);
-    }
-
     public void defer(final Runnable runnable) {
         try {
             _txm.getTransaction().registerSynchronization(new Synchronization() {
@@ -360,11 +378,21 @@
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
-    public void onRollback(final Runnable runnable) {
-        _scheduler.registerSynchronizer(new Scheduler.Synchronizer() {
-            public void afterCompletion(boolean success) {
-                if (!success) runnable.run();
-            }
-            public void beforeCompletion() {
     }
+    
+    
+    public void onRollback(final Runnable runnable) {
+        try {
+            _txm.getTransaction().registerSynchronization(new Synchronization() {
+                public void afterCompletion(int status) {
+                    if (status != Status.STATUS_COMMITTED) runnable.run();
+                }
+                
+                public void beforeCompletion() {}
+            });
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
 }
diff --git a/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageExchangeDAOImpl.java b/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageExchangeDAOImpl.java
index d6c4979..8a3e7e0 100644
--- a/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageExchangeDAOImpl.java
+++ b/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/MessageExchangeDAOImpl.java
@@ -40,33 +40,33 @@
 
 public class MessageExchangeDAOImpl extends DaoBaseImpl implements MessageExchangeDAO {
 
-    private String messageExchangeId;
-	private MessageDAO response;
-	private Date createTime;
-	private MessageDAO request;
-	private String operation;
-	private QName portType;
-	private Status status;
-	private int partnerLinkModelId;
-	private String correlationId;
-	private String pattern;
-	private Element ePR;
-	private String channel;
-	private QName fault;
-    private String faultExplanation;
-    private String correlationStatus;
-	private ProcessDAO process;
-	private ProcessInstanceDAO instance;
-	private char direction;
-	private QName callee;
-	private Properties properties = new Properties();
-    private PartnerLinkDAOImpl _plink;
-    private InvocationStyle _istyle;
-    private String _pipedExchange;
-    private FailureType _failureType;
-    private long _timeout;
-    private AckType _ackType;
-    private QName _pipedPID;
+    String messageExchangeId;
+	MessageDAO response;
+	Date createTime;
+	MessageDAO request;
+	String operation;
+	QName portType;
+	Status status;
+	int partnerLinkModelId;
+	String correlationId;
+	String pattern;
+	Element ePR;
+	String channel;
+	QName fault;
+    String faultExplanation;
+    String correlationStatus;
+	ProcessDAO process;
+	ProcessInstanceDAO instance;
+	char direction;
+	QName callee;
+	Properties properties = new Properties();
+    PartnerLinkDAOImpl _plink;
+    InvocationStyle _istyle;
+    String _pipedExchange;
+    FailureType _failureType;
+    long _timeout;
+    AckType _ackType;
+    QName _pipedPID;
 
 	public MessageExchangeDAOImpl(char direction, String messageEchangeId){
 		this.direction = direction;
@@ -265,7 +265,6 @@
         _plink = null;
         request = null;
         response = null;
-        BpelDAOConnectionImpl.removeMessageExchange(getMessageExchangeId());
     }
 
     public String toString() {
diff --git a/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java b/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java
index a81ee29..2a49bb3 100644
--- a/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java
+++ b/bpel-runtime/src/main/java/org/apache/ode/bpel/memdao/ProcessDaoImpl.java
@@ -22,6 +22,9 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
@@ -55,6 +58,7 @@
     private Collection<Long> _instancesToRemove = new ConcurrentLinkedQueue<Long>();
     private static volatile long _lastRemoval = 0;
 
+
     private String _guid;
 
     public ProcessDaoImpl(BpelDAOConnectionImpl conn, Map<QName, ProcessDaoImpl> store,
diff --git a/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/REPLY.java b/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/REPLY.java
index 26833a1..d1e66b9 100644
--- a/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/REPLY.java
+++ b/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/REPLY.java
@@ -63,7 +63,6 @@
             getBpelRuntimeContext()
                     .reply(_scopeFrame.resolve(oreply.partnerLink), oreply.operation.getName(),
                             oreply.messageExchangeId, (Element)msg,
-                            (oreply.fault != null) ? oreply.fault : null);
                             oreply.fault);
         } catch (FaultException e) {
             __log.error(e);
diff --git a/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java b/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java
index fa079b6..658c5a8 100644
--- a/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java
+++ b/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java
@@ -18,7 +18,6 @@
  */
 package org.apache.ode.test;
 
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
@@ -62,8 +61,8 @@
 import org.w3c.dom.Element;
 
 public abstract class BPELTestAbstract {
-	private static final String SHOW_EVENTS_ON_CONSOLE = "no";
-	
+    private static final String SHOW_EVENTS_ON_CONSOLE = "no";
+
     protected BpelServerImpl _server;
 
     protected ProcessStore store;
@@ -92,7 +91,6 @@
 
     private MockTransactionManager _txm;
 
-
     @Before
     public void setUp() throws Exception {
         _failures = new CopyOnWriteArrayList<Failure>();
@@ -136,7 +134,7 @@
             }
         });
         _server.setConfigProperties(getConfigProperties());
-        //_server.registerBpelEventListener(new DebugBpelEventListener());
+        // _server.registerBpelEventListener(new DebugBpelEventListener());
         _server.init();
         _server.start();
     }
@@ -244,7 +242,7 @@
 
             inv.expectedResponsePattern = Pattern.compile(responsePattern, Pattern.DOTALL);
         } else
-            inv.expectedFinalStatus = AckType.ONEWAY; 
+            inv.expectedFinalStatus = AckType.ONEWAY;
 
         _invocations.add(inv);
         return inv;
@@ -261,14 +259,14 @@
 
     protected void checkFailure() {
         StringBuffer sb = new StringBuffer("Failure report:\n");
-    	for (Failure failure : _failures) {
+        for (Failure failure : _failures) {
             sb.append(failure);
             sb.append('\n');
         }
-    	if (_failures.size() != 0) {
-        	System.err.println(sb.toString());
+        if (_failures.size() != 0) {
+            System.err.println(sb.toString());
             Assert.fail(sb.toString());
-    	}
+        }
     }
 
     protected Deployment deploy(String location) {
@@ -384,12 +382,12 @@
             Assert.fail("Resource not found: " + deployxml);
         }
         try {
-			return new File(deployxmlurl.toURI().getPath()).getParentFile();
-		} catch (URISyntaxException e) {
-			e.printStackTrace();
-			Assert.fail(e.getMessage());
-			return null;
-		}
+            return new File(deployxmlurl.toURI().getPath()).getParentFile();
+        } catch (URISyntaxException e) {
+            e.printStackTrace();
+            Assert.fail(e.getMessage());
+            return null;
+        }
     }
 
     /**
@@ -398,11 +396,11 @@
      * @return
      */
     protected Properties getConfigProperties() {
-    	// could also return null, returning an empty properties 
-    	// object is more fail-safe.
-    	Properties p = new Properties();
-    	p.setProperty("debugeventlistener.dumpToStdOut", SHOW_EVENTS_ON_CONSOLE);
-    	return p;
+        // could also return null, returning an empty properties
+        // object is more fail-safe.
+        Properties p = new Properties();
+        p.setProperty("debugeventlistener.dumpToStdOut", SHOW_EVENTS_ON_CONSOLE);
+        return p;
     }
 
     protected static class Failure {
@@ -431,7 +429,7 @@
         public String toString() {
             StringBuffer sbuf = new StringBuffer(where + ": " + msg);
             if (ex != null) {
-            	sbuf.append("; got exception msg: " + ex.getMessage());
+                sbuf.append("; got exception msg: " + ex.getMessage());
             }
             if (actual != null)
                 sbuf.append("; got " + actual + ", expected " + expected);
@@ -488,11 +486,9 @@
         /** If non-null, expect an exception of this class (or subclass) on invoke. */
         public Class expectedInvokeException = null;
 
-
         /** If non-null, expect this status after response received. */
         public AckType expectedFinalStatus = AckType.RESPONSE;
 
-
         /** If non-null, expect this correlation status right after invoke. */
         public CorrelationStatus expectedCorrelationStatus = null;
 
@@ -539,8 +535,8 @@
             }
 
             try {
-                mex = _server.createMessageExchange(InvocationStyle.UNRELIABLE, _invocation.target, _invocation.operation, new GUID()
-                        .toString());
+                mex = _server.createMessageExchange(InvocationStyle.UNRELIABLE, _invocation.target, _invocation.operation,
+                        new GUID().toString());
 
                 Message request = mex.createMessage(_invocation.requestType);
                 request.setMessage(_invocation.request);
@@ -563,11 +559,10 @@
 
             if (mex.getStatus() != Status.ACK)
                 failure(_invocation, "No ACK status", Status.ACK.toString(), mex.getStatus().toString());
-            
+
             if (isFailed())
                 return;
 
-
             long ctime = System.currentTimeMillis();
             long itime = ctime - _invocation.invokeTime;
             if (_invocation.minimumWaitMs != null && _invocation.minimumWaitMs >= itime)
@@ -580,29 +575,29 @@
                 return;
 
             AckType finalstat = mex.getAckType();
-            if (_invocation.expectedFinalStatus != null && _invocation.expectedFinalStatus != finalstat)
-                    if (finalstat.equals(Status.FAULT)) {
-                    	failure(_invocation, "Unexpected final message exchange status", _invocation.expectedFinalStatus, "FAULT: " 
-                    			+ mex.getFault() + " | " + mex.getFaultExplanation());
-                    } else {
-                failure(_invocation, "Unexpected final message exchange status", _invocation.expectedFinalStatus, finalstat);
+            if (_invocation.expectedFinalStatus != null && _invocation.expectedFinalStatus != finalstat) {
+                if (finalstat.equals(AckType.FAULT)) {
+                    failure(_invocation, "Unexpected final message exchange status", _invocation.expectedFinalStatus, "FAULT: "
+                            + mex.getFault() + " | " + mex.getFaultExplanation());
+                } else {
+                    failure(_invocation, "Unexpected final message exchange status", _invocation.expectedFinalStatus, finalstat);
 
-
-            if (_invocation.expectedFinalCorrelationStatus != null
-                    && !_invocation.expectedFinalCorrelationStatus.equals(mex.getCorrelationStatus())) {
-                failure(_invocation, "Unexpected final correlation status", _invocation.expectedFinalCorrelationStatus, mex
-                        .getCorrelationStatus());
+                    if (_invocation.expectedFinalCorrelationStatus != null
+                            && !_invocation.expectedFinalCorrelationStatus.equals(mex.getCorrelationStatus())) {
+                        failure(_invocation, "Unexpected final correlation status", _invocation.expectedFinalCorrelationStatus, mex
+                                .getCorrelationStatus());
+                    }
+                    if (_invocation.expectedResponsePattern != null) {
+                        if (mex.getResponse() == null)
+                            failure(_invocation, "Expected response, but got none.", null);
+                        String responseStr = DOMUtils.domToString(mex.getResponse().getMessage());
+                        Matcher matcher = _invocation.expectedResponsePattern.matcher(responseStr);
+                        if (!matcher.matches())
+                            failure(_invocation, "Response does not match expected pattern", _invocation.expectedResponsePattern,
+                                    responseStr);
+                    }
+                }
             }
-            if (_invocation.expectedResponsePattern != null) {
-                if (mex.getResponse() == null)
-                    failure(_invocation, "Expected response, but got none.", null);
-                String responseStr = DOMUtils.domToString(mex.getResponse().getMessage());
-                Matcher matcher = _invocation.expectedResponsePattern.matcher(responseStr);
-                if (!matcher.matches())
-                    failure(_invocation, "Response does not match expected pattern", _invocation.expectedResponsePattern,
-                            responseStr);
-            }
-
         }
     }
 }
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestCounter/counter.bpel b/bpel-test/src/test/resources/bpel/2.0/TestCounter/counter.bpel
new file mode 100644
index 0000000..19e68e4
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestCounter/counter.bpel
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+<b:process xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+           xsi:schemaLocation="http://docs.oasis-open.org/wsbpel/2.0/process/executable http://docs.oasis-open.org/wsbpel/2.0/CS01/process/executable/ws-bpel_executable.xsd"
+           xmlns:b="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+           name="counter"
+           xmlns:t="http://example.com/bpel/counter"
+           targetNamespace="http://example.com/bpel/counter">
+
+    <b:import importType="http://schemas.xmlsoap.org/wsdl/"
+              location="counter.wsdl"
+              namespace="http://example.com/bpel/counter" />
+
+    <b:partnerLinks>
+        <b:partnerLink name="operations" partnerLinkType="t:plink" myRole="me" />
+    </b:partnerLinks>
+
+    <b:variables>
+        <b:variable name="counter" messageType="t:responseMessage" />
+        <b:variable name="initiation" messageType="t:requestMessage" />
+    </b:variables>
+
+    <b:sequence>
+        <b:receive partnerLink="operations" createInstance="yes" operation="initialize" portType="t:port"
+                   variable="initiation">
+        </b:receive>
+        <b:assign>
+            <b:copy>
+                <b:from>0</b:from>
+                <b:to variable="counter" part="value"></b:to>
+            </b:copy>
+        </b:assign>
+        <b:while>
+            <b:condition>10 &gt; $counter.value</b:condition>
+            <b:sequence>
+                <b:assign>
+                    <b:copy>
+                        <b:from>$counter.value+1</b:from>
+                        <b:to>$counter.value</b:to>
+                    </b:copy>
+                </b:assign>
+            </b:sequence>
+        </b:while>
+        <b:reply partnerLink="operations" operation="initialize" variable="counter"/>
+    </b:sequence>
+</b:process>
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestCounter/counter.cbp b/bpel-test/src/test/resources/bpel/2.0/TestCounter/counter.cbp
new file mode 100644
index 0000000..ac34fb8
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestCounter/counter.cbp
Binary files differ
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestCounter/counter.wsdl b/bpel-test/src/test/resources/bpel/2.0/TestCounter/counter.wsdl
new file mode 100644
index 0000000..cf90af5
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestCounter/counter.wsdl
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions
+    targetNamespace="http://example.com/bpel/counter" 
+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:p="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
+    xmlns:v="http://docs.oasis-open.org/wsbpel/2.0/varprop"
+    xmlns:t="http://example.com/bpel/counter">
+  
+  <wsdl:message name="requestMessage">
+    <wsdl:part name="counterName" type="xsd:string" />
+  </wsdl:message>
+  
+  <wsdl:message name="responseMessage">
+    <wsdl:part name="value" type="xsd:int" />
+  </wsdl:message>
+  
+  <wsdl:portType name="port">
+    <wsdl:operation name="initialize">
+      <wsdl:input message="t:requestMessage" />
+      <wsdl:output message="t:responseMessage" />
+    </wsdl:operation>
+    <wsdl:operation name="get">
+      <wsdl:input message="t:requestMessage" />
+      <wsdl:output message="t:responseMessage" />
+    </wsdl:operation>
+    <wsdl:operation name="getAndIncrement">
+      <wsdl:input message="t:requestMessage" />
+      <wsdl:output message="t:responseMessage" />
+    </wsdl:operation>
+    <wsdl:operation name="close">
+      <wsdl:input message="t:requestMessage" />
+      <wsdl:output message="t:responseMessage" />
+    </wsdl:operation>
+  </wsdl:portType>
+  
+  <wsdl:binding name="binding" type="t:port">
+    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+    <wsdl:operation name="initialize">
+      <soap:operation soapAction="" style="rpc"/>
+      <wsdl:input>
+        <soap:body namespace="http://example.com/bpel/counter" use="literal"/>
+      </wsdl:input>
+      <wsdl:output>
+        <soap:body namespace="http://example.com/bpel/counter" use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+    <wsdl:operation name="get">
+      <soap:operation soapAction="" style="rpc"/>
+      <wsdl:input>
+        <soap:body namespace="http://example.com/bpel/counter" use="literal"/>
+      </wsdl:input>
+      <wsdl:output>
+        <soap:body namespace="http://example.com/bpel/counter" use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+    <wsdl:operation name="getAndIncrement">
+      <soap:operation soapAction="" style="rpc"/>
+      <wsdl:input>
+        <soap:body namespace="http://example.com/bpel/counter" use="literal"/>
+      </wsdl:input>
+      <wsdl:output>
+        <soap:body namespace="http://example.com/bpel/counter" use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+    <wsdl:operation name="close">
+      <soap:operation soapAction="" style="rpc"/>
+      <wsdl:input>
+        <soap:body namespace="http://example.com/bpel/counter" use="literal"/>
+      </wsdl:input>
+      <wsdl:output>
+        <soap:body namespace="http://example.com/bpel/counter" use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+  </wsdl:binding>
+  <wsdl:service name="counterService">
+    <wsdl:port name="port" binding="t:binding">
+      <soap:address location="http://localhost:8080/ode/processes/counter"/>
+    </wsdl:port>
+  </wsdl:service>
+  
+  <p:partnerLinkType name="plink">
+    <p:role name="me" portType="t:port" />
+    <p:role name="you" portType="t:port" />
+  </p:partnerLinkType>
+  
+</wsdl:definitions>
\ No newline at end of file
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestCounter/deploy.xml b/bpel-test/src/test/resources/bpel/2.0/TestCounter/deploy.xml
new file mode 100644
index 0000000..207e450
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestCounter/deploy.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<deploy xmlns="http://www.apache.org/ode/schemas/dd/2007/03" xmlns:tns="http://example.com/bpel/counter">
+  <process name="tns:counter">
+    <active>true</active>
+    <provide partnerLink="operations">
+      <service name="tns:counterService" port="port"/>
+    </provide>
+  </process>
+</deploy>
\ No newline at end of file
diff --git a/bpel-test/src/test/resources/bpel/2.0/TestCounter/test.properties b/bpel-test/src/test/resources/bpel/2.0/TestCounter/test.properties
new file mode 100644
index 0000000..f6ff835
--- /dev/null
+++ b/bpel-test/src/test/resources/bpel/2.0/TestCounter/test.properties
@@ -0,0 +1,23 @@
+#
+#    Licensed to the Apache Software Foundation (ASF) under one or more
+#    contributor license agreements.  See the NOTICE file distributed with
+#    this work for additional information regarding copyright ownership.
+#    The ASF licenses this file to You 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.
+#
+
+namespace=http://example.com/bpel/counter
+service=counterService
+operation=initialize
+request1=<message><counterName>foo</counterName></message>
+response1=.*10.*
+
diff --git a/distro/src/bin/bpelc b/distro/src/bin/bpelc
new file mode 100644
index 0000000..486c55a
--- /dev/null
+++ b/distro/src/bin/bpelc
@@ -0,0 +1,107 @@
+#!/bin/sh
+#
+#    Licensed to the Apache Software Foundation (ASF) under one or more
+#    contributor license agreements.  See the NOTICE file distributed with
+#    this work for additional information regarding copyright ownership.
+#    The ASF licenses this file to You 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.
+
+cygwin=false;
+darwin=false;
+case "`uname`" in
+    Darwin*) 
+	darwin=true
+	if [ -z "$JAVA_HOME" ] ; then
+	    JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
+	fi
+	;;
+    CYGWIN*) 
+	cygwin=true 
+	;;
+esac
+
+## Try to find our home directory 
+command="$0"
+progname=`basename "$0"`
+# need this for relative symlinks
+while [ -h "$command" ] ; do
+    ls=`ls -ld "$command"`
+    link=`expr "$command" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+	command="$link"
+    else
+	command=`dirname "$command"`"/$link"
+    fi
+done
+
+ODE_BIN=`dirname "$command"`
+ODE_BIN=`cd "$ODE_BIN" && pwd`
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+    [ -n "$ODE_BIN" ] && ODE_BIN=`cygpath --unix "$ODE_BIN"`
+    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+ODE_HOME=`cd "$ODE_BIN/.." && pwd`
+LIB="$ODE_HOME/lib"
+ETC="$ODE_HOME/etc"
+
+
+if [ -z "$JAVACMD" ] ; then
+  if [ -n "$JAVA_HOME"  ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+      # IBM's JDK on AIX uses strange locations for the executables
+      JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+      JAVACMD="$JAVA_HOME/bin/java"
+    fi
+  else
+    JAVACMD=`which java 2> /dev/null `
+    if [ -z "$JAVACMD" ] ; then
+        JAVACMD=java
+    fi
+  fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+  echo "Error: JAVA_HOME is not defined correctly."
+  echo "  We cannot execute $JAVACMD"
+  exit 1
+fi
+
+if [ ! -d "$JAVA_HOME" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly (no such directory)."
+ exit 1
+fi
+
+# Add user-specified classpath. 
+LOCALCLASSPATH="$ODE_CLASSPATH"
+
+# Add Ode libraries
+for f in $LIB/*.jar
+do
+  LOCALCLASSPATH=$LOCALCLASSPATH:$f
+done
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+    ODE_HOME=`cygpath --windows "$ODE_HOME"`
+    JAVA_HOME=`cygpath --windows "$JAVA_HOME"`
+    LOCALCLASSPATH=`cygpath --path --windows "$LOCALCLASSPATH"`
+    CYGHOME=`cygpath --windows "$HOME"`
+    LIB=`cygpath --windows "$LIB"`
+    ODE_BIN=`cygpath --windows "$ODE_BIN"`
+    ETC=`cygpath --windows "$ETC"`
+fi
+
+exec "$JAVACMD" $ODE_JAVAOPTS -cp "$LOCALCLASSPATH" org.apache.ode.tools.bpelc.cline.BpelC "$@"
diff --git a/distro/src/bin/bpelc.bat b/distro/src/bin/bpelc.bat
new file mode 100644
index 0000000..75ea176
--- /dev/null
+++ b/distro/src/bin/bpelc.bat
@@ -0,0 +1,67 @@
+@echo off
+rem
+rem    Licensed to the Apache Software Foundation (ASF) under one or more
+rem    contributor license agreements.  See the NOTICE file distributed with
+rem    this work for additional information regarding copyright ownership.
+rem    The ASF licenses this file to You under the Apache License, Version 2.0
+rem    (the "License"); you may not use this file except in compliance with
+rem    the License.  You may obtain a copy of the License at
+rem
+rem       http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem    Unless required by applicable law or agreed to in writing, software
+rem    distributed under the License is distributed on an "AS IS" BASIS,
+rem    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem    See the License for the specific language governing permissions and
+rem    limitations under the License.
+rem
+
+if not "%OS%"=="Windows_NT" goto wrongOS
+
+@setlocal
+
+set command=%0
+set progname=%~n0
+
+set ODE_HOME=%~dp0..
+set ODE_BIN=%~dp0..\bin
+set ODE_LIB=%~dp0..\lib
+set ODE_ETC=%~dp0..\etc
+
+if "%JAVA_HOME%"=="" goto noJavaHome
+if not exist "%JAVA_HOME%"\bin\java.exe goto noJava
+
+set JAVACMD="%JAVA_HOME%\bin\java.exe"
+
+set LOCALCLASSPATH=%ODE_CLASSPATH%;%ODE_LIB%
+FOR %%c in (%ODE_LIB%\*.jar) DO (call :append_cp %%c)
+
+%JAVACMD% %ODE_JAVAOPTS% -cp "%LOCALCLASSPATH%" org.apache.ode.tools.bpelc.cline.BpelC %* 
+goto end
+
+:append_cp
+set LOCALCLASSPATH=%LOCALCLASSPATH%;%1
+goto end
+
+=====================================================================
+                              ERRORS
+=====================================================================
+
+
+:wrongOS
+echo ERROR: ODE requires WindowsNT/XP. Aborting.
+goto end
+
+:noJavaHome
+echo ERROR: JAVA_HOME not set! Aborting.
+goto end
+
+:noJava
+echo ERROR: The Java VM (java.exe) was not found in %JAVA_HOME%\bin! Aborting
+goto end
+
+REM ================================================================
+REM                             END
+REM ================================================================
+:end
+@endlocal
diff --git a/distro/src/bin/sendsoap b/distro/src/bin/sendsoap
new file mode 100644
index 0000000..53a6010
--- /dev/null
+++ b/distro/src/bin/sendsoap
@@ -0,0 +1,107 @@
+#!/bin/sh
+#
+#    Licensed to the Apache Software Foundation (ASF) under one or more
+#    contributor license agreements.  See the NOTICE file distributed with
+#    this work for additional information regarding copyright ownership.
+#    The ASF licenses this file to You 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.
+
+cygwin=false;
+darwin=false;
+case "`uname`" in
+    Darwin*) 
+	darwin=true
+	if [ -z "$JAVA_HOME" ] ; then
+	    JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
+	fi
+	;;
+    CYGWIN*) 
+	cygwin=true 
+	;;
+esac
+
+## Try to find our home directory 
+command="$0"
+progname=`basename "$0"`
+# need this for relative symlinks
+while [ -h "$command" ] ; do
+    ls=`ls -ld "$command"`
+    link=`expr "$command" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+	command="$link"
+    else
+	command=`dirname "$command"`"/$link"
+    fi
+done
+
+ODE_BIN=`dirname "$command"`
+ODE_BIN=`cd "$ODE_BIN" && pwd`
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched
+if $cygwin ; then
+    [ -n "$ODE_BIN" ] && ODE_BIN=`cygpath --unix "$ODE_BIN"`
+    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+ODE_HOME=`cd "$ODE_BIN/.." && pwd`
+LIB="$ODE_HOME/lib"
+ETC="$ODE_HOME/etc"
+
+
+if [ -z "$JAVACMD" ] ; then
+  if [ -n "$JAVA_HOME"  ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+      # IBM's JDK on AIX uses strange locations for the executables
+      JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+      JAVACMD="$JAVA_HOME/bin/java"
+    fi
+  else
+    JAVACMD=`which java 2> /dev/null `
+    if [ -z "$JAVACMD" ] ; then
+        JAVACMD=java
+    fi
+  fi
+fi
+
+if [ ! -x "$JAVACMD" ] ; then
+  echo "Error: JAVA_HOME is not defined correctly."
+  echo "  We cannot execute $JAVACMD"
+  exit 1
+fi
+
+if [ ! -d "$JAVA_HOME" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly (no such directory)."
+ exit 1
+fi
+
+# Add user-specified classpath. 
+LOCALCLASSPATH="$ODE_CLASSPATH"
+
+# Add Ode libraries
+for f in $LIB/*.jar
+do
+  LOCALCLASSPATH=$LOCALCLASSPATH:$f
+done
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin; then
+    ODE_HOME=`cygpath --windows "$ODE_HOME"`
+    JAVA_HOME=`cygpath --windows "$JAVA_HOME"`
+    LOCALCLASSPATH=`cygpath --path --windows "$LOCALCLASSPATH"`
+    CYGHOME=`cygpath --windows "$HOME"`
+    LIB=`cygpath --windows "$LIB"`
+    ODE_BIN=`cygpath --windows "$ODE_BIN"`
+    ETC=`cygpath --windows "$ETC"`
+fi
+
+exec "$JAVACMD" $ODE_JAVAOPTS -cp "$LOCALCLASSPATH" org.apache.ode.tools.sendsoap.cline.HttpSoapSender "$@"
diff --git a/distro/src/bin/sendsoap.bat b/distro/src/bin/sendsoap.bat
new file mode 100644
index 0000000..7101414
--- /dev/null
+++ b/distro/src/bin/sendsoap.bat
@@ -0,0 +1,67 @@
+@echo off
+rem
+rem    Licensed to the Apache Software Foundation (ASF) under one or more
+rem    contributor license agreements.  See the NOTICE file distributed with
+rem    this work for additional information regarding copyright ownership.
+rem    The ASF licenses this file to You under the Apache License, Version 2.0
+rem    (the "License"); you may not use this file except in compliance with
+rem    the License.  You may obtain a copy of the License at
+rem
+rem       http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem    Unless required by applicable law or agreed to in writing, software
+rem    distributed under the License is distributed on an "AS IS" BASIS,
+rem    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem    See the License for the specific language governing permissions and
+rem    limitations under the License.
+rem
+
+if not "%OS%"=="Windows_NT" goto wrongOS
+
+@setlocal
+
+set command=%0
+set progname=%~n0
+
+set ODE_HOME=%~dp0..
+set ODE_BIN=%~dp0..\bin
+set ODE_LIB=%~dp0..\lib
+set ODE_ETC=%~dp0..\etc
+
+if "%JAVA_HOME%"=="" goto noJavaHome
+if not exist "%JAVA_HOME%"\bin\java.exe goto noJava
+
+set JAVACMD="%JAVA_HOME%\bin\java.exe"
+
+set LOCALCLASSPATH=%ODE_CLASSPATH%;%ODE_LIB%
+FOR %%c in (%ODE_LIB%\*.jar) DO (call :append_cp %%c)
+
+%JAVACMD% %ODE_JAVAOPTS% -cp "%LOCALCLASSPATH%" org.apache.ode.tools.sendsoap.cline.HttpSoapSender %* 
+goto end
+
+:append_cp
+set LOCALCLASSPATH=%LOCALCLASSPATH%;%1
+goto end
+
+=====================================================================
+                              ERRORS
+=====================================================================
+
+
+:wrongOS
+echo ERROR: ODE requires WindowsNT/XP. Aborting.
+goto end
+
+:noJavaHome
+echo ERROR: JAVA_HOME not set! Aborting.
+goto end
+
+:noJava
+echo ERROR: The Java VM (java.exe) was not found in %JAVA_HOME%\bin! Aborting
+goto end
+
+REM ================================================================
+REM                             END
+REM ================================================================
+:end
+@endlocal
diff --git a/jbi/src/main/java/org/apache/ode/jbi/OdeConsumer.java b/jbi/src/main/java/org/apache/ode/jbi/OdeConsumer.java
index b5eb401..3578e5e 100755
--- a/jbi/src/main/java/org/apache/ode/jbi/OdeConsumer.java
+++ b/jbi/src/main/java/org/apache/ode/jbi/OdeConsumer.java
@@ -120,8 +120,6 @@
     }
 
 
-    protected abstract void inOutDone(InOut inout);
-
     public void onJbiMessageExchange(MessageExchange jbiMex) throws MessagingException {
         if (!jbiMex.getPattern().equals(MessageExchangePattern.IN_ONLY)
                 && !jbiMex.getPattern().equals(MessageExchangePattern.IN_OUT)) {
@@ -130,13 +128,11 @@
         }
         if (jbiMex.getStatus() == ExchangeStatus.ACTIVE) {
             if (jbiMex.getPattern().equals(MessageExchangePattern.IN_OUT)) {
-                inOutDone((InOut) jbiMex);
                 outResponse((InOut) jbiMex);
             }
             jbiMex.setStatus(ExchangeStatus.DONE);
             _ode.getChannel().send(jbiMex);
         } else if (jbiMex.getStatus() == ExchangeStatus.ERROR) {
-            inOutDone((InOut) jbiMex);
             outFailure((InOut) jbiMex);
         } else if (jbiMex.getStatus() == ExchangeStatus.DONE) {
             ; // anything todo here? 
diff --git a/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java b/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java
index 5d7e34b..7aec9df 100755
--- a/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java
+++ b/jbi/src/main/java/org/apache/ode/jbi/OdeContext.java
@@ -40,12 +40,12 @@
 import org.apache.ode.bpel.engine.BpelServerImpl;
 import org.apache.ode.bpel.iapi.Endpoint;
 import org.apache.ode.bpel.iapi.ProcessConf;
+import org.apache.ode.bpel.iapi.Scheduler;
 import org.apache.ode.bpel.o.OPartnerLink;
 import org.apache.ode.bpel.o.OProcess;
 import org.apache.ode.bpel.o.Serializer;
 import org.apache.ode.jbi.msgmap.Mapper;
 import org.apache.ode.jbi.util.WSDLFlattener;
-import org.apache.ode.scheduler.simple.SimpleScheduler;
 import org.apache.ode.store.ProcessStoreImpl;
 import org.w3c.dom.Document;
 
@@ -81,7 +81,7 @@
 
     MessageExchangeContextImpl _mexContext;
 
-    SimpleScheduler _scheduler;
+    Scheduler _scheduler;
 
     ExecutorService _executorService;
 
diff --git a/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java b/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java
index 461ce53..7107909 100755
--- a/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java
+++ b/jbi/src/main/java/org/apache/ode/jbi/OdeLifeCycle.java
@@ -200,11 +200,10 @@
             _ode._executorService = Executors.newCachedThreadPool();
         else
             _ode._executorService = Executors.newFixedThreadPool(_ode._config.getThreadPoolMaxSize());
-        _ode._scheduler = new SimpleScheduler(new GUID().toString(), new JdbcDelegate(_ode._dataSource));
-
-        _ode._scheduler.setJobProcessor(_ode._server);
-
-        _ode._scheduler.setTransactionManager((TransactionManager) _ode.getContext().getTransactionManager());
+        SimpleScheduler sched =new SimpleScheduler(new GUID().toString(), new JdbcDelegate(_ode._dataSource));
+        sched.setJobProcessor(_ode._server);
+        sched.setTransactionManager((TransactionManager) _ode.getContext().getTransactionManager());
+        _ode._scheduler = sched;
 
         _ode._store = new ProcessStoreImpl(_ode._dataSource, _ode._config.getDAOConnectionFactory(), false);
         _ode._store.loadAll();