camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r674185 - in /activemq/camel/trunk/components/camel-spring/src: main/java/org/apache/camel/spring/spi/ test/java/org/apache/camel/spring/interceptor/ test/resources/org/apache/camel/spring/interceptor/
Date Sat, 05 Jul 2008 12:04:58 GMT
Author: davsclaus
Date: Sat Jul  5 05:04:57 2008
New Revision: 674185

URL: http://svn.apache.org/viewvc?rev=674185&view=rev
Log:
CAMEL-668: Spring friendly configuration of transactional policy

Modified:
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTest.java
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionalClientDataSource.xml

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java?rev=674185&r1=674184&r2=674185&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java
Sat Jul  5 05:04:57 2008
@@ -21,6 +21,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.springframework.transaction.support.TransactionTemplate;
+import org.springframework.transaction.PlatformTransactionManager;
 
 /**
  * Wraps the processor in a Spring transaction
@@ -31,6 +32,12 @@
     private static final transient Log LOG = LogFactory.getLog(SpringTransactionPolicy.class);
     private TransactionTemplate template;
 
+    /**
+     * Default constructor for easy spring configuration.
+     */
+    public SpringTransactionPolicy() {
+    }
+
     public SpringTransactionPolicy(TransactionTemplate template) {
         this.template = template;
     }
@@ -54,4 +61,14 @@
     public void setTemplate(TransactionTemplate template) {
         this.template = template;
     }
+
+    /**
+     * Sets the transaction manager to use creating and also setting indirectly
+     * the transaction template.
+     */
+    public void setTransactionManager(PlatformTransactionManager transactionManager) {
+        TransactionTemplate template = new TransactionTemplate(transactionManager);
+        setTemplate(template);
+    }
+
 }

Modified: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTest.java?rev=674185&r1=674184&r2=674185&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTest.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTest.java
Sat Jul  5 05:04:57 2008
@@ -24,7 +24,6 @@
 import org.apache.camel.spring.spi.SpringTransactionPolicy;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.transaction.support.TransactionTemplate;
 
 /**
  * Unit test to demonstrate the transactional client pattern.
@@ -91,9 +90,8 @@
             public void configure() throws Exception {
                 // START SNIPPET: e1
                 // setup the transaction policy
-                TransactionTemplate tt = context.getRegistry()
-                    .lookup("PROPAGATION_REQUIRED", TransactionTemplate.class);
-                SpringTransactionPolicy required = new SpringTransactionPolicy(tt);
+                SpringTransactionPolicy required = context.getRegistry()
+                    .lookup("PROPAGATION_REQUIRED", SpringTransactionPolicy.class);
 
                 // use this error handler instead of DeadLetterChannel that is the default
                 // Notice: transactionErrorHandler is in SpringRouteBuilder

Modified: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionalClientDataSource.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionalClientDataSource.xml?rev=674185&r1=674184&r2=674185&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionalClientDataSource.xml
(original)
+++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/transactionalClientDataSource.xml
Sat Jul  5 05:04:57 2008
@@ -36,7 +36,7 @@
     </bean>
 
     <!-- policy for required transaction used in our Camel routes -->
-    <bean id="PROPAGATION_REQUIRED" class="org.springframework.transaction.support.TransactionTemplate">
+    <bean id="PROPAGATION_REQUIRED" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
         <property name="transactionManager" ref="txManager"/>
     </bean>
 



Mime
View raw message