截至目前,我正在用GenericCommand
更新像這樣的變量。
kSession.execute(new GenericCommand<Boolean>() {
public Boolean execute(Context context) {
//Get session in the command context
StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
//Get the process instance
ProcessInstance processInstance = (ProcessInstance) ksession.getProcessInstance(processInstanceId);
//Get variable scoprts
VariableScopeInstance variableScope = (VariableScopeInstance) processInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
Iterator<String> piStateItr=piStateVariables.keySet().iterator();
//Modify required variables
while(piStateItr.hasNext()){
String variableName=piStateItr.next();
String variableValue=piStateVariables.get(variableName);
logger.debug(">>> Setting State - key "+variableName +" , to "+variableValue);
variableScope.setVariable(variableName, variableValue);
}
return true;
}
});
匿名GenericCommand工作正常。 – 2013-04-28 09:25:01
嗨,感謝您的代碼,我面臨同樣的問題。你如何檢索'processInstanceId'變量? – ocramot 2013-08-07 13:10:11
@ocramot,爲包含給定代碼的方法輸入processInstanceId。 – 2013-08-15 09:45:21