-
1. Re: specifying context variables through the process definit
aguizar Jun 20, 2006 8:27 PM (in response to ccrouch)We do not have a syntax for automatically substituting the value of a variable while initializing an action handler field. You can, however, interpret the literal from the process definition as a variable name and retrieve the variable value from the execution context:
public class MyActionHandler implements ActionHandler { private String source; public void execute(ExecutionContext executionContext) { Object value = executionContext.getVariable(source); // ... do something with the variable value } }
Your process definition would specify the variable name rather than a specific value:<action class='MyActionHandler'> <source>pathToPatch</source> </action>
Regarding child processes, you can assign values from the variables of the parent process to the variables of the child process, but not literal values. In your scenario, you can pass the required values in variables and then use the above technique to access these values from action handlers. -
2. Re: specifying context variables through the process definit
ccrouch Jun 21, 2006 1:04 AM (in response to ccrouch)I can get what I need by associating an action with a node-enter event on the process-state and then having that action copy properties into context variables, i.e.
"<process-definition name='super'>" + " <start-state>" + " <transition to='p' />" + " </start-state>" + " <process-state name='p'>" + " <event type='node-enter'>" + " <action name='copy' class='org.jbpm.tutorial.action.CopyActionHandler'>" + " <backup>JBOSS_HOME/lib/jboss-${timestamp}.jar</backup>"+ " </action>" + " </event>" + " <sub-process name='sub' />" + " <variable name='backup'/>" + " <transition to='end' />" + " </process-state>" + " <end-state name='end' />" + "</process-definition>"
and in CopyActionHolderexecutionContext.getContextInstance().setVariable("backup", getBackup());
and
"<process-definition name='sub'>" + " <start-state>" + " <transition to='end' />" + " <event type='node-leave'>" + " <action class='org.jbpm.tutorial.action.MyActionHandler'>" + " <source>JBOSSboo</source>"+ " </action>" + " </event>" + " </start-state>" + " <end-state name='end' />" + "</process-definition>"
then in MyActionHandler I can doObject object = executionContext.getContextInstance().getVariable("backup");
This approach works, but seems like a bit of a hack.
Thanks -
3. Re: specifying context variables through the process definit
koen.aers Jun 21, 2006 7:18 AM (in response to ccrouch)Charles,
You are correct. This is not (yet) supported AFAIK. If you would like it, file a JIRA issue and pray to the jBPM God that he likes it ;-)
Cheers,
Koen -
4. Re: specifying context variables through the process definit
kukeltje Jun 21, 2006 8:40 AM (in response to ccrouch)Amen
(I've been told by one of the apostles that a bottle of Dutch beer helps) -
5. Re: specifying context variables through the process definit
koen.aers Jun 21, 2006 9:29 AM (in response to ccrouch)Dutch beer? I don't think the beer God will approve :-))
-
6. Re: specifying context variables through the process definit
ccrouch Jun 21, 2006 1:11 PM (in response to ccrouch)Raised http://jira.jboss.com/jira/browse/JBPM-679
Thanks