Jbpm 4.1 与Spring 集成
2009-09-22 00:00:00 来源:WEB开发网Jbpm4.1特性:
4.1与Tomcat集成的很好
4.1提供基于Web的流程编辑功能
在开发指南中有相关整合章节:
16.2. Configuration
Replace the standard-transaction-interceptor with the spring-transaction-interceptor. The hibernate session needs the attribute current=”true”. Also, the <transaction/> must be removed from the transaction-context if you want the transactions to be handled by Spring only. This forces jBPM to search for the current session, which will be provided by Spring.
<process-engine-context>
<command-service>
<spring-transaction-interceptor />
...
</command-service>
...
</process-engine-context>
<transaction-context>
...
<hibernate-session current="true"/>
</transaction-context>
The Spring integration provides a special context, which is added to the set of context where the jBPM engine will look for beans. Using this SpringContext, it is now possible to retrieve beans from the Spring Application Context. For the Spring context to be known, a SpringConfiguration must be created. This class extends the JbpmConfiguration but will add itself as a context. The single constructor take the location of the jBPM configuration.
<bean id="jbpmConfiguration" class="org.jbpm.pvm.internal.cfg.SpringConfiguration">
<constructor-arg value="be/inze/spring/demo/jbpm.cfg.xml" />
</bean>
The jBPM services can also be defined in the Spring applicationContext, as following:
<bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" />
<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
<bean id="executionService" factory-bean="processEngine" factory-method="getExecutionService" />
16.3. Usage
The previous section already showed how the jBPM services can be made accessible for other Spring services. The other use case is calling Spring beans from within a process. This can be done by using an expression which resolves to the name of a Spring bean.
<java name="echo" expr="#{echoService}" method="sayHello" >
<transition name="to accept" to="join1"/>
</java>
The scripting engine will look into all contexts from the bean named echoService. If you configured the ScriptManager as above, Spring will be the last context to search for. You can also add a Spring bean to the Spring Application context (eg IdentitySessionImpl with id identitySession) and use it in the jBPM config (eg by adding <env class="identitySession" />)
整合过程与 4 基本相同。
jbpm.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<jbpm-configuration>
<import resource="jbpm.default.cfg.xml" />
<import resource="jbpm.tx.spring.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
<!-- Job executor is excluded for running the example test cases. -->
<!-- To enable timers and messages in production use, this should be included. -->
<!--
<import resource="jbpm.jobexecutor.cfg.xml" />
-->
<import resource="jbpm.jobexecutor.cfg.xml" />
<import resource="jbpm/jbpm.mail.templates.examples.xml" />
</jbpm-configuration>
工作日历从 default中分离
整合XML在原生的jbpm.tx.spring.cfg.xml 中
- ››Spring源码学习-含有通配符路径解析(上)
- ››Spring MVC与JAX-RS比较与分析
- ››集成医疗保健服务,第 2 部分: 使用 Apache Servi...
- ››集成医疗保健服务,第 1 部分: 将 Enterprise Ser...
- ››Spring 框架的设计理念与设计模式分析
- ››Spring Web Flow 2 中流管理的持久化
- ››集成 Rational Software Architect 和 Rational D...
- ››Spring 事务管理高级应用难点剖析: 第 2 部分
- ››Spring 事务管理高级应用难点剖析: 第 3 部分
- ››集成 Windows Azure:适用于企业的 Windows Azure...
- ››Spring 事务管理高级应用难点剖析,第 1 部分
- ››Spring之@Autowired问题
赞助商链接