[seam-commits] Seam SVN: r13995 - in branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam: bpm and 2 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Jan 18 06:35:22 EST 2011


Author: manaRH
Date: 2011-01-18 06:35:21 -0500 (Tue, 18 Jan 2011)
New Revision: 13995

Modified:
   branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/async/Asynchronous.java
   branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/BusinessProcess.java
   branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/BusinessProcessInterceptor.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/navigation/TaskControl.java
   branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/pageflow/Page.java
Log:
JBPAPP-5517

Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/async/Asynchronous.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/async/Asynchronous.java	2011-01-14 12:37:43 UTC (rev 13994)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/async/Asynchronous.java	2011-01-18 11:35:21 UTC (rev 13995)
@@ -55,7 +55,14 @@
          Contexts.getEventContext().set(AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL, true);
          if (taskId!=null)
          {
-            BusinessProcess.instance().resumeTask(taskId);
+            try
+            {
+               BusinessProcess.instance().resumeTask(taskId);
+            }
+            catch (Exception e) {
+               log.error("Exception was thrown in BusinessProcess.resumeTask", e);
+               throw new RuntimeException(e);
+            }
          }
          else if (processId!=null)
          {

Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/BusinessProcess.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/BusinessProcess.java	2011-01-14 12:37:43 UTC (rev 13994)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/BusinessProcess.java	2011-01-18 11:35:21 UTC (rev 13995)
@@ -220,7 +220,7 @@
          }
       }
       catch (Exception e) {
-         log.debug("Exception while ending bussiness task!");
+         log.error("Exception while ending bussiness task!");
          processId = null;
          taskId = null;
          throw new RuntimeException(e);
@@ -241,10 +241,21 @@
     * 
     * @param transitionName the jBPM transition name 
     */
-   public void transition(String transitionName)
+   public void transition(String transitionName) throws Exception
    {
       ProcessInstance process = org.jboss.seam.bpm.ProcessInstance.instance();
-      process.signal(transitionName);
+      try
+      {
+         process.signal(transitionName);
+      }
+      catch (Exception e)
+      {
+         log.error("Exception while transition is in process!");
+         processId = null;
+         taskId = null;
+         throw new RuntimeException(e);
+      }
+      
       if ( process.hasEnded() )
       {
          Events.instance().raiseEvent("org.jboss.seam.endProcess." + process.getProcessDefinition().getName());
@@ -258,7 +269,7 @@
     * @param taskId the jBPM task instance id
     * @return true if the task was found and was not ended
     */
-   public boolean resumeTask(Long taskId)
+   public boolean resumeTask(Long taskId) throws Exception
    {
       setTaskId(taskId);
       TaskInstance task = org.jboss.seam.bpm.TaskInstance.instance();

Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/BusinessProcessInterceptor.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/BusinessProcessInterceptor.java	2011-01-14 12:37:43 UTC (rev 13994)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/BusinessProcessInterceptor.java	2011-01-18 11:35:21 UTC (rev 13995)
@@ -17,21 +17,23 @@
 import org.jboss.seam.annotations.intercept.Interceptor;
 import org.jboss.seam.contexts.Contexts;
 import org.jboss.seam.core.BijectionInterceptor;
+import org.jboss.seam.core.EventInterceptor;
 import org.jboss.seam.core.Expressions;
 import org.jboss.seam.core.Init;
 import org.jboss.seam.intercept.AbstractInterceptor;
 import org.jboss.seam.intercept.InvocationContext;
 import org.jboss.seam.log.LogProvider;
 import org.jboss.seam.log.Logging;
+import org.jboss.seam.transaction.TransactionInterceptor;
 import org.jboss.seam.util.Strings;
 import org.jboss.seam.web.Parameters;
-import org.jbpm.JbpmContext;
 
 /**
  * Implements annotation-based business-process demarcation.
  *
  * @author <a href="mailto:steve at hibernate.org">Steve Ebersole</a>
  * @author Gavin King
+ * @author Marek Novotny
  */
 @Interceptor(stateless=true, around=BijectionInterceptor.class)
 public class BusinessProcessInterceptor extends AbstractInterceptor
@@ -42,7 +44,7 @@
 
    @AroundInvoke
    public Object aroundInvoke(InvocationContext invocation) throws Exception
-   {
+   {     
       if ( !beforeInvocation(invocation) )
       {
          return null;
@@ -61,14 +63,28 @@
          log.trace( "encountered @StartTask" );
          StartTask tag = method.getAnnotation(StartTask.class);
          Long taskId = getProcessOrTaskId( tag.taskIdParameter(), tag.taskId() );
-         return BusinessProcess.instance().resumeTask(taskId);
+         try
+         {
+            return BusinessProcess.instance().resumeTask(taskId);
+         }
+         catch (Exception e) {
+            log.error("BusinessProcess.resumeTask thrown exception!");
+            return false;
+         }
       }
       else if ( method.isAnnotationPresent(BeginTask.class) ) 
       {
          log.trace( "encountered @BeginTask" );
          BeginTask tag = method.getAnnotation(BeginTask.class);
          Long taskId = getProcessOrTaskId( tag.taskIdParameter(), tag.taskId() );
-         return BusinessProcess.instance().resumeTask(taskId);
+         try
+         {
+            return BusinessProcess.instance().resumeTask(taskId);
+         }
+         catch (Exception e) {
+            log.error("BusinessProcess.resumeTask thrown exception!");
+            return false;
+         }
       }
       else if ( method.isAnnotationPresent(ResumeProcess.class) ) 
       {
@@ -126,8 +142,7 @@
                BusinessProcess.instance().endTask( method.getAnnotation(EndTask.class).transition() );   
             }
             catch (Exception e) {
-               log.debug("Closing JBPM context because exception(s) was thrown!");
-               Contexts.getBusinessProcessContext().flush();
+               log.error("Closing JBPM context because exception(s) was thrown!", e);
                throw new RuntimeException(e);
             }
             finally
@@ -141,7 +156,18 @@
             log.trace( "encountered @Transition" );
             String transitionName = method.getAnnotation(org.jboss.seam.annotations.bpm.Transition.class).value();
             if ( "".equals(transitionName) ) transitionName = method.getName();
-            BusinessProcess.instance().transition(transitionName);
+            try
+            {
+               BusinessProcess.instance().transition(transitionName);
+            }
+            catch (Exception e) {
+               log.error("Closing JBPM context because exception(s) was thrown!", e);
+               throw new RuntimeException(e);
+            }
+            finally
+            {
+               ManagedJbpmContext.instance().close();
+            }
          }
       }
       return result;

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	2011-01-14 12:37:43 UTC (rev 13994)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/ProcessInstance.java	2011-01-18 11:35:21 UTC (rev 13995)
@@ -16,6 +16,7 @@
 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
@@ -34,17 +35,27 @@
    public org.jbpm.graph.exe.ProcessInstance getProcessInstance() throws Exception
    {
       if ( !Contexts.isConversationContextActive() ) return null;
+
+      return new Work<org.jbpm.graph.exe.ProcessInstance>()
+      {
+         
+         @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();
       
-      Long processId = BusinessProcess.instance().getProcessId();
-      if (processId!=null)
-      {
-         //TODO: do we need to cache this??
-         return ManagedJbpmContext.instance().getProcessInstance(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	2011-01-14 12:37:43 UTC (rev 13994)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/TaskInstance.java	2011-01-18 11:35:21 UTC (rev 13995)
@@ -36,16 +36,26 @@
    {
       if ( !Contexts.isConversationContextActive() ) return null;
       
-      Long taskId = BusinessProcess.instance().getTaskId();
-      if (taskId!=null)
-      {
-         //TODO: do we need to cache this??
-         return ManagedJbpmContext.instance().getTaskInstanceForUpdate(taskId);
-      }
-      else
-      {
-         return null;
-      }
+      return new Work<org.jbpm.taskmgmt.exe.TaskInstance>()
+     {
+         
+         @Override
+         protected org.jbpm.taskmgmt.exe.TaskInstance work()
+         {
+            Long taskId = BusinessProcess.instance().getTaskId();
+            if (taskId!=null)
+            {
+               //TODO: do we need to cache this??
+               return ManagedJbpmContext.instance().getTaskInstance(taskId);
+            }
+            else
+            {
+               return null;
+            }
+         }
+         
+      }.workInTransaction();
+
    }
    
    public static org.jbpm.taskmgmt.exe.TaskInstance instance()

Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/navigation/TaskControl.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/navigation/TaskControl.java	2011-01-14 12:37:43 UTC (rev 13994)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/navigation/TaskControl.java	2011-01-18 11:35:21 UTC (rev 13995)
@@ -2,7 +2,6 @@
 
 import org.jboss.seam.bpm.BusinessProcess;
 import org.jboss.seam.bpm.ManagedJbpmContext;
-import org.jboss.seam.contexts.Contexts;
 import org.jboss.seam.core.Expressions.ValueExpression;
 import org.jboss.seam.log.LogProvider;
 import org.jboss.seam.log.Logging;
@@ -33,7 +32,6 @@
          }
          catch (Exception e) {
             log.debug("Closing JBPM context because exception(s) was thrown!");
-            Contexts.getBusinessProcessContext().flush();
             throw new RuntimeException(e);
          }
          finally
@@ -47,7 +45,13 @@
          {
             throw new NullPointerException("task id may not be null");
          }
-         BusinessProcess.instance().resumeTask(taskId.getValue());
+         try
+         {
+            BusinessProcess.instance().resumeTask(taskId.getValue());
+         }
+         catch (Exception e) {
+            log.warn("BusinessProcess.resumeTask thrown exception!");
+         }
       }
       if ( startTask() )
       {

Modified: branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/pageflow/Page.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/pageflow/Page.java	2011-01-14 12:37:43 UTC (rev 13994)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/pageflow/Page.java	2011-01-18 11:35:21 UTC (rev 13995)
@@ -3,8 +3,6 @@
 import org.dom4j.Element;
 import org.jboss.seam.bpm.BusinessProcess;
 import org.jboss.seam.bpm.ManagedJbpmContext;
-import org.jboss.seam.contexts.BusinessProcessContext;
-import org.jboss.seam.contexts.Contexts;
 import org.jboss.seam.core.Conversation;
 import org.jboss.seam.core.Interpolator;
 import org.jboss.seam.log.LogProvider;
@@ -113,7 +111,6 @@
          }
          catch (Exception e) {
             log.debug("Closing JBPM context because exception(s) was thrown!");
-            Contexts.getBusinessProcessContext().flush();
             throw new RuntimeException(e);
          }
          finally



More information about the seam-commits mailing list