`
bh三少
  • 浏览: 102052 次
  • 性别: Icon_minigender_1
  • 来自: 北海
社区版块
存档分类
最新评论

ssh与jbpm4.3的整合

阅读更多
首先说一下环境,spring3.0+struts2+hibernate3.4.0+jbpm4.3
jbpm的配置文件:logging.properties,jbpm.mail.properties,jbpm.mail.templates.examples.xml这三个配置文件就先不说了。主要是jbpm.cfg.xml和jbpm.hibernate.cfg.xml。
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" />
  <import resource="jbpm.tx.spring.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.mail.templates.examples.xml" />
 
  <process-engine-context>
  <!-- <string name="spring.cfg" value="applicationContext-jbpm.xml" />-->
 
  <command-service name="txRequiredCommandService">
  <retry-interceptor />
  <environment-interceptor />
  <spring-transaction-interceptor current="true" />
  </command-service>
 
  <command-service name="newTxRequiredCommandService">
  <retry-interceptor />
  <environment-interceptor />
  <spring-transaction-interceptor current="true" />
  </command-service>
  </process-engine-context>
 
  <transaction-context>
  <hibernate-session factory="sessionFactory" current="true" />
  </transaction-context>
 
</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="current_session_context_class">thread</property>-->
    <!-- property name="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</property -->

<property name="hibernate.hbm2ddl.auto">create-drop</property><!--update也可以-->

<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-jbpm.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-3.0.xsd
                           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
                           http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
                           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" />

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

<bean id="processEngineWireContext" factory-bean="processEngine" factory-method="getProcessEngineWireContext" /> 

    <!--这样写是因为jbpm4.3有一个循环引用的bug-->  
    <bean id="repositoryService" factory-bean="processEngineWireContext" factory-method="get"> 
    <constructor-arg> 
     <value type="java.lang.Class">org.jbpm.api.RepositoryService</value> 
    </constructor-arg> 
    </bean>
    <bean id="executionService" factory-bean="processEngineWireContext" factory-method="get"> 
    <constructor-arg> 
     <value type="java.lang.Class">org.jbpm.api.ExecutionService</value> 
    </constructor-arg> 
    </bean>
    <bean id="managementService" factory-bean="processEngineWireContext" factory-method="get"> 
    <constructor-arg> 
     <value type="java.lang.Class">org.jbpm.api.ManagementService</value> 
    </constructor-arg> 
    </bean>
    <bean id="taskService" factory-bean="processEngineWireContext" factory-method="get"> 
    <constructor-arg> 
     <value type="java.lang.Class">org.jbpm.api.TaskService</value> 
    </constructor-arg> 
    </bean>
    <bean id="historyService" factory-bean="processEngineWireContext" factory-method="get"> 
    <constructor-arg> 
     <value type="java.lang.Class">org.jbpm.api.HistoryService</value> 
    </constructor-arg> 
    </bean>
    <bean id="identityService" factory-bean="processEngineWireContext" factory-method="get"> 
    <constructor-arg> 
     <value type="java.lang.Class">org.jbpm.api.IdentityService</value> 
    </constructor-arg> 
    </bean>
   
</beans>

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


<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
                           http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
                           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">


    <!-- ========================= GENERAL DEFINITIONS ========================= -->

    <!-- Configurer that replaces ${...} placeholders with values from properties files -->
    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:conf/jdbc.properties</value>
                <value>classpath:conf/hibernate/hibernate.properties</value>  
            </list>
        </property>
    </bean>
   
    <context:component-scan base-package="com.asiasoft.ecrm"/>

<!-- Local Apache Commons DBCP DataSource that refers to a combined database -->
<!-- The placeholders are resolved from jdbc.properties through the PropertyPlaceholderConfigurer in applicationContext.xml -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>

<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configLocation" value="classpath:jbpm.hibernate.cfg.xml" />
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.asiasoft.ecrm.corebiz.entity.*" />

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
<prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>
<prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
</props>
</property>
</bean>

<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
<property name="dataSource" ref="dataSource" />

</bean>

<bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate">
<property name="transactionManager" ref="transactionManager" />
</bean>

    <!-- ========================= BUSINESS OBJECT DEFINITIONS ========================= -->

    <!--
        Activates various annotations to be detected in bean classes: Spring's
        @Required and @Autowired, as well as JSR 250's @PostConstruct,
        @PreDestroy and @Resource (if available) and JPA's @PersistenceContext
        and @PersistenceUnit (if available).
        The implicitly registered post-processors include:
        1. AutowiredAnnotationBeanPostProcessor,
        2. CommonAnnotationBeanPostProcessor,
        3. PersistenceAnnotationBeanPostProcessor,
        4. RequiredAnnotationBeanPostProcessor.
    -->
    <context:annotation-config />

    <!--
        Instruct Spring to retrieve and apply @AspectJ aspects which are defined
        as beans in this context.
    -->
    <aop:aspectj-autoproxy />


    <!-- ========================= Aspect Configuration ======================== -->

    <aop:config>
        <!--
            This definition creates auto-proxy infrastructure based on the given pointcut,
            expressed in AspectJ pointcut language. Here: applying the advice named
            "txAdvice" to all methods defined in the com.asiasoft.ecrm.corebiz package
            or any sub-package under that.
        -->
        <aop:advisor pointcut="within(com.asiasoft.ecrm.corebiz.service..*)" advice-ref="txAdvice"/>
    </aop:config>

    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="*"/>
        </tx:attributes>
    </tx:advice>

</beans>

这样就可整合成了!
分享到:
评论
1 楼 lykm02 2011-01-06  
jbpm.cfg.xml好像有一部分内容和tx.spring.cfg.xml 中重复了

相关推荐

    SSH 与jbpm4.3 整合的资料以及ssh的jar包

    `ssh整合需要的jar包目录.doc`应该列出了整合SSH与jbpm4.3所需的所有依赖库,包括SSH框架的jar包和jbpm4.3的jar包,这对于正确构建项目环境至关重要。 总之,SSH与jbpm4.3的整合是企业级应用中常见的技术实践,它能...

    SSH+JBPM4.3的整合 JBPM4.3

    SSH+JBPM4.3的整合是企业级应用开发中的一种常见组合,SSH指的是Spring、Struts和Hibernate这三个开源框架的集成,而JBPM4.3则是一个强大的工作流管理系统,用于实现业务流程自动化。这篇内容将深入探讨这两个技术...

    JBPM4.3 整合SSH part1 JBPM4.3 整合 struts2 hibernate spring 请假实例

    JBPM4.3 整合struts2 hibernate spring 请假实例, lib下载,在我的另外资源,路径: http://download.csdn.net/source/2485359 http://download.csdn.net/source/2485373 http://download.csdn.net/source/2485385 ...

    jbpm4.3所需jar包

    **jbpm4.3所需jar包** JBPM(Java Business Process Management)是一个开源的工作流管理系统,主要用于业务流程的建模、执行和管理。在JBPM 4.3版本中,为了实现完整功能,需要一系列的jar包来支持其运行环境。...

    JBPM4.3 整合SSH lib part7

    JBPM4.3 整合SSH lib part7 源码在另外一个资源: http://download.csdn.net/source/2485339

    JBPM4.3 整合SSH lib part3

    JBPM4.3 整合SSH lib part3 源码在另外一个资源: http://download.csdn.net/source/2485339

    JBPM4.3 整合SSH lib part1

    JBPM4.3 整合SSH lib part1 源码在另外一个资源: http://download.csdn.net/source/2485339

    JBPM4.3 整合SSH lib part4

    JBPM4.3 整合SSH lib part3 源码在另外一个资源: http://download.csdn.net/source/2485339

    JBPM4.3 整合SSH lib part6

    JBPM4.3 整合SSH lib part6 源码在另外一个资源: http://download.csdn.net/source/2485339

    JBPM4.3 整合SSH lib part5

    JBPM4.3 整合SSH lib part5 源码在另外一个资源: http://download.csdn.net/source/2485339

    JBPM4.3 整合SSH lib part2

    JBPM4.3 整合SSH lib part2 源码在另外一个资源: http://download.csdn.net/source/2485339

    请假工作流JBPM整合SSH2完整实例

    在"请假工作流"实例中,SSH2与JBPM4.3的整合可能涉及以下步骤: 1. **集成Spring和JBPM**: 利用Spring的Bean管理功能,配置和管理JBPM的相关组件,如流程引擎、工作单元等。 2. **Struts2控制器**: 创建Struts2 ...

    jbpm 整合 ssh框架

    将jbpm整合到SSH框架中,可以实现业务流程与应用服务的无缝结合,提高系统的可维护性和灵活性。 在jbpm整合SSH的过程中,主要涉及以下几个关键点: 1. **jbpm与Spring的集成**: - **Spring管理jbpm**: 通过...

    jbpm与ssh的集成

    3. **整合Hibernate**:jbpm4.3版本可以与Hibernate结合,通过HibernateSession来管理数据库事务。在jbpm配置中,指定Hibernate的SessionFactory,确保jbpm的数据操作与应用的其他数据操作在同一个事务中进行。 4. ...

    jbpm工作流

    它与SSH(Struts、Spring、Hibernate)三大框架的整合,为开发者提供了一种高效且灵活的业务流程自动化解决方案。SSH框架组合是Java开发中的常用技术栈,Struts负责控制层,Spring处理业务逻辑和依赖注入,Hibernate...

    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 向...

Global site tag (gtag.js) - Google Analytics