camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1078258 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/test/java/org/apache/camel/builder/ components/camel-blueprint/src/main/java/org/apache/camel/blueprint/ components/camel-spring/src/main/java/org...
Date Sat, 05 Mar 2011 10:31:34 GMT
Author: davsclaus
Date: Sat Mar  5 10:31:33 2011
New Revision: 1078258

URL: http://svn.apache.org/viewvc?rev=1078258&view=rev
Log:
CAMEL-3739: Added missing logName to XML DSL error handler. Added missing redeliveryPolicyRef
to blueprint XML DSL.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/builder/LoggingErrorHandlerBuilderTest.java
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelErrorHandlerFactoryBean.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/ErrorHandlerDefinition.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/handler/ErrorHandlerDefinitionParserTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/handler/ErrorHandlerDefinitionParser.xml

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java?rev=1078258&r1=1078257&r2=1078258&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java
Sat Mar  5 10:31:33 2011
@@ -73,6 +73,14 @@ public class LoggingErrorHandlerBuilder 
         this.log = log;
     }
 
+    public String getLogName() {
+        return log != null ? log.getName() : null;
+    }
+
+    public void setLogName(String logName) {
+        this.log = LoggerFactory.getLogger(logName);
+    }
+
     public LoggingErrorHandlerBuilder level(final LoggingLevel level) {
         this.level = level;
         return this;
@@ -83,4 +91,9 @@ public class LoggingErrorHandlerBuilder 
         return this;
     }
 
+    public LoggingErrorHandlerBuilder logName(final String logName) {
+        setLogName(logName);
+        return this;
+    }
+
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/builder/LoggingErrorHandlerBuilderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/LoggingErrorHandlerBuilderTest.java?rev=1078258&r1=1078257&r2=1078258&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/builder/LoggingErrorHandlerBuilderTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/builder/LoggingErrorHandlerBuilderTest.java
Sat Mar  5 10:31:33 2011
@@ -122,4 +122,22 @@ public class LoggingErrorHandlerBuilderT
             // expected
         }
     }
+
+    public void testLoggingErrorHandler5() throws Exception {
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                errorHandler(loggingErrorHandler().level(LoggingLevel.ERROR).logName("foo"));
+
+                from("direct:start").to("mock:foo").throwException(new IllegalArgumentException("Damn"));
+            }
+        });
+        context.start();
+
+        try {
+            template.sendBody("direct:start", "Hello World");
+        } catch (Exception e) {
+            // expected
+        }
+    }
 }

Modified: camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelErrorHandlerFactoryBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelErrorHandlerFactoryBean.java?rev=1078258&r1=1078257&r2=1078258&view=diff
==============================================================================
--- camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelErrorHandlerFactoryBean.java
(original)
+++ camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelErrorHandlerFactoryBean.java
Sat Mar  5 10:31:33 2011
@@ -23,7 +23,6 @@ import javax.xml.bind.annotation.XmlElem
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 
-import org.apache.aries.blueprint.ExtendedBlueprintContainer;
 import org.apache.camel.CamelContext;
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.Processor;
@@ -32,6 +31,8 @@ import org.apache.camel.builder.ErrorHan
 import org.apache.camel.builder.LoggingErrorHandlerBuilder;
 import org.apache.camel.core.xml.AbstractCamelFactoryBean;
 import org.apache.camel.model.RedeliveryPolicyDefinition;
+import org.apache.camel.processor.RedeliveryPolicy;
+import org.apache.camel.util.CamelContextHelper;
 import org.osgi.service.blueprint.container.BlueprintContainer;
 import org.osgi.service.blueprint.container.NoSuchComponentException;
 
@@ -46,11 +47,15 @@ public class CamelErrorHandlerFactoryBea
     @XmlAttribute
     private LoggingLevel level = LoggingLevel.ERROR;
     @XmlAttribute
+    private String logName;
+    @XmlAttribute
     private Boolean useOriginalMessage;
     @XmlAttribute
     private String onRedeliveryRef;
     @XmlAttribute
     private String retryWhileRef;
+    @XmlAttribute
+    private String redeliveryPolicyRef;
     @XmlElement
     private RedeliveryPolicyDefinition redeliveryPolicy;
     @XmlTransient
@@ -70,6 +75,11 @@ public class CamelErrorHandlerFactoryBea
             if (redeliveryPolicy != null) {
                 handler.setRedeliveryPolicy(redeliveryPolicy.createRedeliveryPolicy(getCamelContext(),
null));
             }
+            if (redeliveryPolicyRef != null) {
+                // lookup redelivery
+                RedeliveryPolicy policy = CamelContextHelper.mandatoryLookup(getCamelContext(),
redeliveryPolicyRef, RedeliveryPolicy.class);
+                handler.setRedeliveryPolicy(policy);
+            }
             if (onRedeliveryRef != null) {
                 handler.setOnRedelivery(lookup(onRedeliveryRef, Processor.class));
             }
@@ -81,6 +91,9 @@ public class CamelErrorHandlerFactoryBea
             if (level != null) {
                 handler.setLevel(level);
             }
+            if (logName != null) {
+                handler.setLogName(logName);
+            }
         }
         return errorHandler;
     }

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=1078258&r1=1078257&r2=1078258&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
Sat Mar  5 10:31:33 2011
@@ -42,6 +42,8 @@ public class ErrorHandlerDefinition exte
     @XmlAttribute
     private LoggingLevel level = LoggingLevel.ERROR;
     @XmlAttribute
+    private String logName;
+    @XmlAttribute
     private Boolean useOriginalMessage;
     @XmlAttribute
     private String transactionTemplateRef;

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/handler/ErrorHandlerDefinitionParserTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/handler/ErrorHandlerDefinitionParserTest.java?rev=1078258&r1=1078257&r2=1078258&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/handler/ErrorHandlerDefinitionParserTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/handler/ErrorHandlerDefinitionParserTest.java
Sat Mar  5 10:31:33 2011
@@ -40,7 +40,8 @@ public class ErrorHandlerDefinitionParse
     public void testLoggingErrorHandler() {
         LoggingErrorHandlerBuilder errorHandler = (LoggingErrorHandlerBuilder) ctx.getBean("loggingErrorHandler");
         assertNotNull(errorHandler);
-        assertEquals("The loglevel should be INFO", LoggingLevel.INFO, errorHandler.getLevel());
+        assertEquals("The log level should be INFO", LoggingLevel.INFO, errorHandler.getLevel());
+        assertEquals("The log name should be foo", "foo", errorHandler.getLogName());
     }
     
     public void testDefaultErrorHandler() {

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/handler/ErrorHandlerDefinitionParser.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/handler/ErrorHandlerDefinitionParser.xml?rev=1078258&r1=1078257&r2=1078258&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/handler/ErrorHandlerDefinitionParser.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/handler/ErrorHandlerDefinitionParser.xml
Sat Mar  5 10:31:33 2011
@@ -24,7 +24,7 @@
     ">
 
     <!-- START SNIPPET: example -->
-    <errorHandler id="loggingErrorHandler" type="LoggingErrorHandler" level="INFO" xmlns="http://camel.apache.org/schema/spring"/>
+    <errorHandler id="loggingErrorHandler" type="LoggingErrorHandler" logName="foo" level="INFO"
xmlns="http://camel.apache.org/schema/spring"/>
 
     <!-- If don't specify type attribute, the type value will be set to DefaultErrorHandler
-->
     <errorHandler id="errorHandler" xmlns="http://camel.apache.org/schema/spring"/>



Mime
View raw message