<?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:tx="http://www.springframework.org/schema/tx"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="
	http://www.springframework.org/schema/beans
	http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
	http://www.springframework.org/schema/aop
	http://www.springframework.org/schema/aop/spring-aop-3.1.xsd 
	http://www.springframework.org/schema/tx
	http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
	http://www.springframework.org/schema/context
	http://www.springframework.org/schema/context/spring-context-3.1.xsd
	">

	<bean id="dataSource"
		class="org.apache.commons.dbcp.BasicDataSource">
		<property name="url"
			value="jdbc:mysql://219.216.65.127/scan_progress">
		</property>
		<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
		<property name="username" value="root"></property>
		<property name="password" value="narata"></property>
	</bean>
	<bean id="dataSourceScada"
		class="org.apache.commons.dbcp.BasicDataSource">
		<property name="url"
			value="jdbc:mysql://219.216.65.127/scada_scan">
		</property>
		<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
		<property name="username" value="root"></property>
		<property name="password" value="narata"></property>
	</bean>
	<bean id="sessionFactoryScada"
		class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
		<property name="dataSource">
			<ref bean="dataSourceScada" />
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">
					org.hibernate.dialect.MySQLDialect
				</prop>
				<!-- 在Console显示数据库语句 -->
				<prop key="hibernate.show_sql">true</prop>
				<!-- 超时重新连接数据库 -->
				<prop key="hibernate.autoReconnect">true</prop>
				
			</props>
		</property>
		<!-- 通过扫描包的方式批量加载vo实体 -->
		<property name="packagesToScan" value="com.ps.vo" />
		</bean>
	
	
	
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
		<property name="dataSource">
			<ref bean="dataSource" />
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">
					org.hibernate.dialect.MySQLDialect
				</prop>
				<!-- 在Console显示数据库语句 -->
				<prop key="hibernate.show_sql">true</prop>
				<!-- 超时重新连接数据库 -->
				<prop key="hibernate.autoReconnect">true</prop>
				
			</props>
		</property>
		<!-- 通过扫描包的方式批量加载vo实体 -->
		<property name="packagesToScan" value="com.ps.vo" />
		<!-- 一个个加载vo实体 <property name="annotatedClasses"> <list> <value>neu.cse.ctic.supervise.vo.Cnvd</value></list> 
			</property> -->

		<!--  <property name="annotatedClasses">
			<list>
				<value>com.ps.visualization.vo.CountryProgress</value>
				<value>com.ps.visualization.vo.ProtocolProgress</value>
				<value>com.ps.visualization.vo.ScanSpeed</value>
				<value>com.ps.visualization.vo.Portsinfo</value>
				<value>com.ps.visualization.vo.RegnameProgress</value>
				<value>com.ps.visualization.vo.PortsinfoClear</value>
			</list>
		</property>
		-->
		</bean>
	<bean id="transactionManager"
		class="org.springframework.orm.hibernate4.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	<tx:advice id="txAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="save*" propagation="REQUIRED" read-only="false" />
			<tx:method name="add*" propagation="REQUIRED" read-only="false" />
			<tx:method name="insert*" propagation="REQUIRED" read-only="false" />
			<tx:method name="create*" propagation="REQUIRED" read-only="false" />
			<tx:method name="update*" propagation="REQUIRED" read-only="false" />
			<tx:method name="delete*" propagation="REQUIRED" read-only="false" />
			<tx:method name="find*" propagation="REQUIRED" read-only="true" />
			<tx:method name="get*" propagation="REQUIRED" read-only="true" />
			<tx:method name="is*" propagation="REQUIRED" read-only="true" />
			<tx:method name="*" propagation="REQUIRED" read-only="true" />
		</tx:attributes>
	</tx:advice>
		<bean id="transactionManagerScada"
		class="org.springframework.orm.hibernate4.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactoryScada" />
	</bean>
	
	<aop:config expose-proxy="true">
		<aop:pointcut id="txPointcut"
			expression="execution(* com.ps.visualization.dao.*.*(..)) || execution(* com.ps.base.dao.*.*(..))" />
		<aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut" />
	</aop:config>

	<!-- 指明需要扫描的包 -->
	<context:component-scan base-package="com.ps" />
	<!--  <tx:annotation-driven transaction-manager="transactionManager" />-->
	</beans>