程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> 關於JAVA >> JBPM 4.0使用問題 -- 3:也談 JBPM 4 整合Spring..

JBPM 4.0使用問題 -- 3:也談 JBPM 4 整合Spring..

編輯:關於JAVA

前段時間對 JBPM 4.0 Spring 2.6 進行了整合

方法有幾種,經過比較感覺原生集成較好~

整合後的結構:

src\resources

src\resources\jbpm

src\resources\jbpm\jbpm.cfg.xml

src\resources\jbpm\jbpm.default.cfg.xml

src\resources\jbpm\jbpm.tx.hibernate.cfg.xml

src\resources\jbpm\jbpm.mail.properties

src\resources\jbpm\jbpm.mail.templates.examples.xml

src\resources\jbpm\logging.properties

src\resources\spring\applicationContext-jbpm.xml

src\resources\spring\applicationContext-hibernate.xml

重點是5個標色文件

jbpm.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<jbpm-configuration>
   <import resource="jbpm/jbpm.default.cfg.xml" />
   <import resource="jbpm/jbpm.tx.hibernate.cfg.xml" />
   <import resource="jbpm.jpdl.cfg.xml" />
   <import resource="jbpm.identity.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/jbpm.mail.templates.examples.xml" />

   <process-engine-context>
     <command-service>
       <retry-interceptor />
       <environment-interceptor />
       <spring-transaction-interceptor />
     </command-service>
   </process-engine-context>
   <transaction-context>
     <transaction />
     <hibernate-session />
   </transaction-context>
</jbpm-configuration>

jbpm.default.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<jbpm-configuration>
   <process-engine-context>

     <repository-service />
     <repository-cache />
     <execution-service />
     <history-service />
     <management-service />
     <identity-service />
     <task-service />
     <!--kim
     <hibernate-configuration>
       <cfg resource="jbpm.hibernate.cfg.xml" />
     </hibernate-configuration>
     <hibernate-session-factory />
     !-->
     <script-manager default-expression-language="juel"
                     default-script-language="juel">
       <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
     </script-manager>

     <authentication />
     <id-generator />
     <types resource="jbpm.variable.types.xml" />
     <address-resolver />
     <business-calendar>
       <monday    hours="9:00-12:00 and 12:30-17:00"/>
       <tuesday   hours="9:00-12:00 and 12:30-17:00"/>
       <wednesday hours="9:00-12:00 and 12:30-17:00"/>
       <thursday  hours="9:00-12:00 and 12:30-17:00"/>
       <friday    hours="9:00-12:00 and 12:30-17:00"/>
       <holiday period="01/07/2008 - 31/08/2008"/>
     </business-calendar>

     <mail-template name='task-notification'>
       <to users="${task.assignee}"/>
       <subject>${task.name}</subject>
       <text><![CDATA[Hi ${task.assignee},
Task "${task.name}" has been assigned to you.
${task.description}
Sent by JBoss jBPM
]]></text>
     </mail-template>

     <mail-template name='task-reminder'>
       <to users="${task.assignee}"/>
       <subject>${task.name}</subject>
       <text><![CDATA[Hey ${task.assignee},
Do not forget about task "${task.name}".
${task.description}
Sent by JBoss jBPM
]]></text>
     </mail-template>

   </process-engine-context>
   <transaction-context>
     <repository-session />
     <db-session />

     <message-session />
     <timer-session />
     <history-session />
     <mail-session>
       <mail-server>
         <session-properties resource="jbpm.mail.properties" />
       </mail-server>
     </mail-session>
   </transaction-context>
</jbpm-configuration>

jbpm.tx.hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<jbpm-configuration>
   <process-engine-context>
     <command-service>
       <retry-interceptor />
       <environment-interceptor />
       <!-- <standard-transaction-interceptor /> -->
       <spring-transaction-interceptor current="true" />
     </command-service>
   </process-engine-context>
   <!--kim
   <transaction-context>
     <transaction />
     <hibernate-session />
   </transaction-context>
   -->
   <transaction-context>
     <hibernate-session current="true"/>
   </transaction-context>

</jbpm-configuration>

applicationContext-jbpm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
     <bean id="jbpmConfiguration" class="org.jbpm.pvm.internal.cfg.SpringConfiguration">
            <constructor-arg value="jbpm/jbpm.cfg.xml" />
     </bean>
     <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" />
     <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
     <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
     <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
     <bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" />
</beans>

 

applicationContext-hibernate.xml (片段)

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" parent="AbstractSessionFactory">
         <property name="annotatedClasses">
             <list>
                 <value>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</value>
</list>
         </property>
         <property name="mappingResources">
             <list>
                 <value>jbpm.repository.hbm.xml</value>
                 <value>jbpm.execution.hbm.xml</value>
                 <value>jbpm.history.hbm.xml</value>
                 <value>jbpm.task.hbm.xml</value>
                 <value>jbpm.identity.hbm.xml</value>
             </list>
         </property>

     </bean>

另外該有的Jar包都要有哦~

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved