spring与jbpm整合时Action中使用spring注入service方法
在一个节点中用到action,action又要用到spring提供的service方法怎么做?
在spring的配置文件中:
<beans> <!-- Spring bean visible inside jBPM processed --> <bean id="jbpmAction" singleton="true"> <property name="prop" ref="anotherBean"/> ... </bean>..</beans>
jbpm的action按平常编写:
public class JbpmAction implements ActionHandler { private UserService userService; public void execute(ExecutionContext executionContext) throws Exception { userservice.getUser(); } public void setUserService(UserService userService){ this.userService=userService; } }
在jbpm的流程定义文件里:
<?xml version="1.0" encoding="UTF-8"?><process-definition name="simpleWorkflow"> <start-state> <transition to="myState"> </transition> </start-state> <state name="myState"> <transition to="end"> <action name="myAction" config-type="bean" class="org.springmodules.workflow.jbpm31.JbpmHandlerProxy"> <targetBean>jbpmAction</targetBean> </action> </transition> </state> <end-state name="end"/></process-definition>