You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2007/09/17 16:05:55 UTC
svn commit: r576446 - in /activemq/camel/trunk/camel-core/src:
main/java/org/apache/camel/impl/ main/java/org/apache/camel/model/
main/java/org/apache/camel/processor/ test/java/org/apache/camel/model/
test/java/org/apache/camel/processor/
Author: gnodet
Date: Mon Sep 17 07:05:53 2007
New Revision: 576446
URL: http://svn.apache.org/viewvc?rev=576446&view=rev
Log:
Fix some java DSL missing verbs and code redundancy using generics
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteContext.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/CatchType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ChoiceType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/MulticastType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OtherwiseType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OutputType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ResequencerType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TryType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/WhenType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Pipeline.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteContext.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteContext.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteContext.java Mon Sep 17 07:05:53 2007
@@ -16,21 +16,17 @@
*/
package org.apache.camel.impl;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
-import org.apache.camel.NoSuchEndpointException;
-import org.apache.camel.Processor;
-import org.apache.camel.Route;
+import org.apache.camel.*;
import org.apache.camel.model.FromType;
import org.apache.camel.model.ProcessorType;
import org.apache.camel.model.RouteType;
import org.apache.camel.processor.Interceptor;
import org.apache.camel.processor.Pipeline;
import org.apache.camel.processor.ProceedProcessor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
/**
* The context used to activate new routing rules
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/CatchType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/CatchType.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/CatchType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/CatchType.java Mon Sep 17 07:05:53 2007
@@ -42,7 +42,7 @@
@XmlElement(name = "exception")
private List<String> exceptions = new ArrayList<String>();
@XmlElementRef
- private List<ProcessorType> outputs = new ArrayList<ProcessorType>();
+ private List<ProcessorType<?>> outputs = new ArrayList<ProcessorType<?>>();
@XmlTransient
private List<Class> exceptionClasses;
@@ -82,11 +82,11 @@
this.interceptors = interceptors;
}
- public List<ProcessorType> getOutputs() {
+ public List<ProcessorType<?>> getOutputs() {
return outputs;
}
- public void setOutputs(List<ProcessorType> outputs) {
+ public void setOutputs(List<ProcessorType<?>> outputs) {
this.outputs = outputs;
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ChoiceType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ChoiceType.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ChoiceType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ChoiceType.java Mon Sep 17 07:05:53 2007
@@ -41,7 +41,7 @@
*/
@XmlRootElement(name = "choice")
@XmlAccessorType(XmlAccessType.FIELD)
-public class ChoiceType extends ProcessorType {
+public class ChoiceType extends ProcessorType<ChoiceType> {
@XmlElementRef
private List<InterceptorType> interceptors = new ArrayList<InterceptorType>();
@XmlElementRef
@@ -80,192 +80,6 @@
return answer;
}
- public ChoiceType proceed() {
- super.proceed();
- return this;
- }
-
- public ChoiceType to(Endpoint endpoint) {
- super.to(endpoint);
- return this;
- }
-
- public ChoiceType to(Collection<Endpoint> endpoints) {
- super.to(endpoints);
- return this;
- }
-
- public ChoiceType to(Endpoint... endpoints) {
- super.to(endpoints);
- return this;
- }
-
- public ChoiceType to(String uri) {
- super.to(uri);
- return this;
- }
-
- public ChoiceType to(String... uris) {
- super.to(uris);
- return this;
- }
-
- @Override
- public ChoiceType bean(Object bean) {
- super.bean(bean);
- return this;
- }
-
- @Override
- public ChoiceType bean(Object bean, String method) {
- super.bean(bean, method);
- return this;
- }
-
- @Override
- public ChoiceType beanRef(String ref) {
- super.beanRef(ref);
- return this;
- }
-
- @Override
- public ChoiceType beanRef(String ref, String method) {
- super.beanRef(ref, method);
- return this;
- }
-
- @Override
- public ChoiceType convertBodyTo(Class type) {
- super.convertBodyTo(type);
- return this;
- }
-
- @Override
- public ChoiceType convertFaultBodyTo(Class type) {
- super.convertFaultBodyTo(type);
- return this;
- }
-
- @Override
- public ChoiceType convertOutBodyTo(Class type) {
- super.convertOutBodyTo(type);
- return this;
- }
-
- @Override
- public ChoiceType inheritErrorHandler(boolean condition) {
- super.inheritErrorHandler(condition);
- return this;
- }
-
- @Override
- public ChoiceType intercept(DelegateProcessor interceptor) {
- super.intercept(interceptor);
- return this;
- }
-
- @Override
- public ChoiceType interceptor(String ref) {
- super.interceptor(ref);
- return this;
- }
-
- @Override
- public ChoiceType interceptors(String... refs) {
- super.interceptors(refs);
- return this;
- }
-
- @Override
- public ChoiceType pipeline(Collection<Endpoint> endpoints) {
- super.pipeline(endpoints);
- return this;
- }
-
- @Override
- public ChoiceType pipeline(Endpoint... endpoints) {
- super.pipeline(endpoints);
- return this;
- }
-
- @Override
- public ChoiceType pipeline(String... uris) {
- super.pipeline(uris);
- return this;
- }
-
- @Override
- public ChoiceType process(Processor processor) {
- super.process(processor);
- return this;
- }
-
- @Override
- public ChoiceType recipientList(Expression receipients) {
- super.recipientList(receipients);
- return this;
- }
-
- @Override
- public ChoiceType removeHeader(String name) {
- super.removeHeader(name);
- return this;
- }
-
- @Override
- public ChoiceType removeOutHeader(String name) {
- super.removeOutHeader(name);
- return this;
- }
-
- @Override
- public ChoiceType removeProperty(String name) {
- super.removeProperty(name);
- return this;
- }
-
- @Override
- public ChoiceType setBody(Expression expression) {
- super.setBody(expression);
- return this;
- }
-
- @Override
- public ChoiceType setHeader(String name, Expression expression) {
- super.setHeader(name, expression);
- return this;
- }
-
- @Override
- public ChoiceType setOutBody(Expression expression) {
- super.setOutBody(expression);
- return this;
- }
-
- @Override
- public ChoiceType setOutHeader(String name, Expression expression) {
- super.setOutHeader(name, expression);
- return this;
- }
-
- @Override
- public ChoiceType setProperty(String name, Expression expression) {
- super.setProperty(name, expression);
- return this;
- }
-
- @Override
- public ChoiceType trace() {
- super.trace();
- return this;
- }
-
- @Override
- public ChoiceType trace(String category) {
- super.trace(category);
- return this;
- }
-
// Properties
// -------------------------------------------------------------------------
@@ -287,7 +101,7 @@
this.whenClauses = whenClauses;
}
- public List<ProcessorType> getOutputs() {
+ public List<ProcessorType<?>> getOutputs() {
if (otherwise != null) {
return otherwise.getOutputs();
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java Mon Sep 17 07:05:53 2007
@@ -39,7 +39,8 @@
*/
@XmlRootElement(name = "onException")
@XmlAccessorType(XmlAccessType.FIELD)
-public class ExceptionType extends ProcessorType {
+public class ExceptionType extends ProcessorType<ProcessorType> {
+
@XmlElementRef
private List<InterceptorType> interceptors = new ArrayList<InterceptorType>();
@XmlElement(name = "exception")
@@ -47,7 +48,7 @@
@XmlElement(name = "redeliveryPolicy", required = false)
private RedeliveryPolicyType redeliveryPolicy;
@XmlElementRef
- private List<ProcessorType> outputs = new ArrayList<ProcessorType>();
+ private List<ProcessorType<?>> outputs = new ArrayList<ProcessorType<?>>();
@XmlTransient
private List<Class> exceptionClasses;
@XmlTransient
@@ -151,11 +152,11 @@
this.interceptors = interceptors;
}
- public List<ProcessorType> getOutputs() {
+ public List<ProcessorType<?>> getOutputs() {
return outputs;
}
- public void setOutputs(List<ProcessorType> outputs) {
+ public void setOutputs(List<ProcessorType<?>> outputs) {
this.outputs = outputs;
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExpressionNode.java Mon Sep 17 07:05:53 2007
@@ -21,7 +21,6 @@
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import org.apache.camel.Expression;
@@ -37,13 +36,13 @@
* @version $Revision: $
*/
@XmlAccessorType(XmlAccessType.FIELD)
-public class ExpressionNode extends ProcessorType {
+public class ExpressionNode extends ProcessorType<ProcessorType> {
@XmlElementRef
private List<InterceptorType> interceptors = new ArrayList<InterceptorType>();
@XmlElementRef
private ExpressionType expression;
@XmlElementRef
- private List<ProcessorType> outputs = new ArrayList<ProcessorType>();
+ private List<ProcessorType<?>> outputs = new ArrayList<ProcessorType<?>>();
public ExpressionNode() {
}
@@ -76,11 +75,11 @@
this.expression = expression;
}
- public List<ProcessorType> getOutputs() {
+ public List<ProcessorType<?>> getOutputs() {
return outputs;
}
- public void setOutputs(List<ProcessorType> outputs) {
+ public void setOutputs(List<ProcessorType<?>> outputs) {
this.outputs = outputs;
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptType.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptType.java Mon Sep 17 07:05:53 2007
@@ -33,7 +33,8 @@
*/
@XmlRootElement(name = "intercept")
@XmlAccessorType(XmlAccessType.FIELD)
-public class InterceptType extends OutputType {
+public class InterceptType extends OutputType<ProcessorType> {
+
@Override
public String toString() {
return "Intercept[" + getOutputs() + "]";
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/MulticastType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/MulticastType.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/MulticastType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/MulticastType.java Mon Sep 17 07:05:53 2007
@@ -31,7 +31,7 @@
*/
@XmlRootElement(name = "multicast")
@XmlAccessorType(XmlAccessType.FIELD)
-public class MulticastType extends OutputType {
+public class MulticastType extends OutputType<ProcessorType> {
@Override
public String toString() {
return "Multicast[" + getOutputs() + "]";
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OtherwiseType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OtherwiseType.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OtherwiseType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OtherwiseType.java Mon Sep 17 07:05:53 2007
@@ -29,6 +29,7 @@
@XmlRootElement(name = "otherwise")
@XmlAccessorType(XmlAccessType.FIELD)
public class OtherwiseType extends OutputType {
+
@Override
public String toString() {
return "Otherwise[" + getOutputs() + "]";
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OutputType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OutputType.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OutputType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OutputType.java Mon Sep 17 07:05:53 2007
@@ -19,7 +19,6 @@
import java.util.ArrayList;
import java.util.List;
-import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlAccessorType;
@@ -35,19 +34,19 @@
*/
@XmlType(name = "outputType")
@XmlAccessorType(XmlAccessType.FIELD)
-public class OutputType extends ProcessorType {
+public class OutputType<Type extends ProcessorType> extends ProcessorType<Type> {
private static final transient Log LOG = LogFactory.getLog(OutputType.class);
@XmlElementRef
- protected List<ProcessorType> outputs = new ArrayList<ProcessorType>();
+ protected List<ProcessorType<?>> outputs = new ArrayList<ProcessorType<?>>();
@XmlElementRef
private List<InterceptorType> interceptors = new ArrayList<InterceptorType>();
- public List<ProcessorType> getOutputs() {
+ public List<ProcessorType<?>> getOutputs() {
return outputs;
}
- public void setOutputs(List<ProcessorType> outputs) {
+ public void setOutputs(List<ProcessorType<?>> outputs) {
this.outputs = outputs;
if (outputs != null) {
for (ProcessorType output : outputs) {
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java Mon Sep 17 07:05:53 2007
@@ -53,7 +53,7 @@
/**
* @version $Revision: 1.1 $
*/
-public abstract class ProcessorType {
+public abstract class ProcessorType<Type extends ProcessorType> {
public static final String DEFAULT_TRACE_CATEGORY = "org.apache.camel.TRACE";
private ErrorHandlerBuilder errorHandlerBuilder;
private Boolean inheritErrorHandlerFlag = Boolean.TRUE; // TODO not sure how
@@ -64,7 +64,7 @@
// attribute in
// JAXB2
- public abstract List<ProcessorType> getOutputs();
+ public abstract List<ProcessorType<?>> getOutputs();
public abstract List<InterceptorType> getInterceptors();
@@ -73,7 +73,7 @@
}
public Processor createOutputsProcessor(RouteContext routeContext) throws Exception {
- Collection<ProcessorType> outputs = getOutputs();
+ Collection<ProcessorType<?>> outputs = getOutputs();
return createOutputsProcessor(routeContext, outputs);
}
@@ -97,50 +97,50 @@
/**
* Sends the exchange to the given endpoint URI
*/
- public ProcessorType to(String uri) {
+ public Type to(String uri) {
addOutput(new ToType(uri));
- return this;
+ return (Type) this;
}
/**
* Sends the exchange to the given endpoint
*/
- public ProcessorType to(Endpoint endpoint) {
+ public Type to(Endpoint endpoint) {
addOutput(new ToType(endpoint));
- return this;
+ return (Type) this;
}
/**
* Sends the exchange to a list of endpoints using the
* {@link MulticastProcessor} pattern
*/
- public ProcessorType to(String... uris) {
+ public Type to(String... uris) {
for (String uri : uris) {
addOutput(new ToType(uri));
}
- return this;
+ return (Type) this;
}
/**
* Sends the exchange to a list of endpoints using the
* {@link MulticastProcessor} pattern
*/
- public ProcessorType to(Endpoint... endpoints) {
+ public Type to(Endpoint... endpoints) {
for (Endpoint endpoint : endpoints) {
addOutput(new ToType(endpoint));
}
- return this;
+ return (Type) this;
}
/**
* Sends the exchange to a list of endpoint using the
* {@link MulticastProcessor} pattern
*/
- public ProcessorType to(Collection<Endpoint> endpoints) {
+ public Type to(Collection<Endpoint> endpoints) {
for (Endpoint endpoint : endpoints) {
addOutput(new ToType(endpoint));
}
- return this;
+ return (Type) this;
}
/**
@@ -159,7 +159,7 @@
* will get processed by each endpoint in turn and for request/response the
* output of one endpoint will be the input of the next endpoint
*/
- public ProcessorType pipeline(String... uris) {
+ public Type pipeline(String... uris) {
// TODO pipeline v mulicast
return to(uris);
}
@@ -169,7 +169,7 @@
* will get processed by each endpoint in turn and for request/response the
* output of one endpoint will be the input of the next endpoint
*/
- public ProcessorType pipeline(Endpoint... endpoints) {
+ public Type pipeline(Endpoint... endpoints) {
// TODO pipeline v mulicast
return to(endpoints);
}
@@ -179,7 +179,7 @@
* will get processed by each endpoint in turn and for request/response the
* output of one endpoint will be the input of the next endpoint
*/
- public ProcessorType pipeline(Collection<Endpoint> endpoints) {
+ public Type pipeline(Collection<Endpoint> endpoints) {
// TODO pipeline v mulicast
return to(endpoints);
}
@@ -236,10 +236,10 @@
* @param receipients is the builder of the expression used in the
* {@link RecipientList} to decide the destinations
*/
- public ProcessorType recipientList(Expression receipients) {
+ public Type recipientList(Expression receipients) {
RecipientListType answer = new RecipientListType(receipients);
addOutput(answer);
- return this;
+ return (Type) this;
}
/**
@@ -415,9 +415,9 @@
return answer;
}
- public ProcessorType interceptor(String ref) {
+ public Type interceptor(String ref) {
getInterceptors().add(new InterceptorRef(ref));
- return this;
+ return (Type) this;
}
public InterceptType intercept() {
@@ -426,9 +426,9 @@
return answer;
}
- public ProcessorType proceed() {
+ public Type proceed() {
addOutput(new ProceedType());
- return this;
+ return (Type) this;
}
public ExceptionType exception(Class exceptionType) {
@@ -446,11 +446,11 @@
return answer.when(predicate);
}
- public ProcessorType interceptors(String... refs) {
+ public Type interceptors(String... refs) {
for (String ref : refs) {
interceptor(ref);
}
- return this;
+ return (Type) this;
}
public FilterType filter(ExpressionType expression) {
@@ -470,7 +470,7 @@
*
* @return
*/
- public ProcessorType trace() {
+ public Type trace() {
return trace(DEFAULT_TRACE_CATEGORY);
}
@@ -481,7 +481,7 @@
* @param category the logging category trace messages will sent to.
* @return
*/
- public ProcessorType trace(String category) {
+ public Type trace(String category) {
final Log log = LogFactory.getLog(category);
return intercept(new DelegateProcessor() {
@Override
@@ -504,10 +504,10 @@
return answer;
}
- public ProcessorType intercept(DelegateProcessor interceptor) {
+ public Type intercept(DelegateProcessor interceptor) {
getInterceptors().add(new InterceptorRef(interceptor));
lastInterceptor = interceptor;
- return this;
+ return (Type) this;
}
/**
@@ -517,9 +517,9 @@
* all child routes
* @return the current builder with the error handler configured
*/
- public ProcessorType errorHandler(ErrorHandlerBuilder errorHandlerBuilder) {
+ public Type errorHandler(ErrorHandlerBuilder errorHandlerBuilder) {
setErrorHandlerBuilder(errorHandlerBuilder);
- return this;
+ return (Type) this;
}
/**
@@ -530,9 +530,9 @@
* inherited or not
* @return the current builder
*/
- public ProcessorType inheritErrorHandler(boolean condition) {
+ public Type inheritErrorHandler(boolean condition) {
setInheritErrorHandlerFlag(condition);
- return this;
+ return (Type) this;
}
// Transformers
@@ -542,129 +542,150 @@
* Adds the custom processor to this destination which could be a final
* destination, or could be a transformation in a pipeline
*/
- public ProcessorType process(Processor processor) {
+ public Type process(Processor processor) {
ProcessorRef answer = new ProcessorRef(processor);
addOutput(answer);
- return this;
+ return (Type) this;
}
/**
* Adds a bean which is invoked which could be a final destination, or could
* be a transformation in a pipeline
*/
- public ProcessorType bean(Object bean) {
+ public Type bean(Object bean) {
BeanRef answer = new BeanRef();
answer.setBean(bean);
addOutput(answer);
- return this;
+ return (Type) this;
}
/**
* Adds a bean and method which is invoked which could be a final
* destination, or could be a transformation in a pipeline
*/
- public ProcessorType bean(Object bean, String method) {
+ public Type bean(Object bean, String method) {
BeanRef answer = new BeanRef();
answer.setBean(bean);
answer.setMethod(method);
addOutput(answer);
- return this;
+ return (Type) this;
}
/**
* Adds a bean which is invoked which could be a final destination, or could
* be a transformation in a pipeline
*/
- public ProcessorType beanRef(String ref) {
+ public Type beanRef(String ref) {
BeanRef answer = new BeanRef(ref);
addOutput(answer);
- return this;
+ return (Type) this;
}
/**
* Adds a bean and method which is invoked which could be a final
* destination, or could be a transformation in a pipeline
*/
- public ProcessorType beanRef(String ref, String method) {
+ public Type beanRef(String ref, String method) {
BeanRef answer = new BeanRef(ref, method);
addOutput(answer);
- return this;
+ return (Type) this;
}
/**
* Adds a processor which sets the body on the IN message
*/
- public ProcessorType setBody(Expression expression) {
+ public Type setBody(Expression expression) {
return process(ProcessorBuilder.setBody(expression));
}
/**
* Adds a processor which sets the body on the OUT message
*/
- public ProcessorType setOutBody(Expression expression) {
+ public Type setOutBody(Expression expression) {
return process(ProcessorBuilder.setOutBody(expression));
}
/**
+ * Adds a processor which sets the body on the FAULT message
+ */
+ public Type setFaultBody(Expression expression) {
+ return process(ProcessorBuilder.setFaultBody(expression));
+ }
+
+ /**
* Adds a processor which sets the header on the IN message
*/
- public ProcessorType setHeader(String name, Expression expression) {
+ public Type setHeader(String name, Expression expression) {
return process(ProcessorBuilder.setHeader(name, expression));
}
/**
* Adds a processor which sets the header on the OUT message
*/
- public ProcessorType setOutHeader(String name, Expression expression) {
+ public Type setOutHeader(String name, Expression expression) {
return process(ProcessorBuilder.setOutHeader(name, expression));
}
/**
+ * Adds a processor which sets the header on the FAULT message
+ */
+ public Type setFaultHeader(String name, Expression expression) {
+ return process(ProcessorBuilder.setFaultHeader(name, expression));
+ }
+
+ /**
* Adds a processor which sets the exchange property
*/
- public ProcessorType setProperty(String name, Expression expression) {
+ public Type setProperty(String name, Expression expression) {
return process(ProcessorBuilder.setProperty(name, expression));
}
/**
* Adds a processor which removes the header on the IN message
*/
- public ProcessorType removeHeader(String name) {
+ public Type removeHeader(String name) {
return process(ProcessorBuilder.removeHeader(name));
}
/**
* Adds a processor which removes the header on the OUT message
*/
- public ProcessorType removeOutHeader(String name) {
+ public Type removeOutHeader(String name) {
return process(ProcessorBuilder.removeOutHeader(name));
}
/**
+ * Adds a processor which removes the header on the FAULT message
+ */
+ public Type removeFaultHeader(String name) {
+ return process(ProcessorBuilder.removeFaultHeader(name));
+ }
+
+ /**
* Adds a processor which removes the exchange property
*/
- public ProcessorType removeProperty(String name) {
+ public Type removeProperty(String name) {
return process(ProcessorBuilder.removeProperty(name));
}
/**
* Converts the IN message body to the specified type
*/
- public ProcessorType convertBodyTo(Class type) {
+ public Type convertBodyTo(Class type) {
return process(ProcessorBuilder.setBody(Builder.body().convertTo(type)));
}
/**
* Converts the OUT message body to the specified type
*/
- public ProcessorType convertOutBodyTo(Class type) {
+ public Type convertOutBodyTo(Class type) {
return process(ProcessorBuilder.setOutBody(Builder.outBody().convertTo(type)));
}
/**
* Converts the FAULT message body to the specified type
*/
- public ProcessorType convertFaultBodyTo(Class type) {
+ public Type convertFaultBodyTo(Class type) {
return process(ProcessorBuilder.setFaultBody(Builder.faultBody().convertTo(type)));
}
@@ -811,7 +832,7 @@
return new Pipeline(list);
}
- protected Processor createOutputsProcessor(RouteContext routeContext, Collection<ProcessorType> outputs)
+ protected Processor createOutputsProcessor(RouteContext routeContext, Collection<ProcessorType<?>> outputs)
throws Exception {
List<Processor> list = new ArrayList<Processor>();
for (ProcessorType output : outputs) {
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ResequencerType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ResequencerType.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ResequencerType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ResequencerType.java Mon Sep 17 07:05:53 2007
@@ -40,13 +40,13 @@
* @version $Revision: 1.1 $
*/
@XmlRootElement(name = "resequencer")
-public class ResequencerType extends ProcessorType {
+public class ResequencerType extends ProcessorType<ProcessorType> {
@XmlElementRef
private List<InterceptorType> interceptors = new ArrayList<InterceptorType>();
@XmlElementRef
private List<ExpressionType> expressions = new ArrayList<ExpressionType>();
@XmlElementRef
- private List<ProcessorType> outputs = new ArrayList<ProcessorType>();
+ private List<ProcessorType<?>> outputs = new ArrayList<ProcessorType<?>>();
// Binding annotation at setter
private BatchResequencerConfig batchConfig;
// Binding annotation at setter
@@ -129,11 +129,11 @@
this.interceptors = interceptors;
}
- public List<ProcessorType> getOutputs() {
+ public List<ProcessorType<?>> getOutputs() {
return outputs;
}
- public void setOutputs(List<ProcessorType> outputs) {
+ public void setOutputs(List<ProcessorType<?>> outputs) {
this.outputs = outputs;
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java Mon Sep 17 07:05:53 2007
@@ -16,27 +16,16 @@
*/
package org.apache.camel.model;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElementRef;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
-import javax.xml.bind.annotation.XmlType;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.CamelContextAware;
-import org.apache.camel.Endpoint;
-import org.apache.camel.NoSuchEndpointException;
-import org.apache.camel.Route;
+import org.apache.camel.*;
import org.apache.camel.impl.RouteContext;
import org.apache.camel.util.CamelContextHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import javax.xml.bind.annotation.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
/**
* Represents an XML <route/> element
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java Mon Sep 17 07:05:53 2007
@@ -22,7 +22,6 @@
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlRootElement;
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ToType.java Mon Sep 17 07:05:53 2007
@@ -23,7 +23,6 @@
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlElementRef;
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TryType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TryType.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TryType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TryType.java Mon Sep 17 07:05:53 2007
@@ -17,7 +17,6 @@
package org.apache.camel.model;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
@@ -25,7 +24,6 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
-import org.apache.camel.Endpoint;
import org.apache.camel.Processor;
import org.apache.camel.impl.RouteContext;
import org.apache.camel.processor.CatchProcessor;
@@ -36,7 +34,7 @@
*/
@XmlRootElement(name = "try")
@XmlAccessorType(XmlAccessType.FIELD)
-public class TryType extends OutputType {
+public class TryType extends OutputType<TryType> {
@XmlTransient
private List<CatchType> catchClauses;
@XmlTransient
@@ -44,7 +42,7 @@
@XmlTransient
private boolean initialized;
@XmlTransient
- private List<ProcessorType> outputsWithoutCatches;
+ private List<ProcessorType<?>> outputsWithoutCatches;
@Override
public String toString() {
@@ -82,36 +80,6 @@
return answer;
}
- public TryType process(Processor processor) {
- super.process(processor);
- return this;
- }
-
- public TryType to(Endpoint endpoint) {
- super.to(endpoint);
- return this;
- }
-
- public TryType to(Collection<Endpoint> endpoints) {
- super.to(endpoints);
- return this;
- }
-
- public TryType to(Endpoint... endpoints) {
- super.to(endpoints);
- return this;
- }
-
- public TryType to(String uri) {
- super.to(uri);
- return this;
- }
-
- public TryType to(String... uris) {
- super.to(uris);
- return this;
- }
-
// Properties
// -------------------------------------------------------------------------
@@ -129,14 +97,14 @@
return finallyClause;
}
- public List<ProcessorType> getOutputsWithoutCatches() {
+ public List<ProcessorType<?>> getOutputsWithoutCatches() {
if (outputsWithoutCatches == null) {
checkInitialized();
}
return outputsWithoutCatches;
}
- public void setOutputs(List<ProcessorType> outputs) {
+ public void setOutputs(List<ProcessorType<?>> outputs) {
initialized = false;
super.setOutputs(outputs);
}
@@ -152,7 +120,7 @@
protected void checkInitialized() {
if (!initialized) {
initialized = true;
- outputsWithoutCatches = new ArrayList<ProcessorType>();
+ outputsWithoutCatches = new ArrayList<ProcessorType<?>>();
catchClauses = new ArrayList<CatchType>();
finallyClause = null;
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/WhenType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/WhenType.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/WhenType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/WhenType.java Mon Sep 17 07:05:53 2007
@@ -27,7 +27,7 @@
* @version $Revision: 1.1 $
*/
@XmlRootElement(name = "when")
-public class WhenType extends ExpressionNode {
+public class WhenType<Type extends ProcessorType> extends ExpressionNode {
public WhenType() {
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Pipeline.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Pipeline.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Pipeline.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Pipeline.java Mon Sep 17 07:05:53 2007
@@ -83,7 +83,7 @@
* exception but it seem that folks don't expect to get that exception.
*
* @param exchange
- * @throws Exception
+ * @throws Exception thx
*/
public void xprocess(Exchange exchange) throws Exception {
// This could become a base class method for an AsyncProcessor
@@ -182,8 +182,8 @@
// now lets set the input of the next exchange to the output of the
// previous message if it is not null
- Message previousOut = previousExchange.getOut();
- Object output = previousOut.getBody();
+ Message previousOut = previousExchange.getOut(false);
+ Object output = previousOut != null ? previousOut.getBody() : null;
Message in = answer.getIn();
if (output != null) {
in.setBody(output);
Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/model/XmlParseTest.java Mon Sep 17 07:05:53 2007
@@ -140,8 +140,8 @@
assertEquals("From URI", uri, from.getUri());
}
- protected void assertChildTo(String message, ProcessorType route, String uri) {
- ProcessorType processor = assertOneElement(route.getOutputs());
+ protected void assertChildTo(String message, ProcessorType<?> route, String uri) {
+ ProcessorType<?> processor = assertOneElement(route.getOutputs());
ToType value = assertIsInstanceOf(ToType.class, processor);
String text = message + "To URI";
log.info("Testing: " + text + " is equal to: " + uri + " for processor: " + processor);
@@ -156,41 +156,41 @@
}
protected void assertChildTo(ProcessorType route, String... uris) {
- List<ProcessorType> list = assertListSize(route.getOutputs(), uris.length);
+ List<ProcessorType<?>> list = assertListSize(route.getOutputs(), uris.length);
int idx = 0;
for (String uri : uris) {
assertTo("output[" + idx + "] ", list.get(idx++), uri);
}
}
- protected void assertProcessor(ProcessorType route, String processorRef) {
- ProcessorType processor = assertOneElement(route.getOutputs());
+ protected void assertProcessor(ProcessorType<?> route, String processorRef) {
+ ProcessorType<?> processor = assertOneElement(route.getOutputs());
ProcessorRef to = assertIsInstanceOf(ProcessorRef.class, processor);
assertEquals("Processor ref", processorRef, to.getRef());
}
- protected FilterType assertFilter(ProcessorType route) {
- ProcessorType processor = assertOneElement(route.getOutputs());
+ protected FilterType assertFilter(ProcessorType<?> route) {
+ ProcessorType<?> processor = assertOneElement(route.getOutputs());
return assertIsInstanceOf(FilterType.class, processor);
}
- protected RecipientListType assertRecipientList(ProcessorType route) {
- ProcessorType processor = assertOneElement(route.getOutputs());
+ protected RecipientListType assertRecipientList(ProcessorType<?> route) {
+ ProcessorType<?> processor = assertOneElement(route.getOutputs());
return assertIsInstanceOf(RecipientListType.class, processor);
}
- protected ChoiceType assertChoice(ProcessorType route) {
- ProcessorType processor = assertOneElement(route.getOutputs());
+ protected ChoiceType assertChoice(ProcessorType<?> route) {
+ ProcessorType<?> processor = assertOneElement(route.getOutputs());
return assertIsInstanceOf(ChoiceType.class, processor);
}
- protected SplitterType assertSplitter(ProcessorType route) {
- ProcessorType processor = assertOneElement(route.getOutputs());
+ protected SplitterType assertSplitter(ProcessorType<?> route) {
+ ProcessorType<?> processor = assertOneElement(route.getOutputs());
return assertIsInstanceOf(SplitterType.class, processor);
}
- protected ResequencerType assertResequencer(ProcessorType route) {
- ProcessorType processor = assertOneElement(route.getOutputs());
+ protected ResequencerType assertResequencer(ProcessorType<?> route) {
+ ProcessorType<?> processor = assertOneElement(route.getOutputs());
return assertIsInstanceOf(ResequencerType.class, processor);
}
Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java?rev=576446&r1=576445&r2=576446&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ChoiceTest.java Mon Sep 17 07:05:53 2007
@@ -77,7 +77,7 @@
return new RouteBuilder() {
public void configure() {
from("direct:start").choice()
- .when(header("foo").isEqualTo("bar")).to("mock:x")
+ .when(header("foo").isEqualTo("bar")).setHeader("name", constant("a")).to("mock:x")
.when(header("foo").isEqualTo("cheese")).to("mock:y")
.otherwise().to("mock:z");
}