camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1327430 - in /camel/trunk/camel-core/src/main/java/org/apache/camel/processor: ./ validation/
Date Wed, 18 Apr 2012 09:10:13 GMT
Author: davsclaus
Date: Wed Apr 18 09:10:12 2012
New Revision: 1327430

URL: http://svn.apache.org/viewvc?rev=1327430&view=rev
Log:
CAMEL-5188: All EIPs from Camel now offers JMX utilization stats. Also make sure transform/setBody
does the same logic to be consistent.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ConvertBodyProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ExchangePatternProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LogProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RollbackProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SetBodyProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SortProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StopProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ThrowExceptionProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TransformProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/PredicateValidatingProcessor.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ConvertBodyProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ConvertBodyProcessor.java?rev=1327430&r1=1327429&r2=1327430&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ConvertBodyProcessor.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ConvertBodyProcessor.java
Wed Apr 18 09:10:12 2012
@@ -19,27 +19,31 @@ package org.apache.camel.processor;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
+import org.apache.camel.support.ServiceSupport;
 import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.ObjectHelper;
 
 /**
  * A processor which converts the payload of the input message to be of the given type
  * <p/>
- * If the convertions fails an {@link org.apache.camel.InvalidPayloadException} is thrown.
+ * If the conversion fails an {@link org.apache.camel.InvalidPayloadException} is thrown.
  *
  * @version 
  */
