[jboss-user] [JBoss jBPM] - custom events / executionContext

gchanteb do-not-reply at jboss.com
Mon Mar 30 05:01:15 EDT 2009


Hi all,

I'm trying to implement custom events. It works, but i have some questions:

I made a test with this process definition:

<process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="process8">
  | 
  | 	<start-state name="start-state">
  | 		<transition to="state1" name="to state1"/>
  | 	</start-state>
  | 
  | 	<state name="state1">
  | 		<event type="node-enter">
  | 			<action class="package.Action1"/>
  | 			<script>
  | 				System.out.println("node-enter!");
  | 			</script>
  | 		</event>
  | 		<event type="custom-event">
  | 			<action class="package.Action2"/>
  | 		</event>
  | 		<transition to="end-state" name="to end-state"/>
  | 	</state>
  | 	
  | 	<end-state name="end-state"/>
  | 
  | </process-definition>

With Action1:

	public void execute(ExecutionContext executionContext) throws Exception 
  | 	{
  | 		executionContext.getToken().getNode().fireEvent("custom-event", executionContext);
  | 	}

And Action2:

	public void execute(ExecutionContext executionContext) throws Exception 
  | 	{
  | 		System.out.println("custom-event!");
  | 	}

I start and signal the process with jbpm-console, it's ok.

But, first question:

If i change in my processdefinition.xml

		<event type="custom-event">
  | 			<action class="package.Action2"/>
  | 		</event>

to

		<event type="custom-event">
  | 			<script>
  | 				System.out.println("custom-event!");
  | 			</script>
  | 		</event>

I have an exception... :

anonymous wrote : Error signalling token: An exception of type "org.jbpm.JbpmException" was thrown. The message is: couldn't get value for file 'classes/java/lang/bsh.class'

Question 1- Why ? My System.out.println("node-enter!"); into node-enter!

My second question is:

Question 2 - I would like to start my custom-event into an EJB. I would like to know how to recover the "executionContext" in my code?

I made this test which doesn't work:

	public void launchCustomEvent(String processName, long idProcess)
  | 	{
  | 		System.out.println("Launch custom event for "+processName+" / "+idProcess);
  | 		
  | 		jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
  | 		ProcessInstance processInstance = jbpmContext.getProcessInstance(idProcess);
  | 		ExecutionContext executionContext = new ExecutionContext(processInstance.getRootToken());
  | 		processInstance.getRootToken().getNode().fireEvent("custom-event", executionContext);
  | 	}

Thx.

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4221866#4221866

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4221866



More information about the jboss-user mailing list