KK

Kim-'s-Blog.Object-Everything.I'm POJO.

.紀-錄.爲了忘卻的記憶..真的勇士,要敢于直面遇到的問題,敢于正視繁雜的原碼......在實踐中積累!

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  74 Posts :: 1 Stories :: 70 Comments :: 0 Trackbacks
前段时间对 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包都要有哦~
posted on 2009-08-21 15:19 Kim' 阅读(1909) 评论(1)  编辑  收藏

Feedback

# re: JBPM 4.0 使用问题 -- 3:也谈 JBPM 4 整合Spring.. 2009-08-21 17:40 99读书人
不错啊!  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航:
 
jj