`

jBPM4.4:配置(包括和Spring的整合,和Hibernate配置)

    博客分类:
  • jbpm
阅读更多
jBPM4.4,获取ProcessEngine是通过Configuration.getProcessEngine()中获取的。



Configuration.getProcessEngine()的代码如下: 
  /** get the singleton ProcessEngine that is created from the default 
   * configuration file 'jbpm.cfg.xml'. */ 
  public static ProcessEngine getProcessEngine() { 
    if (singleton == null) { 
      synchronized (Configuration.class) { 
        if (singleton == null) { 
          singleton = new Configuration().setResource("jbpm.cfg.xml").buildProcessEngine(); 
        } 
      } 
    } 
    return Configuration.singleton; 
  }


(虽然这一段代码可能会有“双重检查锁定”失败的问题,但是不影响到分析jBPM的配置 -- 详见IBM04年的文章:双重检查锁定及单例模式)



系统缺省的加载jbpm.cfg.xml,作为主配置文件。



在jBPM4.4的install/src/cfg中,带了几套配置文件的样板。

在cfg中:有几个目录:

hibernate:采用hibernate时候的配置(其中还分为好几种方式的数据源方式:datasource/jdbc/spring/tomcat)

jbpm      :主配置文件的样板(分为:采用jta/spring/standalone--这种方式直接配置hibernate)

logging   : logging的几种配置法

mail       : 邮件的配置样板

spring    : 如果使用到spring的时候,applicationcontext.xml的样板



在jbpm目录中,拿一个样板来讲:spring.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" />
  <import resource="jbpm.jobexecutor.cfg.xml" />
  
  <process-engine-context>
    <string name="spring.cfg" value="applicationContext.xml" />
  </process-engine-context>

</jbpm-configuration>

对于3种不同的配置,就是在第二个配置项上有差异,其余部分都是一样的。

spring:      <import resource="jbpm.tx.spring.cfg.xml" />

jta     :      <import resource="jbpm.tx.jta.cfg.xml" />

standalone: <import resource="jbpm.tx.hibernate.cfg.xml" />



这几个文件都在{jBPM4.4}的src目录中。

现在要做的和spring结合起来,因此在自己项目中,采用第一个配置:



其实这3个文件的差别也是不大,主要在于配置transaction-context上,而且如果采用spring的话,hibernate的配置进了spring的配置文件,因此在jbpm.tx.spring.cfg中,不需要有hibernate的配置,而另外2种方式,都要声明hibernate配置采用哪个文件。



样例的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" />

  <bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />

  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="configLocation" value="classpath:jbpm.hibernate.cfg.xml" />
    <property name="dataSource" ref="dataSource" />
  </bean>

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

  <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="@jdbc.driver@" />
    <property name="url" value="@jdbc.url@" />
    <property name="username" value="@jdbc.username@" />
    <property name="password" value="@jdbc.password@" />
  </bean>

</beans>

数据库的配置在spring配置文件中,单独的有一段:

 
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="configLocation" value="classpath:jbpm.hibernate.cfg.xml" />
    <property name="dataSource" ref="dataSource" />
  </bean>
而且数据源配置在spring的配置文件中,因此在hibernate的配置文件中,就不需要配置数据源了。

hibernate的配置文件:在{JBPM4.4}/install/src/cfg/hibernate/spring中:

以oracle的配置文件为例:


<?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.Oracle10gDialect</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>
在hibernate的配置文件中,见不到数据库的连接配置信息了,这样数据库连接可以在spring中统一配置,避免了在一个系统中,多处配置数据库连接的情况。



这样完成了jBPM4.4和spring的结合。(好像自己没做什么,就是看了一下jBPM提供的各种不同方式的组合。)

分享到:
评论

相关推荐

    Jbpm4.4+hibernate3.5.4+spring3.0.4+struts2.1.8整合

    Jbpm4.4+hibernate3.5.4+spring3.0.4+struts2.1.8整合 超级详细的文档,透彻讲解JBPM与SSH的整合过程

    Spring+hibernate4+SpringMVC+Jbpm4.4

    Spring+hibernate4+SpringMVC+Jbpm4.4 。Jbpm 4.4 整合 spring,数据库是mysql,hibernate大版本是4。供以后参考使用

    jbpm4.4整合spring2.5(ibatis与hibernate全整合)

    jbpm4.4整合spring2.5(ibatis与hibernate全整合)

    Jbpm4.4 整合Spring Hibernate4

    NULL 博文链接:https://1960370817.iteye.com/blog/2392653

    jbpm4.4+spring2.5.6+hibernate 3.6+struts2.2.1 集成 保证运行成功

    本人的实例 工具为myeclipse 9.0 解压后直接导入即可运行,类库已经包含不用添加了

    jbpm4.4+ssh整合

    jbpm4.4+ssh整合还需要安装插件进入到myeclipse中 将相应的jar文件放进去 就能够运行 jbpm4.4 jar ssh(strut2,hibernate3,spring3)三大框架整合的jar包 例子是 请假流程 代码中有很好的注释 便于初学者学习

    jbpm4.4学习笔记

    16 JBPM4.4+SSH+Tomcat整合 42 一.配置Spring相关文件: 42 二、配置Hibernate相关文件: 44 三、整合需要jbpm提供的jar包: 44 17 HelloWorld 45 Xml: 45 Code: 45 18 从数据库中取出xml文件和png图片 48 19 向...

    jbpm4.4整合s2sh 请假流程例子

    jbpm4.4整合s2sh 请假流程例子,项目很好,是学习JBPM的很好的例子,已经测试过,很好用,可以下载后好好研究一下

    jbpm4.4与ssh集成做的一个简单的会签例子

    新手,近段时间正在自学jbpm4.4,然后花了很长一段时间做会签,并与ssh集成,今天终于做出来。...开发环境为:jdk1.6.0_18+mysql5.1.48+jbpm4.4+struts2+spring3+hibernate3+ eclipse-jee-galileo-SR2-win32。

    Spring3.1 集成 JBPM4.4

    NULL 博文链接:https://guoyinjian.iteye.com/blog/1259538

    jbpm4.4+ssh+oracle + jqueryeasyui请假审批系统

    一个完整的工作流请假审批系统,代码注释很全,很容易看懂,非常适合初学者,分虽然高但绝对超值!反正评价完分还会返给你的,欢迎下载啦

    ssh+jbpm整合好的demo

    这个实例,是将strust2,hibernate,spring,jbpm4.4完美整合好的例子,可供大家参考使用!

    SSH+JBPM4实现请假流程

    一个请假流程的实现(struts2.1.8+spring2.5+hibernate3集成jbpm4.4)

    JBPM OA 实例

    struts2+spring+hibernate+jbpm4.4 实现OA 的一个例子 非常简单,很适合初学者

    浪曦航母战斗编队式企业级项目培训系列明细

    浪曦航母战斗编队式企业级项目培训系列明细 JAVA,JSP/Servlet基础 Struts2 Hibernate Spring ...浪曦JavaScript框架实战开发及应用 ...另配套附送本项目其它高级部分,手把手教学视频在浪曦...JBPM4.4开发销售工作流

    jbpm与SSH的整合

    有代码示例也有文档说明,适合学习JBPM的童鞋们上手

    JBPM4工作流应用开始指南.rar

    包括jBPM4扩展研发先决条件、深入jPDL和jBPM Service API、升级jBPM3到jBPM4、流程虚拟机原理、jBPM4的设计思想、随需而配jBPM4、异步工作执行器、深入jBPM4电子邮件支持、系统日志、jBPM4与Spring框架集成、jBPM4与...

    超级全面jar包

    该文件包含和spring framwork3和spring framwork4,jbpm-4.4,等常见框架jar包。(需要说明一下的是,使用hibernate的时候,要注意版本和spring framework 版本的问题!!)

    Spring攻略(第二版 中文高清版).part1

    1.2 配置Spring IoC容器中的Bean 4 1.2.1 问题 4 1.2.2 解决方案 4 1.2.3 工作原理 4 1.3 调用构造程序创建Bean 14 1.3.1 问题 14 1.3.2 解决方案 14 1.3.3 工作原理 14 1.4 解决构造程序歧义 17 ...

Global site tag (gtag.js) - Google Analytics