基本步驟
1、集成JBPM到系統(tǒng)(第一步:創(chuàng)建數(shù)據(jù)庫表)
* 拷貝相關(guān)的依賴包到WEB-INF/lib下面(bsh.jar/ jcr-1.0.jar/
jbpm-identity.jar/ jbpm-jpdl.jar)
* 修改hibernate.cfg.xml,添加JBPM的映射配置,以及緩存屬性的配置,可從jbpm包下的config文件夾下參考其hibernate.cfg.xml文件
*在使用Jbpm工作流引擎的時候,Hibernate配置文件一定要加上屬性
<property
name="hibernate.hbm2ddl.auto">update</property>
Hbm2dll.auto是數(shù)據(jù)庫表和類自動連接更新
* 因為JBPM中的User對象與OA系統(tǒng)中的User對象名稱上有沖突,所以需要修改系統(tǒng)中User映射的auto-import屬性為"false"。(參考User.hbm.xml)
* 當(dāng)修改了User映射的auto-import="false"之后,需要在查詢User對象的時候,使用其全路徑類名(請參考UserManagerImpl.java)
* 啟動Tomcat,應(yīng)能正確創(chuàng)建JBPM的所有數(shù)據(jù)庫表
2、 集成JBPM到系統(tǒng)(第二步:與Spring集成)
* 集成JBPM與spring,需要用到第三方的集成包:spring-modules-0.8.zip
* 將其中的spring-modules-jbpm31.jar拷貝到WEB-INF/lib下面即可
* 集成JBPM與Spring的方法是:將JbpmConfiguration對象的創(chuàng)建交給Spring來完成
* 所以,需要在spring配置文件中配置JbpmConfiguration對象的創(chuàng)建
<!-- 配置JbmpConfiguration -->
<bean
id="jbpmConfiguration"
class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean">
<property
name="configuration"
value="classpath:jbpm.cfg.xml"></property>
</bean>
* 這時候,需要jbpm.cfg.xml,這是JBPM的配置文件,我們可以從:JBPM_HOME"src"jpdl"org"jbpm目錄下拷貝default.jbpm.cfg.xml文件,并重新命名為jbpm.cfg.xml
3、集成JBPM到系統(tǒng)(第三步:如何實現(xiàn)業(yè)務(wù)邏輯類,請參考WorkflowManagerImpl.java)
* 用到j(luò)bpmConfiguration對象的時候,需要注入 (<property
name="jbpmConfiguration"
ref="jbpmConfiguration"></property>)
* 當(dāng)我們使用JbpmContext對象來操縱JBPM的時候,需要將JbpmContext的HibernateSession對象設(shè)置為當(dāng)前的HibernateSession對象
private JbpmContext getContext(){
JbpmContext context =
jbpmConfiguration.createJbpmContext();
context.setSession(getSession());
return context;
}
4、實現(xiàn)WorkflowManagerImpl
- 理解基本的JBPM操作:流程定義、流程實例、任務(wù)列表、流向
Jbpm與ssh整合常出現(xiàn)的問題
1、因為JBPM中的User對象與OA系統(tǒng)中的User對象名稱上有沖突,所以需要修改OA系統(tǒng)中User映射的auto-import屬性為"false"。(參考User.hbm.xml)
* 當(dāng)修改了User映射的auto-import="false"之后,需要在查詢User對象的時候,使用其全路徑類名(請參考UserManagerImpl.java)
2、在使用Jbpm工作流引擎的時候,Hibernate配置文件一定要加上屬性
<property
name="hibernate.hbm2ddl.auto">update</property>
Hbm2dll.auto是數(shù)據(jù)庫表和類自動連接更新
3、jbpm與Spring整合報錯:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'jbpmConfiguration' defined in ServletContext resource
[/WEB-INF/classes/applicationContext.xml]: Initialization of bean failed;
nested exception is java.lang.IllegalArgumentException: a beanFactoryReference already exists for
key jbpmConfiguration
解決方法:去掉struts-config.xml文件中的org.springframework.web.struts.ContextLoaderPlugIn,也就是與Spring整合的插件
posted on 2009-11-29 13:52
唯美古典 閱讀(3979)
評論(6) 編輯 收藏 所屬分類:
SSH整合