You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by rr...@apache.org on 2010/06/22 14:57:43 UTC

svn commit: r956870 [1/2] - in /ode/trunk: bpel-api/src/main/java/org/apache/ode/bpel/iapi/ bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/ bpel-obj/src/main/java/org/apache/ode/bp...

Author: rr
Date: Tue Jun 22 12:57:41 2010
New Revision: 956870

URL: http://svn.apache.org/viewvc?rev=956870&view=rev
Log:
ODE-854: Port isolated and atomic scopes from experimental branch into trunk - initial work

Added:
    ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/InstanceGlobals.java
    ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/READWRITELOCK.java
    ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/channels/ReadWriteLock.java
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorld.bpel
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorld.wsdl
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorldAtomic.bpel
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorldAtomic.wsdl
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorldExternal.wsdl
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/deploy.xml
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/test.properties
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorld.bpel
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorld.wsdl
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorldAtomic.bpel
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorldAtomic.wsdl
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorldExternal.wsdl
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/deploy.xml
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/test.properties
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScopeBasic/
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScopeBasic/HelloWorld.bpel
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScopeBasic/HelloWorld.wsdl
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScopeBasic/HelloWorldAtomic.bpel
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScopeBasic/HelloWorldAtomic.wsdl
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScopeBasic/HelloWorldExternal.wsdl
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScopeBasic/deploy.xml
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScopeBasic/test.properties
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestIsolatedScopes1/
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestIsolatedScopes1/TestActivityFlow.bpel
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestIsolatedScopes1/TestActivityFlow.wsdl
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestIsolatedScopes1/deploy.xml
    ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestIsolatedScopes1/test.properties
Modified:
    ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/MessageExchange.java
    ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
    ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/CommonCompilationMessages.java
    ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/PickReceiveGenerator.java
    ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/Scope.java
    ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OScope.java
    ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java
    ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/BpelRuntimeContext.java
    ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/PROCESS.java
    ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/SCOPEACT.java
    ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ScopeFrame.java
    ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java
    ode/trunk/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Test.java

Modified: ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/MessageExchange.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/MessageExchange.java?rev=956870&r1=956869&r2=956870&view=diff
==============================================================================
--- ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/MessageExchange.java (original)
+++ ode/trunk/bpel-api/src/main/java/org/apache/ode/bpel/iapi/MessageExchange.java Tue Jun 22 12:57:41 2010
@@ -233,4 +233,5 @@ public interface MessageExchange {
     public static final String PROPERTY_SEP_MYROLE_SESSIONID = "org.apache.ode.bpel.myRoleSessionId";
     public static final String PROPERTY_SEP_PARTNERROLE_SESSIONID = "org.apache.ode.bpel.partnerRoleSessionId";
     public static final String PROPERTY_SEP_PARTNERROLE_EPR = "org.apache.ode.bpel.partnerRoleEPR";
+    public static final String PROPERTY_SEP_MYROLE_TRANSACTED = "org.apache.ode.bpel.myRoleTransacted";
 }

Modified: ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java?rev=956870&r1=956869&r2=956870&view=diff
==============================================================================
--- ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java (original)
+++ ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/BpelCompiler.java Tue Jun 22 12:57:41 2010
@@ -128,9 +128,8 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 
 /**
- * Compiler for converting BPEL process descriptions (and their associated WSDL
- * and XSD documents) into compiled representations suitable for execution by
- * the ODE BPEL Service Provider. TODO: Move process validation into this class.
+ * Compiler for converting BPEL process descriptions (and their associated WSDL and XSD documents) into compiled representations
+ * suitable for execution by the ODE BPEL Service Provider. TODO: Move process validation into this class.
  */
 public abstract class BpelCompiler implements CompilerContext {
     /** Class-severity logger. */
@@ -148,8 +147,12 @@ public abstract class BpelCompiler imple
 
     private boolean _supressJoinFailure = false;
 
+    /** Are we currently in an atomic scope context? */
     private boolean _atomicScope = false;
 
+    /** Are we currently compiling an isolated scope context. */
+    private boolean _isolatedScope = false;
+
     /** Syntactic scope stack. */
     private StructureStack _structureStack = new StructureStack();
 
@@ -195,8 +198,8 @@ public abstract class BpelCompiler imple
             WSDLLocatorImpl locator = new WSDLLocatorImpl(_resourceFinder, _resourceFinder.resolve(from, wsdlImport));
             def = (Definition4BPEL) r.readWSDL(locator);
         } catch (WSDLException e) {
-            recoveredFromError(sloc, new CompilationException(__cmsgs.errWsdlParseError(e
-                    .getFaultCode(), e.getLocation(), e.getMessage())));
+            recoveredFromError(sloc, new CompilationException(__cmsgs.errWsdlParseError(e.getFaultCode(), e.getLocation(), e
+                    .getMessage())));
             throw new CompilationException(__cmsgs.errWsdlImportFailed(wsdlImport.toASCIIString(), e.getFaultCode())
                     .setSource(sloc), e);
         }
@@ -228,13 +231,13 @@ public abstract class BpelCompiler imple
             Map<URI, byte[]> schemas = XSUtils.captureSchema(resFrom, data, resolver);
             _wsdlRegistry.addSchemas(schemas);
         } catch (XsdException e) {
-            CompilationException ce =  new CompilationException(__cmsgs.errInvalidImport(location.toString()));
+            CompilationException ce = new CompilationException(__cmsgs.errInvalidImport(location.toString()));
             recoveredFromError(sloc, ce);
         } catch (MalformedURLException e) {
-            CompilationException ce =  new CompilationException(__cmsgs.errInvalidImport(location.toString()));
+            CompilationException ce = new CompilationException(__cmsgs.errInvalidImport(location.toString()));
             recoveredFromError(sloc, ce);
         } catch (IOException e) {
-            CompilationException ce =  new CompilationException(__cmsgs.errInvalidImport(location.toString()));
+            CompilationException ce = new CompilationException(__cmsgs.errInvalidImport(location.toString()));
             recoveredFromError(sloc, ce);
         }
     }
@@ -442,8 +445,8 @@ public abstract class BpelCompiler imple
         OMessageVarType msgVarType = (OMessageVarType) var.type;
         OMessageVarType.Part part = msgVarType.parts.get(partname);
         if (part == null)
-            throw new CompilationException(__cmsgs.errUndeclaredMessagePart(var.name,
-                    ((OMessageVarType) var.type).messageType, partname));
+            throw new CompilationException(__cmsgs.errUndeclaredMessagePart(var.name, ((OMessageVarType) var.type).messageType,
+                    partname));
         return part;
     }
 
@@ -491,8 +494,8 @@ public abstract class BpelCompiler imple
                 });
 
         if (found == null)
-            throw new CompilationException(__cmsgs.errUndeclaredOperation(partnerLink.partnerRolePortType.getQName(),
-                    operationName));
+            throw new CompilationException(__cmsgs
+                    .errUndeclaredOperation(partnerLink.partnerRolePortType.getQName(), operationName));
         return found;
     }
 
@@ -513,8 +516,7 @@ public abstract class BpelCompiler imple
                     }
                 });
         if (found == null) {
-            throw new CompilationException(__cmsgs.errUndeclaredOperation(partnerLink.myRolePortType.getQName(),
-                    operationName));
+            throw new CompilationException(__cmsgs.errUndeclaredOperation(partnerLink.myRolePortType.getQName(), operationName));
         }
         return found;
     }
