camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r764683 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/main/java/org/apache/camel/management/ camel-core/src/main/java/org/apache/camel/model/ camel-core/...
Date Tue, 14 Apr 2009 06:10:19 GMT
Author: davsclaus
Date: Tue Apr 14 06:10:17 2009
New Revision: 764683

URL: http://svn.apache.org/viewvc?rev=764683&view=rev
Log:
CAMEL-1475: Easier transacted route configuration. Camel will auto lookup the PlatformTransactionManager and use it if found. Fixed CS. Fixed some TODO that dont apply anymore. 

Added:
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/TransactionMinimalConfigurationTest.java
      - copied, changed from r763533, camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/TransactionErrorHandlerBuilderAsSpringBeanTest.java
    camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/TransactionMinimalConfigurationTest.xml
      - copied, changed from r763533, camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/TransactionErrorHandlerBuilderAsSpringBeanTest.xml
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceMinimalConfigurationTest.java
      - copied, changed from r763533, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataSourceMinimalConfiguration.xml
      - copied, changed from r763533, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataSourceUsingTransacted.xml
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/PolicyDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/TransactedDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Delayer.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DelegateProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/HandleFaultProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Interceptor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/StreamCachingInterceptor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/InterceptStrategy.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/BodyAndHeaderConvertTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/builder/InterceptorBuilderTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ProducerTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlTestSupport.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/resequencer/ResequencerRunner.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringRouteBuilder.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java Tue Apr 14 06:10:17 2009
@@ -18,8 +18,6 @@
 
 import org.apache.camel.Processor;
 import org.apache.camel.processor.DefaultErrorHandler;