-public class ConvertBodyProcessor implements Processor {
+public class ConvertBodyProcessor extends ServiceSupport implements Processor {
     private final Class<?> type;
     private final String charset;
 
     public ConvertBodyProcessor(Class<?> type) {
+        ObjectHelper.notNull(type, "type", this);
         this.type = type;
         this.charset = null;
     }
 
     public ConvertBodyProcessor(Class<?> type, String charset) {
+        ObjectHelper.notNull(type, "type", this);
         this.type = type;
-        this.charset = charset;
+        this.charset = IOHelper.normalizeCharset(charset);
     }
 
     @Override
@@ -50,7 +54,7 @@ public class ConvertBodyProcessor implem
     public void process(Exchange exchange) throws Exception {
         Message in = exchange.getIn();
         if (charset != null) {
-            exchange.setProperty(Exchange.CHARSET_NAME, IOHelper.normalizeCharset(charset));
+            exchange.setProperty(Exchange.CHARSET_NAME, charset);
         }
 
         // only convert if the is a body
@@ -70,4 +74,14 @@ public class ConvertBodyProcessor implem
     public Class<?> getType() {
         return type;
     }
+
+    @Override
+    protected void doStart() throws Exception {
+        // noop
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        // noop
+    }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ExchangePatternProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ExchangePatternProcessor.java?rev=1327430&r1=1327429&r2=1327430&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ExchangePatternProcessor.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ExchangePatternProcessor.java
Wed Apr 18 09:10:12 2012
@@ -19,8 +19,9 @@ package org.apache.camel.processor;
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Processor;
+import org.apache.camel.support.ServiceSupport;
 
-public class ExchangePatternProcessor implements Processor {
+public class ExchangePatternProcessor extends ServiceSupport implements Processor {
     private ExchangePattern exchangePattern = ExchangePattern.InOnly;
     
     public ExchangePatternProcessor() {
@@ -42,4 +43,14 @@ public class ExchangePatternProcessor im
     public String toString() {
         return "SetExchangePattern[" + exchangePattern + "]";
     }
+
+    @Override
+    protected void doStart() throws Exception {
+        // noop
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        // noop
+    }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LogProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LogProcessor.java?rev=1327430&r1=1327429&r2=1327430&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LogProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LogProcessor.java Wed
Apr 18 09:10:12 2012
@@ -21,15 +21,16 @@ import org.apache.camel.AsyncProcessor;
 import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
 import org.apache.camel.Traceable;
+import org.apache.camel.support.ServiceSupport;
 import org.apache.camel.util.AsyncProcessorHelper;
 import org.apache.camel.util.CamelLogger;
 
 /**
- * A processor which evaluates an Expression and logs it.
+ * A processor which evaluates an {@link Expression} and logs it.
  *
  * @version 
  */
-public class LogProcessor implements AsyncProcessor, Traceable {
+public class LogProcessor extends ServiceSupport implements AsyncProcessor, Traceable {
 
     private final Expression expression;
     private final CamelLogger logger;
@@ -67,4 +68,14 @@ public class LogProcessor implements Asy
     public String getTraceLabel() {
         return "log[" + expression + "]";
     }
+
+    @Override
+    protected void doStart() throws Exception {
+        // noop
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        // noop
+    }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RollbackProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RollbackProcessor.java?rev=1327430&r1=1327429&r2=1327430&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RollbackProcessor.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RollbackProcessor.java
Wed Apr 18 09:10:12 2012
@@ -20,13 +20,14 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.RollbackExchangeException;
 import org.apache.camel.Traceable;
+import org.apache.camel.support.ServiceSupport;
 
 /**
  * Processor for marking an {@link org.apache.camel.Exchange} to rollback.
  *
  * @version 
  */
-public class RollbackProcessor implements Processor, Traceable {
+public class RollbackProcessor extends ServiceSupport implements Processor, Traceable {
 
     private boolean markRollbackOnly;
     private boolean markRollbackOnlyLast;
@@ -90,4 +91,14 @@ public class RollbackProcessor implement
     public void setMarkRollbackOnlyLast(boolean markRollbackOnlyLast) {
         this.markRollbackOnlyLast = markRollbackOnlyLast;
     }
+
+    @Override
+    protected void doStart() throws Exception {
+        // noop
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        // noop
+    }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SetBodyProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SetBodyProcessor.java?rev=1327430&r1=1327429&r2=1327430&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SetBodyProcessor.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SetBodyProcessor.java
Wed Apr 18 09:10:12 2012
@@ -22,11 +22,12 @@ import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.Traceable;
 import org.apache.camel.impl.DefaultMessage;
+import org.apache.camel.support.ServiceSupport;
 
 /**
- * A processor which sets the body on the IN message with an expression
+ * A processor which sets the body on the IN message with an {@link Expression}
  */
-public class SetBodyProcessor implements Processor, Traceable {
+public class SetBodyProcessor extends ServiceSupport implements Processor, Traceable {
     private final Expression expression;
 
     public SetBodyProcessor(Expression expression) {
@@ -53,4 +54,14 @@ public class SetBodyProcessor implements
     public String getTraceLabel() {
         return "setBody[" + expression + "]";
     }
+
+    @Override
+    protected void doStart() throws Exception {
+        // noop
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        // noop
+    }
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SortProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SortProcessor.java?rev=1327430&r1=1327429&r2=1327430&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SortProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SortProcessor.java Wed
Apr 18 09:10:12 2012
@@ -24,11 +24,12 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
+import org.apache.camel.support.ServiceSupport;
 
 /**
  * A processor that sorts the expression using a comparator
  */
-public class SortProcessor<T> implements Processor {
+public class SortProcessor<T> extends ServiceSupport implements Processor {
 
     private final Expression expression;
     private final Comparator<? super T> comparator;
@@ -57,6 +58,16 @@ public class SortProcessor<T> implements
     public String toString() {
         return "Sort[" + expression + "]";
     }
+
+    @Override
+    protected void doStart() throws Exception {
+        // noop
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        // noop
+    }
 }
 
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StopProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StopProcessor.java?rev=1327430&r1=1327429&r2=1327430&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StopProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StopProcessor.java Wed
Apr 18 09:10:12 2012
@@ -18,13 +18,14 @@ package org.apache.camel.processor;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
+import org.apache.camel.support.ServiceSupport;
 
 /**
  * Stops continue processing the route and marks it as complete.
  *
  * @version 
  */
-public class StopProcessor implements Processor {
+public class StopProcessor extends ServiceSupport implements Processor {
 
     public void process(Exchange exchange) throws Exception {
         // mark the exchange to stop continue routing
@@ -35,4 +36,14 @@ public class StopProcessor implements Pr
     public String toString() {
         return "Stop";
     }
+
+    @Override
+    protected void doStart() throws Exception {
+        // noop
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        // noop
+    }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ThrowExceptionProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ThrowExceptionProcessor.java?rev=1327430&r1=1327429&r2=1327430&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ThrowExceptionProcessor.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ThrowExceptionProcessor.java
Wed Apr 18 09:10:12 2012
@@ -19,14 +19,17 @@ package org.apache.camel.processor;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.Traceable;
+import org.apache.camel.support.ServiceSupport;
+import org.apache.camel.util.ObjectHelper;
 
 /**
- * The processor which implements the ThrowException DSL
+ * The processor which sets an {@link Exception} on the {@link Exchange}
  */
-public class ThrowExceptionProcessor implements Processor, Traceable {
+public class ThrowExceptionProcessor extends ServiceSupport implements Processor, Traceable
{
     private final Exception exception;
 
     public ThrowExceptionProcessor(Exception exception) {
+        ObjectHelper.notNull(exception, "exception", this);
         this.exception = exception;
     }
 
@@ -44,4 +47,14 @@ public class ThrowExceptionProcessor imp
     public String toString() {
         return "ThrowException";
     }
+
+    @Override
+    protected void doStart() throws Exception {
+        // noop
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        // noop
+    }
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TransformProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TransformProcessor.java?rev=1327430&r1=1327429&r2=1327430&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TransformProcessor.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/TransformProcessor.java
Wed Apr 18 09:10:12 2012
@@ -18,26 +18,34 @@ package org.apache.camel.processor;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
+import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.Traceable;
+import org.apache.camel.impl.DefaultMessage;
+import org.apache.camel.support.ServiceSupport;
+import org.apache.camel.util.ObjectHelper;
 
 /**
- * A processor which sets the body on the OUT message with an expression
+ * A processor which sets the body on the OUT message with an {@link Expression}
  */
-public class TransformProcessor implements Processor, Traceable {
+public class TransformProcessor extends ServiceSupport implements Processor, Traceable {
     private final Expression expression;
 
     public TransformProcessor(Expression expression) {
+        ObjectHelper.notNull(expression, "expression", this);
         this.expression = expression;
     }
 
     public void process(Exchange exchange) throws Exception {
         Object newBody = expression.evaluate(exchange, Object.class);
-        exchange.getOut().setBody(newBody);
 
-        // propagate headers and attachments
-        exchange.getOut().getHeaders().putAll(exchange.getIn().getHeaders());
-        exchange.getOut().setAttachments(exchange.getIn().getAttachments());
+        Message old = exchange.getIn();
+
+        // create a new message container so we do not drag specialized message objects along
+        Message msg = new DefaultMessage();
+        msg.copyFrom(old);
+        msg.setBody(newBody);
+        exchange.setOut(msg);
     }
 
     @Override
@@ -48,4 +56,14 @@ public class TransformProcessor implemen
     public String getTraceLabel() {
         return "transform[" + expression + "]";
     }
+
+    @Override
+    protected void doStart() throws Exception {
+        // noop
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        // noop
+    }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/PredicateValidatingProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/PredicateValidatingProcessor.java?rev=1327430&r1=1327429&r2=1327430&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/PredicateValidatingProcessor.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/validation/PredicateValidatingProcessor.java
Wed Apr 18 09:10:12 2012
@@ -20,22 +20,24 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
 import org.apache.camel.Traceable;
+import org.apache.camel.support.ServiceSupport;
+import org.apache.camel.util.ObjectHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * A processor which validates the content of the inbound message body
- * against a predicate.
+ * A processor which validates the content of the inbound message body against a {@link Predicate}.
  * 
  * @version 
  */
-public class PredicateValidatingProcessor implements Processor, Traceable {
+public class PredicateValidatingProcessor extends ServiceSupport implements Processor, Traceable
{
     
     private static final Logger LOG = LoggerFactory.getLogger(PredicateValidatingProcessor.class);
 
     private final Predicate predicate;
     
     public PredicateValidatingProcessor(Predicate predicate) {
+        ObjectHelper.notNull(predicate, "predicate", this);
         this.predicate = predicate;
     }
 
@@ -63,4 +65,14 @@ public class PredicateValidatingProcesso
     public String getTraceLabel() {
         return "validate[" + predicate + "]";
     }
+
+    @Override
+    protected void doStart() throws Exception {
+        // noop
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        // noop
+    }
 }



Mime
View raw message