You can provide input parameters to your process much the same way you did with jBPM3.
For example, here’s how to set the initial value for the “money” process variable:
KnowledgeBase kbase = readKnowledgeBase(); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); Map<String, Object> inputParams = new HashMap<String, Object>(); inputParams.put("money", new Long(15)); // start a new process instance ProcessInstance process = ksession.startProcess("com.sample.bpmn.task",inputParams);
Remember, that process variables need to be defined into your BPMN 2.0 process file. In this example:
<itemDefinition id="_moneyItem" structureRef="Integer" /> <process processType="Private" isExecutable="true" id="com.sample.bpmn.task" name="Sample Task" > <!-- process variables --> <property id="money" itemSubjectRef="_moneyItem"/> . . . . . </process>
Hint: if you are using Eclipse jBPM plugin, then you can define a variable by simply pointing to any place on your BPMN 2.0 diagram (where there are no nodes) and in the “Properties” Tab insert your variable: