读书人

JBPM的运用心得

发布时间: 2012-08-31 12:55:03 作者: rapoo

JBPM的使用心得
首先是安装4.4版本的插件.通过使用links方式安装好了插件,前提是7.0以上版本的myeclipse吧. 插件见附件jbpm_jpd_site.zip!

之后,由于插件对于中文支持不是太好,经常二次打开后,乱码,故修改myeclipse.ini,在最后加上 '-Dfile.encoding=UTF-8'. 这样做使得jbpm配置文件不再乱码.但是导致tomcat控制台中文乱码,再次修改tomcat目录下/bin/catalina.bat文件,在set JAVA OPT=XXX 这段话最后也加上'-Dfile.encoding=UTF-8' . 这样就搞定乱码问题了!
一 ssh整合jbpm了,其实很简单:
1.首先写下jbpm在spring中的配置:

<?xml version="1.0" encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"><bean id="springHelper" value="jbpm.cfg.xml" />   </bean>   <bean id="processEngine" factory-bean="springHelper"  factory-method="createProcessEngine" />  <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />         <bean id="executionService" factory-bean="processEngine" factory-method="getExecutionService" />         <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService"/>         <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService"/>         <bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService"/>   <bean id="jbpmService" parent="baseService">           <property name="repositoryService" ref="repositoryService" />          <property name="taskService" ref="taskService" />          <property name="executionService" ref="executionService" />         <property name="jbpmLogService" ref="jbpmLogService" /> </bean>  <bean id="jbpmLogService" parent="baseService">   </bean>  </beans>


jbpmService是自己封装的工作流服务类,既然是做成组件,那当然业务对象里不能参合工作流的东西了.这个service一会再讲.
jbpmLogService是是用来做历史服务的,详细记录了什么人什么时间执行了什么流程,成功执行还是回退到某个流程.

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.bpmn.cfg.xml" />       <import resource="jbpm.identity.cfg.xml" />       <import resource="jbpm.businesscalendar.cfg.xml" />       <import resource="jbpm.console.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" />  --></jbpm-configuration>


最后,事务控制别忘了做哦:
<!-- 事务控制  --><bean id="transactionManager" /></property></bean><tx:advice id="txAdvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="saveOrUpdate" propagation="REQUIRED" /><tx:method name="delete" propagation="REQUIRED" /><tx:method name="get" read-only="true" /><tx:method name="count" read-only="true" /><tx:method name="find" read-only="true" /></tx:attributes></tx:advice><tx:advice id="jbpmAdvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="*" propagation="REQUIRED" /></tx:attributes></tx:advice><aop:config><aop:pointcut id="jbpmPointcut"expression="execution(* com.creditease.engine.**.service.*.*(..))" /><aop:pointcut id="servicePointcut"expression="execution(* com.creditease.clic.**.service.*.*(..))" /><aop:advisor advice-ref="txAdvice" pointcut-ref="servicePointcut" /><aop:advisor advice-ref="jbpmAdvice" pointcut-ref="jbpmPointcut" /></aop:config>


jbpmService最好注入在其他服务类中,使用时,调用其他服务类中带事务的方法也就保持了事务一致性了.

这样我们经过以上的一些配置,jbpm与sping就完成了结合的工作了.

二 jbpmService服务类,下班了,下次有空再写吧.



目前在做接口,供其他开发人员调用,也就是说组件化jbpm.做完了,再上来说,继续忙!

读书人网 >软件架构设计

热点推荐