2 Replies Latest reply on Dec 13, 2007 8:41 AM by asaf sh

    Injecting Business Process context scoped variables

    Manuel Gombocz Newbie

      Hi,

      I've defined a workflow that is started by a method called "receive(...)" (annotated with @CreateProcess). In this method I outject a variable named "workEffortId" into the Business Process context.

      My jPDL is rather short (start-node -> transition -> task-node -> transition -> end-node).

      In the 1st transition I have defined an action expression which calls a method called "assignToTimeSheet". In this method I inject variable "workEffortId" (Business Process context), but it is always null!

      If I call "assignToTimeSheet" in the 2nd transition, "workEffortId" gets the value that was outjected in "receive(...)".

      So, my assumption is that, because jBPM performs a transaction commit at the 1st wait-state (in this example at the task-node) and "assignToTimeSheet" is called before, Seam tries to read data that have not been committed yet, which results to a null value.

      Alternatively using an async node is not yet supported by Seam (see http://jira.jboss.com/jira/browse/JBSEAM-161).

      Does anybody has an idea how to solve this?

      Thx,
      Manuel

      PS. See my example code below (excerpts).

      Workflow "receiveWorkEffort"

      <?xml version="1.0"?>
      <process-definition name="receiveWorkEffort">
      
       <start-state name="start">
       <transition to="enter">
       <action expression="#{workEffortReception.assignToTimeSheet}" />
       </transition>
       </start-state>
      
       <task-node name="enter" end-tasks="true">
       <task name="enterDocumentation">
       <assignment actor-id="#{processInstance.contextInstance.variables['actorId']}"/>
       </task>
       <transition name="done" to="complete" />
       </task-node>
      
       <end-state name="complete"/>
      </process-definition>
      


      Methods "receive" and "assignToTimeSheet":
      @Stateless
      @Name("workEffortRecipient")
      public class WorkEffortRecipientBean implements WorkEffortRecipient,
       Serializable {
      
       // ... ...
      
       @In
       private EntityManager entityManager;
      
       @In(scope = ScopeType.BUSINESS_PROCESS, required = false)
       @Out(scope = ScopeType.BUSINESS_PROCESS, required = false)
       private Long workEffortId;
      
       // ... ...
      
      
       @CreateProcess(definition = "receiveWorkEffort")
       public void receive(WorkEffortDTO effortDTO) {
      
       // ... ...
       workEffortId = workEffort.getId();
       // ... ...
       }
      
       public void assignToTimeSheet() {
       // workEffortId is always null if called in the 1st transition
       if (workEffortId != null) {
       // ... ...
       }
       }
      }
      
      [/url]