@@ -903,8 +905,8 @@ public abstract class BpelCompiler imple
 
         OActivity compiled;
         try {
-            compiled = (source instanceof ScopeLikeActivity) ? compileSLC((ScopeLikeActivity) source,
-                    new OScope.Variable[0]) : compileActivity(true, source);
+            compiled = (source instanceof ScopeLikeActivity) ? compileSLC((ScopeLikeActivity) source, new OScope.Variable[0])
+                    : compileActivity(true, source);
             compiled.suppressJoinFailure = _supressJoinFailure;
         } finally {
             _supressJoinFailure = previousSupressJoinFailure;
@@ -974,8 +976,8 @@ public abstract class BpelCompiler imple
         for (LinkTarget lt : source.getLinkTargets())
             compileLinkTarget(lt);
 
-        _structureStack.topActivity().joinCondition = (source.getJoinCondition() == null || source.getLinkTargets()
-                .isEmpty()) ? null : compileJoinCondition(source.getJoinCondition());
+        _structureStack.topActivity().joinCondition = (source.getJoinCondition() == null || source.getLinkTargets().isEmpty()) ? null
+                : compileJoinCondition(source.getJoinCondition());
     }
 
     private String createName(Activity source, String type) {
@@ -1006,11 +1008,9 @@ public abstract class BpelCompiler imple
         OProcess.OProperty property = resolveProperty(src.getPropertyName());
 
         OProcess.OPropertyAlias alias = new OProcess.OPropertyAlias(_oprocess);
-        alias.debugInfo = createDebugInfo(_processDef, "PropertyAlias " + src.getPropertyName() + " for "
-                + src.getMessageType());
-        if (src.getMessageType() == null){
-            throw new CompilationException(__cmsgs.errAliasUndeclaredMessage(src.getPropertyName(),
-                    src.getQuery().getPath()));
+        alias.debugInfo = createDebugInfo(_processDef, "PropertyAlias " + src.getPropertyName() + " for " + src.getMessageType());
+        if (src.getMessageType() == null) {
+            throw new CompilationException(__cmsgs.errAliasUndeclaredMessage(src.getPropertyName(), src.getQuery().getPath()));
         }
 
         OMessageVarType messageType = resolveMessageType(src.getMessageType());
@@ -1084,8 +1084,7 @@ public abstract class BpelCompiler imple
             if (plink.hasPartnerRole()) {
                 PartnerLinkType.Role partnerRole = plinkType.getRole(plink.getPartnerRole());
                 if (partnerRole == null)
-                    throw new CompilationException(__cmsgs.errUndeclaredRole(plink.getPartnerRole(), plinkType
-                            .getName()));
+                    throw new CompilationException(__cmsgs.errUndeclaredRole(plink.getPartnerRole(), plinkType.getName()));
                 oplink.partnerRoleName = partnerRole.getName();
                 QName portType = partnerRole.getPortType();
                 if (portType == null)
@@ -1122,7 +1121,7 @@ public abstract class BpelCompiler imple
 
     public void compile(OActivity context, BpelObject source, Runnable run) {
         DefaultActivityGenerator.defaultExtensibilityElements(context, source);
-        _structureStack.push(context,source);
+        _structureStack.push(context, source);
         try {
             run.run();
         } finally {
@@ -1163,6 +1162,16 @@ public abstract class BpelCompiler imple
 
             oscope.atomicScope = _atomicScope = newValue;
         }
+
+        if (src.getIsolatedScope() != null) {
+            if (src.getIsolatedScope()) {
+                if (_isolatedScope)
+                    throw new CompilationException(__cmsgs.errIsolatedScopeNesting());
+
+                oscope.isolatedScope = _isolatedScope = true;
+            }
+        }
+
         try {
             compile(oscope, src, new Runnable() {
                 public void run() {
@@ -1302,11 +1311,9 @@ public abstract class BpelCompiler imple
                 case BPEL20_DRAFT:
                 case BPEL20:
                     if (onEvent.getMessageType() == null && onEvent.getElementType() == null)
-                        throw new CompilationException(__cmsgs.errVariableDeclMissingType(onEvent.getVariable())
-                                .setSource(onEvent));
+                        throw new CompilationException(__cmsgs.errVariableDeclMissingType(onEvent.getVariable()).setSource(onEvent));
                     if (onEvent.getMessageType() != null && onEvent.getElementType() != null)
-                        throw new CompilationException(__cmsgs.errVariableDeclInvalid(onEvent.getVariable()).setSource(
-                                onEvent));
+                        throw new CompilationException(__cmsgs.errVariableDeclInvalid(onEvent.getVariable()).setSource(onEvent));
 
                     OVarType varType;
                     if (onEvent.getMessageType() != null)
@@ -1314,8 +1321,7 @@ public abstract class BpelCompiler imple
                     else if (onEvent.getElement() != null)
                         varType = resolveElementType(onEvent.getElementType());
                     else
-                        throw new CompilationException(__cmsgs
-                                .errUnrecognizedVariableDeclaration(onEvent.getVariable()));
+                        throw new CompilationException(__cmsgs.errUnrecognizedVariableDeclaration(onEvent.getVariable()));
 
                     oevent.variable = new OScope.Variable(_oprocess, varType);
                     oevent.variable.name = onEvent.getVariable();
@@ -1332,8 +1338,7 @@ public abstract class BpelCompiler imple
                 oevent.messageExchangeId = onEvent.getMessageExchangeId();
                 oevent.route = onEvent.getRoute();
 
-                if (onEvent.getPortType() != null
-                        && !onEvent.getPortType().equals(oevent.partnerLink.myRolePortType.getQName()))
+                if (onEvent.getPortType() != null && !onEvent.getPortType().equals(oevent.partnerLink.myRolePortType.getQName()))
                     throw new CompilationException(__cmsgs.errPortTypeMismatch(onEvent.getPortType(),
                             oevent.partnerLink.myRolePortType.getQName()));
 
@@ -1448,8 +1453,7 @@ public abstract class BpelCompiler imple
         oscope.terminationHandler.debugInfo = createDebugInfo(terminationHandler, null);
         if (terminationHandler == null) {
             oscope.terminationHandler.activity = createDefaultCompensateActivity(null,
-                    "Auto-generated 'compensate all' pseudo-activity for default termination handler on "
-                            + oscope.toString());
+                    "Auto-generated 'compensate all' pseudo-activity for default termination handler on " + oscope.toString());
         } else {
             _recoveryContextStack.push(oscope);
             try {
@@ -1467,8 +1471,7 @@ public abstract class BpelCompiler imple
         oscope.compensationHandler.debugInfo = createDebugInfo(compensationHandler, null);
         if (compensationHandler == null) {
             oscope.compensationHandler.activity = createDefaultCompensateActivity(compensationHandler,
-                    "Auto-generated 'compensate all' pseudo-activity for default compensation handler on  "
-                            + oscope.toString());
+                    "Auto-generated 'compensate all' pseudo-activity for default compensation handler on  " + oscope.toString());
         } else {
             _recoveryContextStack.push(oscope);
             try {
@@ -1542,8 +1545,8 @@ public abstract class BpelCompiler imple
                                     else if (catchSrc.getFaultVariableElementType() != null)
                                         faultVarType = resolveElementType(catchSrc.getFaultVariableElementType());
                                     else
-                                        throw new CompilationException(__cmsgs
-                                                .errUnrecognizedVariableDeclaration(catchSrc.getFaultVariable()));
+                                        throw new CompilationException(__cmsgs.errUnrecognizedVariableDeclaration(catchSrc
+                                                .getFaultVariable()));
 
                                     faultVar = new OScope.Variable(_oprocess, faultVarType);
                                     faultVar.name = catchSrc.getFaultVariable();
@@ -1552,8 +1555,7 @@ public abstract class BpelCompiler imple
                                     ctch.addLocalVariable(faultVar);
                                     break;
                                 default:
-                                    throw new AssertionError("Unexpected BPEL VERSION constatnt: "
-                                            + _processDef.getBpelVersion());
+                                    throw new AssertionError("Unexpected BPEL VERSION constatnt: " + _processDef.getBpelVersion());
                                 }
 
                                 ctch.faultVariable = faultVar;
@@ -1764,7 +1766,7 @@ public abstract class BpelCompiler imple
 
         public void push(OActivity act, BpelObject src) {
             _stack.push(act);
-            _srcMap.put(act,src);
+            _srcMap.put(act, src);
         }
 
         public BpelObject topSource() {

Modified: ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/CommonCompilationMessages.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/CommonCompilationMessages.java?rev=956870&r1=956869&r2=956870&view=diff
==============================================================================
--- ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/CommonCompilationMessages.java (original)
+++ ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/CommonCompilationMessages.java Tue Jun 22 12:57:41 2010
@@ -450,6 +450,10 @@ public class CommonCompilationMessages e
             return this.formatCompilationMessage("A scope enclosed inside an atomic scope cannot declare itself as not atomic");
     }
 
+    public CompilationMessage errIsolatedScopeNesting() {
+        return this.formatCompilationMessage("Cannot nest isolated scopes.");
+    }
+
     public CompilationMessage errProcessNameNotSpecified() {
         return this.formatCompilationMessage("The process name was not specified.");
     }

Modified: ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/PickReceiveGenerator.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/PickReceiveGenerator.java?rev=956870&r1=956869&r2=956870&view=diff
==============================================================================
--- ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/PickReceiveGenerator.java (original)
+++ ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/PickReceiveGenerator.java Tue Jun 22 12:57:41 2010
@@ -70,9 +70,10 @@ abstract class PickReceiveGenerator exte
         OPickReceive.OnMessage onMessage = new OPickReceive.OnMessage(_context.getOProcess());
         onMessage.partnerLink = _context.resolvePartnerLink(plink);
         onMessage.operation = _context.resolveMyRoleOperation(onMessage.partnerLink, operation);
-        if (onMessage.operation.getInput() != null && onMessage.operation.getInput().getMessage() != null)
+        if (onMessage.operation.getInput() != null && onMessage.operation.getInput().getMessage() != null) {
             onMessage.variable = _context.resolveMessageVariable(varname, onMessage.operation.getInput().getMessage()
                     .getQName());
+        }
         onMessage.messageExchangeId = messageExchangeId;
         onMessage.route = route;
 

Modified: ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/Scope.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/Scope.java?rev=956870&r1=956869&r2=956870&view=diff
==============================================================================
--- ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/Scope.java (original)
+++ ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/bom/Scope.java Tue Jun 22 12:57:41 2010
@@ -21,7 +21,6 @@ package org.apache.ode.bpel.compiler.bom
 import java.util.Collections;
 import java.util.List;
 
-import javax.xml.namespace.QName;
 
 import org.apache.ode.utils.stl.CollectionsX;
 import org.apache.ode.utils.stl.MemberOfFunction;
@@ -162,7 +161,15 @@ public class Scope extends JoinFailureSu
             return Boolean.FALSE;
         return Boolean.FALSE;
     }
-
+    
+    public Boolean getIsolatedScope() {
+        String value = getAttribute("isolated", "no");
+        if ("yes".equals(value))
+            return Boolean.TRUE;
+        if ("no".equals(value))
+            return Boolean.FALSE;
+        return null;
+    }
     /**
      * Get a partnerLink declared in this scope.
      *

Modified: ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OScope.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OScope.java?rev=956870&r1=956869&r2=956870&view=diff
==============================================================================
--- ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OScope.java (original)
+++ ode/trunk/bpel-obj/src/main/java/org/apache/ode/bpel/o/OScope.java Tue Jun 22 12:57:41 2010
@@ -65,8 +65,12 @@ public class OScope extends OActivity {
 
     public boolean implicitScope;
 
+    /** Is this scope <em>atomic</em> i.e. meant to execute in a single transaction. */
     public boolean atomicScope;
 
+    /** Is this scope <em>isolated</em> i.e. protected against concurrent access to its variables. */
+    public boolean isolatedScope;
+
     public OScope(OProcess owner, OActivity parent) {
         super(owner, parent);
     }

Modified: ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java?rev=956870&r1=956869&r2=956870&view=diff
==============================================================================
--- ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java (original)
+++ ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/BpelRuntimeContextImpl.java Tue Jun 22 12:57:41 2010
@@ -138,6 +138,8 @@ public class BpelRuntimeContextImpl impl
     protected BpelProcess _bpelProcess;
 
     private Date _currentEventDateTime;
+    
+    private boolean _forceFlush;
 
     /** Five second maximum for continous execution. */
     private long _maxReductionTimeMs = 2000000;
@@ -954,7 +956,7 @@ public class BpelRuntimeContextImpl impl
         long maxTime = System.currentTimeMillis() + _maxReductionTimeMs;
         boolean canReduce = true;
         assert _outstandingRequests == null && _imaManager != null;
-        while (ProcessState.canExecute(_dao.getState()) && System.currentTimeMillis() < maxTime && canReduce) {
+        while (ProcessState.canExecute(_dao.getState()) && System.currentTimeMillis() < maxTime && canReduce && !_forceFlush) {
             canReduce = _vpu.execute();
         }
         _dao.setLastActiveTime(new Date());
@@ -1565,4 +1567,7 @@ public class BpelRuntimeContextImpl impl
         }
     }
 
+    public void forceFlush() {
+        _forceFlush = true;
+    }
 }

Modified: ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/BpelRuntimeContext.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/BpelRuntimeContext.java?rev=956870&r1=956869&r2=956870&view=diff
==============================================================================
--- ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/BpelRuntimeContext.java (original)
+++ ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/BpelRuntimeContext.java Tue Jun 22 12:57:41 2010
@@ -167,6 +167,7 @@ public interface BpelRuntimeContext {
 
     void writeCorrelation(CorrelationSetInstance cset, CorrelationKey correlation);
 
+    void forceFlush();
     /**
      * Should be invoked by process template, signalling process completion
      * with no faults.

Added: ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/InstanceGlobals.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/InstanceGlobals.java?rev=956870&view=auto
==============================================================================
--- ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/InstanceGlobals.java (added)
+++ ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/InstanceGlobals.java Tue Jun 22 12:57:41 2010
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+package org.apache.ode.bpel.runtime;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.ode.bpel.o.OScope;
+import org.apache.ode.bpel.runtime.channels.ReadWriteLockChannel;
+
+
+/**
+ * Data structure used to keep track of global (instance-level) data. 
+ * @author Maciej Szefler <mszefler at gmail dot com>
+ *
+ */
+public class InstanceGlobals implements Serializable {
+    
+    /** Variable locks. Used by isolated scopes. */
+    Map<OScope.Variable, ReadWriteLockChannel> _varLocks = new HashMap<OScope.Variable, ReadWriteLockChannel>();
+}

Modified: ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/PROCESS.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/PROCESS.java?rev=956870&r1=956869&r2=956870&view=diff
==============================================================================
--- ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/PROCESS.java (original)
+++ ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/PROCESS.java Tue Jun 22 12:57:41 2010
@@ -19,12 +19,15 @@
 package org.apache.ode.bpel.runtime;
 
 import org.apache.ode.bpel.evt.ProcessInstanceStartedEvent;
+import org.apache.ode.bpel.o.OBase;
 import org.apache.ode.bpel.o.OProcess;
 import org.apache.ode.bpel.o.OScope;
 import org.apache.ode.bpel.o.OFailureHandling;
+import org.apache.ode.bpel.o.OScope.Variable;
 import org.apache.ode.bpel.runtime.channels.FaultData;
 import org.apache.ode.bpel.runtime.channels.ParentScopeChannel;
 import org.apache.ode.bpel.runtime.channels.ParentScopeChannelListener;
+import org.apache.ode.bpel.runtime.channels.ReadWriteLockChannel;
 import org.apache.ode.bpel.runtime.channels.TerminationChannel;
 import org.apache.ode.jacob.SynchChannel;
 
@@ -34,6 +37,7 @@ import org.w3c.dom.Element;
 public class PROCESS extends BpelJacobRunnable {
     private static final long serialVersionUID = 1L;
     private OProcess _oprocess;
+    private InstanceGlobals _globals;
 
     public PROCESS(OProcess process) {
         _oprocess = process;
@@ -43,6 +47,7 @@ public class PROCESS extends BpelJacobRu
         BpelRuntimeContext ntive = getBpelRuntimeContext();
         Long scopeInstanceId = ntive.createScopeInstance(null, _oprocess.procesScope);
 
+        createGlobals();
         ProcessInstanceStartedEvent evt = new ProcessInstanceStartedEvent();
         evt.setRootScopeId(scopeInstanceId);
         evt.setScopeDeclarationId(_oprocess.procesScope.getId());
@@ -51,7 +56,7 @@ public class PROCESS extends BpelJacobRu
         ActivityInfo child = new ActivityInfo(genMonotonic(),
             _oprocess.procesScope,
             newChannel(TerminationChannel.class), newChannel(ParentScopeChannel.class));
-        ScopeFrame processFrame = new ScopeFrame(_oprocess.procesScope, scopeInstanceId, null, null);
+        ScopeFrame processFrame = new ScopeFrame(_oprocess.procesScope, scopeInstanceId, null, null,_globals);
         instance(new SCOPE(child, processFrame, new LinkFrame(null)));
 
         object(new ParentScopeChannelListener(child.parent) {
@@ -80,4 +85,18 @@ public class PROCESS extends BpelJacobRu
             }
         });
     }
+
+    private void createGlobals() {
+        _globals = new InstanceGlobals();
+        
+        // For each variable, we create a lock.
+        for (OBase child : _oprocess.getChildren()) 
+            if (child instanceof OScope.Variable) {
+                OScope.Variable var = (Variable) child;
+                ReadWriteLockChannel vlock = newChannel(ReadWriteLockChannel.class);
+                instance(new READWRITELOCK(vlock));
+                _globals._varLocks.put(var, vlock);
+                
+            }
+    }
 }

Added: ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/READWRITELOCK.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/READWRITELOCK.java?rev=956870&view=auto
==============================================================================
--- ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/READWRITELOCK.java (added)
+++ ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/READWRITELOCK.java Tue Jun 22 12:57:41 2010
@@ -0,0 +1,141 @@
+/*
+ * 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.
+ */
+package org.apache.ode.bpel.runtime;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import org.apache.ode.bpel.runtime.channels.ReadWriteLockChannel;
+import org.apache.ode.bpel.runtime.channels.ReadWriteLockChannelListener;
+import org.apache.ode.jacob.JacobRunnable;
+import org.apache.ode.jacob.SynchChannel;
+
+/**
+ * A fair READ-WRITE lock.
+ * 
+ * @author Maciej Szefler <mszefler at gmail dot com>
+ * 
+ */
+public class READWRITELOCK extends JacobRunnable {
+
+    private static final long serialVersionUID = -7415586067226921615L;
+
+    private static enum Status {
+        UNLOCKED, READLOCK, WRITELOCK,
+    }
+    
+    private LinkedList<Waiter> _waiters = new LinkedList<Waiter>();
+
+    private HashSet<SynchChannel> _owners = new HashSet<SynchChannel>();
+
+    private Status _status = Status.UNLOCKED;
+
+    private ReadWriteLockChannel _self;
+
+    public READWRITELOCK(ReadWriteLockChannel self) {
+        _self = self;
+    }
+
+    @Override
+    public void run() {
+        object(new ReadWriteLockChannelListener(_self) {
+            private static final long serialVersionUID = -8644268413754259515L;
+
+            public void readLock(SynchChannel s) {
+                switch (_status) {
+                case UNLOCKED:
+                    _status = Status.READLOCK;
+                    _owners.add(s);
+                    s.ret();
+                    break;
+                case READLOCK:
+                    _owners.add(s);
+                    s.ret();
+                    break;
+                case WRITELOCK:
+                    _waiters.add(new Waiter(s, false));
+                    break;
+
+                }
+
+                instance(READWRITELOCK.this);
+
+            }
+
+            public void writeLock(SynchChannel s) {
+                switch (_status) {
+                case UNLOCKED:
+                    _status = Status.WRITELOCK;
+                    _owners.add(s);
+                    s.ret();
+                    break;
+                case READLOCK:
+                    _waiters.add(new Waiter(s, true));
+                    break;
+                case WRITELOCK:
+                    _waiters.add(new Waiter(s, false));
+                    break;
+                }
+
+                instance(READWRITELOCK.this);
+            }
+
+            public void unlock(SynchChannel s) {
+
+                _owners.remove(s);
+                if (_owners.isEmpty()) {
+                    _status = Status.UNLOCKED;
+                    if (!_waiters.isEmpty()) {
+                        Waiter w = _waiters.removeFirst();
+                        _owners.add(w.synch);
+                        _status = w.write ? Status.WRITELOCK : Status.READLOCK;
+                        w.synch.ret();
+
+                        if (_status == Status.READLOCK)
+                            for (Iterator<Waiter> i = _waiters.iterator(); i.hasNext();) {
+                                Waiter w1 = i.next();
+                                if (w1.write)
+                                    break;
+                                _owners.add(w1.synch);
+                                w1.synch.ret();
+                                i.remove();
+                            }
+                    }
+                }
+
+                instance(READWRITELOCK.this);
+            }
+
+        });
+    }
+
+    private static class Waiter {
+        SynchChannel synch;
+
+        boolean write;
+
+        Waiter(SynchChannel s, boolean w) {
+            synch = s;
+            write = w;
+        }
+    }
+
+  
+}

Modified: ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/SCOPEACT.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/SCOPEACT.java?rev=956870&r1=956869&r2=956870&view=diff
==============================================================================
--- ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/SCOPEACT.java (original)
+++ ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/SCOPEACT.java Tue Jun 22 12:57:41 2010
@@ -18,24 +18,372 @@
  */
 package org.apache.ode.bpel.runtime;
 
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.o.OLink;
 import org.apache.ode.bpel.o.OScope;
+import org.apache.ode.bpel.o.OScope.Variable;
+import org.apache.ode.bpel.runtime.channels.FaultData;
+import org.apache.ode.bpel.runtime.channels.LinkStatusChannel;
+import org.apache.ode.bpel.runtime.channels.LinkStatusChannelListener;
+import org.apache.ode.bpel.runtime.channels.ParentScopeChannel;
+import org.apache.ode.bpel.runtime.channels.ParentScopeChannelListener;
+import org.apache.ode.bpel.runtime.channels.ReadWriteLockChannel;
+import org.apache.ode.jacob.ChannelListener;
+import org.apache.ode.jacob.SynchChannel;
+import org.apache.ode.jacob.SynchChannelListener;
+import org.apache.ode.jacob.ValChannel;
+import org.apache.ode.jacob.ValChannelListener;
+import org.w3c.dom.Element;
 
 /**
- * A scope activity. The scope activity creates a new scope frame and proceeeds
- * using the {@link SCOPE} template.
+ * A scope activity. The scope activity creates a new scope frame and proceeeds using the {@link SCOPE} template.
  */
 public class SCOPEACT extends ACTIVITY {
-  private static final long serialVersionUID = -4593029783757994939L;
+    private static final Log __log = LogFactory.getLog(SCOPEACT.class);
+    
+    private static final long serialVersionUID = -4593029783757994939L;
+
+    public SCOPEACT(ActivityInfo self, ScopeFrame scopeFrame, LinkFrame linkFrame) {
+        super(self, scopeFrame, linkFrame);
+    }
+
+    public void run() {
+
+        
+        if (((OScope) _self.o).isolatedScope) {
+            __log.debug("found ISOLATED scope, instance ISOLATEDGUARD");
+            instance(new ISOLATEDGUARD(createLockList(), newChannel(SynchChannel.class)));
+
+        } else {
+            ScopeFrame newFrame = new ScopeFrame((OScope) _self.o, getBpelRuntimeContext().createScopeInstance(
+                    _scopeFrame.scopeInstanceId, (OScope) _self.o), _scopeFrame, null);
+
+            // Depending on whether we are ATOMIC or not, we'll need to create outgoing link status interceptors
+            LinkFrame linkframe;
+            if (((OScope) _self.o).atomicScope && !_self.o.outgoingLinks.isEmpty()) {
+                ValChannel linkInterceptorControl = newChannel(ValChannel.class);
+                ParentScopeChannel psc = newChannel(ParentScopeChannel.class);
+                linkframe = createInterceptorLinkFrame();
+                instance(new LINKSTATUSINTERCEPTOR(linkInterceptorControl,linkframe));
+                instance(new UNLOCKER(psc, _self.parent, null, Collections.<IsolationLock>emptyList(), linkInterceptorControl));
+                _self.parent = psc;
+            } else
+                linkframe = _linkFrame;
+            
+            instance(new SCOPE(_self, newFrame, linkframe));
+        }
+
+    }
+
+    /**
+     * Create an ordered list of required locks that need to be acquired before the activity can execute. The list is ordered to
+     * prevent dead-lock. The method of ordering is not especially important, so long as the same method is always used.
+     * 
+     * @return
+     */
+    private List<IsolationLock> createLockList() {
+        LinkedList<IsolationLock> requiredLocks = new LinkedList<IsolationLock>();
+        OScope o = ((OScope) _self.o);
+
+        Set<Variable> vrs = new HashSet<Variable>(o.variableRd);
+        vrs.addAll(o.variableWr);
+
+        for (Variable v : vrs)
+            requiredLocks.add(new IsolationLock(v, o.variableWr.contains(v), _scopeFrame.globals._varLocks.get(v)));
+
+        // Very important, we must sort the locks to prevent deadlocks.
+        Collections.sort(requiredLocks);
+
+        return requiredLocks;
+    }
+
+    /**
+     * Create outgoing link interceptors. Necessary for ISOLATED and ATOMIC (non-standard ext) scopes. I.e we need to prevent the
+     * links from coming out until the scope completes successfully.
+     * 
+     */
+    private LinkFrame createInterceptorLinkFrame() {
+        LinkFrame newframe = new LinkFrame(_linkFrame);
+        for (OLink outlink : _self.o.outgoingLinks) {
+            LinkInfo original = _linkFrame.resolve(outlink);
+            LinkStatusChannel newchannel = newChannel(LinkStatusChannel.class);
+            newframe.links.put(original.olink, new LinkInfo(original.olink, newchannel, newchannel));
+        }
+        return newframe;
+    }
+
+    /**
+     * Link Status interceptor. Used in ISOLATED and ATOMIC scopes to prevent links from getting out until its time.
+     * 
+     * @author Maciej Szefler <mszefler at gmail dot com>
+     * 
+     */
+    private class LINKSTATUSINTERCEPTOR extends BpelJacobRunnable {
+        private static final long serialVersionUID = 3104008741240676253L;
+
+        /** We'll listen here for notification that its ok to send links status out. */
+        private final ValChannel _self;
+
+        private final LinkFrame _interceptedChannels;
+
+        /** The statuses that have been received */
+        private final Map<OLink, Boolean> _statuses = new HashMap<OLink, Boolean>();
+
+        /** NULL means defer links, TRUE means passthrough, FALSE means send FALSE */
+        private Boolean _status;
+
+        LINKSTATUSINTERCEPTOR(ValChannel self, LinkFrame interceptedChannels) {
+            _self = self;
+            _interceptedChannels = interceptedChannels;
+        }
+
+        @Override
+        public void run() {
+
+            __log.debug("LINKSTATUSINTERCEPTOR: running ");
+
+            Set<ChannelListener> mlset = new HashSet<ChannelListener>();
+            
+            if (_status == null)
+                mlset.add(new ValChannelListener(_self) {
+    
+                    private static final long serialVersionUID = 5029554538593371750L;
+    
+                    /** Our owner will notify us when it becomes clear what to do with the links. */
+                    public void val(Object retVal) {
+                        __log.debug("LINKSTATUSINTERCEPTOR: status received " + retVal);
+                        
+                        _status = (Boolean) retVal;
+                        for (OLink available : _statuses.keySet())
+                            _linkFrame.resolve(available).pub.linkStatus(_statuses.get(available) && _status);
+    
+                        // Check if we still need to wait around for more links.
+                        if (!isDone())
+                            instance(LINKSTATUSINTERCEPTOR.this);
+    
+                    }
+    
+                });
+
+            for (final Map.Entry<OLink, LinkInfo> m : _interceptedChannels.links.entrySet()) {
+                if (_statuses.containsKey(m.getKey()))
+                    continue;
+            
+                mlset.add(new LinkStatusChannelListener(m.getValue().pub) {
+                    private static final long serialVersionUID = 1568144473514091593L;
+
+                    public void linkStatus(boolean value) {
+                        _statuses.put(m.getKey(), value);
+                        if (_status != null)
+                            _linkFrame.resolve(m.getKey()).pub.linkStatus(value && _status);
+                        
+                        if (!isDone())
+                            instance(LINKSTATUSINTERCEPTOR.this);
+
+                    }
+
+                });
+            }
+            
+            object(false, mlset);
+
+        }
+
+        /**
+         * Did we get all the links we need?
+         * @return
+         */
+        private boolean isDone() {
+            return (_statuses.keySet().size() < SCOPEACT.this._self.o.outgoingLinks.size());
+
+        }
+
+    }
+    
+    
+    /**
+     * Guard for ISOLATED scopes to prevent start until all locks are acquired.
+     * 
+     * @author Maciej Szefler <mszefler at gmail dot com>
+     *
+     */
+    private class ISOLATEDGUARD extends BpelJacobRunnable {
+
+        private static final long serialVersionUID = -5017579415744600900L;
+
+        final List<IsolationLock> _locksNeeded;
+
+        final LinkedList<IsolationLock> _locksAcquired = new LinkedList<IsolationLock>();
+
+        final SynchChannel _synchChannel;
+
+        ISOLATEDGUARD(List<IsolationLock> locks, SynchChannel synchChannel) {
+            _locksNeeded = locks;
+            _synchChannel = synchChannel;
+        }
+
+        @Override
+        public void run() {
+            if (_locksNeeded.isEmpty()) {
+                // acquired all locks.
+                __log.debug("ISOLATIONGUARD: got all required locks: " + _locksAcquired);
+
+                ScopeFrame newFrame = new ScopeFrame((OScope) _self.o, getBpelRuntimeContext().createScopeInstance(
+                        _scopeFrame.scopeInstanceId, (OScope) _self.o), _scopeFrame, null);
+
+                
+                final ParentScopeChannel parent = _self.parent;
+                _self.parent = newChannel(ParentScopeChannel.class);
+                ValChannel lsi = newChannel(ValChannel.class);
+                instance(new UNLOCKER(_self.parent, parent, _synchChannel, _locksAcquired, lsi));
+                LinkFrame linkframe = createInterceptorLinkFrame();
+                instance(new LINKSTATUSINTERCEPTOR(lsi,linkframe));
+                instance(new SCOPE(_self, newFrame, linkframe));
+                return;
+            } else {
+                __log.debug("ISOLATIONGUARD: don't have all locks still need: " + _locksNeeded);
+
+                // try to acquire the locks in sequence (IMPORTANT) not all at once.
+                IsolationLock il = _locksNeeded.get(0);
+                
+                if (il.writeLock)
+                    il.lockChannel.writeLock(_synchChannel);
+                else
+                    il.lockChannel.readLock(_synchChannel);
+
+                object(new SynchChannelListener(_synchChannel) {
+                    private static final long serialVersionUID = 2857261074409098274L;
+
+                    public void ret() {
+                        __log.debug("ISOLATIONGUARD: got lock: " + _locksNeeded.get(0));
+                        _locksAcquired.add(_locksNeeded.remove(0));
+                        instance(ISOLATEDGUARD.this);
+                    }
+                });
+
+            }
+        }
+
+    }
+
+    /**
+     * Interceptor that waits for the scope to finish and unlock the acquired locks.
+     * 
+     * @author Maciej Szefler <mszefler at gmail dot com>
+     *
+     */
+    private class UNLOCKER extends BpelJacobRunnable {
+
+        private static final long serialVersionUID = -476393080609348172L;
+
+        private final ParentScopeChannel _self;
+
+        private final ParentScopeChannel _parent;
+
+        private final SynchChannel _synchChannel;
+        
+        private final List<IsolationLock> _locks;
+
+        private final ValChannel _linkStatusInterceptor;
+
+        public UNLOCKER(ParentScopeChannel self, ParentScopeChannel parent, SynchChannel synchChannel,
+                List<IsolationLock> locksAcquired,
+                ValChannel linkStatusInterceptor) {
+            _self = self;
+            _parent = parent;
+            _synchChannel = synchChannel;
+            _locks = locksAcquired;
+            _linkStatusInterceptor = linkStatusInterceptor;
+        }
+
+        @Override
+        public void run() {
+
+            __log.debug("running UNLOCKER");
+            object(new ParentScopeChannelListener(_self) {
+
+                public void cancelled() {
+                    _parent.cancelled();
+                    unlockAll();
+                    _linkStatusInterceptor.val(false);
+                    // no more listening.
+                }
+
+                public void compensate(OScope scope, SynchChannel ret) {
+                    _parent.compensate(scope, ret);
+                    // keep listening
+                    instance(UNLOCKER.this);
+                }
+
+                public void completed(FaultData faultData, Set<CompensationHandler> compensations) {
+                    _parent.completed(faultData, compensations);
+                    _linkStatusInterceptor.val(faultData == null);
+                    unlockAll();
+                    // no more listening
+
+                }
+
+                public void failure(String reason, Element data) {
+                    _parent.failure(reason, data);
+                    _linkStatusInterceptor.val(false);
+                    unlockAll();
+                    // no more listening
+                }
+
+            });
+        }
+
+        /**
+         * Unlock all the acquired locks.
+         * 
+         */
+        private void unlockAll() {
+            __log.debug("UNLOCKER: unlockAll: " + _locks);
+
+            if (((OScope)SCOPEACT.this._self.o).atomicScope)
+                getBpelRuntimeContext().forceFlush();
+                
+            for (IsolationLock il : _locks)
+                il.lockChannel.unlock(_synchChannel);
+            _locks.clear();
+        }
+
+    }
+
+    /**
+     * Representation of a lock needed by an isolated scope.
+     * 
+     * @author Maciej Szefler <mszefler at gmail dot com>
+     * 
+     */
+    private static class IsolationLock implements Comparable<IsolationLock>, Serializable {
+        private static final long serialVersionUID = 4214864393241172705L;
+
+        OScope.Variable guardedObject;
+
+        boolean writeLock;
+
+        ReadWriteLockChannel lockChannel;
+
+        public IsolationLock(OScope.Variable go, boolean writeLock, ReadWriteLockChannel channel) {
+            this.guardedObject = go;
+            this.writeLock = writeLock;
+            this.lockChannel = channel;
+        }
+
+        public int compareTo(IsolationLock o) {
+            return guardedObject.getId() - o.guardedObject.getId();
+        }
 
-  public SCOPEACT(ActivityInfo self, ScopeFrame scopeFrame, LinkFrame linkFrame) {
-    super(self, scopeFrame, linkFrame);
-  }
-
-  public void run() {
-    ScopeFrame newFrame = new ScopeFrame(
-            (OScope) _self.o,getBpelRuntimeContext().createScopeInstance(_scopeFrame.scopeInstanceId,(OScope) _self.o),
-            _scopeFrame,
-            null);
-    instance(new SCOPE(_self,newFrame, _linkFrame));
-  }
+    }
 }

Modified: ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ScopeFrame.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ScopeFrame.java?rev=956870&r1=956869&r2=956870&view=diff
==============================================================================
--- ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ScopeFrame.java (original)
+++ ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/ScopeFrame.java Tue Jun 22 12:57:41 2010
@@ -64,6 +64,8 @@ class ScopeFrame implements Serializable
 
     /** The fault context for this scope. */
     private FaultData _faultData;
+    
+    final InstanceGlobals globals;
 
     /** Constructor used to create "fault" scopes. */
     ScopeFrame( OScope scopeDef,
@@ -71,19 +73,27 @@ class ScopeFrame implements Serializable
                 ScopeFrame parent,
                 Set<CompensationHandler> visibleCompensationHandlers,
                 FaultData fault) {
-        this(scopeDef,scopeInstanceId,parent,visibleCompensationHandlers);
+        this(scopeDef,scopeInstanceId,parent,visibleCompensationHandlers, parent.globals);
         _faultData = fault;
 
     }
-
+    public ScopeFrame( OScope scopeDef,
+            Long scopeInstanceId,
+            ScopeFrame parent,
+            Set<CompensationHandler> visibleCompensationHandlers) {
+        this(scopeDef,scopeInstanceId,parent,visibleCompensationHandlers,parent.globals);
+    }
+    
     public ScopeFrame( OScope scopeDef,
                        Long scopeInstanceId,
                        ScopeFrame parent,
-                       Set<CompensationHandler> visibleCompensationHandlers) {
+                       Set<CompensationHandler> visibleCompensationHandlers,
+                       InstanceGlobals globals) {
         this.oscope = scopeDef;
         this.scopeInstanceId = scopeInstanceId;
         this.parent = parent;
         this.availableCompensations = visibleCompensationHandlers;
+        this.globals = globals;
     }
 
 

Added: ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/channels/ReadWriteLock.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/channels/ReadWriteLock.java?rev=956870&view=auto
==============================================================================
--- ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/channels/ReadWriteLock.java (added)
+++ ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/channels/ReadWriteLock.java Tue Jun 22 12:57:41 2010
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+package org.apache.ode.bpel.runtime.channels;
+
+import org.apache.ode.jacob.SynchChannel;
+import org.apache.ode.jacob.ap.ChannelType;
+
+@ChannelType
+public interface ReadWriteLock {
+
+    public void readLock(SynchChannel s);
+    
+    public void writeLock(SynchChannel s);
+    
+    public void unlock(SynchChannel s);
+}

Modified: ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java?rev=956870&r1=956869&r2=956870&view=diff
==============================================================================
--- ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java (original)
+++ ode/trunk/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/CoreBpelTest.java Tue Jun 22 12:57:41 2010
@@ -472,4 +472,10 @@ public class CoreBpelTest extends TestCa
     public PartnerRoleConfig getConfigForPartnerLink(OPartnerLink pLink) {
         return new PartnerRoleConfig(null, true);
     }
+
+    public void forceFlush() {
+        // TODO Auto-generated method stub
+        
+    }
+
 }

Modified: ode/trunk/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Test.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Test.java?rev=956870&r1=956869&r2=956870&view=diff
==============================================================================
--- ode/trunk/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Test.java (original)
+++ ode/trunk/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Test.java Tue Jun 22 12:57:41 2010
@@ -33,6 +33,20 @@ public class StructuredActivities20Test 
         // Test Flow with XPath10
         go("/bpel/2.0/TestFlowLinks");
     }
+    
+    @Test public void testIsolatedScopes1() throws Throwable {
+        // Test Flow with XPath10
+        go("/bpel/2.0/TestIsolatedScopes1");
+    }
+    @Test public void testAtomicScopeBasic() throws Throwable {
+        go("/bpel/2.0/TestAtomicScopeBasic");
+    }
+//    @Test public void testAtomicProcess() throws Throwable {
+//        go("/bpel/2.0/TestAtomicProcess");
+//    }
+//    @Test public void testAtomicScopes() throws Throwable {
+//        go("/bpel/2.0/TestAtomicScope");
+//    }
     @Test public void testForEach() throws Throwable {
         // Test Flow with XPath10
         go("/bpel/2.0/TestForEach");

Added: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorld.bpel
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorld.bpel?rev=956870&view=auto
==============================================================================
--- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorld.bpel (added)
+++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorld.bpel Tue Jun 22 12:57:41 2010
@@ -0,0 +1,74 @@
+<!--
+  ~ 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.
+  -->
+<process name="HelloWorld"
+    targetNamespace="http://ode/bpel/unit-test" 
+    xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+    xmlns:tns="http://ode/bpel/unit-test"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:test="http://ode/bpel/unit-test.wsdl"
+    queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+    expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
+
+  <import location="HelloWorld.wsdl"
+     namespace="http://ode/bpel/unit-test.wsdl"
+     importType="http://schemas.xmlsoap.org/wsdl/" />
+
+   <partnerLinks>
+      <partnerLink name="helloPartnerLink" 
+         partnerLinkType="test:HelloPartnerLinkType" 
+         myRole="me" />
+   </partnerLinks>
+    
+   <variables>
+     <variable name="myVar" messageType="test:HelloMessage"/>
+     <variable name="tmpVar" type="xsd:string"/>
+   </variables>
+
+   <sequence>
+       <receive
+          name="start"
+          partnerLink="helloPartnerLink"
+          portType="test:HelloPortType"
+          operation="hello"
+          variable="myVar"
+          createInstance="yes"/>
+
+      <assign name="assign1">
+          <copy>
+              <from variable="myVar" part="TestPart"/>
+              <to variable="tmpVar"/>
+          </copy>
+          <copy>
+              <from>concat($tmpVar,' World')</from>
+              <to variable="myVar" part="TestPart"/>
+          </copy>
+      </assign>
+       <!--<reply name="end"  
+              partnerLink="helloPartnerLink"
+              portType="test:HelloPortType" 
+              operation="hello"
+              variable="myVar"/>-->
+       <reply name="end"  
+              partnerLink="helloPartnerLink"
+              portType="test:HelloPortType" 
+              operation="hello"
+              faultName="test:TestFault"
+              variable="myVar"/>
+   </sequence>
+</process>

Added: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorld.wsdl
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorld.wsdl?rev=956870&view=auto
==============================================================================
--- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorld.wsdl (added)
+++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorld.wsdl Tue Jun 22 12:57:41 2010
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+  ~ 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.
+  -->
+
+<wsdl:definitions 
+    targetNamespace="http://ode/bpel/unit-test.wsdl"
+    xmlns="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:tns="http://ode/bpel/unit-test.wsdl"
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+    xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype">
+    
+    <wsdl:message name="HelloMessage">
+        <wsdl:part name="TestPart" type="xsd:string"/>
+    </wsdl:message>
+    
+    <wsdl:portType name="HelloPortType">
+        <wsdl:operation name="hello">
+            <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+            <wsdl:output message="tns:HelloMessage" name="TestOut"/>
+            <wsdl:fault message="tns:HelloMessage" name="TestFault"/>
+        </wsdl:operation>    
+    </wsdl:portType>
+    
+     <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
+        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="hello">
+            <soap:operation soapAction="" style="rpc"/>
+            <wsdl:input>
+                <soap:body
+                    namespace="http://ode/bpel/unit-test.wsdl"
+                    use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body
+                    namespace="http://ode/bpel/unit-test.wsdl" 
+                    use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="HelloService">
+		<wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
+     		<soap:address location="http://localhost:8080/ode/processes/helloWorld"/>			
+		</wsdl:port>
+    </wsdl:service>
+    
+   <plnk:partnerLinkType name="HelloPartnerLinkType">
+       <plnk:role name="me" portType="tns:HelloPortType"/>
+       <plnk:role name="you" portType="tns:HelloPortType"/>
+   </plnk:partnerLinkType>
+</wsdl:definitions>
+

Added: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorldAtomic.bpel
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorldAtomic.bpel?rev=956870&view=auto
==============================================================================
--- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorldAtomic.bpel (added)
+++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorldAtomic.bpel Tue Jun 22 12:57:41 2010
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	~ 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.
+-->
+<bpel:process
+	xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+	xmlns:xs="http://www.w3.org/2001/XMLSchema"
+	xmlns:vprop="http://docs.oasis-open.org/wsbpel/2.0/varprop"
+	xmlns:pnlk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:Start="http://ode/bpel/unit-test/Start"
+	xmlns:HelloWorld="http://ode/bpel/unit-test/HelloWorld"
+	xmlns:this="http://ode/bpel/unit-test"
+	xmlns:diag="http://ode/bpel/unit-test.wsdl"
+	xmlns:tns="http://ode/bpel/unit-test.wsdl"
+	xmlns:xml="http://www.w3.org/XML/1998/namespace"
+	xmlns:atomic="http://ode.apache.org/atomicScope"
+	queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+	expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+	name="HelloWorldAtomic" targetNamespace="http://ode/bpel/unit-test" 
+    atomic="yes">
+	<bpel:import namespace="http://ode/bpel/unit-test.wsdl"
+		location="HelloWorld.wsdl"
+		importType="http://schemas.xmlsoap.org/wsdl/"/>
+	<bpel:import namespace="http://ode/bpel/unit-test.wsdl"
+		location="HelloWorldAtomic.wsdl"
+		importType="http://schemas.xmlsoap.org/wsdl/"/>
+	<bpel:partnerLinks>
+		<bpel:partnerLink name="helloWorldAndPoolForHelloPortPlkVar"
+			partnerLinkType="diag:HelloWorldAndPoolForHelloPortPlk"
+			initializePartnerRole="true" partnerRole="HelloWorld_for_Pool"/>
+		<bpel:partnerLink name="poolAndStartForHelloPortPlkVar"
+			partnerLinkType="diag:PoolAndStartForHelloPortPlk"
+			myRole="Pool_for_Start"/>
+	</bpel:partnerLinks>
+	<bpel:variables>
+		<bpel:variable name="tnsHelloRequestMsg" messageType="tns:HelloMessage"/>
+		<bpel:variable name="tnsHelloResponseMsg" messageType="tns:HelloMessage"/>
+	</bpel:variables>
+    <bpel:sequence>
+        <bpel:receive partnerLink="poolAndStartForHelloPortPlkVar"
+            portType="tns:HelloPortType" operation="hello"
+            variable="tnsHelloRequestMsg" createInstance="yes"/>
+        <bpel:invoke partnerLink="helloWorldAndPoolForHelloPortPlkVar"
+            portType="tns:HelloPortType" operation="hello"
+            inputVariable="tnsHelloRequestMsg"
+            outputVariable="tnsHelloResponseMsg"/>
+        <bpel:reply partnerLink="poolAndStartForHelloPortPlkVar"
+            portType="tns:HelloPortType" operation="hello"
+            variable="tnsHelloResponseMsg"/>
+    </bpel:sequence>
+</bpel:process>

Added: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorldAtomic.wsdl
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorldAtomic.wsdl?rev=956870&view=auto
==============================================================================
--- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorldAtomic.wsdl (added)
+++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorldAtomic.wsdl Tue Jun 22 12:57:41 2010
@@ -0,0 +1,44 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+	~ 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.
+-->
+<wsdl:definitions
+	xmlns:bpdm="http://www.intalio/designer/business-process-data-modeling"
+	xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+	xmlns:diag="http://ode/bpel/unit-test.wsdl"
+	xmlns:Start="http://ode/bpel/unit-test.wsdl/Start"
+	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+	xmlns:tns="http://ode/bpel/unit-test.wsdl"
+	xmlns:Pool="http://example.com/diagram/Pool"
+	xmlns:xs="http://www.w3.org/2001/XMLSchema"
+	xmlns:vprop="http://docs.oasis-open.org/wsbpel/2.0/varprop"
+	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+	xmlns:pnlk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	targetNamespace="http://ode/bpel/unit-test.wsdl">
+	<wsdl:import namespace="http://ode/bpel/unit-test.wsdl"
+		location="HelloWorld.wsdl"/>
+	<wsdl:import namespace="http://ode/bpel/unit-test.wsdl"
+		location="HelloWorldExternal.wsdl"/>
+	<pnlk:partnerLinkType name="HelloWorldAndPoolForHelloPortPlk">
+		<pnlk:role name="HelloWorld_for_Pool" portType="tns:HelloPortType"/>
+	</pnlk:partnerLinkType>
+	<pnlk:partnerLinkType name="PoolAndStartForHelloPortPlk">
+		<pnlk:role name="Pool_for_Start" portType="tns:HelloPortType"/>
+	</pnlk:partnerLinkType>
+</wsdl:definitions>

Added: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorldExternal.wsdl
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorldExternal.wsdl?rev=956870&view=auto
==============================================================================
--- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorldExternal.wsdl (added)
+++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/HelloWorldExternal.wsdl Tue Jun 22 12:57:41 2010
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+  ~ 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.
+  -->
+
+<wsdl:definitions 
+    targetNamespace="http://ode/bpel/unit-test.wsdl"
+    xmlns="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:tns="http://ode/bpel/unit-test.wsdl"
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+    xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype">
+    
+    <wsdl:message name="HelloMessage">
+        <wsdl:part name="TestPart" type="xsd:string"/>
+    </wsdl:message>
+    
+    <wsdl:portType name="HelloPortType">
+        <wsdl:operation name="hello">
+            <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+            <wsdl:output message="tns:HelloMessage" name="TestOut"/>
+        </wsdl:operation>    
+    </wsdl:portType>
+    
+     <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
+        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="hello">
+            <soap:operation soapAction="" style="rpc"/>
+            <wsdl:input>
+                <soap:body
+                    namespace="http://ode/bpel/unit-test.wsdl"
+                    use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body
+                    namespace="http://ode/bpel/unit-test.wsdl" 
+                    use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="AtomicHelloService">
+		<wsdl:port name="AtomicHelloPort" binding="tns:HelloSoapBinding">
+     		<soap:address location="http://localhost:8080/ode/processes/AtomicHelloWorld"/>
+		</wsdl:port>
+    </wsdl:service>
+    
+   <plnk:partnerLinkType name="HelloPartnerLinkType">
+       <plnk:role name="me" portType="tns:HelloPortType"/>
+       <plnk:role name="you" portType="tns:HelloPortType"/>
+   </plnk:partnerLinkType>
+</wsdl:definitions>
+

Added: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/deploy.xml
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/deploy.xml?rev=956870&view=auto
==============================================================================
--- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/deploy.xml (added)
+++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/deploy.xml Tue Jun 22 12:57:41 2010
@@ -0,0 +1,42 @@
+<!--
+  ~ 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.
+  -->
+<deploy xmlns="http://www.apache.org/ode/schemas/dd/2007/03"
+	xmlns:pns="http://ode/bpel/unit-test" 
+	xmlns:wns="http://ode/bpel/unit-test.wsdl">
+
+	<process name="pns:HelloWorld">
+		<active>true</active>
+        <in-memory>true</in-memory>
+		<provide partnerLink="helloPartnerLink">
+			<service name="wns:HelloService" port="HelloPort"/>
+		</provide>
+	</process>
+	
+	<process name="pns:HelloWorldAtomic">
+		<active>true</active>
+        <in-memory>true</in-memory>
+		<provide partnerLink="poolAndStartForHelloPortPlkVar">
+			<service name="wns:AtomicHelloService" port="AtomicHelloPort"/>
+		</provide>
+		<invoke partnerLink="helloWorldAndPoolForHelloPortPlkVar">
+		    <service name="wns:HelloService" port="HelloPort"/>
+	    </invoke>
+  </process>
+	
+</deploy>

Added: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/test.properties
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/test.properties?rev=956870&view=auto
==============================================================================
--- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/test.properties (added)
+++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicProcess/test.properties Tue Jun 22 12:57:41 2010
@@ -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://ode/bpel/unit-test.wsdl
+service=AtomicHelloService
+operation=hello
+request1=<message><TestPart><content>Hello</content></TestPart></message>
+response1=FAILURE
+

Added: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorld.bpel
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorld.bpel?rev=956870&view=auto
==============================================================================
--- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorld.bpel (added)
+++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorld.bpel Tue Jun 22 12:57:41 2010
@@ -0,0 +1,74 @@
+<!--
+  ~ 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.
+  -->
+<process name="HelloWorld"
+    targetNamespace="http://ode/bpel/unit-test" 
+    xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+    xmlns:tns="http://ode/bpel/unit-test"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:test="http://ode/bpel/unit-test.wsdl"
+    queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+    expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
+
+  <import location="HelloWorld.wsdl"
+     namespace="http://ode/bpel/unit-test.wsdl"
+     importType="http://schemas.xmlsoap.org/wsdl/" />
+
+   <partnerLinks>
+      <partnerLink name="helloPartnerLink" 
+         partnerLinkType="test:HelloPartnerLinkType" 
+         myRole="me" />
+   </partnerLinks>
+    
+   <variables>
+     <variable name="myVar" messageType="test:HelloMessage"/>
+     <variable name="tmpVar" type="xsd:string"/>
+   </variables>
+
+   <sequence>
+       <receive
+          name="start"
+          partnerLink="helloPartnerLink"
+          portType="test:HelloPortType"
+          operation="hello"
+          variable="myVar"
+          createInstance="yes"/>
+
+      <assign name="assign1">
+          <copy>
+              <from variable="myVar" part="TestPart"/>
+              <to variable="tmpVar"/>
+          </copy>
+          <copy>
+              <from>concat($tmpVar,' World')</from>
+              <to variable="myVar" part="TestPart"/>
+          </copy>
+      </assign>
+       <!--<reply name="end"  
+              partnerLink="helloPartnerLink"
+              portType="test:HelloPortType" 
+              operation="hello"
+              variable="myVar"/>-->
+       <reply name="end"  
+              partnerLink="helloPartnerLink"
+              portType="test:HelloPortType" 
+              operation="hello"
+              faultName="test:TestFault"
+              variable="myVar"/>
+   </sequence>
+</process>

Added: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorld.wsdl
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorld.wsdl?rev=956870&view=auto
==============================================================================
--- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorld.wsdl (added)
+++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorld.wsdl Tue Jun 22 12:57:41 2010
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+  ~ 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.
+  -->
+
+<wsdl:definitions 
+    targetNamespace="http://ode/bpel/unit-test.wsdl"
+    xmlns="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:tns="http://ode/bpel/unit-test.wsdl"
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+    xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype">
+    
+    <wsdl:message name="HelloMessage">
+        <wsdl:part name="TestPart" type="xsd:string"/>
+    </wsdl:message>
+    
+    <wsdl:portType name="HelloPortType">
+        <wsdl:operation name="hello">
+            <wsdl:input message="tns:HelloMessage" name="TestIn"/>
+            <wsdl:output message="tns:HelloMessage" name="TestOut"/>
+            <wsdl:fault message="tns:HelloMessage" name="TestFault"/>
+        </wsdl:operation>    
+    </wsdl:portType>
+    
+     <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType">
+        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="hello">
+            <soap:operation soapAction="" style="rpc"/>
+            <wsdl:input>
+                <soap:body
+                    namespace="http://ode/bpel/unit-test.wsdl"
+                    use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body
+                    namespace="http://ode/bpel/unit-test.wsdl" 
+                    use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="HelloService">
+		<wsdl:port name="HelloPort" binding="tns:HelloSoapBinding">
+     		<soap:address location="http://localhost:8080/ode/processes/helloWorld"/>			
+		</wsdl:port>
+    </wsdl:service>
+    
+   <plnk:partnerLinkType name="HelloPartnerLinkType">
+       <plnk:role name="me" portType="tns:HelloPortType"/>
+       <plnk:role name="you" portType="tns:HelloPortType"/>
+   </plnk:partnerLinkType>
+</wsdl:definitions>
+

Added: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorldAtomic.bpel
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorldAtomic.bpel?rev=956870&view=auto
==============================================================================
--- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorldAtomic.bpel (added)
+++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAtomicScope/HelloWorldAtomic.bpel Tue Jun 22 12:57:41 2010
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	~ 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.
+-->
+<bpel:process
+	xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+	xmlns:xs="http://www.w3.org/2001/XMLSchema"
+	xmlns:vprop="http://docs.oasis-open.org/wsbpel/2.0/varprop"
+	xmlns:pnlk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:Start="http://ode/bpel/unit-test/Start"
+	xmlns:HelloWorld="http://ode/bpel/unit-test/HelloWorld"
+	xmlns:this="http://ode/bpel/unit-test"
+	xmlns:diag="http://ode/bpel/unit-test.wsdl"
+	xmlns:tns="http://ode/bpel/unit-test.wsdl"
+	xmlns:xml="http://www.w3.org/XML/1998/namespace"
+	xmlns:atomic="http://ode.apache.org/atomicScope"
+	queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+	expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"
+	name="HelloWorldAtomic" targetNamespace="http://ode/bpel/unit-test">
+	<bpel:import namespace="http://ode/bpel/unit-test.wsdl"
+		location="HelloWorld.wsdl"
+		importType="http://schemas.xmlsoap.org/wsdl/"/>
+	<bpel:import namespace="http://ode/bpel/unit-test.wsdl"
+		location="HelloWorldAtomic.wsdl"
+		importType="http://schemas.xmlsoap.org/wsdl/"/>
+	<bpel:partnerLinks>
+		<bpel:partnerLink name="helloWorldAndPoolForHelloPortPlkVar"
+			partnerLinkType="diag:HelloWorldAndPoolForHelloPortPlk"
+			initializePartnerRole="true" partnerRole="HelloWorld_for_Pool"/>
+		<bpel:partnerLink name="poolAndStartForHelloPortPlkVar"
+			partnerLinkType="diag:PoolAndStartForHelloPortPlk"
+			myRole="Pool_for_Start"/>
+	</bpel:partnerLinks>
+	<bpel:variables>
+		<bpel:variable name="tnsHelloRequestMsg" messageType="tns:HelloMessage"/>
+		<bpel:variable name="tnsHelloResponseMsg" messageType="tns:HelloMessage"/>
+	</bpel:variables>
+    <bpel:sequence>
+        <bpel:receive partnerLink="poolAndStartForHelloPortPlkVar"
+            portType="tns:HelloPortType" operation="hello"
+            variable="tnsHelloRequestMsg" createInstance="yes"/>
+        <bpel:scope atomic="yes">
+                <bpel:invoke partnerLink="helloWorldAndPoolForHelloPortPlkVar"
+                    portType="tns:HelloPortType" operation="hello"
+                    inputVariable="tnsHelloRequestMsg"
+                    outputVariable="tnsHelloResponseMsg"/>
+        </bpel:scope>
+        <bpel:reply partnerLink="poolAndStartForHelloPortPlkVar"
+            portType="tns:HelloPortType" operation="hello"
+            variable="tnsHelloResponseMsg"/>
+    </bpel:sequence>
+</bpel:process>