-import org.apache.camel.processor.ErrorHandlerSupport;
-import org.apache.camel.processor.exceptionpolicy.ExceptionPolicyStrategy;
 import org.apache.camel.spi.RouteContext;
 
 /**

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java Tue Apr 14 06:10:17 2009
@@ -127,7 +127,6 @@
      * Converts the given exchange to the specified exchange type
      */
     public Exchange convertTo(Class<Exchange> type, Exchange exchange) {
-        // TODO we could infer type parameter
         if (type.isInstance(exchange)) {
             return type.cast(exchange);
         }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteContext.java Tue Apr 14 06:10:17 2009
@@ -141,6 +141,8 @@
 
             // lets create the async processor
             final AsyncProcessor asyncProcessor = AsyncProcessorTypeConverter.convert(processor);
+            // and wrap it in a unit of work so the UoW is on the top, so the entire route
+            // will be in the same UoW
             Processor unitOfWorkProcessor = new UnitOfWorkProcessor(asyncProcessor);
 
             // TODO: hz: move all this into the lifecycle strategy! (used by jmx naming strategy)

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationLifecycleStrategy.java Tue Apr 14 06:10:17 2009
@@ -268,7 +268,7 @@
             // add exception handlers as top children
             routeType.getOutputs().addAll(exceptionHandlers);
 
-            // add an interceptor
+            // add an interceptor to instrument the route
             InstrumentationProcessor processor = new InstrumentationProcessor();
             routeType.intercept(processor);
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationProcessor.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationProcessor.java Tue Apr 14 06:10:17 2009
@@ -44,7 +44,7 @@
     
     @Override
     public String toString() {
-        return "Instrumentation(" + processor + ")";
+        return "Instrumentation[" + processor + "]";
     }
 
     public void setCounter(PerformanceCounter counter) {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java Tue Apr 14 06:10:17 2009
@@ -51,8 +51,7 @@
 public class MarshalDefinition extends OutputDefinition<ProcessorDefinition> {
     @XmlAttribute(required = false)
     private String ref;
-    // TODO cannot use @XmlElementRef as it doesn't allow optional properties
-    // @XmlElementRef
+    // cannot use @XmlElementRef as it doesn't allow optional properties
     @XmlElements({
     @XmlElement(required = false, name = "artixDS", type = ArtixDSDataFormat.class),
     @XmlElement(required = false, name = "csv", type = CsvDataFormat.class),

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/PolicyDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/PolicyDefinition.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/PolicyDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/PolicyDefinition.java Tue Apr 14 06:10:17 2009
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.model;
 
-import java.util.Map;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
@@ -26,7 +25,6 @@
 import org.apache.camel.Processor;
 import org.apache.camel.spi.Policy;
 import org.apache.camel.spi.RouteContext;
-import org.apache.camel.spi.TransactedPolicy;
 import org.apache.camel.util.ObjectHelper;
 
 /**
@@ -41,8 +39,6 @@
     // TODO: Align this code with TransactedDefinition
 
     @XmlTransient
-    public static final String PROPAGATION_REQUIRED = "PROPAGATION_REQUIRED";
-    @XmlTransient
     protected Class<? extends Policy> type;
     @XmlAttribute(required = true)
     protected String ref;
@@ -121,36 +117,6 @@
         return policy.wrap(routeContext, childProcessor);
     }
 
-    protected Policy resolvePolicy(RouteContext routeContext) {
-        if (policy == null) {
-            // try ref first
-            String ref = getRef();
-            if (ObjectHelper.isNotEmpty(ref)) {
-                policy = routeContext.lookup(ref, Policy.class);
-            }
-
-            // try to lookup by scoped type
-            if (policy == null && type != null) {
-                // try find by type, note that this method is not supported by all registry
-                Map types = routeContext.lookupByType(type);
-                if (types.size() == 1) {
-                    // only one policy defined so use it
-                    Object found = types.values().iterator().next();
-                    if (type.isInstance(found)) {
-                        return type.cast(found);
-                    }
-                }
-            }
-
-            // for transacted routing try the default REQUIRED name
-            if (policy == null && type == TransactedPolicy.class) {
-                // still not found try with the default name PROPAGATION_REQUIRED
-                policy = routeContext.lookup(PROPAGATION_REQUIRED, TransactedPolicy.class);
-            }
-        }
-        return policy;
-    }
-
     protected String description() {
         if (policy != null) {
             return policy.toString();
@@ -158,4 +124,13 @@
             return "ref: " + ref;
         }
     }
+
+    protected Policy resolvePolicy(RouteContext routeContext) {
+        if (policy != null) {
+            return policy;
+        }
+        // reuse code on transacted definition to do the resolution
+        return TransactedDefinition.doResolvePolicy(routeContext, getRef(), type);
+    }
+
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java Tue Apr 14 06:10:17 2009
@@ -2040,6 +2040,7 @@
         CamelContext camelContext = routeContext.getCamelContext();
         strategies.addAll(camelContext.getInterceptStrategies());
         strategies.addAll(routeContext.getInterceptStrategies());
+        // TODO: Order the strategies, eg using Comparable so we can have Tracer near the real processor
         for (InterceptStrategy strategy : strategies) {
             if (strategy != null) {
                 target = strategy.wrapProcessorInInterceptors(this, target);

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/TransactedDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TransactedDefinition.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/TransactedDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/TransactedDefinition.java Tue Apr 14 06:10:17 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.model;
 
+import java.lang.reflect.Method;
 import java.util.Map;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
@@ -24,10 +25,13 @@
 import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.camel.Processor;
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spi.Policy;
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.spi.TransactedPolicy;
 import org.apache.camel.util.ObjectHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * Represents an XML &lt;transacted/&gt; element
@@ -44,6 +48,9 @@
     // if we extend PolicyDefinition so we must make a copy of the class
     @XmlTransient
     public static final String PROPAGATION_REQUIRED = "PROPAGATION_REQUIRED";
+
+    private static final transient Log LOG = LogFactory.getLog(TransactedDefinition.class);
+
     @XmlTransient
     protected Class<? extends Policy> type = TransactedPolicy.class;
     @XmlAttribute
@@ -123,41 +130,99 @@
         return policy.wrap(routeContext, childProcessor);
     }
 
+
+    protected String description() {
+        if (policy != null) {
+            return policy.toString();
+        } else {
+            return "ref: " + ref;
+        }
+    }
+
     protected Policy resolvePolicy(RouteContext routeContext) {
-        if (policy == null) {
-            // try ref first
-            String ref = getRef();
-            if (ObjectHelper.isNotEmpty(ref)) {
-                policy = routeContext.lookup(ref, Policy.class);
-            }
+        if (policy != null) {
+            return policy;
+        }
+        return doResolvePolicy(routeContext, getRef(), type);
+    }
 
-            // try to lookup by scoped type
-            if (policy == null && type != null) {
-                // try find by type, note that this method is not supported by all registry
-                Map types = routeContext.lookupByType(type);
-                if (types.size() == 1) {
-                    // only one policy defined so use it
-                    Object found = types.values().iterator().next();
-                    if (type.isInstance(found)) {
-                        return type.cast(found);
-                    }
+    @SuppressWarnings("unchecked")
+    protected static Policy doResolvePolicy(RouteContext routeContext, String ref, Class<? extends Policy> type) {
+        Policy answer = null;
+
+        // try ref first
+        if (ObjectHelper.isNotEmpty(ref)) {
+            answer = routeContext.lookup(ref, Policy.class);
+        }
+
+        // try to lookup by scoped type
+        if (answer == null && type != null) {
+            // try find by type, note that this method is not supported by all registry
+            Map types = routeContext.lookupByType(type);
+            if (types.size() == 1) {
+                // only one policy defined so use it
+                Object found = types.values().iterator().next();
+                if (type.isInstance(found)) {
+                    return type.cast(found);
                 }
             }
+        }
 
-            // for transacted routing try the default REQUIRED name
-            if (policy == null && type == TransactedPolicy.class) {
-                // still not found try with the default name PROPAGATION_REQUIRED
-                policy = routeContext.lookup(PROPAGATION_REQUIRED, TransactedPolicy.class);
-            }
+        // for transacted routing try the default REQUIRED name
+        if (answer == null && type == TransactedPolicy.class) {
+            // still not found try with the default name PROPAGATION_REQUIRED
+            answer = routeContext.lookup(PROPAGATION_REQUIRED, TransactedPolicy.class);
         }
-        return policy;
-    }
 
-    protected String description() {
-        if (policy != null) {
-            return policy.toString();
-        } else {
-            return "ref: " + ref;
+        // no policy then try lookup the platform transaction manager and use it as policy
+        if (answer == null && type == TransactedPolicy.class) {
+            Class tmClazz = routeContext.getCamelContext().getClassResolver().resolveClass("org.springframework.transaction.PlatformTransactionManager");
+            if (tmClazz != null) {
+                // see if we can find the platform transaction manager in the registry
+                Map<String, Object> maps = routeContext.lookupByType(tmClazz);
+                if (maps.size() == 1) {
+                    // only one platform manager then use it as default and create a transacted
+                    // policy with it and default to required
+
+                    // as we do not want dependency on spring jars in the camel-core we use
+                    // reflection to lookup classes and create new objects and call methods
+                    // as this is only done during route building it does not matter that we
+                    // use reflection as performance is no a concern during route building
+                    Object transactionManager = maps.values().iterator().next();
+                    if (LOG.isDebugEnabled()) {
+                        LOG.debug("One instance of PlatformTransactionManager found in registry: " + transactionManager);
+                    }
+                    Class txClazz = routeContext.getCamelContext().getClassResolver().resolveClass("org.apache.camel.spring.spi.SpringTransactionPolicy");
+                    if (txClazz != null) {
+                        if (LOG.isDebugEnabled()) {
+                            LOG.debug("Creating a new temporary SpringTransactionPolicy using the PlatformTransactionManager: " + transactionManager);
+                        }
+                        TransactedPolicy txPolicy = ObjectHelper.newInstance(txClazz, TransactedPolicy.class);
+                        Method method;
+                        try {
+                            method = txClazz.getMethod("setTransactionManager", tmClazz);
+                        } catch (NoSuchMethodException e) {
+                            throw new RuntimeCamelException("Cannot get method setTransactionManager(PlatformTransactionManager) on class: " + txClazz);
+                        }
+                        ObjectHelper.invokeMethod(method, txPolicy, transactionManager);
+                        return txPolicy;
+                    } else {
+                        LOG.warn("Cannot create a transacted policy as camel-spring.jar is not on the classpath!");
+                    }
+                } else {
+                    if (LOG.isDebugEnabled()) {
+                        if (maps.isEmpty()) {
+                            LOG.debug("No PlatformTransactionManager found in registry.");
+                        } else {
+                            LOG.debug("Found " + maps.size() + " PlatformTransactionManager in registry. "
+                                    + "Cannot determine which one to use. Please configure a TransactionTemplate on the policy");
+                        }
+                    }
+                }
+            }
         }
+
+        return answer;
     }
+
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java Tue Apr 14 06:10:17 2009
@@ -52,8 +52,7 @@
 public class UnmarshalDefinition extends OutputDefinition<ProcessorDefinition> {
     @XmlAttribute(required = false)
     private String ref;
-    // TODO cannot use @XmlElementRef as it doesn't allow optional properties
-    // @XmlElementRef
+    // cannot use @XmlElementRef as it doesn't allow optional properties
     @XmlElements({
     @XmlElement(required = false, name = "artixDS", type = ArtixDSDataFormat.class),
     @XmlElement(required = false, name = "csv", type = CsvDataFormat.class),

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java Tue Apr 14 06:10:17 2009
@@ -33,8 +33,7 @@
 @XmlAccessorType(XmlAccessType.FIELD)
 public class DataFormatsDefinition {
 
-    // TODO cannot use @XmlElementRef as it doesn't allow optional properties
-    // @XmlElementRef
+    // cannot use @XmlElementRef as it doesn't allow optional properties
     @XmlElements({
         @XmlElement(required = false, name = "artixDS", type = ArtixDSDataFormat.class),
         @XmlElement(required = false, name = "csv", type = CsvDataFormat.class),   

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Delayer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Delayer.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Delayer.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Delayer.java Tue Apr 14 06:10:17 2009
@@ -42,7 +42,7 @@
 
     @Override
     public String toString() {
-        return "Delayer[on: " + timeExpression + " delay: " + delay + " to: " + getProcessor() + "]";
+        return "Delayer[" + (timeExpression != null ? "on: " + timeExpression : "") + " delay: " + delay + " to: " + getProcessor() + "]";
     }
 
     // Properties

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DelegateProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DelegateProcessor.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DelegateProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DelegateProcessor.java Tue Apr 14 06:10:17 2009
@@ -52,7 +52,7 @@
 
     @Override
     public String toString() {
-        return "Delegate(" + processor + ")";
+        return "Delegate[" + processor + "]";
     }
 
     public Processor getProcessor() {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/HandleFaultProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/HandleFaultProcessor.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/HandleFaultProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/HandleFaultProcessor.java Tue Apr 14 06:10:17 2009
@@ -27,7 +27,7 @@
     
     @Override
     public String toString() {
-        return "HandleFaultProcessor(" + processor + ")";
+        return "HandleFault[" + processor + "]";
     }
 
     @Override

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Interceptor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Interceptor.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Interceptor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Interceptor.java Tue Apr 14 06:10:17 2009
@@ -50,6 +50,11 @@
     }
 
     @Override
+    public String toString() {
+        return "Interceptor[" + interceptorLogic + "]";
+    }
+
+    @Override
     protected void doStart() throws Exception {
         ServiceHelper.startService(interceptorLogic);
         super.doStart();

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/StreamCachingInterceptor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/StreamCachingInterceptor.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/StreamCachingInterceptor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/StreamCachingInterceptor.java Tue Apr 14 06:10:17 2009
@@ -45,7 +45,7 @@
 
     @Override
     public String toString() {
-        return "StreamCachingInterceptor(" + processor + ")";
+        return "StreamCachingInterceptor[" + processor + "]";
     }
 
     /**

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/spi/InterceptStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/InterceptStrategy.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/spi/InterceptStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/spi/InterceptStrategy.java Tue Apr 14 06:10:17 2009
@@ -40,5 +40,5 @@
      * @throws Exception can be thrown
      */
     Processor wrapProcessorInInterceptors(ProcessorDefinition processorType,
-            Processor target) throws Exception;
+                                          Processor target) throws Exception;
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/BodyAndHeaderConvertTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/BodyAndHeaderConvertTest.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/BodyAndHeaderConvertTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/BodyAndHeaderConvertTest.java Tue Apr 14 06:10:17 2009
@@ -47,15 +47,11 @@
     public void testConversionOfExchangeProperties() throws Exception {
         String text = exchange.getProperty("foo", String.class);
         assertEquals("foo property", "1234", text);
-
-        // TODO better conversion example when the property editor support is added
     }
 
     public void testConversionOfMessageHeaders() throws Exception {
         String text = exchange.getIn().getHeader("bar", String.class);
         assertEquals("bar header", "567", text);
-
-        // TODO better conversion example when the property editor support is added
     }
 
     public void testConversionOfMessageAttachments() throws Exception {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/builder/InterceptorBuilderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/InterceptorBuilderTest.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/builder/InterceptorBuilderTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/builder/InterceptorBuilderTest.java Tue Apr 14 06:10:17 2009
@@ -73,12 +73,7 @@
 
         RouteBuilder builder = new RouteBuilder() {
             public void configure() {
-                //from("direct:a").intercept(interceptor1).intercept(interceptor2).to("direct:d");
                 from("direct:a").intercept(interceptor1).process(orderProcessor).intercept(interceptor2).process(toProcessor);
-                /*
-                 * TODO keep old DSL? .intercept() .add(interceptor1)
-                 * .add(interceptor2) .target().to("direct:d");
-                 */
             }
         };
         container.addRoutes(builder);

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ProducerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ProducerTest.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ProducerTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/ProducerTest.java Tue Apr 14 06:10:17 2009
@@ -69,18 +69,11 @@
         Exchange exchange = new DefaultExchange(context);
         producer.process(exchange);
 
-        // TODO: fix me
-        // Class<?> type = endpoint.getExchangeType();
-        // assertEquals("exchange type", MyExchange.class, type);
-
         MyExchange actual = (MyExchange) endpoint.createExchange(exchange);
         assertNotNull(actual);
         assertTrue("Not same exchange", actual != exchange);
 
         MyExchange expected = new MyExchange(context, pattern);
         actual = (MyExchange) endpoint.createExchange(expected);
-
-        // TODO: fix me
-        // assertSame("Should not copy an exchange when of the correct type", expected, actual);
     }
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlTestSupport.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlTestSupport.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlTestSupport.java Tue Apr 14 06:10:17 2009
@@ -55,7 +55,6 @@
     }
 
     public static JAXBContext createJaxbContext() throws JAXBException {
-        return JAXBContext
-            .newInstance(Constants.JAXB_CONTEXT_PACKAGES);
+        return JAXBContext.newInstance(Constants.JAXB_CONTEXT_PACKAGES);
     }
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/resequencer/ResequencerRunner.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/resequencer/ResequencerRunner.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/resequencer/ResequencerRunner.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/resequencer/ResequencerRunner.java Tue Apr 14 06:10:17 2009
@@ -44,7 +44,6 @@
                 e.printStackTrace();
             }
         }
-        // TODO Auto-generated method stub
         super.run();
     }
 

