Improve transaction management
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 28 Jun 2008 18:49:58 +0000 (18:49 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 28 Jun 2008 18:49:58 +0000 (18:49 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@1316 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.slc.server/src/main/resources/org/argeo/slc/server/spring/servletContext.xml
org.argeo.slc.server/src/main/resources/org/argeo/slc/server/spring/slc-ws-servlet.xml
org.argeo.slc.server/src/main/resources/org/argeo/slc/server/spring/transaction.xml [new file with mode: 0644]

index 21efb5d087ee9ad18670a3bd808923b197b41079..651ddb2d843e7164f9677ce2ba03281e4292a6ab 100644 (file)
@@ -11,6 +11,7 @@
 
        <import
                resource="classpath:/org/argeo/slc/hibernate/spring/applicationContext.xml" />
+       <import resource="transaction.xml" />
 
        <!--  Default data source -->
        <bean
index 794d977824937f314855c243f8e91bb3c3a7e223..b6125df19faa479ac13a3cada339c910af1eec19 100644 (file)
        </bean>
 
        <bean class="org.argeo.slc.ws.CustomSoapExceptionResolver" />
-
-       <!-- Transaction -->
-
+       
+       <!-- Web Services transactions -->
        <aop:config>
                <aop:pointcut id="epMethods"
                        expression="execution(* org.springframework.ws.server.endpoint.MessageEndpoint.invoke(..))" />
 
        <tx:advice id="epAdvice" transaction-manager="transactionManager">
                <tx:attributes>
-                       <tx:method name="*" propagation="REQUIRES_NEW" />
+                       <tx:method name="*" propagation="REQUIRED" />
                </tx:attributes>
        </tx:advice>
-
 </beans>
\ No newline at end of file
diff --git a/org.argeo.slc.server/src/main/resources/org/argeo/slc/server/spring/transaction.xml b/org.argeo.slc.server/src/main/resources/org/argeo/slc/server/spring/transaction.xml
new file mode 100644 (file)
index 0000000..43cabb8
--- /dev/null
@@ -0,0 +1,51 @@
+<?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/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
+       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
+
+       <!-- Transaction -->
+       <bean id="transactionManager"
+               class="org.springframework.orm.hibernate3.HibernateTransactionManager"
+               lazy-init="false">
+               <property name="sessionFactory" ref="sessionFactory" />
+       </bean>
+
+       <!-- DAO transactions -->
+       <aop:config>
+               <aop:pointcut id="daoProcessMethods"
+                       expression="execution(* org.argeo.slc.dao.process.*.*(..))" />
+               <aop:advisor advice-ref="daoAdvice"
+                       pointcut-ref="daoProcessMethods" />
+       </aop:config>
+
+       <aop:config>
+               <aop:pointcut id="daoTestMethods"
+                       expression="execution(* org.argeo.slc.dao.test.*.*(..))" />
+               <aop:advisor advice-ref="daoAdvice"
+                       pointcut-ref="daoTestMethods" />
+       </aop:config>
+
+       <aop:config>
+               <aop:pointcut id="daoTestTreeMethods"
+                       expression="execution(* org.argeo.slc.dao.test.tree.*.*(..))" />
+               <aop:advisor advice-ref="daoAdvice"
+                       pointcut-ref="daoTestTreeMethods" />
+       </aop:config>
+
+       <tx:advice id="daoAdvice"
+               transaction-manager="transactionManager">
+               <tx:attributes>
+                       <tx:method name="get*" propagation="REQUIRED"
+                               read-only="true" />
+                       <tx:method name="list*" propagation="REQUIRED"
+                               read-only="true" />
+                       <tx:method name="*" propagation="REQUIRED" />
+               </tx:attributes>
+       </tx:advice>
+
+</beans>
\ No newline at end of file