[jbpm-commits] JBoss JBPM SVN: r4833 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/api/history and 12 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon May 18 12:53:46 EDT 2009


Author: tom.baeyens at jboss.com
Date: 2009-05-18 12:53:45 -0400 (Mon, 18 May 2009)
New Revision: 4833

Added:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivity.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivityMessage.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivity.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTake.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTakeMessage.java
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/async/
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/async/AsyncBasicsTest.java
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryTaskAssigneeTest.java
Removed:
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestination.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestinationMessage.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransitionMessage.java
Modified:
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/activity/ActivityExecution.java
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryActivityInstanceQuery.java
   jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/Activity.java
   jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlBinding.java
   jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ActivityBuilder.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExceptionHandlerImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/SignalMessage.java
   jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AsyncCommandMessage.java
   jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/eventlistener/EventListenerTest.java
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/EndProcessInstanceTest.java
   jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java
Log:
JBPM-2256 introducing async continuations

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/activity/ActivityExecution.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/activity/ActivityExecution.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/activity/ActivityExecution.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -23,15 +23,10 @@
 
 import org.jbpm.api.Execution;
 import org.jbpm.api.JbpmException;
-import org.jbpm.api.client.ClientProcessDefinition;
-import org.jbpm.api.client.ClientProcessInstance;
-import org.jbpm.api.env.Environment;
 import org.jbpm.api.model.Activity;
 import org.jbpm.api.model.ObservableElement;
 import org.jbpm.api.model.OpenExecution;
 import org.jbpm.api.model.Transition;
-import org.jbpm.api.session.PvmDbSession;
-import org.jbpm.api.task.Task;
 
 
 /** view upon an {@link Execution path of execution} exposed to 

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryActivityInstanceQuery.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryActivityInstanceQuery.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/history/HistoryActivityInstanceQuery.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -24,9 +24,7 @@
 import java.util.Date;
 import java.util.List;
 
-import org.jbpm.api.task.Task;
 
-
 /**
  * @author Tom Baeyens
  */

Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/Activity.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/Activity.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/Activity.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -111,17 +111,8 @@
 
   /** indicates if this activity should be executed 
    * <a href="package-summary.html#asynchronouscontinuations">asynchronously</a>. */
-  boolean isExecutionAsync();
+  boolean isAsync();
 
-  /** indicates if signals should be processed  
-   * <a href="package-summary.html#asynchronouscontinuations">asynchronously</a>. */
-  boolean isSignalAsync();
-
-  /** indicates if execution should proceed  
-   * <a href="package-summary.html#asynchronouscontinuations">asynchronously</a> 
-   * when this activity is left over any of the outgoing transitions. */
-  boolean isLeaveAsync();
-
   /** indicates if this activity behaviour needs to know 
    * {@link Execution#getPreviousActivity() the previous activity} or 
    * {@link Execution#getPreviousTransition() previous transition}. 

Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlBinding.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JpdlBinding.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -82,6 +82,7 @@
       }
 
       TransitionImpl transition = activity.createOutgoingTransition(transitionName);
+
       unresolvedTransitions.add(transition, transitionElement);
       
       jpdlParser.parseOnEvent(transitionElement, transition, Event.TAKE, parse);

Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -41,6 +41,7 @@
 import org.jbpm.pvm.internal.model.ActivityImpl;
 import org.jbpm.pvm.internal.model.CompositeElementImpl;
 import org.jbpm.pvm.internal.model.EventImpl;
+import org.jbpm.pvm.internal.model.EventListenerReference;
 import org.jbpm.pvm.internal.model.ObservableElementImpl;
 import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
 import org.jbpm.pvm.internal.model.ScopeElementImpl;
@@ -237,7 +238,7 @@
             activityBinding.parseTransitions(nestedElement, activity, parse, this);
 
             if (XmlUtil.attributeBoolean(nestedElement, "async", false, parse, Boolean.FALSE)) {
-              activity.setExecutionAsync(true);
+              activity.setAsync(true);
             }
 
             ActivityBehaviour activityBehaviour = (ActivityBehaviour) activityBinding.parse(nestedElement, parse, this);
@@ -313,7 +314,7 @@
     for (Element onElement: onElements) {
       String eventName = XmlUtil.attribute(onElement, "event", true, parse);
       parseOnEvent(onElement, scopeElement, eventName, parse);
-      
+
       Element timerElement = XmlUtil.element(onElement, "timer");
       if (timerElement!=null) {
         TimerDefinitionImpl timerDefinitionImpl = parseTimerDefinition(timerElement, parse, scopeElement);
@@ -329,11 +330,20 @@
         event = scopeElement.createEvent(eventName);
       }
       
+      if (XmlUtil.attributeBoolean(element, "async", false, parse, Boolean.FALSE)) {
+        event.setAsync(true);
+      }
+
       for (Element eventListenerElement: XmlUtil.elements(element)) {
         JpdlBinding eventBinding = (JpdlBinding) getBinding(eventListenerElement, "eventlistener");
         if (eventBinding!=null) {
           EventListener eventListener = (EventListener) eventBinding.parse(eventListenerElement, parse, this);
-          event.createEventListenerReference(eventListener);
+          EventListenerReference eventListenerReference = event.createEventListenerReference(eventListener);
+          
+          if (XmlUtil.attributeBoolean(eventListenerElement, "async", false, parse, Boolean.FALSE)) {
+            eventListenerReference.setAsync(true);
+          }
+
         } else {
           String tagName = XmlUtil.getTagLocalName(eventListenerElement);
           if ( ! ( (scopeElement instanceof TransitionImpl)

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ActivityBuilder.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ActivityBuilder.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/builder/ActivityBuilder.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -97,7 +97,7 @@
   }
 
   public ActivityBuilder asyncExecute() {
-    activity.setExecutionAsync(true);
+    activity.setAsync(true);
     return this;
   }
 

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -46,9 +46,7 @@
   protected ActivityImpl parentActivity;
 
   protected String type;
-  protected boolean isExecutionAsync;
-  protected boolean isSignalAsync;
-  protected boolean isLeaveAsync;
+  protected boolean isAsync;
   protected boolean isPreviousNeeded;
 
   protected ActivityCoordinatesImpl coordinates;
@@ -455,24 +453,12 @@
   public void setParentActivity(ActivityImpl parentActivity) {
     this.parentActivity = parentActivity;
   }
-  public boolean isExecutionAsync() {
-    return isExecutionAsync;
+  public boolean isAsync() {
+    return isAsync;
   }
-  public boolean isSignalAsync() {
-    return isSignalAsync;
+  public void setAsync(boolean isExecutionAsync) {
+    this.isAsync = isExecutionAsync;
   }
-  public void setSignalAsync(boolean isSignalAsync) {
-    this.isSignalAsync = isSignalAsync;
-  }
-  public void setExecutionAsync(boolean isExecutionAsync) {
-    this.isExecutionAsync = isExecutionAsync;
-  }
-  public boolean isLeaveAsync() {
-    return isLeaveAsync;
-  }
-  public void setLeaveAsync(boolean isLeaveAsync) {
-    this.isLeaveAsync = isLeaveAsync;
-  }
   public boolean isPreviousNeeded() {
     return isPreviousNeeded;
   }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventImpl.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventImpl.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -38,6 +38,7 @@
 
   protected String name;
   protected List<EventListenerReference> listenerReferences;
+  protected boolean isAsync;
 
   public String toString() {
     return (name != null ? "event(" + name + ")" : "event");
@@ -89,4 +90,10 @@
   public void setListenerReferences(List<EventListenerReference> eventListenerReferences) {
     this.listenerReferences = eventListenerReferences;
   }
+  public boolean isAsync() {
+    return isAsync;
+  }
+  public void setAsync(boolean isAsync) {
+    this.isAsync = isAsync;
+  }
 }
\ No newline at end of file

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/EventListenerReference.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -32,6 +32,7 @@
 
   /** does this action accept propagated events ?  */
   boolean isPropagationEnabled = false;
