well, jBPM3 had a nice idea, IMO :-) especially if the transient data has to be used at several parts of the process, so that it is overall better than mine.
here is what I did, I pass the data when signalling the Custom that uses them with method ExecutionService.signalExecutionById(String, String, Map<String, ?>) JPDL : | <?xml version="1.0" encoding="UTF-8"?> | | <process name="CustomParameters" xmlns="http://jbpm.org/4.0/jpdl"> | <start g="161,71,48,48" name="start1"> | <transition g="-30,-37" name="to input_some_info" to="input_some_info"/> | </start> | <state g="301,129,209,52" name="input_some_info"> | <transition g="-68,-18" name="to exclusive1" to="exclusive1"/> | </state> | <decision g="381,222,48,48" name="exclusive1"> | <handler class="org.jbpm.npi.Exclusive1Handler" /> | <transition g="-58,-18" name="to custom1" to="custom1"/> | </decision> | <custom class="org.jbpm.npi.MyCustom" g="361,319,92,52" name="custom1"> | <transition name="to exclusive2" to="exclusive2" g="-68,-18"/> | </custom> | <decision g="384,416,48,48" name="exclusive2"> | <handler class="org.jbpm.npi.Exclusive2Handler" /> | <transition name="to wait2" to="wait2" g="-44,-18"/> | </decision> | <end g="569,500,48,48" name="end1"/> | <state name="wait2" g="350,479,92,52"> | <transition name="to end1" to="end1" g="-42,-18"/> | </state> | </process> | two simple DecisionHandlers : | package org.jbpm.npi; | | import org.jbpm.api.jpdl.DecisionHandler; | import org.jbpm.api.model.OpenExecution; | | public class Exclusive1Handler implements DecisionHandler { | | @Override | public String decide(OpenExecution arg0) { | return "to custom1"; | } | } | | package org.jbpm.npi; | | import org.jbpm.api.jpdl.DecisionHandler; | import org.jbpm.api.model.OpenExecution; | | public class Exclusive2Handler implements DecisionHandler { | | @Override | public String decide(OpenExecution arg0) { | return "to wait2"; | } | } | | my Custom : | package org.jbpm.npi; | | import java.util.Map; | | import org.jbpm.api.activity.ActivityExecution; | import org.jbpm.api.activity.ExternalActivityBehaviour; | | public class MyCustom implements ExternalActivityBehaviour { | | @Override | public void signal(ActivityExecution activityExecution, String signal, Map<String, ?> parameters) throws Exception { | System.out.println("signal() - ring the Kremlin !! " + parameters.get("putinPhoneNumber")); | | activityExecution.takeDefaultTransition(); | } | | @Override | public void execute(ActivityExecution activityExecution) throws Exception { | System.out.println("MyCustom.execute()"); | activityExecution.waitForSignal(); | } | | } | the test class | package org.jbpm.npi; | | import java.util.HashMap; | import java.util.Map; | | import org.jbpm.api.Execution; | import org.jbpm.api.ProcessInstance; | import org.jbpm.test.JbpmTestCase; | | /** | * test the possibility to inject parameters at some point of a process without | * persisting them | * | * @author npirard | */ | public class CustomParametersTest extends JbpmTestCase { | | String deploymentId; | | @Override | protected void setUp() throws Exception { | super.setUp(); | | deploymentId = repositoryService.createDeployment().addResourceFromClasspath("org/jbpm/npi/CustomParameters.jpdl.xml").deploy(); | } | | @Override | protected void tearDown() throws Exception { | repositoryService.deleteDeploymentCascade(deploymentId); | | super.tearDown(); | } | | public void testProcess(){ | Map<String, Object> variables = new HashMap<String, Object>(); | | //this is a variable that can be persisted without problem | variables.put("publicInfo", "this is not really secret"); | ProcessInstance processInstance = executionService.startProcessInstanceByKey("CustomParameters", variables); | | Execution executionInA = processInstance.findActiveExecutionIn("input_some_info"); | assertNotNull(executionInA); | | processInstance = executionService.signalExecutionById(executionInA.getId()); | | Execution executionInCustom = processInstance.findActiveExecutionIn("custom1"); | Map<String, String> parameters = new HashMap<String, String>(); | | //this is really secret matter | parameters.put("putinPhoneNumber", "+7123456789"); | processInstance = executionService.signalExecutionById(executionInCustom.getId(), "mySignal", parameters); | | Execution executionInWait2 = processInstance.findActiveExecutionIn("wait2"); | | assertNotNull(executionInWait2);// breakpoint A | | processInstance = executionService.signalExecutionById(executionInWait2.getId()); | | assertTrue(processInstance.isEnded());// breakpoint B | } | } | I executed it in debug ; at breakpoint A I found "publicInfo" in table JBPM4_VARIABLE, but not "putinPhoneNumber" at breakpoint B I do not find anything in JBPM4_VARIABLE. By the way, I would have expected "publicInfo" in JBPM4_HIST_VAR, but it is not. Maybe I have not understood the purpose of this latter table : it is not supposed to record the variables of past executions? View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4253515#4253515 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4253515 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user