[seam-commits] Seam SVN: r13937 - in branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam: navigation and 1 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Dec 7 11:14:11 EST 2010


Author: manaRH
Date: 2010-12-07 11:14:11 -0500 (Tue, 07 Dec 2010)
New Revision: 13937

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/BusinessProcessInterceptor.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 added exception handling in case of EL expresion fails in jbpm process definition

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	2010-12-07 09:30:29 UTC (rev 13936)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/BusinessProcess.java	2010-12-07 16:14:11 UTC (rev 13937)
@@ -15,6 +15,8 @@
 import org.jboss.seam.core.Events;
 import org.jboss.seam.international.StatusMessage;
 import org.jboss.seam.international.StatusMessages;
+import org.jboss.seam.log.LogProvider;
+import org.jboss.seam.log.Logging;
 import org.jbpm.graph.def.ProcessDefinition;
 import org.jbpm.graph.exe.ProcessInstance;
 import org.jbpm.taskmgmt.exe.TaskInstance;
@@ -32,7 +34,8 @@
 @Install(dependencies="org.jboss.seam.bpm.jbpm", precedence=BUILT_IN)
 public class BusinessProcess extends AbstractMutable implements Serializable 
 {
-
+   private static final LogProvider log = Logging.getLogProvider(BusinessProcess.class);
+   
    private static final long serialVersionUID = 4722350870845851070L;
    private Long processId;
    private Long taskId;
@@ -192,7 +195,7 @@
     * 
     * @param transitionName the jBPM transition name, or null
     */
-   public void endTask(String transitionName)
+   public void endTask(String transitionName) throws Exception
    {
       TaskInstance task = org.jboss.seam.bpm.TaskInstance.instance();
       if (task==null)
@@ -205,13 +208,22 @@
          transitionName = Transition.instance().getName();
       }
       
-      if (transitionName==null)
+      try 
       {
-         task.end();
+         if (transitionName==null)
+         {
+            task.end();
+         }
+         else
+         {
+            task.end(transitionName);
+         }
       }
-      else
-      {
-         task.end(transitionName);
+      catch (Exception e) {
+         log.debug("Exception while ending bussiness task!");
+         processId = null;
+         taskId = null;
+         throw new RuntimeException(e);
       }
       
       setTaskId(null); //TODO: do I really need this???!

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	2010-12-07 09:30:29 UTC (rev 13936)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/bpm/BusinessProcessInterceptor.java	2010-12-07 16:14:11 UTC (rev 13937)
@@ -25,6 +25,7 @@
 import org.jboss.seam.log.Logging;
 import org.jboss.seam.util.Strings;
 import org.jboss.seam.web.Parameters;
+import org.jbpm.JbpmContext;
 
 /**
  * Implements annotation-based business-process demarcation.
@@ -120,7 +121,20 @@
          if ( method.isAnnotationPresent(EndTask.class) )
          {
             log.trace( "encountered @EndTask" );
-            BusinessProcess.instance().endTask( method.getAnnotation(EndTask.class).transition() );
+            try
+            {
+               BusinessProcess.instance().endTask( method.getAnnotation(EndTask.class).transition() );   
+            }
+            catch (Exception e) {
+               log.debug("Closing JBPM context because exception(s) was thrown!");
+               Contexts.getBusinessProcessContext().flush();
+               throw new RuntimeException(e);
+            }
+            finally
+            {
+               ManagedJbpmContext.instance().close();
+            }
+            
          }
          if ( method.isAnnotationPresent(org.jboss.seam.annotations.bpm.Transition.class) )
          {
@@ -131,7 +145,7 @@
          }
       }
       return result;
-   }
+   }  
 
    private String getProcessKey(String el)
    {

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	2010-12-07 09:30:29 UTC (rev 13936)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/navigation/TaskControl.java	2010-12-07 16:14:11 UTC (rev 13937)
@@ -1,10 +1,16 @@
 package org.jboss.seam.navigation;
 
 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;
 
 public class TaskControl
 {
+   
+   private static final LogProvider log = Logging.getLogProvider(TaskControl.class);
 
    private boolean isBeginTask;
 
@@ -21,7 +27,19 @@
       if ( endTask() )
       {
          BusinessProcess.instance().validateTask();
-         BusinessProcess.instance().endTask(transition == null ? null : transition.getValue());
+         try
+         {
+            BusinessProcess.instance().endTask(transition == null ? null : transition.getValue());
+         }
+         catch (Exception e) {
+            log.debug("Closing JBPM context because exception(s) was thrown!");
+            Contexts.getBusinessProcessContext().flush();
+            throw new RuntimeException(e);
+         }
+         finally
+         {
+            ManagedJbpmContext.instance().close();
+         }
       }
       if ( beginTask() || 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	2010-12-07 09:30:29 UTC (rev 13936)
+++ branches/enterprise/JBPAPP_5_0/src/main/org/jboss/seam/pageflow/Page.java	2010-12-07 16:14:11 UTC (rev 13937)
@@ -2,8 +2,13 @@
 
 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;
+import org.jboss.seam.log.Logging;
 import org.jbpm.graph.def.Node;
 import org.jbpm.graph.exe.ExecutionContext;
 import org.jbpm.jpdl.xml.JpdlXmlReader;
@@ -26,7 +31,9 @@
    // In case it would be necessary, that file, can be customized
    // by updating the reference to it in the central jbpm configuration 
    // file 'jbpm.cfg.xml'
-
+   
+   private static final LogProvider log = Logging.getLogProvider(Page.class);
+   
    private static final long serialVersionUID = 1L;
    
    private String viewId;
@@ -100,7 +107,19 @@
       
       if ( isTaskEnd ) 
       {
-         BusinessProcess.instance().endTask(transition);         
+         try
+         {
+            BusinessProcess.instance().endTask(transition);
+         }
+         catch (Exception e) {
+            log.debug("Closing JBPM context because exception(s) was thrown!");
+            Contexts.getBusinessProcessContext().flush();
+            throw new RuntimeException(e);
+         }
+         finally
+         {
+            ManagedJbpmContext.instance().close();
+         }
       }
 
       if (isConversationEnd || isTaskEnd ) 



More information about the seam-commits mailing list