You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2011/02/13 18:59:06 UTC

svn commit: r1070270 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/ components/camel-blueprint/src/main/java/org/apache/camel/blueprint/ components/camel-blueprint/src/main/resources/org/apache/camel/blueprint/ components/camel-cor...

Author: davsclaus
Date: Sun Feb 13 17:59:05 2011
New Revision: 1070270

URL: http://svn.apache.org/viewvc?rev=1070270&view=rev
Log:
CAMEL-3661: Added redepliveryPolicyProfile in XML DSL so you can easily use common profiles. They also support property placeholders. Added validation on errorHandler in XML to fail if misconfigured.

Added:
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelRedeliveryPolicyFactoryBean.java
      - copied, changed from r1070041, camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelEndpointFactoryBean.java
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelRedeliveryPolicyFactoryBean.java
      - copied, changed from r1070041, camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelThreadPoolFactoryBean.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelRedeliveryPolicyFactoryBean.java
      - copied, changed from r1070041, camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelThreadPoolFactoryBean.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionRefTest.java
      - copied, changed from r1070059, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertyPlaceholderOnExceptionRefTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringErrorHandlerRedeliveryPolicyProfileTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionRefTest.xml
      - copied, changed from r1070059, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertyPlaceholderOnExceptionRefTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringErrorHandlerRedeliveryPolicyProfileTest.xml
      - copied, changed from r1070041, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/choice.xml
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/RedeliveryPolicyDefinition.java
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
    camel/trunk/components/camel-blueprint/src/main/resources/org/apache/camel/blueprint/jaxb.index
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/ErrorHandlerDefinition.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/ErrorHandlerDefinitionParser.java
    camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/jaxb.index
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/RedeliveryPolicyRefTest.xml

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java?rev=1070270&r1=1070269&r2=1070270&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java Sun Feb 13 17:59:05 2011
@@ -62,6 +62,8 @@ public class OnExceptionDefinition exten
     private ExpressionSubElementDefinition retryWhile;
     @XmlElement(name = "redeliveryPolicy")
     private RedeliveryPolicyDefinition redeliveryPolicy;
+    @XmlAttribute(name = "redeliveryPolicyRef")
+    private String redeliveryPolicyRef;
     @XmlElement(name = "handled")
     private ExpressionSubElementDefinition handled;
     @XmlElement(name = "continued")