Copied: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/TransactionMinimalConfigurationTest.java (from r763533, camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/TransactionErrorHandlerBuilderAsSpringBeanTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/TransactionMinimalConfigurationTest.java?p2=camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/TransactionMinimalConfigurationTest.java&p1=camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/TransactionErrorHandlerBuilderAsSpringBeanTest.java&r1=763533&r2=764683&rev=764683&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/TransactionErrorHandlerBuilderAsSpringBeanTest.java (original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/tx/TransactionMinimalConfigurationTest.java Tue Apr 14 06:10:17 2009
@@ -23,13 +23,13 @@
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 /**
- * To demonstrate the TransactionErrorHandlerBuilder configured in Spring XML.
+ * To demonstrate transacted with minimal configuration.
  */
-public class TransactionErrorHandlerBuilderAsSpringBeanTest extends SpringTestSupport {
+public class TransactionMinimalConfigurationTest extends SpringTestSupport {
 
     protected ClassPathXmlApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext(
-            "/org/apache/camel/component/jms/tx/TransactionErrorHandlerBuilderAsSpringBeanTest.xml");
+            "/org/apache/camel/component/jms/tx/TransactionMinimalConfigurationTest.xml");
     }
 
     protected int getExpectedRouteCount() {

Copied: camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/TransactionMinimalConfigurationTest.xml (from r763533, camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/TransactionErrorHandlerBuilderAsSpringBeanTest.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/TransactionMinimalConfigurationTest.xml?p2=camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/TransactionMinimalConfigurationTest.xml&p1=camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/TransactionErrorHandlerBuilderAsSpringBeanTest.xml&r1=763533&r2=764683&rev=764683&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/TransactionErrorHandlerBuilderAsSpringBeanTest.xml (original)
+++ camel/trunk/components/camel-jms/src/test/resources/org/apache/camel/component/jms/tx/TransactionMinimalConfigurationTest.xml Tue Apr 14 06:10:17 2009
@@ -22,73 +22,36 @@
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
          http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
 
-    <!-- START SNIPPET: e1 -->
-    <!-- here we define our camel context -->
-    <camel:camelContext id="myroutes">
-
-        <!-- first route with transaction error handler -->
-        <!-- here we refer to our transaction error handler we define in this Spring XML file -->
-        <!-- in this route the transactionErrorHandler is used -->
-        <camel:route errorHandlerRef="transactionErrorHandler">
+    <camelContext xmlns="http://camel.apache.org/schema/spring">
+        <route>
             <!-- 1: from the jms queue -->
-            <camel:from uri="activemq:queue:okay"/>
-            <!-- 2: setup the transactional boundaries to require a transaction -->
-            <camel:policy ref="required"/>
+            <from uri="activemq:queue:okay"/>
+            <!-- 2: mark this route as transacted -->
+            <transacted/>
             <!-- 3: call our business logic that is myProcessor -->
-            <camel:process ref="myProcessor"/>
+            <process ref="myProcessor"/>
             <!-- 4: if success then send it to the mock -->
-            <camel:to uri="mock:result"/>
-        </camel:route>
-
-        <!-- 2nd route with no error handling -->
-        <!-- this route doens't use error handler, in fact the spring bean with id noErrorHandler -->
-        <camel:route errorHandlerRef="noErrorHandler">
-            <camel:from uri="activemq:queue:bad"/>
-            <camel:to uri="log:bad"/>
-        </camel:route>
-
-    </camel:camelContext>
-    <!-- END SNIPPET: e1 -->
+            <to uri="mock:result"/>
+        </route>
+    </camelContext>
 
     <bean id="myProcessor" class="org.apache.camel.component.jms.tx.JMSTransactionalClientTest$MyProcessor"/>
 
-    <!-- START SNIPPET: e2 -->
-    <!-- camel policy we refer to in our route -->
-    <bean id="required" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
-        <property name="transactionTemplate" ref="PROPAGATION_REQUIRED"/>
-    </bean>
-
-    <!-- the standard spring transaction template for required -->
-    <bean id="PROPAGATION_REQUIRED" class="org.springframework.transaction.support.TransactionTemplate">
-        <property name="transactionManager" ref="jmsTransactionManager"/>
-    </bean>
-
-    <!-- the transaction error handle we refer to from the route -->
-    <bean id="transactionErrorHandler" class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder">
-        <property name="transactionTemplate" ref="PROPAGATION_REQUIRED"/>
-    </bean>
-
-    <!-- the no error handler -->
-    <bean id="noErrorHandler" class="org.apache.camel.builder.NoErrorHandlerBuilder"/>
-    <!-- END SNIPPET: e2 -->
-
+    <!-- setup JMS connection factory -->
     <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
         <property name="brokerURL" value="vm://localhost?broker.persistent=false&amp;broker.useJmx=false"/>
     </bean>
 
+    <!-- setup spring jms TX manager -->
     <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
         <property name="connectionFactory" ref="jmsConnectionFactory"/>
     </bean>
 
-    <bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
+    <!-- define our activemq component -->
+    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
         <property name="connectionFactory" ref="jmsConnectionFactory"/>
-        <property name="transactionManager" ref="jmsTransactionManager"/>
+        <!-- define the jms consumer/producer as transacted -->
         <property name="transacted" value="true"/>
-        <property name="concurrentConsumers" value="1"/>
-    </bean>
-
-    <bean id="activemq" class="org.apache.camel.component.jms.JmsComponent">
-        <property name="configuration" ref="jmsConfig"/>
     </bean>
 
 </beans>

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringRouteBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringRouteBuilder.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringRouteBuilder.java (original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringRouteBuilder.java Tue Apr 14 06:10:17 2009
@@ -23,6 +23,7 @@
 import org.apache.camel.spring.spi.TransactionErrorHandlerBuilder;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
+import org.springframework.transaction.PlatformTransactionManager;
 import org.springframework.transaction.support.TransactionTemplate;
 
 /**
@@ -124,4 +125,15 @@
         return answer;
     }
 
+    /**
+     * Creates a transaction error handler.
+     *
+     * @param transactionManager the spring transaction manager
+     * @return the created error handler
+     */
+    public TransactionErrorHandlerBuilder transactionErrorHandler(PlatformTransactionManager transactionManager) {
+        TransactionTemplate template = new TransactionTemplate(transactionManager);
+        return transactionErrorHandler(template);
+    }
+
 }

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java?rev=764683&r1=764682&r2=764683&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java (original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java Tue Apr 14 06:10:17 2009
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.spring.spi;
 
+import java.util.Map;
+
 import org.apache.camel.Processor;
 import org.apache.camel.builder.ErrorHandlerBuilder;
 import org.apache.camel.builder.ErrorHandlerBuilderRef;

Copied: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceMinimalConfigurationTest.java (from r763533, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceMinimalConfigurationTest.java?p2=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceMinimalConfigurationTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedTest.java&r1=763533&r2=764683&rev=764683&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceMinimalConfigurationTest.java Tue Apr 14 06:10:17 2009
@@ -16,35 +16,61 @@
  */
 package org.apache.camel.spring.interceptor;
 
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.spring.SpringRouteBuilder;
+import javax.sql.DataSource;
+
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.jdbc.core.JdbcTemplate;
 
 /**
- * Easier transaction configuration as we do not have to setup a transaction error handler
+ * Easier transaction configuration as we only setup Spring TX stuff.
  */
-public class TransactionalClientDataSourceTransactedTest extends TransactionalClientDataSourceTest {
+public class TransactionalClientDataSourceMinimalConfigurationTest extends SpringTestSupport {
+
+    protected JdbcTemplate jdbc;
+
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext(
+            "/org/apache/camel/spring/interceptor/springTransactionalClientDataSourceMinimalConfiguration.xml");
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // create database and insert dummy data
+        final DataSource ds = getMandatoryBean(DataSource.class, "dataSource");
+        jdbc = new JdbcTemplate(ds);
+        jdbc.execute("create table books (title varchar(50))");
+        jdbc.update("insert into books (title) values (?)", new Object[] {"Camel in Action"});
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        jdbc.execute("drop table books");
+    }
+
+    public void testTransactionSuccess() throws Exception {
+        template.sendBody("direct:okay", "Hello World");
+
+        int count = jdbc.queryForInt("select count(*) from books");
+        assertEquals("Number of books", 3, count);
+    }
+
+    public void testTransactionRollback() throws Exception {
+        try {
+            template.sendBody("direct:fail", "Hello World");
+        } catch (RuntimeCamelException e) {
+            // expeced as we fail
+            assertTrue(e.getCause() instanceof IllegalArgumentException);
+            assertEquals("We don't have Donkeys, only Camels", e.getCause().getMessage());
+        }
 
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new SpringRouteBuilder() {
-            public void configure() throws Exception {
-                // START SNIPPET: e1
-                from("direct:okay")
-                    // marks this route as transacted, and we dont pass in any parameters so we
-                    // will auto lookup and use the Policy defined in the spring XML file
-                    .transacted()
-                    .setBody(constant("Tiger in Action")).beanRef("bookService")
-                    .setBody(constant("Elephant in Action")).beanRef("bookService");
-
-                // marks this route as transacted that will use the single policy defined in the registry
-                from("direct:fail")
-                    // marks this route as transacted, and we dont pass in any parameters so we
-                    // will auto lookup and use the Policy defined in the spring XML file
-                    .transacted()
-                    .setBody(constant("Tiger in Action")).beanRef("bookService")
-                    .setBody(constant("Donkey in Action")).beanRef("bookService");
-                // END SNIPPET: e1
-            }
-        };
+        int count = jdbc.queryForInt("select count(*) from books");
+        assertEquals("Number of books", 1, count);
     }
 
-}
+}
\ No newline at end of file

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataSourceMinimalConfiguration.xml (from r763533, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataSourceUsingTransacted.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataSourceMinimalConfiguration.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataSourceMinimalConfiguration.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataSourceUsingTransacted.xml&r1=763533&r2=764683&rev=764683&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataSourceUsingTransacted.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/interceptor/springTransactionalClientDataSourceMinimalConfiguration.xml Tue Apr 14 06:10:17 2009
@@ -21,12 +21,36 @@
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
          http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
 
-    <import resource="transactionalClientDataSource.xml"/>
-
     <!-- START SNIPPET: e1 -->
+    <!-- this example uses JDBC so we define a data source -->
+    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+        <property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
+        <property name="url" value="jdbc:hsqldb:mem:camel"/>
+        <property name="username" value="sa"/>
+        <property name="password" value=""/>
+    </bean>
+
+    <!-- spring transaction manager -->
+    <!-- this is the transaction manager Camel will use for transacted routes -->
+    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
+        <property name="dataSource" ref="dataSource"/>
+    </bean>
+
+    <!-- bean for book business logic -->
+    <bean id="bookService" class="org.apache.camel.spring.interceptor.BookService">
+        <property name="dataSource" ref="dataSource"/>
+    </bean>
+    <!-- END SNIPPET: e1 -->
+
+    <!-- START SNIPPET: e2 -->
     <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
         <route>
             <from uri="direct:okay"/>
+            <!-- we mark this route as transacted. Camel will lookup the spring transaction manager
+                 and use it by default. We can optimally pass in arguments to specify a policy to use
+                 that is configured with a spring transaction manager of choice. However Camel supports
+                 convention over configuration as we can just use the defaults out of the box and Camel
+                 that suites in most situations -->
             <transacted/>
             <setBody>
                 <constant>Tiger in Action</constant>
@@ -40,6 +64,7 @@
 
         <route>
             <from uri="direct:fail"/>
+            <!-- we mark this route as transacted. See comments above. -->
             <transacted/>
             <setBody>
                 <constant>Tiger in Action</constant>
@@ -51,6 +76,6 @@
             <bean ref="bookService"/>
         </route>
     </camelContext>
-    <!-- END SNIPPET: e1 -->
+    <!-- END SNIPPET: e2 -->
 
 </beans>



Mime
View raw message