Spring整合jbpm4.4

spring.jbpm.cfg.xml 配置

<?xml version="1.0" encoding="UTF-8"?>

<jbpm-configuration>
  <import resource="jbpm.default.cfg.xml" />
  <import resource="jbpm.businesscalendar.cfg.xml" />
  <import resource="jbpm.tx.hibernate.cfg.xml" />
  <import resource="jbpm.jpdl.cfg.xml" />
  <import resource="jbpm.bpmn.cfg.xml" />
  <import resource="jbpm.identity.cfg.xml" />
</jbpm-configuration>

jbpm.hibernate.cfg.xml配置

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
     <property   name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect

    </property> 
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver

    </property>
     <property name="hibernate.connection.url">

jdbc:mysql://127.0.0.1:3306/zzg?useUnicode=true&amp;characterEncoding=UTF-8

    </property>
     <property name="hibernate.connection.username">root</property>
     <property name="hibernate.connection.password"></property>
     <property name="hibernate.hbm2ddl.auto">update</property>
     <property name="hibernate.format_sql">true</property>
     
     <mapping resource="jbpm.repository.hbm.xml" />
     <mapping resource="jbpm.execution.hbm.xml" />
     <mapping resource="jbpm.history.hbm.xml" />
     <mapping resource="jbpm.task.hbm.xml" />
     <mapping resource="jbpm.identity.hbm.xml" />
  </session-factory>
</hibernate-configuration>

spring的applicationContext.xml配置

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
  xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
  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.5.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

  <bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" >
  <property name="jbpmCfg" value="edu-core-jbpm/config/spring.jbpm.cfg.xml" />
  </bean>

  <bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />
 
  <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://127.0.0.1:3306/zzg" />
        <property name="username" value="root" />
        <property name="password" value="" />
  </bean>
  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="configLocation" value="classpath:jbpm.hibernate.cfg.xml" />
  </bean>

  <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
  </bean>
</beans>


测试

import java.util.List;

import org.jbpm.api.HistoryService;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.history.HistoryProcessInstance;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 */

/**
 * @author running
 * @since 2013-8-12 上午10:42:52
 */
public class springTest {
    @Test
    public void jbpmTest(){
        try{
            ApplicationContext ap = new ClassPathXmlApplicationContext("applicationContext.xml");
             ProcessEngine pe = (ProcessEngine) ap.getBean("processEngine");
             
             HistoryService hs = pe.getHistoryService();
          //查看系统中定义的流程的历史流程实例信息
         List<HistoryProcessInstance> hpis = hs.createHistoryProcessInstanceQuery().processDefinitionId("demo-1").list();
        for (HistoryProcessInstance historyProcessInstance : hpis) {
     System.out.println(historyProcessInstance.getProcessInstanceId());
    }
        }catch(Exception e ){
            System.out.println(e);
        }
    }
}


你可能感兴趣的:(Spring整合jbpm4.4)