ssh框架整合 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:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-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/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

<!-- 开启注解配置 -->
<context:annotation-config />
   
<!-- 对指定的包进行组件扫描 --><!-- ##########此处加包模块########### -->
<context:component-scan base-package="com.donglusoft.leavedemo" />
<context:component-scan base-package="com.donglusoft.bacterin" />
<context:component-scan base-package="com.donglusoft.charge" />
<context:component-scan base-package="com.donglusoft.goods" />
<context:component-scan base-package="com.donglusoft.stat" />
<context:component-scan base-package="com.donglusoft.healthcard" />
<context:component-scan base-package="com.donglusoft.hygienemonitor" />
<context:component-scan base-package="com.donglusoft.license" />
<context:component-scan base-package="com.donglusoft.officialdocument" />
<context:component-scan base-package="com.donglusoft.person" />
<context:component-scan base-package="com.donglusoft.rightmanagement" />
<context:component-scan base-package="com.donglusoft.sampletesting" />
<context:component-scan base-package="com.donglusoft.vehicle" />

<!-- 读取配置文件 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath*:conf/properties/jdbc.properties</value>
<value>classpath*:conf/properties/hibernate.properties</value>
</list>
</property>
</bean>

<!-- 配置数据源,导入c3p0-0.9.1.2.jar -->
<bean id="dataSourceImpl" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClassName}" />
<property name="jdbcUrl" value="${jdbc.url}" />
<property name="user" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<!--连接池中保留的最小连接数。-->
<property name="minPoolSize" value="5" />
<!--连接池中保留的最大连接数。Default: 15 -->
<property name="maxPoolSize" value="30" />
<!--初始化时获取的连接数,取值应在minPoolSize与maxPoolSize之间。Default: 3 -->
<property name="initialPoolSize" value="10" />
<!--最大空闲时间,600秒内未使用则连接被丢弃。若为0则永不丢弃。Default: 0 -->
<property name="maxIdleTime" value="600" />
<!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数。Default: 3 -->
<property name="acquireIncrement" value="5" />
<!--JDBC的标准参数,用以控制数据源内加载的PreparedStatements数量。但由于预缓存的statements 
属于单个connection而不是整个连接池。所以设置这个参数需要考虑到多方面的因素。   如果maxStatements与maxStatementsPerConnection均为0,则缓存被关闭。Default: 0-->
<property name="maxStatements" value="0" />
</bean>

<!-- 用p6spy 在console显示变量绑定后的真实sql 与ResultSet,方便开发 -->
<bean id="dataSource" class="com.p6spy.engine.spy.P6DataSource">
<constructor-arg ref="dataSourceImpl" />
</bean>