@@ -121,6 +123,10 @@ public class OnExceptionDefinition exten
      *         for this exception handler.
      */
     public RedeliveryPolicy createRedeliveryPolicy(CamelContext context, RedeliveryPolicy parentPolicy) {
+        if (redeliveryPolicyRef != null) {
+            parentPolicy = CamelContextHelper.mandatoryLookup(context, redeliveryPolicyRef, RedeliveryPolicy.class);
+        }
+
         if (redeliveryPolicy != null) {
             return redeliveryPolicy.createRedeliveryPolicy(context, parentPolicy);
         } else if (errorHandler != null) {
@@ -614,7 +620,7 @@ public class OnExceptionDefinition exten
      * @return the builder
      */
     public OnExceptionDefinition redeliveryPolicyRef(String redeliveryPolicyRef) {
-        getOrCreateRedeliveryPolicy().setRef(redeliveryPolicyRef);
+        setRedeliveryPolicyRef(redeliveryPolicyRef);
         return this;
     }
 
@@ -711,6 +717,14 @@ public class OnExceptionDefinition exten
         this.redeliveryPolicy = redeliveryPolicy;
     }
 
+    public String getRedeliveryPolicyRef() {
+        return redeliveryPolicyRef;
+    }
+
+    public void setRedeliveryPolicyRef(String redeliveryPolicyRef) {
+        this.redeliveryPolicyRef = redeliveryPolicyRef;
+    }
+
     public Predicate getHandledPolicy() {
         return handledPolicy;
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/RedeliveryPolicyDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RedeliveryPolicyDefinition.java?rev=1070270&r1=1070269&r2=1070270&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/RedeliveryPolicyDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/RedeliveryPolicyDefinition.java Sun Feb 13 17:59:05 2011
@@ -36,8 +36,6 @@ import org.apache.camel.util.ObjectHelpe
 @XmlAccessorType(XmlAccessType.FIELD)
 public class RedeliveryPolicyDefinition {
     @XmlAttribute
-    private String ref;
-    @XmlAttribute
     private String maximumRedeliveries;
     @XmlAttribute
     private String redeliveryDelay;
@@ -75,10 +73,6 @@ public class RedeliveryPolicyDefinition 
     private String delayPattern;
 
     public RedeliveryPolicy createRedeliveryPolicy(CamelContext context, RedeliveryPolicy parentPolicy) {
-        if (ref != null) {
-            // lookup in registry if ref provided
-            return CamelContextHelper.mandatoryLookup(context, ref, RedeliveryPolicy.class);
-        }
 
         RedeliveryPolicy answer;
         if (parentPolicy != null) {
@@ -477,17 +471,6 @@ public class RedeliveryPolicyDefinition 
     }
 
     /**
-     * Use redelivery policy looked up in the registry
-     *
-     * @param ref  reference to the redelivery policy to lookup and use
-     * @return the builder
-     */
-    public RedeliveryPolicyDefinition ref(String ref) {
-        setRef(ref);
-        return this;
-    }
-
-    /**
      * Sets the delay pattern with delay intervals.
      *
      * @param delayPattern the delay pattern
@@ -501,14 +484,6 @@ public class RedeliveryPolicyDefinition 
     // Properties
     //-------------------------------------------------------------------------
 
-    public String getRef() {
-        return ref;
-    }
-
-    public void setRef(String ref) {
-        this.ref = ref;
-    }
-
     public String getMaximumRedeliveries() {
         return maximumRedeliveries;
     }

Modified: camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java?rev=1070270&r1=1070269&r2=1070270&view=diff
==============================================================================
--- camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java (original)
+++ camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java Sun Feb 13 17:59:05 2011
@@ -127,6 +127,8 @@ public class CamelContextFactoryBean ext
     private List<CamelEndpointFactoryBean> endpoints;
     @XmlElement(name = "dataFormats", required = false)
     private DataFormatsDefinition dataFormats;
+    @XmlElement(name = "redeliveryPolicyProfile", required = false)
+    private List<CamelRedeliveryPolicyFactoryBean> redeliveryPolicies;
     @XmlElement(name = "onException", required = false)
     private List<OnExceptionDefinition> onExceptions = new ArrayList<OnExceptionDefinition>();
     @XmlElement(name = "onCompletion", required = false)
@@ -298,6 +300,14 @@ public class CamelContextFactoryBean ext
         this.routeRefs = routeRefs;
     }
 
+    public List<CamelRedeliveryPolicyFactoryBean> getRedeliveryPolicies() {
+        return redeliveryPolicies;
+    }
+
+    public void setRedeliveryPolicies(List<CamelRedeliveryPolicyFactoryBean> redeliveryPolicies) {
+        this.redeliveryPolicies = redeliveryPolicies;
+    }
+
     public List<ThreadPoolProfileDefinition> getThreadPoolProfiles() {
         return threadPoolProfiles;
     }

Copied: camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelRedeliveryPolicyFactoryBean.java (from r1070041, camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelEndpointFactoryBean.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelRedeliveryPolicyFactoryBean.java?p2=camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelRedeliveryPolicyFactoryBean.java&p1=camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelEndpointFactoryBean.java&r1=1070041&r2=1070270&rev=1070270&view=diff
==============================================================================
--- camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelEndpointFactoryBean.java (original)
+++ camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelRedeliveryPolicyFactoryBean.java Sun Feb 13 17:59:05 2011
@@ -16,25 +16,23 @@
  */
 package org.apache.camel.blueprint;
 
-
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
-import org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean;
+import org.apache.camel.core.xml.AbstractCamelRedeliveryPolicyFactoryBean;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 
 /**
- * A factory which instantiates {@link Endpoint} objects
+ * A factory which instantiates {@link org.apache.camel.processor.RedeliveryPolicy} objects
  *
  * @version $Revision$
  */
-@XmlRootElement(name = "endpoint")
+@XmlRootElement(name = "redeliveryPolicyProfile")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class CamelEndpointFactoryBean extends AbstractCamelEndpointFactoryBean {
+public class CamelRedeliveryPolicyFactoryBean extends AbstractCamelRedeliveryPolicyFactoryBean {
 
     @XmlTransient
     private BlueprintContainer blueprintContainer;

Modified: camel/trunk/components/camel-blueprint/src/main/resources/org/apache/camel/blueprint/jaxb.index
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-blueprint/src/main/resources/org/apache/camel/blueprint/jaxb.index?rev=1070270&r1=1070269&r2=1070270&view=diff
==============================================================================
--- camel/trunk/components/camel-blueprint/src/main/resources/org/apache/camel/blueprint/jaxb.index (original)
+++ camel/trunk/components/camel-blueprint/src/main/resources/org/apache/camel/blueprint/jaxb.index Sun Feb 13 17:59:05 2011
@@ -20,5 +20,6 @@ CamelEndpointFactoryBean
 CamelErrorHandlerFactoryBean
 CamelProducerTemplateFactoryBean
 CamelThreadPoolFactoryBean
+CamelRedeliveryPolicyFactoryBean
 CamelRouteContextFactoryBean
 CamelProxyFactoryBean

Modified: camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java?rev=1070270&r1=1070269&r2=1070270&view=diff
==============================================================================
--- camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java (original)
+++ camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java Sun Feb 13 17:59:05 2011
@@ -413,6 +413,8 @@ public abstract class AbstractCamelConte
 
     public abstract List<? extends AbstractCamelEndpointFactoryBean> getEndpoints();
 
+    public abstract List<? extends AbstractCamelRedeliveryPolicyFactoryBean> getRedeliveryPolicies();
+
     public abstract List<InterceptDefinition> getIntercepts();
 
     public abstract List<InterceptFromDefinition> getInterceptFroms();

Copied: camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelRedeliveryPolicyFactoryBean.java (from r1070041, camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelThreadPoolFactoryBean.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelRedeliveryPolicyFactoryBean.java?p2=camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelRedeliveryPolicyFactoryBean.java&p1=camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelThreadPoolFactoryBean.java&r1=1070041&r2=1070270&rev=1070270&view=diff
==============================================================================
--- camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelThreadPoolFactoryBean.java (original)
+++ camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelRedeliveryPolicyFactoryBean.java Sun Feb 13 17:59:05 2011
@@ -16,128 +16,274 @@
  */
 package org.apache.camel.core.xml;
 
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.RejectedExecutionHandler;
-import java.util.concurrent.TimeUnit;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.ThreadPoolRejectedPolicy;
-import org.apache.camel.builder.xml.TimeUnitAdapter;
+import org.apache.camel.LoggingLevel;
+import org.apache.camel.processor.RedeliveryPolicy;
+import org.apache.camel.util.CamelContextHelper;
 
 /**
- * A factory which instantiates {@link java.util.concurrent.ExecutorService} objects
+ * A factory which instantiates {@link RedeliveryPolicy} objects
  *
  * @version $Revision: 925208 $
  */
 @XmlAccessorType(XmlAccessType.FIELD)
-public abstract class AbstractCamelThreadPoolFactoryBean extends AbstractCamelFactoryBean<ExecutorService> {
+public abstract class AbstractCamelRedeliveryPolicyFactoryBean extends AbstractCamelFactoryBean<RedeliveryPolicy> {
 
-    @XmlAttribute(required = true)
-    private Integer poolSize;
     @XmlAttribute
-    private Integer maxPoolSize;
+    private String maximumRedeliveries;
     @XmlAttribute
-    private Long keepAliveTime = 60L;
+    private String redeliveryDelay;
     @XmlAttribute
-    @XmlJavaTypeAdapter(TimeUnitAdapter.class)
-    private TimeUnit timeUnit = TimeUnit.SECONDS;
+    private String asyncDelayedRedelivery;
     @XmlAttribute
-    private Integer maxQueueSize = -1;
+    private String backOffMultiplier;
     @XmlAttribute
-    private ThreadPoolRejectedPolicy rejectedPolicy = ThreadPoolRejectedPolicy.CallerRuns;
-    @XmlAttribute(required = true)
-    private String threadName;
+    private String useExponentialBackOff;
     @XmlAttribute
-    private Boolean daemon = Boolean.TRUE;
+    private String collisionAvoidanceFactor;
+    @XmlAttribute
+    private String useCollisionAvoidance;
+    @XmlAttribute
+    private String maximumRedeliveryDelay;
+    @XmlAttribute
+    private LoggingLevel retriesExhaustedLogLevel;
+    @XmlAttribute
+    private LoggingLevel retryAttemptedLogLevel;
+    @XmlAttribute
+    private String logRetryAttempted;
+    @XmlAttribute
+    private String logStackTrace;
+    @XmlAttribute
+    private String logRetryStackTrace;
+    @XmlAttribute
+    private String logHandled;
+    @XmlAttribute
+    private String logContinued;
+    @XmlAttribute
+    private String logExhausted;
+    @XmlAttribute
+    private String disableRedelivery;
+    @XmlAttribute
+    private String delayPattern;
 
-    public ExecutorService getObject() throws Exception {
-        if (poolSize == null || poolSize <= 0) {
-            throw new IllegalArgumentException("PoolSize must be a positive number");
+    public RedeliveryPolicy getObject() throws Exception {
+        RedeliveryPolicy answer = new RedeliveryPolicy();
+        CamelContext context = getCamelContext();
+
+        // copy across the properties - if they are set
+        if (maximumRedeliveries != null) {
+            answer.setMaximumRedeliveries(CamelContextHelper.parseInteger(context, maximumRedeliveries));
         }
-
-        int max = getMaxPoolSize() != null ? getMaxPoolSize() : getPoolSize();
-        RejectedExecutionHandler rejected = null;
-        if (rejectedPolicy != null) {
-            rejected = rejectedPolicy.asRejectedExecutionHandler();
+        if (redeliveryDelay != null) {
+            answer.setRedeliveryDelay(CamelContextHelper.parseLong(context, redeliveryDelay));
+        }
+        if (asyncDelayedRedelivery != null) {
+            if (CamelContextHelper.parseBoolean(context, asyncDelayedRedelivery)) {
+                answer.asyncDelayedRedelivery();
+            }
+        }
+        if (retriesExhaustedLogLevel != null) {
+            answer.setRetriesExhaustedLogLevel(retriesExhaustedLogLevel);
+        }
+        if (retryAttemptedLogLevel != null) {
+            answer.setRetryAttemptedLogLevel(retryAttemptedLogLevel);
+        }
+        if (backOffMultiplier != null) {
+            answer.setBackOffMultiplier(CamelContextHelper.parseDouble(context, backOffMultiplier));
+        }
+        if (useExponentialBackOff != null) {
+            answer.setUseExponentialBackOff(CamelContextHelper.parseBoolean(context, useExponentialBackOff));
+        }
+        if (collisionAvoidanceFactor != null) {
+            answer.setCollisionAvoidanceFactor(CamelContextHelper.parseDouble(context, collisionAvoidanceFactor));
+        }
+        if (useCollisionAvoidance != null) {
+            answer.setUseCollisionAvoidance(CamelContextHelper.parseBoolean(context, useCollisionAvoidance));
+        }
+        if (maximumRedeliveryDelay != null) {
+            answer.setMaximumRedeliveryDelay(CamelContextHelper.parseLong(context, maximumRedeliveryDelay));
+        }
+        if (logStackTrace != null) {
+            answer.setLogStackTrace(CamelContextHelper.parseBoolean(context, logStackTrace));
+        }
+        if (logRetryStackTrace != null) {
+            answer.setLogRetryStackTrace(CamelContextHelper.parseBoolean(context, logRetryStackTrace));
+        }
+        if (logHandled != null) {
+            answer.setLogHandled(CamelContextHelper.parseBoolean(context, logHandled));
+        }
+        if (logContinued != null) {
+            answer.setLogContinued(CamelContextHelper.parseBoolean(context, logContinued));
+        }
+        if (logRetryAttempted != null) {
+            answer.setLogRetryAttempted(CamelContextHelper.parseBoolean(context, logRetryAttempted));
+        }
+        if (logExhausted != null) {
+            answer.setLogExhausted(CamelContextHelper.parseBoolean(context, logExhausted));
+        }
+        if (disableRedelivery != null) {
+            if (CamelContextHelper.parseBoolean(context, disableRedelivery)) {
+                answer.setMaximumRedeliveries(0);
+            }
+        }
+        if (delayPattern != null) {
+            answer.setDelayPattern(delayPattern);
         }
 
-        ExecutorService answer = getCamelContext().getExecutorServiceStrategy().newThreadPool(getId(), getThreadName(), getPoolSize(), max,
-                    getKeepAliveTime(), getTimeUnit(), getMaxQueueSize(), rejected, isDaemon());
         return answer;
     }
 
     protected abstract CamelContext getCamelContextWithId(String camelContextId);
 
-    public Class<ExecutorService> getObjectType() {
-        return ExecutorService.class;
+    public Class<RedeliveryPolicy> getObjectType() {
+        return RedeliveryPolicy.class;
+    }
+
+    public String getMaximumRedeliveries() {
+        return maximumRedeliveries;
+    }
+
+    public void setMaximumRedeliveries(String maximumRedeliveries) {
+        this.maximumRedeliveries = maximumRedeliveries;
+    }
+
+    public String getRedeliveryDelay() {
+        return redeliveryDelay;
+    }
+
+    public void setRedeliveryDelay(String redeliveryDelay) {
+        this.redeliveryDelay = redeliveryDelay;
+    }
+
+    public String getAsyncDelayedRedelivery() {
+        return asyncDelayedRedelivery;
+    }
+
+    public void setAsyncDelayedRedelivery(String asyncDelayedRedelivery) {
+        this.asyncDelayedRedelivery = asyncDelayedRedelivery;
+    }
+
+    public String getBackOffMultiplier() {
+        return backOffMultiplier;
+    }
+
+    public void setBackOffMultiplier(String backOffMultiplier) {
+        this.backOffMultiplier = backOffMultiplier;
+    }
+
+    public String getUseExponentialBackOff() {
+        return useExponentialBackOff;
+    }
+
+    public void setUseExponentialBackOff(String useExponentialBackOff) {
+        this.useExponentialBackOff = useExponentialBackOff;
+    }
+
+    public String getCollisionAvoidanceFactor() {
+        return collisionAvoidanceFactor;
     }
 
-    public Integer getPoolSize() {
-        return poolSize;
+    public void setCollisionAvoidanceFactor(String collisionAvoidanceFactor) {
+        this.collisionAvoidanceFactor = collisionAvoidanceFactor;
     }
 
-    public void setPoolSize(Integer poolSize) {
-        this.poolSize = poolSize;
+    public String getUseCollisionAvoidance() {
+        return useCollisionAvoidance;
     }
 
-    public Integer getMaxPoolSize() {
-        return maxPoolSize;
+    public void setUseCollisionAvoidance(String useCollisionAvoidance) {
+        this.useCollisionAvoidance = useCollisionAvoidance;
     }
 
-    public void setMaxPoolSize(Integer maxPoolSize) {
-        this.maxPoolSize = maxPoolSize;
+    public String getMaximumRedeliveryDelay() {
+        return maximumRedeliveryDelay;
     }
 
-    public Long getKeepAliveTime() {
-        return keepAliveTime;
+    public void setMaximumRedeliveryDelay(String maximumRedeliveryDelay) {
+        this.maximumRedeliveryDelay = maximumRedeliveryDelay;
     }
 
-    public void setKeepAliveTime(Long keepAliveTime) {
-        this.keepAliveTime = keepAliveTime;
+    public LoggingLevel getRetriesExhaustedLogLevel() {
+        return retriesExhaustedLogLevel;
     }
 
-    public TimeUnit getTimeUnit() {
-        return timeUnit;
+    public void setRetriesExhaustedLogLevel(LoggingLevel retriesExhaustedLogLevel) {
+        this.retriesExhaustedLogLevel = retriesExhaustedLogLevel;
     }
 
-    public void setTimeUnit(TimeUnit timeUnit) {
-        this.timeUnit = timeUnit;
+    public LoggingLevel getRetryAttemptedLogLevel() {
+        return retryAttemptedLogLevel;
     }
 
-    public Integer getMaxQueueSize() {
-        return maxQueueSize;
+    public void setRetryAttemptedLogLevel(LoggingLevel retryAttemptedLogLevel) {
+        this.retryAttemptedLogLevel = retryAttemptedLogLevel;
     }
 
-    public void setMaxQueueSize(Integer maxQueueSize) {
-        this.maxQueueSize = maxQueueSize;
+    public String getLogRetryAttempted() {
+        return logRetryAttempted;
     }
 
-    public ThreadPoolRejectedPolicy getRejectedPolicy() {
-        return rejectedPolicy;
+    public void setLogRetryAttempted(String logRetryAttempted) {
+        this.logRetryAttempted = logRetryAttempted;
     }
 
-    public void setRejectedPolicy(ThreadPoolRejectedPolicy rejectedPolicy) {
-        this.rejectedPolicy = rejectedPolicy;
+    public String getLogStackTrace() {
+        return logStackTrace;
     }
 
-    public String getThreadName() {
-        return threadName;
+    public void setLogStackTrace(String logStackTrace) {
+        this.logStackTrace = logStackTrace;
     }
 
-    public void setThreadName(String threadName) {
-        this.threadName = threadName;
+    public String getLogRetryStackTrace() {
+        return logRetryStackTrace;
     }
 
-    public Boolean isDaemon() {
-        return daemon;
+    public void setLogRetryStackTrace(String logRetryStackTrace) {
+        this.logRetryStackTrace = logRetryStackTrace;
     }
 
-    public void setDaemon(Boolean daemon) {
-        this.daemon = daemon;
+    public String getLogHandled() {
+        return logHandled;
     }
 
+    public void setLogHandled(String logHandled) {
+        this.logHandled = logHandled;
+    }
+
+    public String getLogContinued() {
+        return logContinued;
+    }
+
+    public void setLogContinued(String logContinued) {
+        this.logContinued = logContinued;
+    }
+
+    public String getLogExhausted() {
+        return logExhausted;
+    }
+
+    public void setLogExhausted(String logExhausted) {
+        this.logExhausted = logExhausted;
+    }
+
+    public String getDisableRedelivery() {
+        return disableRedelivery;
+    }
+
+    public void setDisableRedelivery(String disableRedelivery) {
+        this.disableRedelivery = disableRedelivery;
+    }
+
+    public String getDelayPattern() {
+        return delayPattern;
+    }
+
+    public void setDelayPattern(String delayPattern) {
+        this.delayPattern = delayPattern;
+    }
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=1070270&r1=1070269&r2=1070270&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java (original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java Sun Feb 13 17:59:05 2011
@@ -32,7 +32,6 @@ import org.apache.camel.ShutdownRoute;
 import org.apache.camel.ShutdownRunningTask;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.core.xml.AbstractCamelContextFactoryBean;
-import org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean;
 import org.apache.camel.core.xml.CamelJMXAgentDefinition;
 import org.apache.camel.core.xml.CamelPropertyPlaceholderDefinition;
 import org.apache.camel.core.xml.CamelProxyFactoryDefinition;
@@ -135,6 +134,8 @@ public class CamelContextFactoryBean ext
     private List<CamelEndpointFactoryBean> endpoints;
     @XmlElement(name = "dataFormats", required = false)
     private DataFormatsDefinition dataFormats;
+    @XmlElement(name = "redeliveryPolicyProfile", required = false)
+    private List<CamelRedeliveryPolicyFactoryBean> redeliveryPolicies;
     @XmlElement(name = "onException", required = false)
     private List<OnExceptionDefinition> onExceptions = new ArrayList<OnExceptionDefinition>();
     @XmlElement(name = "onCompletion", required = false)
@@ -315,6 +316,10 @@ public class CamelContextFactoryBean ext
         return endpoints;
     }
 
+    public List<CamelRedeliveryPolicyFactoryBean> getRedeliveryPolicies() {
+        return redeliveryPolicies;
+    }
+
     public List<InterceptDefinition> getIntercepts() {
         return intercepts;
     }

Copied: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelRedeliveryPolicyFactoryBean.java (from r1070041, camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelThreadPoolFactoryBean.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelRedeliveryPolicyFactoryBean.java?p2=camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelRedeliveryPolicyFactoryBean.java&p1=camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelThreadPoolFactoryBean.java&r1=1070041&r2=1070270&rev=1070270&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelThreadPoolFactoryBean.java (original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelRedeliveryPolicyFactoryBean.java Sun Feb 13 17:59:05 2011
@@ -22,22 +22,20 @@ import javax.xml.bind.annotation.XmlRoot
 import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.core.xml.AbstractCamelThreadPoolFactoryBean;
+import org.apache.camel.core.xml.AbstractCamelRedeliveryPolicyFactoryBean;
 import org.apache.camel.spring.util.CamelContextResolverHelper;
 import org.springframework.beans.factory.FactoryBean;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 
-import static org.apache.camel.util.ObjectHelper.notNull;
-
 /**
- * A {@link org.springframework.beans.factory.FactoryBean} which instantiates {@link java.util.concurrent.ExecutorService} objects
+ * A {@link org.springframework.beans.factory.FactoryBean} which instantiates {@link org.apache.camel.processor.RedeliveryPolicy} objects
  *
  * @version $Revision$
  */
-@XmlRootElement(name = "threadPool")
+@XmlRootElement(name = "redeliveryPolicyProfile")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class CamelThreadPoolFactoryBean extends AbstractCamelThreadPoolFactoryBean implements FactoryBean, ApplicationContextAware {
+public class CamelRedeliveryPolicyFactoryBean extends AbstractCamelRedeliveryPolicyFactoryBean implements FactoryBean, ApplicationContextAware {
 
     @XmlTransient
     private ApplicationContext applicationContext;

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/ErrorHandlerDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/ErrorHandlerDefinition.java?rev=1070270&r1=1070269&r2=1070270&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/ErrorHandlerDefinition.java (original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/ErrorHandlerDefinition.java Sun Feb 13 17:59:05 2011
@@ -51,6 +51,8 @@ public class ErrorHandlerDefinition exte
     private String onRedeliveryRef;
     @XmlAttribute
     private String retryWhileRef;
+    @XmlAttribute
+    private String redeliveryPolicyRef;
     @XmlElement
     private RedeliveryPolicyDefinition redeliveryPolicy;
    

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java?rev=1070270&r1=1070269&r2=1070270&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java (original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java Sun Feb 13 17:59:05 2011
@@ -26,6 +26,7 @@ import javax.xml.bind.Binder;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 
+import org.apache.camel.spring.CamelRedeliveryPolicyFactoryBean;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -101,6 +102,7 @@ public class CamelNamespaceHandler exten
         addBeanDefinitionParser("export", CamelServiceExporter.class, true, false);
         addBeanDefinitionParser("endpoint", CamelEndpointFactoryBean.class, true, false);
         addBeanDefinitionParser("threadPool", CamelThreadPoolFactoryBean.class, true, true);
+        addBeanDefinitionParser("redeliveryPolicyProfile", CamelRedeliveryPolicyFactoryBean.class, true, true);
 
         // jmx agent and property placeholder cannot be used outside of the camel context
         addBeanDefinitionParser("jmxAgent", CamelJMXAgentDefinition.class, false, false);

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/ErrorHandlerDefinitionParser.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/ErrorHandlerDefinitionParser.java?rev=1070270&r1=1070269&r2=1070270&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/ErrorHandlerDefinitionParser.java (original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/ErrorHandlerDefinitionParser.java Sun Feb 13 17:59:05 2011
@@ -59,6 +59,7 @@ public class ErrorHandlerDefinitionParse
                 && !attributeName.equals("type")
                 && !attributeName.equals("onRedeliveryRef")
                 && !attributeName.equals("onRetryWhileRef")
+                && !attributeName.equals("redeliveryPolicyRef")
                 && !attributeName.equals("transactionTemplateRef")
                 && !attributeName.equals("transactionManagerRef");
     }
@@ -66,15 +67,14 @@ public class ErrorHandlerDefinitionParse
     @Override
     protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
         super.doParse(element, parserContext, builder);
+
+        String id = element.getAttribute("id");
+
         ErrorHandlerType type = ErrorHandlerType.DefaultErrorHandler;
         if (ObjectHelper.isNotEmpty(element.getAttribute("type"))) {
             type = ErrorHandlerType.valueOf(element.getAttribute("type"));
         }
-        if (type.equals(ErrorHandlerType.NoErrorHandler) || type.equals(ErrorHandlerType.LoggingErrorHandler)) {
-            // don't need to parser other stuff
-            return;
-        }
-        if (type.equals(ErrorHandlerType.DefaultErrorHandler) 
+        if (type.equals(ErrorHandlerType.DefaultErrorHandler)
             || type.equals(ErrorHandlerType.DeadLetterChannel) 
             || type.equals(ErrorHandlerType.TransactionErrorHandler)) {
             NodeList list = element.getChildNodes();
@@ -86,17 +86,62 @@ public class ErrorHandlerDefinitionParse
                     String localName = child.getLocalName();
                     // set the redeliveryPolicy
                     if (localName.equals("redeliveryPolicy")) {
+                        // cannot have redeliveryPolicyRef attribute as well, only one is allowed
+                        if (ObjectHelper.isNotEmpty(element.getAttribute("redeliveryPolicyRef"))) {
+                            throw new IllegalArgumentException("Cannot set both redeliveryPolicyRef and redeliveryPolicy,"
+                                    + " only one allowed, in error handler with id: " + id);
+                        }
                         BeanDefinition redeliveryPolicyDefinition = redeliveryPolicyParser.parse(childElement, parserContext);
                         builder.addPropertyValue(localName, redeliveryPolicyDefinition);
                     }
                 }
             }
             parserRefAttribute(element, "onRedeliveryRef", "onRedelivery", builder);
+            parserRefAttribute(element, "onRetryWhileRef", "onRetryWhile", builder);
+            parserRefAttribute(element, "redeliveryPolicyRef", "redeliveryPolicy", builder);
+            if (type.equals(ErrorHandlerType.TransactionErrorHandler)) {
+                // deal with transactionTemplateRef
+                parserRefAttribute(element, "transactionTemplateRef", "transactionTemplate", builder);
+                parserRefAttribute(element, "transactionManagerRef", "transactionManager", builder);
+            }
         }
-        if (type.equals(ErrorHandlerType.TransactionErrorHandler)) {
-            // deal with transactionTemplateRef
-            parserRefAttribute(element, "transactionTemplateRef", "transactionTemplate", builder);
-            parserRefAttribute(element, "transactionManagerRef", "transactionManager", builder);
+
+        // validate attributes according to type
+
+        String deadLetterUri = element.getAttribute("deadLetterUri");
+        if (ObjectHelper.isNotEmpty(deadLetterUri) && !type.equals(ErrorHandlerType.DeadLetterChannel)) {
+            throw new IllegalArgumentException("Attribute deadLetterUri can only be used if type is "
+                    + ErrorHandlerType.DeadLetterChannel.name() + ", in error handler with id: " + id);
+        }
+        String transactionTemplateRef = element.getAttribute("transactionTemplateRef");
+        if (ObjectHelper.isNotEmpty(transactionTemplateRef) && !type.equals(ErrorHandlerType.TransactionErrorHandler)) {
+            throw new IllegalArgumentException("Attribute transactionTemplateRef can only be used if type is "
+                    + ErrorHandlerType.TransactionErrorHandler.name() + ", in error handler with id: " + id);
+        }
+        String transactionManagerRef = element.getAttribute("transactionManagerRef");
+        if (ObjectHelper.isNotEmpty(transactionManagerRef) && !type.equals(ErrorHandlerType.TransactionErrorHandler)) {
+            throw new IllegalArgumentException("Attribute transactionManagerRef can only be used if type is "
+                    + ErrorHandlerType.TransactionErrorHandler.name() + ", in error handler with id: " + id);
+        }
+        String useOriginalMessage = element.getAttribute("useOriginalMessage");
+        if (ObjectHelper.isNotEmpty(useOriginalMessage) && (type.equals(ErrorHandlerType.LoggingErrorHandler) || type.equals(ErrorHandlerType.NoErrorHandler))) {
+            throw new IllegalArgumentException("Attribute useOriginalMessage is not supported by error handler type: "
+                    + type.name() + ", in error handler with id: " + id);
+        }
+        String onRedeliveryRef = element.getAttribute("onRedeliveryRef");
+        if (ObjectHelper.isNotEmpty(onRedeliveryRef) && (type.equals(ErrorHandlerType.LoggingErrorHandler) || type.equals(ErrorHandlerType.NoErrorHandler))) {
+            throw new IllegalArgumentException("Attribute onRedeliveryRef is not supported by error handler type: "
+                    + type.name() + ", in error handler with id: " + id);
+        }
+        String retryWhileRef = element.getAttribute("retryWhileRef");
+        if (ObjectHelper.isNotEmpty(retryWhileRef) && (type.equals(ErrorHandlerType.LoggingErrorHandler) || type.equals(ErrorHandlerType.NoErrorHandler))) {
+            throw new IllegalArgumentException("Attribute retryWhileRef is not supported by error handler type: "
+                    + type.name() + ", in error handler with id: " + id);
+        }
+        String redeliveryPolicyRef = element.getAttribute("redeliveryPolicyRef");
+        if (ObjectHelper.isNotEmpty(redeliveryPolicyRef) && (type.equals(ErrorHandlerType.LoggingErrorHandler) || type.equals(ErrorHandlerType.NoErrorHandler))) {
+            throw new IllegalArgumentException("Attribute redeliveryPolicyRef is not supported by error handler type: "
+                    + type.name() + ", in error handler with id: " + id);
         }
     }
 

Modified: camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/jaxb.index
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/jaxb.index?rev=1070270&r1=1070269&r2=1070270&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/jaxb.index (original)
+++ camel/trunk/components/camel-spring/src/main/resources/org/apache/camel/spring/jaxb.index Sun Feb 13 17:59:05 2011
@@ -19,5 +19,6 @@ CamelConsumerTemplateFactoryBean
 CamelContextFactoryBean
 CamelEndpointFactoryBean
 CamelProducerTemplateFactoryBean
+CamelRedeliveryPolicyFactoryBean
 CamelRouteContextFactoryBean
 CamelThreadPoolFactoryBean

Copied: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionRefTest.java (from r1070059, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionRefTest.java?p2=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionRefTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionTest.java&r1=1070059&r2=1070270&rev=1070270&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionRefTest.java Sun Feb 13 17:59:05 2011
@@ -23,10 +23,10 @@ import static org.apache.camel.spring.pr
 /**
  * @version $Revision$
  */
-public class SpringPropertiesComponentOnExceptionTest extends PropertiesComponentOnExceptionTest {
+public class SpringPropertiesComponentOnExceptionRefTest extends PropertiesComponentOnExceptionTest {
 
     protected CamelContext createCamelContext() throws Exception {
-        return createSpringCamelContext(this, "org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionTest.xml");
+        return createSpringCamelContext(this, "org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionRefTest.xml");
     }
 
 }

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertyPlaceholderOnExceptionRefTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertyPlaceholderOnExceptionRefTest.java?rev=1070270&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertyPlaceholderOnExceptionRefTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/properties/SpringPropertyPlaceholderOnExceptionRefTest.java Sun Feb 13 17:59:05 2011
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.properties;
+
+import org.apache.camel.CamelContext;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ * Using Spring property placeholder instead of Camel properties component.
+ *
+ * @version $Revision$
+ */
+public class SpringPropertyPlaceholderOnExceptionRefTest extends PropertiesComponentOnExceptionTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/component/properties/SpringPropertyPlaceholderOnExceptionRefTest.xml");
+    }
+
+}

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringErrorHandlerRedeliveryPolicyProfileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringErrorHandlerRedeliveryPolicyProfileTest.java?rev=1070270&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringErrorHandlerRedeliveryPolicyProfileTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringErrorHandlerRedeliveryPolicyProfileTest.java Sun Feb 13 17:59:05 2011
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.processor;
+
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version $Revision$
+ */
+public class SpringErrorHandlerRedeliveryPolicyProfileTest extends SpringTestSupport {
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/spring/processor/SpringErrorHandlerRedeliveryPolicyProfileTest.xml");
+    }
+
+    public void testErrorHandlerRedeliveryPolicyProfile() throws Exception {
+        try {
+            template.sendBody("direct:start", "Hello World");
+            fail("Should have thrown an exception");
+        } catch (Exception e) {
+            // expected
+        }
+    }
+}

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionRefTest.xml (from r1070059, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionTest.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionRefTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionRefTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionTest.xml&r1=1070059&r2=1070270&rev=1070270&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionTest.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertiesComponentOnExceptionRefTest.xml Sun Feb 13 17:59:05 2011
@@ -26,20 +26,31 @@
         <constructor-arg index="0" value="Damn"/>
     </bean>
 
+    <!-- START SNIPPET: e1 -->
+
     <camelContext xmlns="http://camel.apache.org/schema/spring">
+        <!-- use Camel property placeholders -->
         <propertyPlaceholder id="properties" location="org/apache/camel/component/properties/cheese.properties"/>
 
-        <onException>
-            <exception>java.lang.Exception</exception>
-            <redeliveryPolicy redeliveryDelay="{{delay}}" maximumRedeliveries="{{max}}"/>
-            <to uri="mock:dead"/>
-        </onException>
+        <!-- setup endpoint -->
+        <endpoint id="dead" uri="mock:dead"/>
+
+        <!-- setup a common redelivery policy, using property placeholders -->
+        <redeliveryPolicyProfile id="myRedelivery" redeliveryDelay="{{delay}}" maximumRedeliveries="{{max}}"/>
 
         <route>
             <from uri="direct:start"/>
+            <onException redeliveryPolicyRef="myRedelivery">
+                <!-- refer to common redelivery policy -->
+                <exception>java.lang.Exception</exception>
+                <!-- but we can override the profile and log retry attempts at WARN level -->
+                <redeliveryPolicy logRetryAttempted="true" retryAttemptedLogLevel="WARN"/>
+                <to ref="dead"/>
+            </onException>
             <throwException ref="damn"/>
         </route>
 
     </camelContext>
+    <!-- END SNIPPET: e1 -->
 
 </beans>

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertyPlaceholderOnExceptionRefTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertyPlaceholderOnExceptionRefTest.xml?rev=1070270&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertyPlaceholderOnExceptionRefTest.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/properties/SpringPropertyPlaceholderOnExceptionRefTest.xml Sun Feb 13 17:59:05 2011
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<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"
+       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://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <bean id="damn" class="java.lang.IllegalArgumentException">
+        <constructor-arg index="0" value="Damn"/>
+    </bean>
+
+    <!-- START SNIPPET: e1 -->
+
+    <!-- use Spring property placeholder -->
+    <context:property-placeholder location="org/apache/camel/component/properties/cheese.properties"/>
+
+    <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+        <!-- setup endpoint -->
+        <endpoint id="dead" uri="mock:dead"/>
+
+        <!-- setup a common redelivery policy, using Spring property placeholders -->
+        <redeliveryPolicyProfile id="myRedelivery" redeliveryDelay="${delay}" maximumRedeliveries="${max}"/>
+
+        <route>
+            <from uri="direct:start"/>
+            <onException redeliveryPolicyRef="myRedelivery">
+                <!-- refer to common redelivery policy -->
+                <exception>java.lang.Exception</exception>
+                <!-- but we can override the profile and log retry attempts at WARN level -->
+                <redeliveryPolicy logRetryAttempted="true" retryAttemptedLogLevel="WARN"/>
+                <to ref="dead"/>
+            </onException>
+            <throwException ref="damn"/>
+        </route>
+
+    </camelContext>
+    <!-- END SNIPPET: e1 -->
+
+</beans>

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringErrorHandlerRedeliveryPolicyProfileTest.xml (from r1070041, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/choice.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringErrorHandlerRedeliveryPolicyProfileTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringErrorHandlerRedeliveryPolicyProfileTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/choice.xml&r1=1070041&r2=1070270&rev=1070270&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/choice.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringErrorHandlerRedeliveryPolicyProfileTest.xml Sun Feb 13 17:59:05 2011
@@ -22,26 +22,25 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-  <!-- START SNIPPET: example -->
-  <camelContext xmlns="http://camel.apache.org/schema/spring">
-    <route>
-      <from uri="direct:start"/>
-      <choice>
-        <when>
-          <xpath>$foo = 'bar'</xpath>
-          <to uri="mock:x"/>
-        </when>
-        <when>
-          <xpath>$foo = 'cheese'</xpath>
-          <to uri="mock:y"/>
-        </when>
-        <otherwise>
-          <to uri="mock:z"/>
-        </otherwise>
-      </choice>
-      <to uri="mock:end"/>
-    </route>
-  </camelContext>
-  <!-- END SNIPPET: example -->
+    <bean id="damn" class="java.lang.IllegalArgumentException">
+        <constructor-arg index="0" value="Damn"/>
+    </bean>
+
+    <!-- START SNIPPET: e1 -->
+    <camelContext xmlns="http://camel.apache.org/schema/spring">
+
+        <!-- define the default error handler, and refer to a redelivery policy to use -->
+        <errorHandler id="eh" redeliveryPolicyRef="myPolicy"/>
+
+        <!-- and the redelivery policy is a profile where we can configure it -->
+        <redeliveryPolicyProfile id="myPolicy" maximumRedeliveries="3" redeliveryDelay="25" retryAttemptedLogLevel="WARN"/>
+
+        <route errorHandlerRef="eh">
+            <from uri="direct:start"/>
+            <throwException ref="damn"/>
+        </route>
+
+    </camelContext>
+    <!-- END SNIPPET: e1 -->
 
 </beans>

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/RedeliveryPolicyRefTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/RedeliveryPolicyRefTest.xml?rev=1070270&r1=1070269&r2=1070270&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/RedeliveryPolicyRefTest.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/RedeliveryPolicyRefTest.xml Sun Feb 13 17:59:05 2011
@@ -42,13 +42,12 @@
     <!-- define our error handler as a global error handler -->
     <camelContext errorHandlerRef="errorHandler" xmlns="http://camel.apache.org/schema/spring">
 
-      <onException>
+      <onException redeliveryPolicyRef="myRedeliveryPolicy">
+        <!-- here we reference our redelivery policy -->
         <!-- the exception is full qualified names as plain strings -->
         <!-- there can be more just add a 2nd, 3rd exception element (unbounded) -->
         <exception>org.apache.camel.spring.processor.onexception.OrderFailedException</exception>
         <exception>java.lang.IllegalArgumentException</exception>
-        <!-- here we reference our redelivy policy -->
-        <redeliveryPolicy ref="myRedeliveryPolicy" />
         <!-- mark this as handled -->
         <handled>
           <constant>true</constant>