Package COM. njupt. jbpm; import Java. util. map; import Java. util. set; import Org. jbpm. API. configuration; import Org. jbpm. API. executionservice; import Org. jbpm. API. processengine; import Org. jbpm. API. processinstance; import Org. jbpm. API. taskservice; import Org. JUnit. test; public class processvariabletest {private processengine = configuration. getprocessengine (); Private executionservice = processengine. getexecutionservice (); Private taskservice = processengine. gettaskservice (); // start process instance @ testpublic void teststartprocessinstance () throws exception {processinstance Pi = processengine. getexecutionservice (). startprocessinstancebykey ("test"); system. out. println ("ID =" + pi. GETID () + ", processdefinitionid =" + pi. getprocessdefinitionid ();} // set the process variable @ testpublic void testsetvariable () throws exception {string executionid = "test.110001"; // processengine. getexecutionservice (). setvariable (executionid, "days for leave", new INTEGER (3); Form = new form (); form. setid (1l); // set the ID to correspond to the record whose ID is 1 in the database. settitle ("three days for leave"); processengine. getexecutionservice (). setvariable (executionid, "form", form); // use execution to set the process variable // executionservice. setvariable (executionid, name, value); // sets a // executionservice. setvariables (executionid, variablesmap); // you can specify multiple executionids. setvariables (taskid, variablesmap); // you can specify multiple variables when starting a process instance. startprocessinstancebykey (key); // executionservice. startprocessinstancebykey (Key, variablesmap); // when the task is completed, set some process variables. // taskservice. completetask (taskid); // taskservice. completetask (taskid, variablesmap);} // obtain the process variable @ testpublic void testgetvariable () throws exception {string executionid = "test.110001"; // integer days = (integer) processengine. getexecutionservice (). getvariable (executionid, "days for leave"); // system. out. println ("leave days =" + days); Form = (form) processengine. getexecutionservice (). getvariable (executionid, "form"); system. out. println (form); // obtain the process variable through execution // object value = executionservice. getvariable (executionid, variablename); // get a // set <string> namesset = executionservice. getvariablenames (executionid); // obtain the names of all variables // Map <string, Object> map = executionservice. getvariables (executionid, variablenamesset); // obtain multiple executionids // obtain process variables using tasks // taskservice. getvariable (taskid, variablename); // taskservice. getvariablenames (taskid); // taskservice. getvariables (taskid, variablenames );}}