[seam-commits] Seam SVN: r11308 - in branches/enterprise/JBPAPP_5_0: src/main/org/jboss/seam/bpm and 1 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Tue Jul 28 06:36:29 EDT 2009
Author: manaRH
Date: 2009-07-28 06:36:29 -0400 (Tue, 28 Jul 2009)
New Revision: 11308
Modified:
branches/enterprise/JBPAPP_5_0/examples/todo/resources/jbpm.cfg.xml
branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/ManagedJbpmContext.java
branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/ProcessInstance.java
branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/TaskInstance.java
branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/contexts/Contexts.java
Log:
backport of JBSEAM-1883
Modified: branches/enterprise/JBPAPP_5_0/examples/todo/resources/jbpm.cfg.xml
===================================================================
--- branches/enterprise/JBPAPP_5_0/examples/todo/resources/jbpm.cfg.xml 2009-07-27 19:59:12 UTC (rev 11307)
+++ branches/enterprise/JBPAPP_5_0/examples/todo/resources/jbpm.cfg.xml 2009-07-28 10:36:29 UTC (rev 11308)
@@ -3,8 +3,9 @@
<jbpm-context>
<service name="persistence">
<factory>
- <bean class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
+ <bean class="org.jbpm.persistence.jta.JtaDbPersistenceServiceFactory">
<field name="isTransactionEnabled"><false/></field>
+ <field name="isCurrentSessionEnabled"><true/></field>
</bean>
</factory>
</service>
Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/ManagedJbpmContext.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/ManagedJbpmContext.java 2009-07-27 19:59:12 UTC (rev 11307)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/ManagedJbpmContext.java 2009-07-28 10:36:29 UTC (rev 11308)
@@ -83,6 +83,12 @@
throw new IllegalStateException("JbpmContext may only be used inside a transaction");
}
+ if (jbpmContext == null)
+ {
+ log.debug( "recreating seam managed jBPM context" );
+ jbpmContext = Jbpm.instance().getJbpmConfiguration().createJbpmContext() ;
+ }
+
if ( !synchronizationRegistered && !Lifecycle.isDestroying() && transaction.isActive() )
{
jbpmContext.getSession().isOpen();
@@ -100,7 +106,7 @@
public void beforeCompletion()
{
- log.debug( "flushing seam managed jBPM context" );
+ log.debug( "closing seam managed jBPM context" );
/*org.jbpm.graph.exe.ProcessInstance processInstance = ProcessInstance.instance();
if (processInstance!=null)
{
@@ -113,47 +119,41 @@
//destroyed, flush here:
Contexts.getBusinessProcessContext().flush();
}
- jbpmContext.getSession().flush();
- log.debug( "done flushing seam managed jBPM context" );
+ closeContext();
+ log.debug( "closed seam managed jBPM context" );
}
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()
{
- if ( !synchronizationRegistered )
- {
+// if ( !synchronizationRegistered )
+// {
//in requests that come through SeamPhaseListener,
//there can be multiple transactions per request,
//but they are all completed by the time contexts
- //are dstroyed
+ //are destroyed
//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
closeContext();
- }
+// }
}
private void closeContext()
{
- log.debug( "destroying seam managed jBPM context" );
- jbpmContext.close();
- log.debug( "done destroying seam managed jBPM context" );
+ if (jbpmContext != null)
+ {
+ log.debug( "destroying seam managed jBPM context" );
+ jbpmContext.close();
+ log.debug( "done destroying seam managed jBPM context" );
+ jbpmContext = null;
+ }
}
public static JbpmContext instance()
Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/ProcessInstance.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/ProcessInstance.java 2009-07-27 19:59:12 UTC (rev 11307)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/ProcessInstance.java 2009-07-28 10:36:29 UTC (rev 11308)
@@ -16,7 +16,6 @@
import org.jboss.seam.annotations.Unwrap;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
import org.jboss.seam.contexts.Contexts;
-import org.jboss.seam.util.Work;
/**
* A Seam component that allows injection of the current
@@ -36,26 +35,16 @@
{
if ( !Contexts.isConversationContextActive() ) return null;
- return new Work<org.jbpm.graph.exe.ProcessInstance>()
+ Long processId = BusinessProcess.instance().getProcessId();
+ if (processId!=null)
{
-
- @Override
- protected org.jbpm.graph.exe.ProcessInstance work() throws Exception
- {
- Long processId = BusinessProcess.instance().getProcessId();
- if (processId!=null)
- {
- //TODO: do we need to cache this??
- return ManagedJbpmContext.instance().getProcessInstanceForUpdate(processId);
- }
- else
- {
- return null;
- }
- }
-
- }.workInTransaction();
-
+ //TODO: do we need to cache this??
+ return ManagedJbpmContext.instance().getProcessInstanceForUpdate(processId);
+ }
+ else
+ {
+ return null;
+ }
}
public static org.jbpm.graph.exe.ProcessInstance instance()
Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/TaskInstance.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/TaskInstance.java 2009-07-27 19:59:12 UTC (rev 11307)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/TaskInstance.java 2009-07-28 10:36:29 UTC (rev 11308)
@@ -36,25 +36,16 @@
{
if ( !Contexts.isConversationContextActive() ) return null;
- return new Work<org.jbpm.taskmgmt.exe.TaskInstance>()
+ Long taskId = BusinessProcess.instance().getTaskId();
+ if (taskId!=null)
{
-
- @Override
- protected org.jbpm.taskmgmt.exe.TaskInstance work() throws Exception
- {
- Long taskId = BusinessProcess.instance().getTaskId();
- if (taskId!=null)
- {
- //TODO: do we need to cache this??
- return ManagedJbpmContext.instance().getTaskInstanceForUpdate(taskId);
- }
- else
- {
- return null;
- }
- }
-
- }.workInTransaction();
+ //TODO: do we need to cache this??
+ return ManagedJbpmContext.instance().getTaskInstanceForUpdate(taskId);
+ }
+ else
+ {
+ return null;
+ }
}
public static org.jbpm.taskmgmt.exe.TaskInstance instance()
Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/contexts/Contexts.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/contexts/Contexts.java 2009-07-27 19:59:12 UTC (rev 11307)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/contexts/Contexts.java 2009-07-28 10:36:29 UTC (rev 11308)
@@ -18,6 +18,7 @@
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
import org.jboss.seam.transaction.Transaction;
+import org.jboss.seam.util.Work;
import org.jboss.seam.web.Session;
/**
@@ -344,17 +345,32 @@
//TODO: it would be nice if BP context spanned redirects along with the conversation
// this would also require changes to BusinessProcessContext
- boolean destroyBusinessProcessContext = !Init.instance().isJbpmInstalled() ||
- !BusinessProcess.instance().hasActiveProcess();
- if (destroyBusinessProcessContext)
+ try
{
- //TODO: note that this occurs from Lifecycle.endRequest(), after
- // the Seam-managed txn was committed, but Contexts.destroy()
- // calls BusinessProcessContext.getNames(), which hits the
- // database!
- log.debug("destroying business process context");
- destroy( getBusinessProcessContext() );
+ new Work<Object>()
+ {
+ @Override
+ protected Object work() throws Exception
+ {
+ boolean destroyBusinessProcessContext = !Init.instance().isJbpmInstalled() ||
+ !BusinessProcess.instance().hasActiveProcess();
+ if (destroyBusinessProcessContext)
+ {
+ //TODO: note that this occurs from Lifecycle.endRequest(), after
+ // the Seam-managed txn was committed, but Contexts.destroy()
+ // calls BusinessProcessContext.getNames(), which hits the
+ // database!
+ log.debug("destroying business process context");
+ destroy( getBusinessProcessContext() );
+ }
+ return null;
+ }
+ }.workInTransaction();
}
+ catch (final Exception ex)
+ {
+ log.warn("Exception destroying context ", ex);
+ }
}
if ( !Manager.instance().isLongRunningConversation() )
More information about the seam-commits
mailing list