From 183d50ed8185f7ee24a009897903db02ce1f319c Mon Sep 17 00:00:00 2001 From: Alexander Lomov Date: Fri, 3 Jan 2014 19:32:11 +0400 Subject: [PATCH] Enclosed scopes unregister themselves now if they carry no compensation handlers. --- .../bpel/model/runtime/FaultHandlingContext.java | 6 ++++++ .../runtime/impl/BPELProcessInstanceImpl.java | 10 +++++++++- .../bpel/model/runtime/impl/ScopeUnitImpl.java | 16 +++++++++++++++- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/ojc-core/bpelse/bpelcore/src/com/sun/jbi/engine/bpel/core/bpel/model/runtime/FaultHandlingContext.java b/ojc-core/bpelse/bpelcore/src/com/sun/jbi/engine/bpel/core/bpel/model/runtime/FaultHandlingContext.java index 76f7cf358..cd20fce85 100755 --- a/ojc-core/bpelse/bpelcore/src/com/sun/jbi/engine/bpel/core/bpel/model/runtime/FaultHandlingContext.java +++ b/ojc-core/bpelse/bpelcore/src/com/sun/jbi/engine/bpel/core/bpel/model/runtime/FaultHandlingContext.java @@ -109,6 +109,12 @@ public interface FaultHandlingContext { */ void registerEnclosedScope(FaultHandlingContext enclosedScope); + /** + * Removes itself from the parent context. + * @param enclosedScope + */ + void unregisterEnclosedScope(FaultHandlingContext enclosedScope); + /** * When a callframe is created it will be registered with the FaultHandlingContext. * This is used by the FaultHandlingContext to remove any callframe that is waiting diff --git a/ojc-core/bpelse/bpelcore/src/com/sun/jbi/engine/bpel/core/bpel/model/runtime/impl/BPELProcessInstanceImpl.java b/ojc-core/bpelse/bpelcore/src/com/sun/jbi/engine/bpel/core/bpel/model/runtime/impl/BPELProcessInstanceImpl.java index 7421f6311..011634f2e 100755 --- a/ojc-core/bpelse/bpelcore/src/com/sun/jbi/engine/bpel/core/bpel/model/runtime/impl/BPELProcessInstanceImpl.java +++ b/ojc-core/bpelse/bpelcore/src/com/sun/jbi/engine/bpel/core/bpel/model/runtime/impl/BPELProcessInstanceImpl.java @@ -860,7 +860,15 @@ public class BPELProcessInstanceImpl extends StructuredActivityUnitImpl implemen */ public void registerEnclosedScope(FaultHandlingContext enclosedScope) { enclosedScopes.add(enclosedScope); - } + } + + /** + * @see com.sun.jbi.engine.bpel.core.bpel.model.runtime.FaultHandlingContext#unregisterEnclosedScope( + * com.sun.jbi.engine.bpel.core.bpel.model.runtime.FaultHandlingContext) + */ + public void unregisterEnclosedScope(FaultHandlingContext enclosedScope) { + enclosedScopes.remove(enclosedScope); + } /** * @see com.sun.jbi.engine.bpel.core.bpel.model.runtime.FaultHandlingContext#notifyFault( diff --git a/ojc-core/bpelse/bpelcore/src/com/sun/jbi/engine/bpel/core/bpel/model/runtime/impl/ScopeUnitImpl.java b/ojc-core/bpelse/bpelcore/src/com/sun/jbi/engine/bpel/core/bpel/model/runtime/impl/ScopeUnitImpl.java index 2b6ac6ea5..6d3859816 100755 --- a/ojc-core/bpelse/bpelcore/src/com/sun/jbi/engine/bpel/core/bpel/model/runtime/impl/ScopeUnitImpl.java +++ b/ojc-core/bpelse/bpelcore/src/com/sun/jbi/engine/bpel/core/bpel/model/runtime/impl/ScopeUnitImpl.java @@ -291,6 +291,7 @@ public class ScopeUnitImpl extends StructuredActivityUnitImpl implements Context currentScopeState = ScopeState.Completed; // clear all the FH related data as the scope has completed. clearFHRelatedData(); + unregisterFromParent(this); // push this completed scope instance to the parent sope stack of completed scopes. mCompletionOrder = getParentContext().getFaultHandlingContext().pushCompletedScope(this); updateScopeOnState(rObjs); @@ -310,6 +311,7 @@ public class ScopeUnitImpl extends StructuredActivityUnitImpl implements Context currentScopeState = ScopeState.Completed; // clear all the FH related data as the scope has completed. clearFHRelatedData(); + unregisterFromParent(this); // push this completed scope instance to the parent scope stack of completed scopes. mCompletionOrder = getParentContext().getFaultHandlingContext().pushCompletedScope(this); updateScopeOnState(rObjs); @@ -391,6 +393,7 @@ public class ScopeUnitImpl extends StructuredActivityUnitImpl implements Context currentScopeState = ScopeState.Completed; // clear all the FH related data as the scope has completed. clearFHRelatedData(); + unregisterFromParent(this); // push this completed scope instance to the parent scope stack of completed scopes. mCompletionOrder = getParentContext().getFaultHandlingContext().pushCompletedScope(this); updateScopeOnState(rObjs); @@ -712,7 +715,15 @@ public class ScopeUnitImpl extends StructuredActivityUnitImpl implements Context */ public void registerEnclosedScope(FaultHandlingContext enclosedScope) { enclosedScopes.add(enclosedScope); - } + } + + public void unregisterEnclosedScope(FaultHandlingContext enclosedScope) { + enclosedScopes.remove(enclosedScope); + } + + private void unregisterFromParent(FaultHandlingContext scope) { + mContext.getFaultHandlingContext().unregisterEnclosedScope(scope); + } /** * @see com.sun.jbi.engine.bpel.core.bpel.model.runtime.FaultHandlingContext#notifyFault( @@ -807,6 +818,7 @@ public class ScopeUnitImpl extends StructuredActivityUnitImpl implements Context // clean the FH related data. clearFHRelatedData(); + unregisterFromParent(this); } private void clearFHRelatedData() { @@ -1252,6 +1264,7 @@ public class ScopeUnitImpl extends StructuredActivityUnitImpl implements Context removeVariableReferences(); frame.getProcessInstance().getPersistenctMgr().updateState(this, mContext.getStateContext().getState(), true); + unregisterFromParent(this); } /** @@ -1460,6 +1473,7 @@ public class ScopeUnitImpl extends StructuredActivityUnitImpl implements Context */ private void updateScopeStateAsDone(boolean persistenceEnabled, RequiredObjects rObjs) { currentScopeState = ScopeState.Done; + unregisterFromParent(this); // update the Scope on the StateImpl if (persistenceEnabled) { updateScopeOnState(rObjs);