[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...
Gavin King
gavin.king at jboss.com
Sun Jun 17 21:21:06 EDT 2007
User: gavin
Date: 07/06/17 21:21:06
Modified: src/main/org/jboss/seam/core ManagedJbpmContext.java
Log:
JBSEAM-798
Revision Changes Path
1.27 +38 -4 jboss-seam/src/main/org/jboss/seam/core/ManagedJbpmContext.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ManagedJbpmContext.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/ManagedJbpmContext.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- ManagedJbpmContext.java 11 Jun 2007 16:05:47 -0000 1.26
+++ ManagedJbpmContext.java 18 Jun 2007 01:21:06 -0000 1.27
@@ -33,9 +33,10 @@
import org.jbpm.svc.Services;
/**
- * Manages a reference to a JbpmSession.
+ * Manages a reference to a JbpmContext.
*
* @author <a href="mailto:steve at hibernate.org">Steve Ebersole </a>
+ * @author Gavin King
*/
@Scope(ScopeType.EVENT)
@Name("org.jboss.seam.core.jbpmContext")
@@ -90,18 +91,51 @@
{
jbpmContext.save(processInstance);
}*/
+ if ( Contexts.isBusinessProcessContextActive() )
+ {
+ //in requests that come through SeamPhaseListener,
+ //transactions are committed before the contexts are
+ //destroyed, flush here:
Contexts.getBusinessProcessContext().flush();
+ }
jbpmContext.getSession().flush();
log.debug( "done flushing seam managed jBPM context" );
}
- public void afterCompletion(int status) {
+ public void afterCompletion(int status)
+ {
synchronizationRegistered = false;
+ if ( !Contexts.isEventContextActive() )
+ {
+ //in calls to MDBs and remote calls to SBs, the
+ //transaction doesn't commit until after contexts
+ //are destroyed, so wait until the transaction
+ //completes before closing the session
+ //on the other hand, if we still have an active
+ //event context, leave it open
+ closeContext();
+ }
}
@Destroy
public void destroy()
{
+ //in requests that come through SeamPhaseListener,
+ //there can be multiple transactions per request,
+ //but they are all completed by the time contexts
+ //are dstroyed
+ //so wait until the end of the request to close
+ //the session
+ //on the other hand, if we are still waiting for
+ //the transaction to commit, leave it open
+ if ( !synchronizationRegistered )
+ {
+ closeContext();
+ }
+ }
+
+ private void closeContext()
+ {
log.debug( "destroying seam managed jBPM context" );
jbpmContext.close();
log.debug( "done destroying seam managed jBPM context" );
More information about the jboss-cvs-commits
mailing list