You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by je...@apache.org on 2011/02/23 02:24:57 UTC

svn commit: r1073574 - /ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/SCOPE.java

Author: jeffyu
Date: Wed Feb 23 01:24:57 2011
New Revision: 1073574

URL: http://svn.apache.org/viewvc?rev=1073574&view=rev
Log:
*ODE-913, apply the patch from Gary, Thanks Gary.

Modified:
    ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/SCOPE.java

Modified: ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/SCOPE.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/SCOPE.java?rev=1073574&r1=1073573&r2=1073574&view=diff
==============================================================================
--- ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/SCOPE.java (original)
+++ ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/runtime/SCOPE.java Wed Feb 23 01:24:57 2011
@@ -273,10 +273,51 @@ class SCOPE extends ACTIVITY {
                 // need to load the termination handler:
                 if (_terminated) {
                     if (__log.isDebugEnabled()) {
-                        __log.debug("Scope: " + _oscope + " was terminated.");
+                        __log.debug("Scope: " + _oscope + " was terminated. (fault="+_fault+")");
                     }
                     // ??? Should we forward
-                    _self.parent.completed(null,_compensations);
+                    
+                    // If termination handler defined, and the scope has not faulted
+                    if (_oscope.terminationHandler != null && _fault == null) {
+                    
+                        // We have to create a scope for the catch block.
+                        BpelRuntimeContext ntive = getBpelRuntimeContext();
+
+                        ActivityInfo terminationHandlerActivity = new ActivityInfo(genMonotonic(), _oscope.terminationHandler,
+                                newChannel(TerminationChannel.class,"TH"), newChannel(ParentScopeChannel.class,"TH"));
+
+                        ScopeFrame terminationHandlerScopeFrame = new ScopeFrame(_oscope.terminationHandler,
+                                ntive.createScopeInstance(_scopeFrame.scopeInstanceId, _oscope.terminationHandler),
+                                _scopeFrame, CompensationHandler.emptySet(), (FaultData)null);
+                        
+                        // Create the temination handler scope.
+                        instance(new SCOPE(terminationHandlerActivity,terminationHandlerScopeFrame, SCOPE.this._linkFrame));
+
+                        object(new ParentScopeChannelListener(terminationHandlerActivity.parent) {
+                            private static final long serialVersionUID = -6009078124717125270L;
+
+                            public void compensate(OScope scope, SynchChannel ret) {
+                                // This should never happen.
+                                throw new AssertionError("received compensate request!");
+                            }
+
+                            public void completed(FaultData fault, Set<CompensationHandler> compensations) {
+                                // The compensations that have been registered here, will never be activated,
+                                // so we'll forget them as soon as possible.
+                                for (CompensationHandler compensation : compensations)
+                                    compensation.compChannel.forget();
+
+                                // When a fault occurs within a termination handler, it is not propagated
+                                _self.parent.completed(null, CompensationHandler.emptySet());
+                            }
+
+                            public void cancelled() { completed(null, CompensationHandler.emptySet()); }
+                            public void failure(String reason, Element data) { completed(null, CompensationHandler.emptySet()); }
+                        });
+                    } else {
+                    	_self.parent.completed(null,_compensations);
+                    }
+                    
                 } else if (_fault != null) {
 
                     sendEvent(new ScopeFaultEvent(_fault.getFaultName(), _fault.getFaultLineNo(),_fault.getExplanation()));