<!-- 集成hibernate配置 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSourceImpl" />
<property name="hibernateProperties" ref="hibernateProperties" />
<property name="mappingLocations">
<list>
<!-- 以下几个jbpm.*.hbm.xml由jBPM自带 -->
<value>classpath:jbpm.repository.hbm.xml</value>
<value>classpath:jbpm.execution.hbm.xml</value>
<value>classpath:jbpm.history.hbm.xml</value>
<value>classpath:jbpm.task.hbm.xml</value>
<value>classpath:jbpm.identity.hbm.xml</value>
<!-- #####华丽丽而又非常华丽丽的分界线#### =====注意可以使用通配符======  ### -->
<value>classpath*:com/donglusoft/leavedemo/entities/*.hbm.xml</value>
<value>classpath*:com/donglusoft/bacterin/domain/*.hbm.xml</value>
<value>classpath*:com/donglusoft/charge/domain/*.hbm.xml</value>
<value>classpath*:com/donglusoft/goods/domain/*.hbm.xml</value>
<value>classpath*:com/donglusoft/healthcard/domain/*.hbm.xml</value>
<value>classpath*:com/donglusoft/hygienemonitor/domain/*.hbm.xml</value>
<value>classpath*:com/donglusoft/license/domain/*.hbm.xml</value>
<value>classpath*:com/donglusoft/officialdocument/domain/*.hbm.xml</value>
<value>classpath*:com/donglusoft/person/domain/*.hbm.xml</value>
<value>classpath*:com/donglusoft/rightmanagement/domain/*.hbm.xml</value>
<value>classpath*:com/donglusoft/sampletesting/domain/*.hbm.xml</value>
<value>classpath*:com/donglusoft/vehicle/domain/*.hbm.xml</value>
</list>
</property>
</bean>
<bean name="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<!-- 当你使用mysql的时候,jbpm使用的是org.hibernate.dialect.MySQLInnoDBDialect -->
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
<prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>
<prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
<prop key="hibernate.use_sql_comments">${hibernate.use_sql_comments}</prop>
<prop key="hibernate.connection.driver_class">${hibernate.connection.driver_class}</prop>
<!--Hibernate的缓存部分,可以不用,直接在DAO层进行配置二级缓存 -->
<prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop>
<prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path">${hibernate.cache.provider_configuration_file_resource_path}</prop>
</props>
</property>
</bean>

<!-- jbpm配置 -->
<bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper" />
<bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />

<!-- 模板配置自己写的,不是必须的 -->
<bean id="jbpmTemplate" class="com.donglusoft.zzz.util.JbpmTemplate">
<property name="processEngine" ref="processEngine"></property>
</bean>

<!-- 数据层用的模板工具,不是必须的 -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>

<!-- 事务配置,必须 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager" abstract="false" lazy-init="default" autowire="default" dependency-check="default">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<!-- 切面配置  -->
<aop:config>
<aop:pointcut id="transactionPointcut1" expression="execution(* com.donglusoft.leavedemo.biz.*.*(..))" />
<aop:pointcut id="transactionPointcut2" expression="execution(* com.donglusoft.bacterin.service.*.*(..))" />
<aop:pointcut id="transactionPointcut3" expression="execution(* com.donglusoft.charge.service.*.*(..))" />
<aop:pointcut id="transactionPointcut4" expression="execution(* com.donglusoft.goods.service.*.*(..))" />
<aop:pointcut id="transactionPointcut5" expression="execution(* com.donglusoft.healthcard.service.*.*(..))" />
<aop:pointcut id="transactionPointcut6" expression="execution(* com.donglusoft.hygienemonitor.service.*.*(..))" />
<aop:pointcut id="transactionPointcut7" expression="execution(* com.donglusoft.license.service.*.*(..))" />
<aop:pointcut id="transactionPointcut8" expression="execution(* com.donglusoft.officialdocument.service.*.*(..))" />
<aop:pointcut id="transactionPointcut9" expression="execution(* com.donglusoft.person.service.*.*(..))" />
<aop:pointcut id="transactionPointcut10" expression="execution(* com.donglusoft.rightmanagement.service.*.*(..))" />
<aop:pointcut id="transactionPointcut11" expression="execution(* com.donglusoft.sampletesting.service.*.*(..))" />
<aop:pointcut id="transactionPointcut12" expression="execution(* com.donglusoft.vehicle.service.*.*(..))" />
<aop:pointcut id="transactionPointcut13" expression="execution(* com.donglusoft.leavedemo.service.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut1" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut2" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut3" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut4" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut5" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut6" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut7" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut8" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut9" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut10" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut11" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut12" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="transactionPointcut13" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="get*" read-only="true" propagation="NOT_SUPPORTED" />
<tx:method name="find*" read-only="true" propagation="NOT_SUPPORTED" />
<tx:method name="*" propagation="REQUIRED" />
<!--
<tx:method name="add*" propagation="REQUIRED" /> <tx:method name="del*" propagation="REQUIRED" /> <tx:method name="update*" propagation="REQUIRED" /> <tx:method name="*"
propagation="REQUIRED" /> <tx:method name="get*" propagation="SUPPORTS" read-only="true" /> <tx:method name="search*" propagation="SUPPORTS" read-only="true" />
-->
</tx:attributes>
</tx:advice>
</beans>

猜你喜欢

转载自ytlizen.iteye.com/blog/1273236