-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathdefault_applicationContext.xml
More file actions
151 lines (135 loc) · 7.8 KB
/
default_applicationContext.xml
File metadata and controls
151 lines (135 loc) · 7.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?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/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
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
<!-- 注解 -->
<context:annotation-config/>
<!-- 扫描包 -->
<context:component-scan base-package="com.zhaidaosi.game.server.sdm"/>
<!-- 代理 -->
<aop:aspectj-autoproxy/>
<context:property-placeholder location="classpath*:jdbc.properties" />
<!-- bonecp连接池配置 -->
<bean id="parentDataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close"/>
<!-- jgframework 主数据源-->
<bean id="jgframeworkMasterDataSource" parent="parentDataSource">
<property name="driverClass" value="${jgframework.master.jdbc.driverClassName}" />
<property name="jdbcUrl" value="${jgframework.master.jdbc.url}" />
<property name="username" value="${jgframework.master.jdbc.username}" />
<property name="password" value="${jgframework.master.jdbc.password}" />
<property name="partitionCount" value="${jgframework.master.jdbc.partitionCount}"/>
<property name="maxConnectionsPerPartition" value="${jgframework.master.jdbc.maxConnectionsPerPartition}"/>
<property name="minConnectionsPerPartition" value="${jgframework.master.jdbc.minConnectionsPerPartition}"/>
<property name="poolName" value="jgframework-master-pool"/>
<property name="lazyInit" value="true"/>
</bean>
<!-- jgframework 从数据源-->
<bean id="jgframeworkSlaveDataSource" parent="parentDataSource">
<property name="driverClass" value="${jgframework.slave.jdbc.driverClassName}" />
<property name="jdbcUrl" value="${jgframework.slave.jdbc.url}" />
<property name="username" value="${jgframework.slave.jdbc.username}" />
<property name="password" value="${jgframework.slave.jdbc.password}"/>
<property name="partitionCount" value="${jgframework.slave.jdbc.partitionCount}"/>
<property name="maxConnectionsPerPartition" value="${jgframework.slave.jdbc.maxConnectionsPerPartition}"/>
<property name="minConnectionsPerPartition" value="${jgframework.slave.jdbc.minConnectionsPerPartition}"/>
<property name="poolName" value="jgframework-slave-pool"/>
</bean>
<!-- cronweb 主数据源-->
<bean id="cronwebMasterDataSource" parent="parentDataSource">
<property name="driverClass" value="${cronweb.master.jdbc.driverClassName}" />
<property name="jdbcUrl" value="${cronweb.master.jdbc.url}" />
<property name="username" value="${cronweb.master.jdbc.username}" />
<property name="password" value="${cronweb.master.jdbc.password}" />
<property name="partitionCount" value="${cronweb.master.jdbc.partitionCount}"/>
<property name="maxConnectionsPerPartition" value="${cronweb.master.jdbc.maxConnectionsPerPartition}"/>
<property name="minConnectionsPerPartition" value="${cronweb.master.jdbc.minConnectionsPerPartition}"/>
<property name="poolName" value="cronweb-master-pool"/>
<property name="lazyInit" value="true"/>
</bean>
<!-- cronweb 从数据源-->
<bean id="cronwebSlaveDataSource" parent="parentDataSource">
<property name="driverClass" value="${cronweb.slave.jdbc.driverClassName}" />
<property name="jdbcUrl" value="${cronweb.slave.jdbc.url}" />
<property name="username" value="${cronweb.slave.jdbc.username}" />
<property name="password" value="${cronweb.slave.jdbc.password}"/>
<property name="partitionCount" value="${cronweb.slave.jdbc.partitionCount}"/>
<property name="maxConnectionsPerPartition" value="${cronweb.slave.jdbc.maxConnectionsPerPartition}"/>
<property name="minConnectionsPerPartition" value="${cronweb.slave.jdbc.minConnectionsPerPartition}"/>
<property name="poolName" value="cronweb-slave-pool"/>
</bean>
<bean id="dataSource" class="com.zhaidaosi.game.jgframework.common.spring.DynamicDataSource">
<property name="targetDataSources">
<map key-type="java.lang.String">
<entry key="cronweb-master" value-ref="cronwebMasterDataSource" />
<entry key="cronweb-slave" value-ref="cronwebSlaveDataSource" />
<entry key="jgframework-master" value-ref="jgframeworkMasterDataSource" />
<entry key="jgframework-slave" value-ref="jgframeworkSlaveDataSource" />
</map>
</property>
<property name="defaultTargetDataSource" ref="jgframeworkSlaveDataSource" />
<property name="defaultDatabase" value="jgframework"/>
</bean>
<!-- 自己定义的扫描模型类 -->
<bean id="sessionFactory" class="com.zhaidaosi.game.jgframework.common.spring.AnnotationSessionFactoryBeanEx">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.hbm2ddl.auto">none</prop><!-- update -->
</props>
</property>
<property name="annotatedClassesLocations">
<list>
<value>classpath*:com/zhaidaosi/game/server/sdm/model/*.class</value>
</list>
</property>
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 定义事务管理器 -->
<bean id="txManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 加载事务驱动 -->
<tx:annotation-driven transaction-manager="txManager"/>
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="total*" read-only="true" propagation="SUPPORTS"/>
<tx:method name="find*" read-only="true" propagation="SUPPORTS"/>
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<!-- 切换数据库 -->
<bean id="dataSourceAdvice" class="com.zhaidaosi.game.jgframework.common.spring.DataSourceAdvice" />
<aop:config>
<aop:pointcut id="bussinessService" expression="execution(public * com.zhaidaosi.game.server.sdm.service..*.*(..))" />
<aop:advisor pointcut-ref="bussinessService" advice-ref="dataSourceAdvice" />
<aop:advisor pointcut-ref="bussinessService" advice-ref="txAdvice" />
</aop:config>
<aop:config>
<aop:pointcut id="frameworkbussinessService" expression="execution(public * com.zhaidaosi.game.jgframework.common.sdm.BaseService.*(..))" />
<aop:advisor pointcut-ref="frameworkbussinessService" advice-ref="dataSourceAdvice" />
<aop:advisor pointcut-ref="frameworkbussinessService" advice-ref="txAdvice" />
</aop:config>
<!-- service beans -->
<!-- scope="prototype" -->
<bean id="CronModelService" class="com.zhaidaosi.game.server.sdm.service.CronModelService"/>
<bean id="UserService" class="com.zhaidaosi.game.server.sdm.service.UserService"/>
</beans>