applicationContext_common.xml 5.0 KB
<?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: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/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">
	
	<!-- 1、配置C3P0,数据源 -->
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
		<property name="driverClassName">
			<value>com.mysql.jdbc.Driver</value>
		</property>
		<property name="url">
			<value>jdbc:mysql://localhost:3306/yxybase?useUnicode=true&amp;characterEncoding=utf8&amp;autoReconnect=true</value>
		</property>
		<property name="username">
			<value>root</value>
		</property>
		<property name="password">
			<value>sz1234567890</value>
		</property>
		<property name="maxActive">
			<value>100</value>
		</property>
        <property name="maxIdle">
        	<value>50</value>
        </property>
        <property name="initialSize">
        	<value>30</value>
        </property>
        <property name="maxWait">
        	<value>10000</value>
        </property>
        <property name="defaultAutoCommit">
        	<value>true</value>
        </property>
        <property name="removeAbandoned">
			<value>true</value>        
        </property>
        <property name="removeAbandonedTimeout">
        	<value>300</value>
        </property>
        <property name="logAbandoned">
        	<value>false</value>
        </property>
        <property name="validationQuery">
        	<value>select 1</value>
        </property>
        <property name="testOnBorrow">  
        	<value>true</value>
        </property>
	</bean>
	
	<!-- 2、配置注解sessionFactory -->
	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
		<!-- 数据源注入 -->
		<property name="dataSource" ref="dataSource" />
		<property name="packagesToScan">
			<list>
				<value>com.espeed.pojo</value>
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
				<prop key="hibernate.show_sql">true</prop>
				<!-- 如果开启, Hibernate将收集有助于性能调节的统计数据. 取值 true | false -->
				<prop key="hibernate.generate_statistics">true</prop>
				<!-- 指定Hibernate在何时释放JDBC连接. -->
				<prop key="hibernate.connetion.release_mode">auto</prop>
			</props>
		</property>
	</bean>
	
	<!--配置公共的hibernate方法注解  -->  
	<bean id="AnnhibernateBaseDAO" class="com.espeed.dao.impl.HibernateBaseDAOImpl" abstract="true" scope="prototype">
		<property name="sessionFactory" ref="sessionFactory"/>
	</bean>
	
	<!--3、配置spring事务(AOP)  -->
	<!-- 事务管理器 -->
	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
		
	<!-- 事务的传播特性(propagation) -->
	<tx:advice id="txAdvice" transaction-manager="transactionManager">  
		<tx:attributes>  
	    	<tx:method name="del*"/>  
	        <tx:method name="save*" />  
	        <tx:method name="update*" />  
	        <tx:method name="edit*" />
	        <tx:method name="add*" />  
	        <tx:method name="insert*" /> 
	       	<tx:method name="get*" propagation="SUPPORTS" read-only="true"/>  
	        <tx:method name="load*" propagation="SUPPORTS" read-only="true"/>  
	        <tx:method name="list*" propagation="SUPPORTS" read-only="true"/>  
	        <tx:method name="*" propagation="SUPPORTS" read-only="true"/> 
	    </tx:attributes>  
   	</tx:advice>  
   	<!-- 配置哪些类哪些方法具有事务 ,采用AOP-->
	<aop:config>
		<aop:pointcut expression="execution(* com.espeed.service.*.*(..))" id="allMethod"/>
		<aop:advisor pointcut-ref="allMethod" advice-ref="txAdvice"/>
	</aop:config>
	
	<!-- 注入SpringFactory类 -->
	<bean id="springfactory"  class="com.espeed.tool.SpringFactory">
	</bean>
	
	<!-- VO配置 -->
	 <bean id="pagebean" class="com.espeed.vo.PageBean" scope="prototype">
	 	<property name="pageSize" value="5"/>
	 	<property name="currentPage" value="1"/>
	 </bean>
	<!-- POJO配置 -->
	
	<!-- 待发邮件实体-->
	<bean id="yxysendmailmaster" class="com.espeed.pojo.YxySendMailMaster"></bean>
	<!-- 邮件信息实体
	<bean id="yxysendmaildetail" class="com.espeed.pojo.YxySendMailDetail"></bean> -->
	<!-- 待发邮件地址实体-->
	<bean id="yxysendmaildetail" class="com.espeed.pojo.YxySendMailDetail"></bean> 
	<!-- 用户文件类别-->
	<bean id="yxymailfolder" class="com.espeed.pojo.YxyMailFolder"></bean> 
	<!-- 发件人配置 -->
	<bean id="yxysenderset" class="com.espeed.pojo.YxySenderSet" ></bean>
</beans>