2 Replies Latest reply on Jan 22, 2009 6:16 PM by Petr Nejedly

    jBPM Question

    Jeremy Davis Newbie

      I have processes running in jBPM.  They are kicked off by quartz and do not require user interaction.


      I am trying to wrap them with seam so that user interaction is possible even though it isn't required.


      I have been running into some problems with the standalone processes in my seam app. 


      I created a page with a button to kick off the process. 


      The process starts and transitions to the first node.  The appropriate method is called.  However the processInstance, jbpmContext, businessProcess are all null.


      Does this use case make sense for seam's jbpm support?  Should I leave the standalone process deployed as a jBPM par and use seam only for the user interaction?


      Thanks,
      Jeremy


      process defintion :


      <?xml version="1.0" encoding="UTF-8"?>
      <process-definition  xmlns="urn:jbpm.org:jpdl-3.2"  name="Test Process 2">
          <start-state name="Start Test Process">
              <transition to="Begin Test" name="to_begin_test"></transition>
          </start-state>
          <node name="Begin Test">
              <action name="begin test action"  expression="#{processTester.beginTest()}" ></action>
              <transition to="Run Test" name="to_run_test"></transition>
          </node>
          <node name="Run Test">
              <action name="Run Test Action" expression="#{processTester.runTest()}"></action>
              <transition to="Test Completed" name="to_test_completed"></transition>
          </node>
          <end-state name="Test Completed"></end-state>
      </process-definition>


      components.xml :



      <!-- For use with jBPM pageflow or process management -->
         <bpm:jbpm>
            <bpm:process-definitions>
              <value>testprocess.jpdl.xml</value>
            </bpm:process-definitions>
         <!-- 
            <bpm:pageflow-definitions></bpm:pageflow-definitions>
         -->
         </bpm:jbpm>


      slsb :



      import javax.ejb.Stateless;

      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Logger;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      import org.jboss.seam.annotations.bpm.BeginTask;
      import org.jboss.seam.annotations.bpm.CreateProcess;
      import org.jboss.seam.annotations.bpm.EndTask;
      import org.jboss.seam.annotations.bpm.Transition;
      import org.jboss.seam.bpm.Actor;
      import org.jboss.seam.bpm.BusinessProcess;
      import org.jboss.seam.log.Log;
      import org.jboss.seam.security.Identity;
      import org.jbpm.JbpmContext;
      import org.jbpm.graph.exe.ProcessInstance;

      @Stateless
      @Name("processTester")
      public class ProcessTester implements IProcessTester {
           
           private static final long serialVersionUID = -8381313002070494166L;

           @Logger
           Log log;
           
           @In(required=false)
           Identity identity;
           
           @In(required=false) @Out(required=false)
           ProcessInstance processInstance;
           
           @In(required=false)
           BusinessProcess businessProcess;
           
           @In(required=false)
           JbpmContext jbpmContext;
           
           @BeginTask @EndTask @Transition("to_run_test")
           public void beginTest(){
                log.debug("executing beginTest");
                if(processInstance != null){
                     log.debug(processInstance.getProcessDefinition().getName());
                }
                
           }
           
           @BeginTask @EndTask @Transition("to_test_completed")
           public void runTest(){
                log.debug("executing runTest");
                if(processInstance != null){
                     log.debug(processInstance.getProcessDefinition().getName());
                }
           }

           @CreateProcess(definition="Test Process 2")
           public void start() {
                log.debug("starting");
                Actor actor = new Actor();
                actor.setId(identity.getUsername());
                
                log.debug(businessProcess.getProcessId());
                jbpmContext.getJbpmConfiguration().getInstance();
                
           }

        • 1. Re: jBPM Question
          Jeremy Davis Newbie

          Sorry about the formatting in the initial post.


          process defintion :


          <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="Test Proces 2">
              <start-state name="Start Test Process"> 
                  <transition to="Begin Test" name="to_begin_test"></transition> 
              </start-state> 
              <node name="Begin Test"> 
                  <action name="begin test action" expression="#{processTester.beginTest()}" ></action>
                  <transition to="Run Test" name="to_run_test"></transition> 
              </node>
              <node name="Run Test"> 
                  <action name="Run Test Action" expression="#{processTester.runTest()}"></action> 
                  <transition to="Test Completed" name="to_test_completed"></transition>     </node> 
              <end-state name="Test Completed"></end-state> 
          </process-definition>
          



          components.xml :


          <bpm:jbpm>  
              <bpm:process-definitions>  
                  <value>testprocess.jpdl.xml</value>  
              </bpm:process-definitions>
          </bpm:jbpm> 
          


          slsb :


          import javax.ejb.Stateless;
          import org.jboss.seam.annotations.In;
          import org.jboss.seam.annotations.Logger;
          import org.jboss.seam.annotations.Name;<br/>
          import org.jboss.seam.annotations.Out;<br/>
          import org.jboss.seam.annotations.bpm.BeginTask;<br/> 
          import org.jboss.seam.annotations.bpm.CreateProcess;<br/> 
          import org.jboss.seam.annotations.bpm.EndTask;<br/>
          import org.jboss.seam.annotations.bpm.Transition; import<br/> org.jboss.seam.bpm.Actor; import org.jboss.seam.bpm.BusinessProcess; import org.jboss.seam.log.Log; import org.jboss.seam.security.Identity; 
          import org.jbpm.JbpmContext; 
          import org.jbpm.graph.exe.ProcessInstance; 
          
          @Stateless @Name("processTester") 
          public class ProcessTester implements IProcessTester { 
          private static final long serialVersionUID = -8381313002070494166L; 
          
              @Logger Log log; 
              @In(required=false) Identity identity; 
              @In(required=false) @Out(required=false) ProcessInstance processInstance;
              @In(required=false) BusinessProcess businessProcess; 
              @In(required=false) JbpmContext jbpmContext; 
              @BeginTask @EndTask @Transition("to_run_test") 
              public void beginTest(){ 
                  log.debug("executing beginTest"); 
                  if(processInstance != null){     
                      log.debug(processInstance.getProcessDefinition().getName()); 
                  }
              } 
          
              @BeginTask @EndTask @Transition("to_test_completed") 
              public void runTest(){ 
                  log.debug("executing runTest"); 
                  if(processInstance != null){
                      log.debug(processInstance.getProcessDefinition().getName()); 
                  }
              } 
          
              @CreateProcess(definition="Test Process 2") public void start() {
                  log.debug("starting"); 
                  Actor actor = new Actor(); 
                  actor.setId(identity.getUsername());
                  log.debug(businessProcess.getProcessId());
                  jbpmContext.getJbpmConfiguration().getInstance(); 
              } 
          }
          

          • 2. Re: jBPM Question
            Petr Nejedly Newbie

            I am trying to wrap them with seam so that user interaction is possible even though it isn't required.


            I don't know if you can do this with JBPM. You can either create Tasks, where user interaction is required (or you can leave the node via API call, e.g. from an ActionHandler) or you create a Node, which just runs your code in ActionHandler.


            The @StartTask, @EndTask annotations are there for task nodes, i.e. when a Token comes to the TaskNode it creates Task(s) and wait for user to work on it. When user starts/finishes working on the task, he can click a button that will call the annotated method and Seam will signal the Token appropriately.


            Or am i not getting what you intend to do?