activiti5.13+Spring3.1.2+hibernate3.6.7整合

  新项目开始,因为以前对jbpm4比较熟悉,这次打算采用新的工作流框架,决定使用activiti5,下面是activiti5对Spring的整合
                首先是lib的选择
                activiti5的lib    
                activiti5内部采用mybatis作为持久化框架,所以还需要,mybatis的版本一定要和activiti5所用的版本对应。
               activiti5内部采用的是sl4j管理日志,所以还需要
               activiti5采用joda-time来处理时间
               剩下的就是spring跟hibernate的依赖jar

  
              lib包选择好以后,开始配置applicationContext.xml

  1. <beans xmlns="http://www.springframework.org/schema/beans"      
  2.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
  3.        xmlns:p="http://www.springframework.org/schema/p"       
  4.        xmlns:context="http://www.springframework.org/schema/context"  
  5.        xmlns:jee="http://www.springframework.org/schema/jee"   
  6.        xmlns:tx="http://www.springframework.org/schema/tx"      
  7.        xmlns:aop="http://www.springframework.org/schema/aop"      
  8.        xsi:schemaLocation="http://www.springframework.org/schema/beans      
  9.            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd      
  10.            http://www.springframework.org/schema/context      
  11.            http://www.springframework.org/schema/context/spring-context-3.0.xsd   
  12.            http://www.springframework.org/schema/jee  
  13.            http://www.springframework.org/schema/jee/spring-jee-3.0.xsd  
  14.            http://www.springframework.org/schema/tx     
  15.            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd      
  16.            http://www.springframework.org/schema/aop      
  17.            http://www.springframework.org/schema/aop/spring-aop-3.0.xsd      
  18.            ">  
  19.     <context:annotation-config />  
  20.     <context:component-scan base-package="org.ch01.sys"/>  
  21.   
  22.           
  23.     <!-- 建立数据源 -->  
  24.     <bean  
  25.         class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
  26.         <property name="locations">  
  27.             <value>classpath:jdbc.properties</value>  
  28.         </property>  
  29.     </bean>  
  30.       
  31.     <!-- 配置数据库连接池(c3p0) -->  
  32.     <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">  
  33.         <!-- 基本信息 -->  
  34.         <property name="jdbcUrl" value="${jdbcUrl}"></property>  
  35.         <property name="driverClass" value="${driverClass}"></property>  
  36.         <property name="user" value="${username}"></property>  
  37.         <property name="password" value="${password}"></property>  
  38.         <!-- 其他配置 -->  
  39.         <!--初始化时获取三个连接,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->  
  40.         <property name="initialPoolSize" value="3"></property>  
  41.         <!--连接池中保留的最小连接数。Default: 3 -->  
  42.         <property name="minPoolSize" value="3"></property>  
  43.         <!--连接池中保留的最大连接数。Default: 15 -->  
  44.         <property name="maxPoolSize" value="5"></property>  
  45.         <!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->  
  46.         <property name="acquireIncrement" value="3"></property>  
  47.         <!-- 控制数据源内加载的PreparedStatements数量。如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0 -->  
  48.         <property name="maxStatements" value="8"></property>  
  49.         <!-- maxStatementsPerConnection定义了连接池内单个连接所拥有的最大缓存statements数。Default: 0 -->  
  50.         <property name="maxStatementsPerConnection" value="5"></property>  
  51.         <!--最大空闲时间,1800秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->  
  52.         <property name="maxIdleTime" value="1800"></property>  
  53.     </bean>  
  54.       
  55.       
  56.       
  57.     <!-- 把数据源注入给session工厂 -->  
  58.     <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">  
  59.         <property name="dataSource" ref="dataSource" />  
  60.         <property name="packagesToScan">  
  61.             <list><value>org.ch01.sys.entity</value></list>  
  62.         </property>  
  63.         <!--  配置映射文件 -->  
  64.         <property name="hibernateProperties">  
  65.             <props>  
  66.                 <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>  
  67.                 <prop key="hbm2ddl.auto">update</prop>    
  68.                 <prop key="hibernate.show_sql">true</prop>  
  69.                 <prop key="hibernate.format_sql">true</prop>   
  70.             </props>  
  71.         </property>  
  72.     </bean>  
  73.       
  74.     <!-- 配置事务管理器 -->  
  75.     <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" p:sessionFactory-ref="sessionFactory"/>  
  76.       
  77.     <!-- 使用声明式配置事物(事务通知) -->  
  78.     <!--Spring中常用事务类型:  
  79.          REQUIRED       支持当前事务,如果当前没有事务,就新建一个事务。这是最常见的选择。  
  80.          SUPPORTS       支持当前事务,如果当前没有事务,就以非事务方式执行。  
  81.          MANDATORY      支持当前事务,如果当前没有事务,就抛出异常。  
  82.          REQUIRES_NEW   新建事务,如果当前存在事务,把当前事务挂起。  
  83.          NOT_SUPPORTED  以非事务方式执行操作,如果当前存在事务,就把当前事务挂起。  
  84.          NEVER          以非事务方式执行,如果当前存在事务,则抛出异常。      
  85.      -->  
  86.     <!-- transaction-manager引用上面的事务管理器 -->         
  87.     <tx:advice id="txAdvice" transaction-manager="transactionManager">  
  88.       <tx:attributes>  
  89.         <tx:method name="*" propagation="REQUIRED"/>  
  90.       </tx:attributes>       
  91.     </tx:advice>     
  92.       
  93.     <!-- 将通知应用到指定的切入点 -->  
  94.      <aop:config>   
  95.        <!--指定切入点 -->  
  96.       <aop:pointcut id="txService" expression="execution(* org.ch01.sys.service.*.*.*(..))"/>  
  97.       <!--  advice-ref引用上面的事务通知,pointcut-ref指定上面配置的切入点 -->  
  98.       <aop:advisor advice-ref="txAdvice" pointcut-ref="txService"/>  
  99.     </aop:config>  
  100.       
  101.       
  102.   <!-- activiti5集成spring配置 -->  
  103.   <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">  
  104.     <property name="dataSource" ref="dataSource" />  
  105.     <property name="transactionManager" ref="transactionManager" />  
  106.     <property name="databaseSchemaUpdate" value="true" />  
  107.     <property name="jobExecutorActivate" value="false" />  
  108.   </bean>  
  109.     
  110.   <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">  
  111.     <property name="processEngineConfiguration" ref="processEngineConfiguration" />  
  112.   </bean>  
  113.     
  114.   <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />  
  115.   <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />  
  116.   <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />  
  117.   <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />  
  118.   <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />  
  119.       
  120.       
  121.   
  122.   
  123. </beans>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值