<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location"> <value>file:./jdbc.properties</value> </property> </bean> <!--定义数据源--> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <!--定义数据库驱动 --> <property name="driverClass"><value>${jdbc.driver}</value></property> <!--定义数据库url --><!-- <property name="jdbcUrl"><value>jdbc:mysql://192.168.0.115:3306/fft-test?useUnicode=true&characterEncoding=UTF-8</value></property> --> <!--这样写避免向数据库添加或更新数据时出现乱码,useUnicode=true&characterEncoding=UTF-8不写在.properties文件中--> <property name="jdbcUrl"><value>${jdbc.url}?useUnicode=true&characterEncoding=UTF-8</value></property> <!-- 定义数据库用户名 --> <property name="user"><value>${jdbc.user}</value></property> <!--定义数据库密码 --> <property name="password"><value>${jdbc.password}</value></property> <property name="maxPoolSize"><value>${jdbc.maxPoolSize}</value></property> <property name="initialPoolSize"><value>${jdbc.initialPoolSize}</value></property> <property name="minPoolSize"><value>${jdbc.minPoolSize}</value></property> </bean> <!--定义一个hibernate的SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <!-- 定义SessionFactory必须注入DataSource--> <property name="dataSource"><ref local="dataSource"/></property> <property name="mappingResources"> <list> <!--以下用来列出所有的PO映射文件--> <value>com/taisys/ota/model/AccountGroup.hbm.xml</value> <value>com/taisys/ota/model/Account.hbm.xml</value> <value>com/taisys/ota/model/cardVendor.hbm.xml</value> <value>com/taisys/ota/model/cardDefinition.hbm.xml</value> <value>com/taisys/ota/model/CardProfile.hbm.xml</value> <value>com/taisys/ota/model/Card.hbm.xml</value> <value>com/taisys/ota/model/Permission.hbm.xml</value> <value>com/taisys/ota/model/Service.hbm.xml</value> <value>com/taisys/ota/model/cardKeySet.hbm.xml</value> <value>com/taisys/ota/model/Key.hbm.xml</value> <value>com/taisys/ota/model/cardProfleContent.hbm.xml</value> <value>com/taisys/ota/model/message.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <!--此处用来定义hibernate的SessionFactory的属性: 不同数据库连接,启动时选择create,update,create-drop--> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop> <prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop> <!-- open cache --> <prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop> <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop> <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop> <prop key="hibernate.query.factory_class">${hibernate.query.factory_class}</prop> <prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop> <prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop> <prop key="hibernate.jdbc.use_streams_for_binary">${hibernate.jdbc.use_streams_for_binary}</prop> <prop key="hibernate.c3p0.max_statements">${hibernate.c3p0.max_statements}</prop> <prop key="hibernate.c3p0.maxStatementsPerConnection">${hibernate.c3p0.maxStatementsPerConnection}</prop> </props> </property> <property name="lobHandler"> <ref bean="lobHandler"/> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <!-- HibernateTransactionManager bean需要依赖注入一个SessionFactory bean的引用--> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean> <!-- Hibernate Transaction Interceptor Definition --> <bean id="hibernateTransactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor" parent="transactionIntercetorTemplate"> <property name="transactionManager"> <bean id="hibernateTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> </property> </bean> <!-- Transction Intercetor's Template --> <bean id="transactionIntercetorTemplate" abstract="true"> <property name="transactionAttributes"> <props> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="is*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="check*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="insert*">PROPAGATION_REQUIRED</prop> <prop key="save">PROPAGATION_REQUIRED,-BussException,-SQLException</prop> <prop key="send">PROPAGATION_REQUIRED,-BussException,-TimeoutException, -GatewayException, -IOException, -InterruptedException</prop> <prop key="update*">PROPAGATION_REQUIRED,-BussException,-SQLException</prop> <prop key="delete*">PROPAGATION_REQUIRED,-BussException,-SQLException</prop> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <bean id="jdbcTransactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor" parent="transactionIntercetorTemplate"> <property name="transactionManager"> <bean id="jdbcTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource"> <ref bean="dataSource" /> </property> </bean> </property> </bean> <!-- 定义自动代理生成器--> <bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"> <property name="interceptorNames"> <list> <idref bean="hibernateTransactionInterceptor" /> <idref bean="jdbcTransactionInterceptor" /> </list> </property> <!--<property name="beanNames"> <list> <idref bean="messagePacketService"/> </list> 添加Service bean </property> --></bean> <bean id="hibernateDaoTemplate" abstract="true"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler"/> <bean id="accountDao" class="com.taisys.ota.dao.AccountDao"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <bean id="cardProfileDao" class="com.taisys.ota.dao.CardProfileDao"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <bean id="cardDao" class="com.taisys.ota.dao.CardDao"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <bean id="keySetDao" class="com.taisys.ota.dao.KeysetDao"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <bean id="systemServiceDao" class="com.taisys.ota.dao.SystemServcieDao"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <bean id="otaSysMsgDao" class="com.taisys.ota.dao.OTASysMsgDao"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <bean id="otaRMIService" class="com.taisys.ota.service.OtaRMIService"> <property name="accountDao" > <ref bean="accountDao"/> </property> <property name="cardProfileDao" > <ref bean="cardProfileDao"/> </property> <property name="cardDao" > <ref bean="cardDao"/> </property> <property name="keySetDao" > <ref bean="keySetDao"/> </property> <property name="systemServiceDao" > <ref bean="systemServiceDao"/> </property> <property name="otaSysMsgDao" > <ref bean="otaSysMsgDao"/> </property> </bean> <bean id="serviceExporter" class="org.springframework.remoting.rmi.RmiServiceExporter"> <property name="service"> <ref bean="otaRMIService"/> </property> <property name="serviceName"> <value>${rmi.serviceName}</value> </property> <property name="serviceInterface"> <value>com.taisys.ota.service.IOtaRMIService</value> </property> <property name="registryPort"> <value>${rmi.registryPort}</value> </property> </bean> <bean id="otaRMIServiceProxy" class="org.springframework.remoting.rmi.RmiProxyFactoryBean"> <property name="serviceUrl"> <value>${rmi.address}</value> </property> <property name="serviceInterface"> <value>${rmi.serviceInterface}</value> </property> </bean> </beans>