Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (52 sloc) 2.67 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:context="http://www.springframework.org/schema/context"
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.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- In memory database & transaction manager -->
<bean id="uniqueDataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc:hsqldb:mem:a" />
<property name="username" value="sa" />
<property name="password" value="" />
</bean>
<bean id="transactionManager1"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="uniqueDataSource" />
</bean>
<!-- DAOs dumb and real one -->
<bean id="dumbDao" class="com.romanenco.transactions.impl.DumbDAOImpl" />
<bean id="uniqueDao" class="com.romanenco.transactions.impl.UniqueDAOImpl"
init-method="init">
<constructor-arg ref="uniqueDataSource" />
</bean>
<!-- Services -->
<bean id="service" class="com.romanenco.transactions.impl.ServiceImpl">
<constructor-arg ref="uniqueDao" />
<constructor-arg ref="dumbDao" />
</bean>
<bean name="localTx" class="com.romanenco.transactions.LocalTX">
<constructor-arg ref="service" />
</bean>
<!-- Service with program management -->
<bean name="localTxProgram" class="com.romanenco.transactions.LocalTXProgram">
<constructor-arg ref="transactionManager1" />
<constructor-arg ref="service" />
</bean>
<!-- Declarative transaction management -->
<tx:advice id="txAdvice" transaction-manager="transactionManager1">
<tx:attributes>
<tx:method name="*" rollback-for="Throwable"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="serviceOperation"
expression="execution(* com.romanenco.transactions.LocalTX.*(..))" />
<aop:advisor pointcut-ref="serviceOperation" advice-ref="txAdvice" />
</aop:config>
</beans>