[jbpm-commits] JBoss JBPM SVN: r6186 - in jbpm3/branches/jbpm-3.2-soa/modules/core: src/main/java/org/jbpm/graph/action and 8 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Sat Feb 20 21:33:31 EST 2010


Author: alex.guizar at jboss.com
Date: 2010-02-20 21:33:30 -0500 (Sat, 20 Feb 2010)
New Revision: 6186

Added:
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2263/
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2263/JBPM2263Test.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2263/
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2263/gpd.xml
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2263/processdefinition.xml
Modified:
   jbpm3/branches/jbpm-3.2-soa/modules/core/pom.xml
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/action/Script.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/CleanUpProcessJob.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/ExecuteActionJob.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/ExecuteNodeJob.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Job.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Timer.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/JpdlException.java
   jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java
Log:
JBPM-2263: preserve existing event source when firing new event

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/pom.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/pom.xml	2010-02-19 17:23:16 UTC (rev 6185)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/pom.xml	2010-02-21 02:33:30 UTC (rev 6186)
@@ -27,7 +27,7 @@
 
   <!-- Properties -->
   <properties>
-    <surefire.jvm.args>-Xmx512m</surefire.jvm.args>
+  	<surefire.jvm.args>-Xmx128m</surefire.jvm.args>
   </properties>
 
   <!-- Dependencies -->

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/action/Script.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/action/Script.java	2010-02-19 17:23:16 UTC (rev 6185)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/action/Script.java	2010-02-21 02:33:30 UTC (rev 6186)
@@ -39,20 +39,23 @@
 import org.jbpm.jpdl.xml.JpdlXmlReader;
 import org.jbpm.jpdl.xml.Parsable;
 
+import bsh.EvalError;
 import bsh.Interpreter;