+  boolean isAsync = false;
 
   /** does this action accept propagated events ?  Default is false. */
   public boolean isPropagationEnabled() {
@@ -42,4 +43,12 @@
   public void setPropagationEnabled(boolean isPropagationEnabled) {
     this.isPropagationEnabled = isPropagationEnabled;
   }
+
+  public boolean isAsync() {
+    return isAsync;
+  }
+
+  public void setAsync(boolean isAsync) {
+    this.isAsync = isAsync;
+  }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExceptionHandlerImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExceptionHandlerImpl.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExceptionHandlerImpl.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -196,7 +196,7 @@
         if (transition!=null) {
           log.trace(toString()+" takes transition "+transitionName);
           execution.setTransition(transition);
-          execution.performAtomicOperationSync(ExecutionImpl.TAKE_TRANSITION);
+          execution.performAtomicOperationSync(ExecutionImpl.TRANSITION_END_ACTIVITY);
         } else {
           log.info("WARNING: "+toString()+" couldn't find transition "+transitionName+" on "+activity);
         }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -43,7 +43,6 @@
 import org.jbpm.api.cmd.CommandService;
 import org.jbpm.api.env.Environment;
 import org.jbpm.api.env.Transaction;
-import org.jbpm.api.listener.EventListener;
 import org.jbpm.api.listener.EventListenerExecution;
 import org.jbpm.api.model.Activity;
 import org.jbpm.api.model.Comment;
@@ -66,11 +65,13 @@
 import org.jbpm.pvm.internal.job.MessageImpl;
 import org.jbpm.pvm.internal.model.op.AtomicOperation;
 import org.jbpm.pvm.internal.model.op.ExecuteActivity;
+import org.jbpm.pvm.internal.model.op.ExecuteEventListener;
 import org.jbpm.pvm.internal.model.op.MoveToChildActivity;
 import org.jbpm.pvm.internal.model.op.MoveToParentActivity;
-import org.jbpm.pvm.internal.model.op.ProceedToDestination;
 import org.jbpm.pvm.internal.model.op.Signal;
-import org.jbpm.pvm.internal.model.op.TakeTransition;
+import org.jbpm.pvm.internal.model.op.TransitionEndActivity;
+import org.jbpm.pvm.internal.model.op.TransitionStartActivity;
+import org.jbpm.pvm.internal.model.op.TransitionTake;
 import org.jbpm.pvm.internal.util.EqualsUtil;
 import org.jbpm.pvm.internal.util.Priority;
 
@@ -89,10 +90,11 @@
   
   // atomic operations 
   public static final AtomicOperation EXECUTE_ACTIVITY = new ExecuteActivity();
-  public static final AtomicOperation PROCEED_TO_DESTINATION = new ProceedToDestination();
-  public static final AtomicOperation TAKE_TRANSITION = new TakeTransition();
+  public static final AtomicOperation TRANSITION_END_ACTIVITY = new TransitionEndActivity();
+  public static final AtomicOperation TRANSITION_TAKE = new TransitionTake();
+  public static final AtomicOperation TRANSITION_START_ACTIVITY = new TransitionStartActivity();
   public static final AtomicOperation PROPAGATE_TO_PARENT = new MoveToParentActivity();
-  
+
   // persistent member fields /////////////////////////////////////////////////
   
   /** an optional name for this execution.  can be used to 
@@ -386,7 +388,7 @@
     if (getActivity()!=null) {
       performAtomicOperation(new Signal(signal, parameters, getActivity()));
     } else if (transition!=null) {
-      performAtomicOperation(ExecutionImpl.PROCEED_TO_DESTINATION);
+      performAtomicOperation(ExecutionImpl.TRANSITION_START_ACTIVITY);
     } else {
       throw new JbpmException("execution is not in a activity or in a transition");
     }
@@ -442,7 +444,7 @@
     setTransitionOrigin(getActivity());
     setPreviousTransition(null);
 
-    performAtomicOperation(TAKE_TRANSITION);
+    performAtomicOperation(TRANSITION_END_ACTIVITY);
   }
   
   public void take(Transition transition, Execution execution) {
@@ -512,12 +514,12 @@
     }
   }
 
-  public void setActivity(Activity destination, Execution execution) {
-    ((ExecutionImpl)execution).setActivity(destination);
+  public void setActivity(Activity activity, Execution execution) {
+    ((ExecutionImpl)execution).setActivity(activity);
   }
 
-  public void setActivity(Activity destination) {
-    setActivity((ActivityImpl) destination);
+  public void setActivity(Activity activity) {
+    setActivity((ActivityImpl) activity);
   }
 
   // execution : internal methods /////////////////////////////////////////////
@@ -633,35 +635,16 @@
 
   /** fires the given event without propagation */
   void fire(EventImpl event, ObservableElement eventSource, ObservableElement observableElement) {
-    try {
-      this.event = event;
-      this.eventSource = (ObservableElementImpl) eventSource;
-      
-      List<EventListenerReference> eventListenerReferences = event.getListenerReferences();
-      
-      if (eventListenerReferences!=null) {
-        for (EventListenerReference eventListenerReference: eventListenerReferences) {
-          
-          if ( (observableElement.equals(eventSource)) // this event is not propagated
-               || (eventListenerReference.isPropagationEnabled()) // propagation is allowed
-             ) {
-            EventListener eventListener = eventListenerReference.get();
-            
-            log.trace("executing "+eventListener+" for "+event);
-            try {
-              // TODO can/should this invocation be unified with the exception handler invocation of the event notification method?
-              eventListener.notify(this);
-            } catch (Exception e) {
-              log.trace("exception during action: "+e);
-              handleException((ObservableElementImpl) observableElement, event, eventListenerReference, e, "couldn't run action "+eventListener);
-            }
-          }
+    List<EventListenerReference> eventListenerReferences = event.getListenerReferences();
+    if (eventListenerReferences!=null) {
+      for (EventListenerReference eventListenerReference: eventListenerReferences) {
+        ExecuteEventListener executeEventListenerOperation = new ExecuteEventListener(eventListenerReference, event, (ObservableElementImpl) eventSource, observableElement);
+        if (eventListenerReference.isAsync()) {
+          sendContinuationMessage(executeEventListenerOperation);
+        } else {
+          executeEventListenerOperation.perform(this);
         }
       }
-
-    } finally {
-      this.eventSource = null;
-      this.event = null;
     }
   }
   
@@ -1203,4 +1186,16 @@
   public String getProcessDefinitionId() {
     return processDefinitionId;
   }
+
+  public boolean hasAsyncEndEvent(List<ActivityImpl> leftActivities) {
+    for (ActivityImpl leftActivity : leftActivities) {
+      EventImpl endEvent = leftActivity.getEvent(Event.END);
+      if ( (endEvent!=null)
+           && (endEvent.isAsync())
+         ) {
+        return true;
+      }
+    }
+    return false;
+  }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -41,7 +41,6 @@
   protected ActivityImpl destination;
   protected Descriptor conditionDescriptor;
   protected Descriptor waitConditionDescriptor;
-  protected boolean isTakeAsync;
   
   /* Use one of the ActivityImpl.createOutgoingTransition methods instead. */
   TransitionImpl() {
@@ -166,10 +165,4 @@
   public void setWaitConditionDescriptor(Descriptor waitConditionDescriptor) {
     this.waitConditionDescriptor = waitConditionDescriptor;
   }
-  public boolean isTakeAsync() {
-    return isTakeAsync;
-  }
-  public void setTakeAsync(boolean isTakeAsync) {
-    this.isTakeAsync = isTakeAsync;
-  }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivity.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -34,17 +34,17 @@
   private static Log log = Log.getLog(ExecuteActivity.class.getName());
   
   public boolean isAsync(ExecutionImpl execution) {
-    return execution.getActivity().isExecutionAsync();
+    return execution.getActivity().isAsync();
   }
 
   public void perform(ExecutionImpl execution) {
     ActivityImpl activity = execution.getActivity();
     
-    if (log.isTraceEnabled()) {
+    if (log.isDebugEnabled()) {
       if (execution.getName()!=null) {
-        log.trace(execution.toString()+" executes "+activity);
+        log.debug(execution.toString()+" executes "+activity);
       } else {
-        log.trace("executing "+activity);
+        log.debug("executing "+activity);
       }
     }
     
@@ -66,7 +66,7 @@
   }
 
   public String toString() {
-    return "execute(activity)";
+    return "ExecuteActivity";
   }
 
   public MessageImpl<?> createAsyncMessage(ExecutionImpl execution) {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -53,7 +53,7 @@
   }
 
   public String toString() {
-    return "execute-activity-message["+dbid+"]";
+    return "ExecuteActivityMessage["+dbid+"]";
   }
 
 }

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -0,0 +1,91 @@
+/*
+ * 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.pvm.internal.model.op;
+
+import org.jbpm.api.listener.EventListener;
+import org.jbpm.api.model.ObservableElement;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.EventImpl;
+import org.jbpm.pvm.internal.model.EventListenerReference;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ObservableElementImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExecuteEventListener implements AtomicOperation {
+  
+  private static Log log = Log.getLog(ExecuteEventListener.class.getName());
+  
+  protected EventListenerReference eventListenerReference;
+  protected EventImpl event;
+  protected ObservableElementImpl eventSource;
+  protected ObservableElement observableElement;
+
+  public ExecuteEventListener(EventListenerReference eventListenerReference, EventImpl event, ObservableElementImpl eventSource, ObservableElement observableElement) {
+    this.eventListenerReference = eventListenerReference;
+    this.event = event;
+    this.eventSource = eventSource;
+    this.observableElement = observableElement;
+  }
+
+  public boolean isAsync(ExecutionImpl execution) {
+    return eventListenerReference.isAsync();
+  }
+
+  public void perform(ExecutionImpl execution) {
+    try {
+      execution.setEvent(event);
+      execution.setEventSource(eventSource);
+
+      if ( (observableElement.equals(eventSource)) // this event is not propagated
+              || (eventListenerReference.isPropagationEnabled()) // propagation is allowed
+            ) {
+        EventListener eventListener = eventListenerReference.get();
+        
+        log.trace("executing "+eventListener+" for "+event);
+        try {
+          // TODO can/should this invocation be unified with the exception handler invocation of the event notification method?
+          eventListener.notify(execution);
+        } catch (Exception e) {
+          log.trace("exception during action: "+e);
+          execution.handleException((ObservableElementImpl) observableElement, event, eventListenerReference, e, "couldn't run action "+eventListener);
+        }
+      }
+      
+    } finally {
+      execution.setEvent(null);
+      execution.setEventSource(null);
+    }
+  }
+
+  public MessageImpl< ? > createAsyncMessage(ExecutionImpl execution) {
+    return null;
+  }
+
+  public String toString() {
+    return "ExecuteEventListener";
+  }
+}


Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestination.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestination.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestination.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -1,90 +0,0 @@
-/*
- * 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.pvm.internal.model.op;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jbpm.pvm.internal.job.MessageImpl;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.ActivityImpl;
-import org.jbpm.pvm.internal.model.ObservableElementImpl;
-
-/**
- * @author Tom Baeyens
- */
-public class ProceedToDestination implements AtomicOperation {
-  
-  public boolean isAsync(ExecutionImpl execution) {
-    return false;
-  }
-
-  public void perform(ExecutionImpl execution) {
-    ActivityImpl destination = execution.getTransition().getDestination();
-    execution.setActivity(destination);
-    List<ActivityImpl> enteredActivities = getActivitiesEntered(execution.getTransitionOrigin(), destination);
-    
-    ExecutionImpl propagatingExecution = execution;
-    for (ActivityImpl enteredActivity : enteredActivities) {
-      propagatingExecution = propagatingExecution.startActivity(enteredActivity);
-    }
-    
-    // Restore original transition source activity 
-    // (so that the call to moveTo updates the previous activity) 
-    propagatingExecution.setActivity(execution.getTransitionOrigin());
-    propagatingExecution.moveTo(destination);
-    
-    propagatingExecution.performAtomicOperation(ExecutionImpl.EXECUTE_ACTIVITY);
-  }
-  
-  public List<ActivityImpl> getActivitiesEntered(ActivityImpl origin, ActivityImpl destination) {
-    LinkedList<ActivityImpl> activitiesEntered = new LinkedList<ActivityImpl>();
-    
-    if (origin.equals(destination)) {
-      activitiesEntered.add(destination);
-      
-    } else {
-      List<ObservableElementImpl> sourceChain = origin.getParentChain();
-      
-      if (!sourceChain.contains(destination)) {
-        ActivityImpl destinationActivity = destination;
-        while ( (destinationActivity!=null)
-                && (!sourceChain.contains(destinationActivity))
-              ) {
-          activitiesEntered.addFirst(destinationActivity);
-          destinationActivity = destinationActivity.getParentActivity(); 
-        }
-      }
-    }
-
-    return activitiesEntered;
-  }
-
-  
-  public String toString() {
-    return "proceed-to-destination";
-  }
-
-  public MessageImpl<?> createAsyncMessage(ExecutionImpl execution) {
-    return new ProceedToDestinationMessage(execution);
-  }
-}

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestinationMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestinationMessage.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestinationMessage.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -1,58 +0,0 @@
-/*
- * 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.pvm.internal.model.op;
-
-import org.jbpm.api.Execution;
-import org.jbpm.api.env.Environment;
-import org.jbpm.pvm.internal.job.MessageImpl;
-import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-
-/**
- * @author Tom Baeyens
- */
-public class ProceedToDestinationMessage extends MessageImpl<Object> {
-
-  private static final long serialVersionUID = 1L;
-
-  public ProceedToDestinationMessage() {
-    super();
-  }
-
-  public ProceedToDestinationMessage(ExecutionImpl execution) {
-    super(execution);
-  }
-
-  public Object execute(Environment environment) throws Exception {
-    execution.setState(Execution.STATE_ACTIVE_ROOT);
-    execution.performAtomicOperationSync(ExecutionImpl.PROCEED_TO_DESTINATION);
-    
-    JobDbSession jobDbSession = environment.get(JobDbSession.class);
-    jobDbSession.delete(this);
-
-    return null;
-  }
-  
-  public String toString() {
-    return "proceed-to-destination-message["+dbid+"]";
-  }
-}

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -49,7 +49,7 @@
   }
 
   public boolean isAsync(ExecutionImpl execution) {
-    return execution.getActivity().isSignalAsync();
+    return false;
   }
 
   public void perform(ExecutionImpl execution) {
@@ -78,7 +78,7 @@
   }
   
   public String toString() {
-    return "signal(activity)";
+    return "Signal";
   }
 
   public MessageImpl<?> createAsyncMessage(ExecutionImpl execution) {

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/SignalMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/SignalMessage.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/SignalMessage.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -60,6 +60,6 @@
   }
 
   public String toString() {
-    return "signal-transition-message["+dbid+"]";
+    return "SignalMessage["+dbid+"]";
   }
 }

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -1,101 +0,0 @@
-/*
- * 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.pvm.internal.model.op;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jbpm.api.model.Condition;
-import org.jbpm.api.model.Event;
-import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.job.MessageImpl;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.ActivityImpl;
-import org.jbpm.pvm.internal.model.ObservableElementImpl;
-import org.jbpm.pvm.internal.model.TransitionImpl;
-
-public class TakeTransition implements AtomicOperation {
-
-  private static Log log = Log.getLog(TakeTransition.class.getName());
-
-  public boolean isAsync(ExecutionImpl execution) {
-    return execution.getActivity().isLeaveAsync() || execution.getTransition().isTakeAsync();
-  }
-
-  public void perform(ExecutionImpl execution) {
-    TransitionImpl transition = execution.getTransition();
-
-    if (execution.getName() != null) {
-      log.debug(execution.toString() + " takes " + transition);
-    } else {
-      log.debug("taking " + transition);
-    }
-
-    List<ActivityImpl> leftActivities = getActivitiesLeft(execution.getActivity(), transition.getDestination());
-    ExecutionImpl propagatingExecution = execution;
-    for (ActivityImpl leftActivity : leftActivities) {
-      propagatingExecution = propagatingExecution.endActivity(leftActivity);
-    }
-
-    propagatingExecution.setActivity(null);
-    propagatingExecution.fire(Event.TAKE, transition);
-
-    boolean wait = false;
-
-    Condition waitCondition = transition.getWaitCondition();
-    if (waitCondition != null) {
-      wait = waitCondition.evaluate(propagatingExecution);
-    }
-
-    if (!wait) {
-      propagatingExecution.performAtomicOperation(ExecutionImpl.PROCEED_TO_DESTINATION);
-    }
-  }
-
-  List<ActivityImpl> getActivitiesLeft(ActivityImpl source, ActivityImpl destination) {
-    List<ActivityImpl> activitiesLeft = new ArrayList<ActivityImpl>();
-
-    if (source.equals(destination)) {
-      activitiesLeft.add(source);
-    } else {
-      List<ObservableElementImpl> destinationChain = destination.getParentChain();
-
-      if (!destinationChain.contains(source)) {
-        ActivityImpl sourceActivity = source;
-        while ((sourceActivity != null) && (!destinationChain.contains(sourceActivity))) {
-          activitiesLeft.add(sourceActivity);
-          sourceActivity = sourceActivity.getParentActivity();
-        }
-      }
-    }
-
-    return activitiesLeft;
-  }
-
-  public String toString() {
-    return "take-transition";
-  }
-
-  public MessageImpl< ? > createAsyncMessage(ExecutionImpl execution) {
-    return new TakeTransitionMessage(execution);
-  }
-}
\ No newline at end of file

Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransitionMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransitionMessage.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransitionMessage.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -1,58 +0,0 @@
-/*
- * 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.pvm.internal.model.op;
-
-import org.jbpm.api.Execution;
-import org.jbpm.api.env.Environment;
-import org.jbpm.pvm.internal.job.MessageImpl;
-import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-
-/**
- * @author Tom Baeyens
- */
-public class TakeTransitionMessage extends MessageImpl<Object> {
-
-  private static final long serialVersionUID = 1L;
-
-  public TakeTransitionMessage() {
-  }
-
-  public TakeTransitionMessage(ExecutionImpl execution) {
-    super(execution);
-  }
-
-  public Object execute(Environment environment) throws Exception {
-    execution.setState(Execution.STATE_ACTIVE_ROOT);
-
-    execution.performAtomicOperationSync(ExecutionImpl.TAKE_TRANSITION);
-    
-    JobDbSession jobDbSession = environment.get(JobDbSession.class);
-    jobDbSession.delete(this);
-
-    return null;
-  }
-
-  public String toString() {
-    return "take-transition-message["+dbid+"]";
-  }
-}

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivity.java (from rev 4830, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivity.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivity.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -0,0 +1,97 @@
+/*
+ * 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.pvm.internal.model.op;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ObservableElementImpl;
+import org.jbpm.pvm.internal.model.TransitionImpl;
+
+public class TransitionEndActivity implements AtomicOperation {
+
+  private static final TransitionTake TRANSITION_TAKE = new TransitionTake();
+  
+  private static Log log = Log.getLog(TransitionEndActivity.class.getName());
+
+  public boolean isAsync(ExecutionImpl execution) {
+    TransitionImpl transition = execution.getTransition();
+    List<ActivityImpl> leftActivities = getActivitiesLeft(execution.getActivity(), transition.getDestination());
+    return execution.hasAsyncEndEvent(leftActivities);
+  }
+
+  public void perform(ExecutionImpl execution) {
+    TransitionImpl transition = execution.getTransition();
+
+    if (execution.getName() != null) {
+      log.debug(execution.toString() + " takes " + transition);
+    } else {
+      log.debug("taking " + transition);
+    }
+
+    List<ActivityImpl> leftActivities = getActivitiesLeft(execution.getActivity(), transition.getDestination());
+    ExecutionImpl propagatingExecution = endActivity(execution, leftActivities);
+    
+    propagatingExecution.performAtomicOperation(TRANSITION_TAKE);
+  }
+
+  public static ExecutionImpl endActivity(ExecutionImpl execution, List<ActivityImpl> leftActivities) {
+    ExecutionImpl propagatingExecution = execution;
+    for (ActivityImpl leftActivity : leftActivities) {
+      propagatingExecution = propagatingExecution.endActivity(leftActivity);
+    }
+    propagatingExecution.setActivity(null);
+    return propagatingExecution;
+  }
+
+  List<ActivityImpl> getActivitiesLeft(ActivityImpl source, ActivityImpl destination) {
+    List<ActivityImpl> activitiesLeft = new ArrayList<ActivityImpl>();
+
+    if (source.equals(destination)) {
+      activitiesLeft.add(source);
+    } else {
+      List<ObservableElementImpl> destinationChain = destination.getParentChain();
+
+      if (!destinationChain.contains(source)) {
+        ActivityImpl sourceActivity = source;
+        while ((sourceActivity != null) && (!destinationChain.contains(sourceActivity))) {
+          activitiesLeft.add(sourceActivity);
+          sourceActivity = sourceActivity.getParentActivity();
+        }
+      }
+    }
+
+    return activitiesLeft;
+  }
+
+  public String toString() {
+    return "TakeTransition";
+  }
+
+  public MessageImpl< ? > createAsyncMessage(ExecutionImpl execution) {
+    return new TransitionEndActivityMessage(execution);
+  }
+}
\ No newline at end of file


Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivity.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivityMessage.java (from rev 4830, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransitionMessage.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivityMessage.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivityMessage.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -0,0 +1,58 @@
+/*
+ * 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.pvm.internal.model.op;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.env.Environment;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TransitionEndActivityMessage extends MessageImpl<Object> {
+
+  private static final long serialVersionUID = 1L;
+
+  public TransitionEndActivityMessage() {
+  }
+
+  public TransitionEndActivityMessage(ExecutionImpl execution) {
+    super(execution);
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    execution.setState(Execution.STATE_ACTIVE_ROOT);
+
+    execution.performAtomicOperationSync(ExecutionImpl.TRANSITION_END_ACTIVITY);
+    
+    JobDbSession jobDbSession = environment.get(JobDbSession.class);
+    jobDbSession.delete(this);
+
+    return null;
+  }
+
+  public String toString() {
+    return "TakeTransitionMessage["+dbid+"]";
+  }
+}


Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivityMessage.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivity.java (from rev 4830, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestination.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivity.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivity.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -0,0 +1,90 @@
+/*
+ * 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.pvm.internal.model.op;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ObservableElementImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TransitionStartActivity implements AtomicOperation {
+  
+  public boolean isAsync(ExecutionImpl execution) {
+    return false;
+  }
+
+  public void perform(ExecutionImpl execution) {
+    ActivityImpl destination = execution.getTransition().getDestination();
+    execution.setActivity(destination);
+    List<ActivityImpl> enteredActivities = getActivitiesEntered(execution.getTransitionOrigin(), destination);
+    
+    ExecutionImpl propagatingExecution = execution;
+    for (ActivityImpl enteredActivity : enteredActivities) {
+      propagatingExecution = propagatingExecution.startActivity(enteredActivity);
+    }
+    
+    // Restore original transition source activity 
+    // (so that the call to moveTo updates the previous activity) 
+    propagatingExecution.setActivity(execution.getTransitionOrigin());
+    propagatingExecution.moveTo(destination);
+    
+    propagatingExecution.performAtomicOperation(ExecutionImpl.EXECUTE_ACTIVITY);
+  }
+  
+  public List<ActivityImpl> getActivitiesEntered(ActivityImpl origin, ActivityImpl destination) {
+    LinkedList<ActivityImpl> activitiesEntered = new LinkedList<ActivityImpl>();
+    
+    if (origin.equals(destination)) {
+      activitiesEntered.add(destination);
+      
+    } else {
+      List<ObservableElementImpl> sourceChain = origin.getParentChain();
+      
+      if (!sourceChain.contains(destination)) {
+        ActivityImpl destinationActivity = destination;
+        while ( (destinationActivity!=null)
+                && (!sourceChain.contains(destinationActivity))
+              ) {
+          activitiesEntered.addFirst(destinationActivity);
+          destinationActivity = destinationActivity.getParentActivity(); 
+        }
+      }
+    }
+
+    return activitiesEntered;
+  }
+
+  
+  public String toString() {
+    return "ProceedToDestination";
+  }
+
+  public MessageImpl<?> createAsyncMessage(ExecutionImpl execution) {
+    return new TransitionStartActivityMessage(execution);
+  }
+}


Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivity.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java (from rev 4830, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ProceedToDestinationMessage.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -0,0 +1,57 @@
+/*
+ * 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.pvm.internal.model.op;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.env.Environment;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TransitionStartActivityMessage extends MessageImpl<Object> {
+
+  private static final long serialVersionUID = 1L;
+
+  public TransitionStartActivityMessage() {
+  }
+
+  public TransitionStartActivityMessage(ExecutionImpl execution) {
+    super(execution);
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    execution.setState(Execution.STATE_ACTIVE_ROOT);
+    execution.performAtomicOperationSync(ExecutionImpl.TRANSITION_START_ACTIVITY);
+    
+    JobDbSession jobDbSession = environment.get(JobDbSession.class);
+    jobDbSession.delete(this);
+
+    return null;
+  }
+  
+  public String toString() {
+    return "ProceedToDestinationMessage["+dbid+"]";
+  }
+}


Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTake.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTake.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTake.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -0,0 +1,51 @@
+/*
+ * 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.pvm.internal.model.op;
+
+import org.jbpm.api.model.Event;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.model.EventImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.TransitionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TransitionTake implements AtomicOperation {
+
+  public boolean isAsync(ExecutionImpl execution) {
+    TransitionImpl transition = execution.getTransition();
+    EventImpl event = transition.getEvent(Event.TAKE);
+    return ((event!=null) && (event.isAsync()));
+  }
+
+  public void perform(ExecutionImpl execution) {
+    TransitionImpl transition = execution.getTransition();
+    execution.fire(Event.TAKE, transition);
+    execution.performAtomicOperation(ExecutionImpl.TRANSITION_START_ACTIVITY);
+  }
+
+  public MessageImpl< ? > createAsyncMessage(ExecutionImpl execution) {
+    return new TransitionTakeMessage(execution);
+  }
+}


Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTake.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTakeMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTakeMessage.java	                        (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTakeMessage.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -0,0 +1,58 @@
+/*
+ * 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.pvm.internal.model.op;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.env.Environment;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TransitionTakeMessage extends MessageImpl<Object> {
+
+  private static final long serialVersionUID = 1L;
+
+  public TransitionTakeMessage() {
+  }
+
+  public TransitionTakeMessage(ExecutionImpl execution) {
+    super(execution);
+  }
+
+  public Object execute(Environment environment) throws Exception {
+    execution.setState(Execution.STATE_ACTIVE_ROOT);
+    execution.performAtomicOperationSync(ExecutionImpl.TRANSITION_TAKE);
+    
+    JobDbSession jobDbSession = environment.get(JobDbSession.class);
+    jobDbSession.delete(this);
+
+    return null;
+  }
+
+  public String toString() {
+    return "TransitionTakeMessage["+dbid+"]";
+  }
+}


Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTakeMessage.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AsyncCommandMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AsyncCommandMessage.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/AsyncCommandMessage.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -65,6 +65,6 @@
   }
   
   public String toString() {
-    return "async-command-message["+dbid+"]";
+    return "AsyncCommandMessage["+dbid+"]";
   }
 }

Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml	2009-05-18 16:53:45 UTC (rev 4833)
@@ -59,14 +59,6 @@
     <property name="priority" column="PRIORITY_" />
     <property name="historyActivityInstanceDbid" column="HISACTINST_" />
 
-    <!-- many-to-one name="transition" column="TRANSITION_" class="TransitionImpl" / -->
-
-    <!-- many-to-one name="transitionOrigin" 
-                 class="org.jbpm.pvm.internal.model.ActivityImpl" 
-                 column="TRANSORIG_"
-                 foreign-key="FK_EXEC_TRANSORIG"
-                 index="IDX_EXEC_TRANSORIG" / -->
-
     <list name="executions" 
           cascade="all-delete-orphan"
           inverse="false"
@@ -254,8 +246,9 @@
                      cascade="none"
                      foreign-key="FK_JOB_NODE"/ -->
       </subclass>
-      <subclass name="org.jbpm.pvm.internal.model.op.TakeTransitionMessage" discriminator-value="TakeTrMsg" />
-      <subclass name="org.jbpm.pvm.internal.model.op.ProceedToDestinationMessage" discriminator-value="ProceedDestMsg" />
+      <subclass name="org.jbpm.pvm.internal.model.op.TransitionEndActivityMessage" discriminator-value="TrEndActMsg" />
+      <subclass name="org.jbpm.pvm.internal.model.op.TransitionTakeMessage" discriminator-value="TrTakeMsg" />
+      <subclass name="org.jbpm.pvm.internal.model.op.TransitionStartActivityMessage" discriminator-value="TrStartActMsg" />
       <subclass name="org.jbpm.pvm.internal.job.CommandMessage" discriminator-value="CmdMsg" />
     </subclass>
     

Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/async/AsyncBasicsTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/async/AsyncBasicsTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/async/AsyncBasicsTest.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -0,0 +1,186 @@
+/*
+ * 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.test.async;
+
+import java.util.List;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AsyncBasicsTest extends JbpmTestCase {
+  
+  static boolean doneSomething;
+  
+  protected void setUp() throws Exception {
+    super.setUp();
+    
+    doneSomething = false;
+  }
+
+
+  public static class Do {
+    public void something() {
+      doneSomething = true;
+    }
+  }
+
+  public void testAsyncWaitStatesSequence() {
+    deployJpdlXmlString(
+      "<process name='TwoAsyncStates'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <java name='a' async='true' class='"+Do.class.getName()+"' method='something'>" +
+      "    <transition to='b' />" +
+      "  </java>" +
+      "  <java name='b' async='true' class='"+Do.class.getName()+"' method='something'>" +
+      "    <transition to='end' />" +
+      "  </java>" +
+      "  <end name='end' />" +
+      "</process>"
+    );
+    
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("TwoAsyncStates");
+    assertEquals("a", processInstance.getActivityName());
+    assertEquals(Execution.STATE_ASYNC, processInstance.getState());
+    
+    assertFalse(doneSomething);
+    
+    List<Job> jobs = managementService
+      .createJobQuery()
+      .processInstanceId(processInstance.getId())
+      .list();
+    
+    assertEquals(1, jobs.size());
+    
+    Job job = jobs.get(0);
+    
+    managementService.executeJob(job.getDbid());
+
+    assertTrue(doneSomething);
+    doneSomething = false;
+
+    processInstance = executionService.findProcessInstanceById(processInstance.getId());
+    assertEquals("b", processInstance.getActivityName());
+    assertEquals(Execution.STATE_ASYNC, processInstance.getState());
+
+    jobs = managementService
+      .createJobQuery()
+      .processInstanceId(processInstance.getId())
+      .list();
+    
+    assertEquals(1, jobs.size());
+    
+    job = jobs.get(0);
+    
+    managementService.executeJob(job.getDbid());
+
+    assertTrue(doneSomething);
+    processInstance = executionService.findProcessInstanceById(processInstance.getId());
+    assertNull(processInstance);
+  }
+
+//  public void testAsyncTransitions() {
+//    deployJpdlXmlString(
+//      "<process name='TwoAsyncStates'>" +
+//      "  <start>" +
+//      "    <transition to='a' />" +
+//      "  </start>" +
+//      "  <java name='a' class='"+Do.class.getName()+"' method='something'>" +
+//      "    <transition async='true' to='b' />" +
+//      "  </java>" +
+//      "  <java name='b' class='"+Do.class.getName()+"' method='something'>" +
+//      "    <transition async='true' to='end' />" +
+//      "  </java>" +
+//      "  <end name='end' />" +
+//      "</process>"
+//    );
+//    
+//    ProcessInstance processInstance = executionService.startProcessInstanceByKey("TwoAsyncStates");
+//    assertEquals("a", processInstance.getActivityName());
+//    assertEquals(Execution.STATE_ASYNC, processInstance.getState());
+//
+//    assertTrue(doneSomething);
+//    doneSomething = false;
+//
+//    List<Job> jobs = managementService
+//      .createJobQuery()
+//      .processInstanceId(processInstance.getId())
+//      .list();
+//    
+//    assertEquals(1, jobs.size());
+//    
+//    Job job = jobs.get(0);
+//    
+//    managementService.executeJob(job.getDbid());
+//
+//    assertTrue(doneSomething);
+//
+//    processInstance = executionService.findProcessInstanceById(processInstance.getId());
+//    assertEquals("b", processInstance.getActivityName());
+//    assertEquals(Execution.STATE_ASYNC, processInstance.getState());
+//
+//    jobs = managementService
+//      .createJobQuery()
+//      .processInstanceId(processInstance.getId())
+//      .list();
+//    
+//    assertEquals(1, jobs.size());
+//    
+//    job = jobs.get(0);
+//    
+//    managementService.executeJob(job.getDbid());
+//
+//    processInstance = executionService.findProcessInstanceById(processInstance.getId());
+//    assertNull(processInstance);
+//  }
+
+
+  public void testExecutionBlockedDuringAsync() {
+    deployJpdlXmlString(
+      "<process name='AsyncState'>" +
+      "  <start>" +
+      "    <transition to='a' />" +
+      "  </start>" +
+      "  <state name='a' async='true'>" +
+      "    <transition to='end' />" +
+      "  </state>" +
+      "  <end name='end' />" +
+      "</process>"
+    );
+    
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncState");
+    
+    try {
+      executionService.signalExecutionById(processInstance.getId());
+      fail("expected exception");
+    } catch (Exception e) {
+      assertTextPresent("process-instance is not active: async", e.getMessage());
+    }
+  }
+}


Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/async/AsyncBasicsTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/eventlistener/EventListenerTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/eventlistener/EventListenerTest.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/eventlistener/EventListenerTest.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -144,7 +144,7 @@
       "  </start>" +
       "  <state name='s'>" +
       "    <on event='end'>" +
-      "      <event-listener class='"+ActivityStartListener.class.getName()+"' />" +
+      "      <event-listener class='"+ActivityEndListener.class.getName()+"' />" +
       "    </on>" +
       "    <transition to='end' />" +
       "  </state>" +

Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/EndProcessInstanceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/EndProcessInstanceTest.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/EndProcessInstanceTest.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -59,6 +59,7 @@
       .processInstanceId(processInstanceId)
       .uniqueResult();
 
+    assertNotNull(historyProcessInstance.getStartTime());
     assertNotNull(historyProcessInstance.getEndTime());
     assertEquals("cancel", historyProcessInstance.getState());
   }

Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryTaskAssigneeTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryTaskAssigneeTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryTaskAssigneeTest.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -0,0 +1,56 @@
+/*
+ * 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.test.history;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.history.HistoryActivityInstance;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryTaskAssigneeTest extends JbpmTestCase {
+
+  public void testHistoryTaskAssignee() {
+    deployJpdlXmlString(
+      "<process name='TaskAssignee'>" +
+      "  <start>" +
+      "    <transition to='review' />" +
+      "  </start>" +
+      "  <task name='review' " +
+      "        assignee='johndoe'>" +
+      "    <transition to='wait' />" +
+      "  </task>" +
+      "  <state name='wait'/>" +
+      "</process>"
+    );
+    
+    executionService.startProcessInstanceByKey("TaskAssignee");
+
+    HistoryActivityInstance historyActivityInstance = historyService
+      .createHistoryActivityInstanceQuery()
+      .uniqueResult();
+    
+  }
+
+}


Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryTaskAssigneeTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java	2009-05-18 12:16:27 UTC (rev 4832)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/ProcessInstanceHistoryTest.java	2009-05-18 16:53:45 UTC (rev 4833)
@@ -61,6 +61,7 @@
       assertEquals(HistoryProcessInstance.STATE_ENDED, historyProcessInstance.getState());
       assertNotNull(historyProcessInstance.getStartTime());
       assertNotNull(historyProcessInstance.getEndTime());
+      assertTrue(historyProcessInstance.getDuration()>=0);
     }
     
     // also check that the ended process instances have been removed from the 




More information about the jbpm-commits mailing list