Hi Britt, Thanks for your reply. It seems the 3.01 version has no support yet for tracking multiple sub processes. The subprocess only works for 1, but not many. I tried to look at some facilties in the code but the super process in the sub process instance refers only to one parent. I also tried looking at the module instances, but it seems I don't know how to use it. Please check my code below, there are some i did a somebit of a hack, not pretty though but it seems to work.
<process-definition name="hire-process"> | | <start-state name="start-hire"> | <transition to="hire-state"/> | </start-state> | | <state name="hire-state"> | <transition name="dummy" to="hire-state"/> | <transition name="close" to="stop-hiring"/> | <transition name="add-candidate" to="add-candidates"/> | </state> | | <node name="add-candidates"> | <event type="node-enter"> | <action name="create-candidate-process" class="org.jbpm.CreateSubProcess"> | <subprocessname>candidate-process</subprocessname> | </action> | </event> | <transition to="hire-state"/> | </node> | | <process-state name="candidate-process"> | <sub-process name="candidate-process"/> | </process-state> | | <node name="stop-hiring"> | <event type="node-enter"> | <action name="kill-subprocess" class="org.jbpm.SubProcessKiller" /> | </event> | <transition to="end-process"/> | </node> | | <end-state name="end-process"/> | | </process-definition> The purpose of the dummy transition is to avoid accidental signalling of this state. I need to specify the transition in this state whether close or add another candidate. So I just get a process, add an "add-candidate" transition and off it goes creating the sub process. I cant use the normal subprocess definition bec. it only continues when i have finished the process. so I did a little bit of hack here, i dont think this is the recommended way to use a subprocess. | public class CreateSubProcess implements ActionHandler { | | String subprocessname; | | public void execute(ExecutionContext executionContext) throws Exception { | ProcessState node = (ProcessState)executionContext.getProcessDefinition().findNode( subprocessname ); | if( node == null ) | throw new Exception(subprocessname + " does not exist! "); | ProcessInstance subProcess = node.getSubProcessDefinition().createProcessInstance(); | ModuleInstance module = new ModuleInstance(); | module.setProcessInstance( subProcess ); | executionContext.getProcessInstance().addInstance( module ); | subProcess.signal(); | System.out.println("EXITING THE PROCESS NOW..."); | } | | } Tried to use the module instance. But it seems it does not work as I thought it would, maybe I'm not using it correctly. In the code below the process instance in the module referred to the parent process instance not the sub process. | public class SubProcessKiller implements ActionHandler { | | public void execute(ExecutionContext executionContext) throws Exception { | System.out.println( "START THE STOPPING PROCESS..."); | int i = 0; | Map m = executionContext.getProcessInstance().getInstances(); | Iterator iter = m.values().iterator(); | while( iter.hasNext() ) { | System.out.println( "looping token->"); | ModuleInstance mod = (ModuleInstance)iter.next(); | ProcessInstance sb = mod.getProcessInstance(); | sb.end(); | System.out.println( "proc name " + sb.getProcessDefinition().getName() ); | System.out.println( "proc id is " + sb.getId() ); | System.out.println("has ended? " + sb.hasEnded() ); | System.out.println(sb.getRootToken().getNode().getName()); | i++; | } | ProcessInstance p; | | System.out.println( "SUBPROCESSES CLEANED UP. NO. OF PROCESS CLOSED " + i ); | } | | } | Anyway, everything seemed to work EXCEPT for the module instance. How do I track sub processes wihtout going to extraordinary means? Any suggestions? Thanks again. Regards, Elmo View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3914552#3914552 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3914552 ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user