+import bsh.ParseException;
 import bsh.TargetError;
 
 public class Script extends Action implements Parsable {
-  
+
   private static final long serialVersionUID = 1L;
-  
+
   protected String expression = null;
   protected Set variableAccesses = null;
 
   public void read(Element scriptElement, JpdlXmlReader jpdlReader) {
     if (scriptElement.isTextOnly()) {
       expression = scriptElement.getText();
-    } else {
+    }
+    else {
       this.variableAccesses = new HashSet(jpdlReader.readVariableAccesses(scriptElement));
       expression = scriptElement.element("expression").getText();
     }
@@ -77,31 +80,29 @@
     Token token = executionContext.getToken();
 
     Map inputMap = new HashMap();
-    inputMap.put( "executionContext", executionContext );
-    inputMap.put( "token", token );
-    inputMap.put( "node", executionContext.getNode() );
-    inputMap.put( "task", executionContext.getTask() );
-    inputMap.put( "taskInstance", executionContext.getTaskInstance() );
-    
-    // if no readable variableInstances are specified, 
+    inputMap.put("executionContext", executionContext);
+    inputMap.put("token", token);
+    inputMap.put("node", executionContext.getNode());
+    inputMap.put("task", executionContext.getTask());
+    inputMap.put("taskInstance", executionContext.getTaskInstance());
+
+    // if no readable variableInstances are specified,
     ContextInstance contextInstance = executionContext.getContextInstance();
-    if (! hasReadableVariable()) {
-      // we copy all the variableInstances of the context into the interpreter 
+    if (!hasReadableVariable()) {
+      // we copy all the variableInstances of the context into the interpreter
       Map variables = contextInstance.getVariables(token);
-      if ( variables != null ) {
-        Iterator iter = variables.entrySet().iterator();
-        while( iter.hasNext() ) {
+      if (variables != null) {
+        for (Iterator iter = variables.entrySet().iterator(); iter.hasNext();) {
           Map.Entry entry = (Map.Entry) iter.next();
           String variableName = (String) entry.getKey();
           Object variableValue = entry.getValue();
           inputMap.put(variableName, variableValue);
         }
       }
-
-    } else {
-      // we only copy the specified variableInstances into the interpreterz
-      Iterator iter = variableAccesses.iterator();
-      while (iter.hasNext()) {
+    }
+    else {
+      // we only copy the specified variableInstances into the interpreter
+      for (Iterator iter = variableAccesses.iterator(); iter.hasNext();) {
         VariableAccess variableAccess = (VariableAccess) iter.next();
         if (variableAccess.isReadable()) {
           String variableName = variableAccess.getVariableName();
@@ -111,55 +112,51 @@
         }
       }
     }
-    
+
     return inputMap;
   }
 
   public Map eval(Map inputMap, Set outputNames) throws Exception {
     Map outputMap = new HashMap();
-    
     try {
-      log.debug("script input: "+inputMap);
+      // set input variables
+      log.debug("script input: " + inputMap);
       Interpreter interpreter = new Interpreter();
-      Iterator iter = inputMap.keySet().iterator();
-      while (iter.hasNext()) {
-        String inputName = (String) iter.next();
-        Object inputValue = inputMap.get(inputName);
-        interpreter.set(inputName, inputValue);
-     }
+      for (Iterator iter = inputMap.entrySet().iterator(); iter.hasNext();) {
+        Map.Entry entry = (Map.Entry) iter.next();
+        interpreter.set((String) entry.getKey(), entry.getValue());
+      }
+      // evaluate script
       interpreter.eval(expression);
-      iter = outputNames.iterator();
-      while (iter.hasNext()) {
+      // get output variables
+      for (Iterator iter = outputNames.iterator(); iter.hasNext();) {
         String outputName = (String) iter.next();
         Object outputValue = interpreter.get(outputName);
         outputMap.put(outputName, outputValue);
       }
-      log.debug("script output: "+outputMap);
-    } catch (TargetError e) {
-      throw new DelegationException("script evaluation exception", e.getTarget());
-    } catch (Exception e) {
-      log.warn("exception during evaluation of script expression", e);
-      // try to throw the cause of the EvalError
-      if (e.getCause() instanceof Exception) {
-        throw (Exception) e.getCause();
-      } else if (e.getCause() instanceof Error) {
-        throw (Error) e.getCause();
-      } else {
-        throw e;
-      }
+      log.debug("script output: " + outputMap);
     }
+    catch (ParseException e) {
+      throw new DelegationException("failed to parse script", e);
+    }
+    catch (TargetError e) {
+      throw new DelegationException("script threw exception", e.getTarget());
+    }
+    catch (EvalError e) {
+      throw new DelegationException("script evaluation halted", e);
+    }
 
     return outputMap;
   }
 
   public void addVariableAccess(VariableAccess variableAccess) {
-    if (variableAccesses==null) variableAccesses = new HashSet();
+    if (variableAccesses == null) variableAccesses = new HashSet();
     variableAccesses.add(variableAccess);
   }
 
   Set getOutputNames() {
     Set outputNames = new HashSet();
-    if (variableAccesses!=null) {
+    if (variableAccesses != null) {
       Iterator iter = variableAccesses.iterator();
       while (iter.hasNext()) {
         VariableAccess variableAccess = (VariableAccess) iter.next();
@@ -172,7 +169,7 @@
   }
 
   boolean hasReadableVariable() {
-    if (variableAccesses==null) return false;
+    if (variableAccesses == null) return false;
     Iterator iter = variableAccesses.iterator();
     while (iter.hasNext()) {
       VariableAccess variableAccess = (VariableAccess) iter.next();
@@ -184,14 +181,11 @@
   }
 
   void setVariables(Map outputMap, ExecutionContext executionContext) {
-    if ( (outputMap!=null)
-         && (!outputMap.isEmpty()) 
-         && (executionContext!=null)
-       ) {
+    if ((outputMap != null) && (!outputMap.isEmpty()) && (executionContext != null)) {
       Map variableNames = getVariableNames();
       ContextInstance contextInstance = executionContext.getContextInstance();
       Token token = executionContext.getToken();
-      
+
       Iterator iter = outputMap.keySet().iterator();
       while (iter.hasNext()) {
         String mappedName = (String) iter.next();
@@ -216,15 +210,18 @@
   public String getExpression() {
     return expression;
   }
+
   public void setExpression(String expression) {
     this.expression = expression;
   }
+
   public Set getVariableAccesses() {
     return variableAccesses;
   }
+
   public void setVariableAccesses(Set variableAccesses) {
     this.variableAccesses = variableAccesses;
   }
-  
+
   private static final Log log = LogFactory.getLog(Script.class);
 }

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java	2010-02-19 17:23:16 UTC (rev 6185)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/graph/def/GraphElement.java	2010-02-21 02:33:30 UTC (rev 6186)
@@ -174,6 +174,8 @@
   public void fireEvent(String eventType, ExecutionContext executionContext) {
     log.debug("event '" + eventType + "' on " + this + " for "
       + executionContext.getToken());
+
+    GraphElement eventSource = executionContext.getEventSource();
     try {
       executionContext.setEventSource(this);
 
@@ -189,7 +191,7 @@
       fireAndPropagateEvent(eventType, executionContext);
     }
     finally {
-      executionContext.setEventSource(null);
+      executionContext.setEventSource(eventSource);
     }
   }
 

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/CleanUpProcessJob.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/CleanUpProcessJob.java	2010-02-19 17:23:16 UTC (rev 6185)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/CleanUpProcessJob.java	2010-02-21 02:33:30 UTC (rev 6186)
@@ -48,4 +48,8 @@
     return true;
   }
 
+  public String toString() {
+    return "CleanUpProcessJob(" + id + ',' + processInstance + ')';
+  }
+
 }

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/ExecuteActionJob.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/ExecuteActionJob.java	2010-02-19 17:23:16 UTC (rev 6185)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/ExecuteActionJob.java	2010-02-21 02:33:30 UTC (rev 6186)
@@ -1,7 +1,5 @@
 package org.jbpm.job;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.jbpm.JbpmContext;
 import org.jbpm.graph.def.Action;
 import org.jbpm.graph.def.Node;
@@ -13,37 +11,38 @@
   private static final long serialVersionUID = 1L;
 
   Action action;
-  
+
   public ExecuteActionJob() {
   }
-  
+
   public ExecuteActionJob(Token token) {
     super(token);
   }
-  
+
   public boolean execute(JbpmContext jbpmContext) throws Exception {
-    log.debug("job["+id+"] executes "+action);
-    
     ExecutionContext executionContext = new ExecutionContext(token);
     executionContext.setAction(action);
     executionContext.setEvent(action.getEvent());
-    
-    Node node = (token!=null ? token.getNode() : null);
-    if (node!=null) {
+
+    Node node;
+    if (token != null && (node = token.getNode()) != null) {
       node.executeAction(action, executionContext);
-    } else {
+    }
+    else {
       action.execute(executionContext);
     }
-
     return true;
   }
 
+  public String toString() {
+    return "ExecuteActionJob(" + id + ',' + action + ')';
+  }
+
   public Action getAction() {
     return action;
   }
+
   public void setAction(Action action) {
     this.action = action;
   }
-  
-  private static Log log = LogFactory.getLog(ExecuteActionJob.class);
 }

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/ExecuteNodeJob.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/ExecuteNodeJob.java	2010-02-19 17:23:16 UTC (rev 6185)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/ExecuteNodeJob.java	2010-02-21 02:33:30 UTC (rev 6186)
@@ -1,7 +1,5 @@
 package org.jbpm.job;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.jbpm.JbpmContext;
 import org.jbpm.graph.def.Node;
 import org.jbpm.graph.exe.ExecutionContext;
@@ -21,15 +19,16 @@
   }
 
   public boolean execute(JbpmContext jbpmContext) throws Exception {
-    log.debug(this + " executes " + node);
-
     token.unlock(this.toString());
     ExecutionContext executionContext = new ExecutionContext(token);
     node.execute(executionContext);
-
     return true;
   }
 
+  public String toString() {
+    return "ExecuteNodeJob(" + id + ',' + node + ')';
+  }
+
   public Node getNode() {
     return node;
   }
@@ -37,6 +36,4 @@
   public void setNode(Node node) {
     this.node = node;
   }
-
-  private static Log log = LogFactory.getLog(ExecuteNodeJob.class);
 }

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Job.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Job.java	2010-02-19 17:23:16 UTC (rev 6185)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Job.java	2010-02-21 02:33:30 UTC (rev 6186)
@@ -1,8 +1,6 @@
 package org.jbpm.job;
 
 import java.io.Serializable;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
 import java.util.Date;
 
 import org.jbpm.JbpmContext;
@@ -13,7 +11,6 @@
 public abstract class Job implements Serializable {
 
   private static final long serialVersionUID = 1L;
-  private static final DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss,SSS");
 
   long id;
   int version;
@@ -23,12 +20,12 @@
   ProcessInstance processInstance;
   Token token;
   TaskInstance taskInstance;
-  
+
   boolean isSuspended;
 
   /**
-   * specifies if this job can be executed concurrently with other jobs for the 
-   * same process instance. 
+   * specifies if this job can be executed concurrently with other jobs for the
+   * same process instance.
    */
   boolean isExclusive;
 
@@ -44,9 +41,9 @@
 
   String exception;
   int retries = 1;
-  
+
   String configuration;
- 
+
   public Job() {
   }
 
@@ -56,99 +53,120 @@
   }
 
   public abstract boolean execute(JbpmContext jbpmContext) throws Exception;
-  
-  public String toString() {
-    return "Job("+id+')';
-  }
-  
+
   public String toStringLongFormat() {
-    return "id="+id
-       + ", version="+version
-       + ", dueDate="+(dueDate!=null ? dateFormat.format(dueDate) : null)
-       + ", isSuspended="+isSuspended
-       + ", isExclusive="+isExclusive
-       + ", lockOwner="+lockOwner
-       + ", lockTime="+lockTime
-       + ", exception="+exception
-       + ", retries="+retries
-       + ", configuration="+configuration;
+    return "Job(id=" + id
+       + ", version=" + version
+       + ", dueDate=" + (dueDate != null ? dueDate : null)
+       + ", suspended=" + isSuspended
+       + ", exclusive=" + isExclusive
+       + ", lockOwner=" + lockOwner
+       + ", lockTime=" + lockTime
+       + ", exception=" + exception
+       + ", retries=" + retries
+       + ", configuration=" + configuration;
   }
 
   public ProcessInstance getProcessInstance() {
     return processInstance;
   }
+
   public void setProcessInstance(ProcessInstance processInstance) {
     this.processInstance = processInstance;
   }
+
   public Token getToken() {
     return token;
   }
+
   public void setToken(Token token) {
     this.token = token;
   }
+
   public long getId() {
     return id;
   }
+
   public Date getAqcuireDate() {
     return lockTime;
   }
+
   public void setLockTime(Date aqcuireDate) {
     this.lockTime = aqcuireDate;
   }
+
   public Date getDueDate() {
     return dueDate;
   }
+
   public void setDueDate(Date dueDate) {
     this.dueDate = dueDate;
   }
+
   public String getException() {
     return exception;
   }
+
   public void setException(String exception) {
     this.exception = exception;
   }
+
   public boolean isExclusive() {
     return isExclusive;
   }
+
   public void setExclusive(boolean isExclusive) {
     this.isExclusive = isExclusive;
   }
+
   public String getJobExecutorName() {
     return lockOwner;
   }
+
   public void setLockOwner(String jobExecutorName) {
     this.lockOwner = jobExecutorName;
   }
+
   public int getRetries() {
     return retries;
   }
+
   public void setRetries(int retries) {
     this.retries = retries;
   }
+
   public TaskInstance getTaskInstance() {
     return taskInstance;
   }
+
   public void setTaskInstance(TaskInstance taskInstance) {
     this.taskInstance = taskInstance;
   }
+
   public String getConfiguration() {
     return configuration;
   }
+
   public void setConfiguration(String configuration) {
     this.configuration = configuration;
   }
+
   public String getLockOwner() {
     return lockOwner;
   }
+
   public Date getLockTime() {
     return lockTime;
   }
+
   public boolean isSuspended() {
     return isSuspended;
   }
+
   public void setSuspended(boolean isSuspended) {
     this.isSuspended = isSuspended;
   }
+
   public int getVersion() {
     return version;
   }

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Timer.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Timer.java	2010-02-19 17:23:16 UTC (rev 6185)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/Timer.java	2010-02-21 02:33:30 UTC (rev 6186)
@@ -1,6 +1,5 @@
 package org.jbpm.job;
 
-import java.text.SimpleDateFormat;
 import java.util.Date;
 
 import org.apache.commons.logging.Log;
@@ -20,14 +19,13 @@
 
   private static final long serialVersionUID = 1L;
 
-  private final static String dateFormat = "yyyy-MM-dd HH:mm:ss,SSS";
   static BusinessCalendar businessCalendar = new BusinessCalendar();
 
   String name;
   String repeat;
-  String transitionName = null;
-  Action action = null;
-  GraphElement graphElement = null;
+  String transitionName;
+  Action action;
+  GraphElement graphElement;
 
   public Timer() {
   }
@@ -52,7 +50,7 @@
     // then execute the action if there is one
     if (action != null) {
       try {
-        log.debug("executing '" + this + "'");
+        log.debug("executing " + this);
         if (graphElement != null) {
           graphElement.executeAction(action, executionContext);
         }
@@ -61,17 +59,19 @@
         }
       }
       catch (Exception actionException) {
-        // NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
+        // NOTE that Errors are not caught because that might halt the JVM
+        // and mask the original Error.
         log.warn("timer action threw exception", actionException);
         // if there is a graphElement connected to this timer...
         if (graphElement != null) {
           try {
-            // we give that graphElement a chance to catch the exception
+            // give that graphElement a chance to catch the exception
             graphElement.raiseException(actionException, executionContext);
-            log.debug("timer exception got handled by '" + graphElement + "'");
+            log.debug("timer exception got handled by " + graphElement);
           }
-          catch (Exception handlerException) {
-            // if the exception handler rethrows or the original exception results in a DelegationException...
+          catch (RuntimeException handlerException) {
+            // if the exception handler rethrows or the original exception
+            // results in a DelegationException...
             throw handlerException;
           }
         }
@@ -106,12 +106,12 @@
         repeatDate = businessCalendar.add(repeatDate, interval);
       } while (repeatDate.getTime() <= currentTime);
 
-      log.debug("scheduling " + this + " for repeat on: " + formatDueDate(repeatDate));
+      log.debug("scheduling " + this + " for repeat on: " + dueDate);
       dueDate = repeatDate;
 
       // unlock timer so that:
       // (a) any job executor thread can acquire it next time
-      // (b) other parts of the engine know it is not executing, and can be deleted
+      // (b) the engine knows it is not executing and can be deleted
       // see https://jira.jboss.org/jira/browse/JBPM-2036
       lockOwner = null;
 
@@ -122,27 +122,22 @@
   }
 
   public String toString() {
-    StringBuffer text = new StringBuffer("Timer");
-    if (name != null || dueDate != null) {
-      text.append('(');
+    StringBuffer text = new StringBuffer("Timer(");
 
-      if (name != null) text.append(name).append(",");
-      if (dueDate != null) text.append(formatDueDate(dueDate)).append(",");
-      if (taskInstance != null) text.append(taskInstance).append(",");
+    // name or id
+    if (name != null) {
+      text.append(name);
+    }
+    else {
+      text.append(id);
+    }
 
-      if (token != null)
-        text.append(token);
-      else if (processInstance != null) text.append(processInstance);
+    // due date
+    text.append(',').append(dueDate);
 
-      text.append(')');
-    }
-    return text.toString();
+    return text.append(')').toString();
   }
 
-  private static String formatDueDate(Date date) {
-    return new SimpleDateFormat(dateFormat).format(date);
-  }
-
   public String getRepeat() {
     return repeat;
   }

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/JpdlException.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/JpdlException.java	2010-02-19 17:23:16 UTC (rev 6185)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/jpdl/JpdlException.java	2010-02-21 02:33:30 UTC (rev 6186)
@@ -37,12 +37,14 @@
     this.problems = problems;
   }
 
-  public JpdlException(String msg) {
-    this(Collections.singletonList(new Problem(Problem.LEVEL_ERROR, msg)));
+  public JpdlException(String message) {
+    super(message);
+    problems = Collections.singletonList(new Problem(Problem.LEVEL_ERROR, message));
   }
 
-  public JpdlException(String msg, Throwable e) {
-    this(Collections.singletonList(new Problem(Problem.LEVEL_ERROR, msg, e)));
+  public JpdlException(String message, Throwable cause) {
+    super(message, cause);
+    problems = Collections.singletonList(new Problem(Problem.LEVEL_ERROR, message, cause));
   }
 
   public List getProblems() {

Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java	2010-02-19 17:23:16 UTC (rev 6185)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/persistence/db/DbPersistenceService.java	2010-02-21 02:33:30 UTC (rev 6186)
@@ -71,7 +71,10 @@
   protected ContextSession contextSession;
   protected LoggingSession loggingSession;
 
-  /** @deprecated for access to other services, invoke {@link JbpmContext#getServices()} */
+  /**
+   * @deprecated for access to other services, invoke
+   * {@link JbpmContext#getServices()}
+   */
   protected Services services;
 
   public DbPersistenceService(DbPersistenceServiceFactory persistenceServiceFactory) {
@@ -82,7 +85,7 @@
 
   public SessionFactory getSessionFactory() {
     return session != null ? session.getSessionFactory()
-        : persistenceServiceFactory.getSessionFactory();
+      : persistenceServiceFactory.getSessionFactory();
   }
 
   public Session getSession() {
@@ -175,9 +178,8 @@
         }
         if (session != null) {
           connection = session.connection();
-          log.debug("fetched " +
-              connection +
-              " from hibernate session, client is responsible for closing it!");
+          log.debug("fetched " + connection
+            + " from hibernate session, client is responsible for closing it!");
           mustConnectionBeClosed = false;
         }
       }
@@ -202,9 +204,9 @@
 
     Exception flushException = flushSession();
     if (flushException != null) {
-      // JBPM-1465: at this point, the transaction is already committed or rolled back
-      // alternatively, the transaction is being managed externally
-      // hence rolling back here is redundant and possibly dangerous
+      // JBPM-1465: here the transaction is already committed or rolled back
+      // alternatively, the transaction is managed externally
+      // hence rolling back is redundant and possibly dangerous
       closeSession();
       closeConnection();
       throw new JbpmPersistenceException("hibernate flush session failed", flushException);
@@ -213,13 +215,14 @@
     Exception closeSessionException = closeSession();
     if (closeSessionException != null) {
       closeConnection();
-      throw new JbpmPersistenceException("hibernate close session failed", closeSessionException);
+      throw new JbpmPersistenceException("hibernate close session failed",
+        closeSessionException);
     }
 
     Exception closeConnectionException = closeConnection();
     if (closeConnectionException != null) {
       throw new JbpmPersistenceException("hibernate close connection failed",
-          closeConnectionException);
+        closeConnectionException);
     }
   }
 
@@ -384,7 +387,8 @@
   }
 
   /**
-   * @throws UnsupportedOperationException if <code>rollbackOnly</code> is <code>false</code>
+   * @throws UnsupportedOperationException if <code>rollbackOnly</code> is
+   * <code>false</code>
    * @deprecated use {@link TxService#setRollbackOnly()} instead
    */
   public void setRollbackOnly(boolean rollbackOnly) {
@@ -406,18 +410,21 @@
   }
 
   /**
-   * Injects an external Hibernate session without affecting transaction management.
+   * Injects an external Hibernate session without affecting transaction
+   * management.
    * 
-   * @deprecated use {@link #setSession(Session, boolean) setSession(session, true)} instead
+   * @deprecated use {@link #setSession(Session, boolean) setSession(session,
+   * true)} instead
    */
   public void setSessionWithoutDisablingTx(Session session) {
     setSession(session, true);
   }
 
   /**
-   * Injects an external Hibernate session. Injecting a session would normally disable transaction
-   * management. The <code>keepTransactionEnabled</code> parameter can be used to prevent
-   * transaction management from being disabled, according to the following table.
+   * Injects an external Hibernate session. Injecting a session normally
+   * disables transaction management. The <code>keepTransactionEnabled</code>
+   * parameter can be used to prevent transaction management from being
+   * disabled, according to the following table.
    * <table border="1">
    * <tr>
    * <th>is currently enabled?</th>
@@ -436,7 +443,7 @@
    * </tr>
    * <tr>
    * <td>false</td>
-   * <td>n/a</td>
+   * <td>any</td>
    * <td>false (no change)</td>
    * </tr>
    * </table>
@@ -444,7 +451,7 @@
   public void setSession(Session session, boolean keepTransactionEnabled) {
     this.session = session;
     if (isTransactionEnabled && !keepTransactionEnabled) {
-      log.debug("disabling transaction due to session injection");
+      log.debug("disabling transaction management due to session injection");
       isTransactionEnabled = false;
     }
   }
@@ -506,7 +513,8 @@
 
   public static boolean isLockingException(Exception exception) {
     for (Throwable t = exception; t != null; t = t.getCause()) {
-      if (t instanceof StaleStateException || t instanceof LockAcquisitionException) return true;
+      if (t instanceof StaleStateException || t instanceof LockAcquisitionException)
+        return true;
     }
     return false;
   }

Added: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2263/JBPM2263Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2263/JBPM2263Test.java	                        (rev 0)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2263/JBPM2263Test.java	2010-02-21 02:33:30 UTC (rev 6186)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jbpm2263;
+
+import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class JBPM2263Test extends AbstractDbTestCase {
+
+  private long processDefinitionId;
+
+  protected void setUp() throws Exception {
+    super.setUp();
+
+    ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("org/jbpm/jbpm2263/processdefinition.xml");
+    jbpmContext.deployProcessDefinition(processDefinition);
+    newTransaction();
+
+    processDefinitionId = processDefinition.getId();
+  }
+
+  protected void tearDown() throws Exception {
+    graphSession.deleteProcessDefinition(processDefinitionId);
+    super.tearDown();
+  }
+
+  public void testMultipleTimers() {
+    ProcessInstance processInstance = jbpmContext.newProcessInstanceForUpdate("multiple timers");
+    processInstance.signal();
+
+    processJobs(60 * 1000);
+
+    processInstance = jbpmContext.loadProcessInstance(processInstance.getId());
+    assertTrue("expected " + processInstance + " to have ended", processInstance.hasEnded());
+
+    Integer calls = (Integer) processInstance.getContextInstance().getVariable("calls");
+    assertEquals(2, calls.intValue());
+  }
+}


Property changes on: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2263/JBPM2263Test.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2263/gpd.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2263/gpd.xml	                        (rev 0)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2263/gpd.xml	2010-02-21 02:33:30 UTC (rev 6186)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<root-container name="multiple timers" width="854" height="521">
+  <node name="start" x="72" y="45" width="132" height="36">
+    <edge>
+      <label x="5" y="-10"/>
+    </edge>
+  </node>
+  <node name="race" x="73" y="114" width="132" height="36">
+    <edge>
+      <label x="5" y="-10"/>
+    </edge>
+  </node>
+  <node name="end" x="0" y="0" width="132" height="36"/>
+</root-container>


Property changes on: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2263/gpd.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native

Added: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2263/processdefinition.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2263/processdefinition.xml	                        (rev 0)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2263/processdefinition.xml	2010-02-21 02:33:30 UTC (rev 6186)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process-definition name="multiple timers" xmlns="urn:jbpm.org:jpdl-3.2">
+
+  <start-state name="start">
+    <transition to="race" />
+  </start-state>
+
+  <state name="race">
+    <event type="timer">
+      <script><![CDATA[
+      calls = executionContext.getVariable("calls");
+      executionContext.setVariable("calls", calls != null ? calls + 1 : 1);
+      ]]></script>
+    </event>
+    <timer duedate="1 second" name="first call" />
+    <timer duedate="2 seconds" name="second call" transition="done" />
+    <transition to="end" name="done" />
+  </state>
+
+  <end-state name="end" />
+
+</process-definition>
\ No newline at end of file


Property changes on: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/resources/org/jbpm/jbpm2263/processdefinition.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + native



More information about the jbpm-commits mailing list