You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2007/07/30 10:41:26 UTC

svn commit: r560889 - in /activemq/camel/trunk/camel-core/src/main: java/org/apache/camel/builder/ java/org/apache/camel/model/ java/org/apache/camel/model/language/ java/org/apache/camel/processor/ java/org/apache/camel/util/ resources/org/apache/came...

Author: jstrachan
Date: Mon Jul 30 01:41:10 2007
New Revision: 560889

URL: http://svn.apache.org/viewvc?view=rev&rev=560889
Log:
first cut at merging the JAXB2 model along with the *Builder classes so the Java DSL and the XML DSL sit on top of the same logical model & reuse code

Added:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/AggregatorType.java   (with props)
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayerType.java   (with props)
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/IdempotentConsumerType.java   (with props)
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java   (with props)
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DelayerBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/FromBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ResequencerBuilder.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/FilterType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorRef.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RecipientListType.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/SplitterType.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/WhenType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/ExpressionType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Resequencer.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionListComparator.java
    activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DelayerBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DelayerBuilder.java?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DelayerBuilder.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DelayerBuilder.java Mon Jul 30 01:41:10 2007
@@ -37,6 +37,8 @@
         this.processAtExpression = processAtExpression;
     }
 
+    
+
     @Override
     public Processor createProcessor() throws Exception {
         final Processor processor = super.createProcessor();

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/FromBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/FromBuilder.java?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/FromBuilder.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/FromBuilder.java Mon Jul 30 01:41:10 2007
@@ -186,8 +186,8 @@
      * @param expression the expression on which to compare messages in order
      * @return the builder
      */
-    public ResequencerBuilder resequencer(Expression<Exchange> expression) {
-        return resequencer(Collections.<Expression<Exchange>>singletonList(expression));
+    public ResequencerBuilder resequencer(Expression expression) {
+        return resequencer(Collections.<Expression>singletonList(expression));
     }
 
     /**
@@ -198,7 +198,7 @@
      * @param expressions the expressions on which to compare messages in order
      * @return the builder
      */
-    public ResequencerBuilder resequencer(List<Expression<Exchange>> expressions) {
+    public ResequencerBuilder resequencer(List<Expression> expressions) {
         ResequencerBuilder answer = new ResequencerBuilder(this, expressions);
         setRouteBuilder(answer);
         return answer;
@@ -212,9 +212,9 @@
      * @param expressions the expressions on which to compare messages in order
      * @return the builder
      */
-    public ResequencerBuilder resequencer(Expression<Exchange>... expressions) {
-        List<Expression<Exchange>> list = new ArrayList<Expression<Exchange>>();
-        for (Expression<Exchange> expression : expressions) {
+    public ResequencerBuilder resequencer(Expression... expressions) {
+        List<Expression> list = new ArrayList<Expression>();
+        for (Expression expression : expressions) {
             list.add(expression);
         }
         return resequencer(list);

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ResequencerBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ResequencerBuilder.java?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ResequencerBuilder.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ResequencerBuilder.java Mon Jul 30 01:41:10 2007
@@ -29,11 +29,11 @@
  * @version $Revision: 1.1 $
  */
 public class ResequencerBuilder extends FromBuilder {
-    private final List<Expression<Exchange>> expressions;
+    private final List<Expression> expressions;
     private long batchTimeout = 1000L;
     private int batchSize = 100;
 
-    public ResequencerBuilder(FromBuilder builder, List<Expression<Exchange>> expressions) {
+    public ResequencerBuilder(FromBuilder builder, List<Expression> expressions) {
         super(builder);
         this.expressions = expressions;
     }

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/AggregatorType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/AggregatorType.java?view=auto&rev=560889
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/AggregatorType.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/AggregatorType.java Mon Jul 30 01:41:10 2007
@@ -0,0 +1,91 @@
+/**
+ *
+ * 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.model;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+import org.apache.camel.Processor;
+import org.apache.camel.Route;
+import org.apache.camel.impl.RouteContext;
+import org.apache.camel.model.language.ExpressionType;
+import org.apache.camel.processor.Aggregator;
+import org.apache.camel.processor.aggregate.AggregationStrategy;
+import org.apache.camel.processor.aggregate.UseLatestAggregationStrategy;
+
+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 java.util.Collection;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+@XmlRootElement(name = "aggregator")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class AggregatorType extends ExpressionNode {
+    @XmlTransient
+    private AggregationStrategy aggregationStrategy = new UseLatestAggregationStrategy();
+
+    public AggregatorType() {
+    }
+
+    public AggregatorType(Expression correlationExpression) {
+        super(correlationExpression);
+    }
+
+    public AggregatorType(ExpressionType correlationExpression) {
+        super(correlationExpression);
+    }
+
+    public AggregatorType(Expression correlationExpression, AggregationStrategy aggregationStrategy) {
+        super(correlationExpression);
+        this.aggregationStrategy = aggregationStrategy;
+    }
+
+    @Override
+    public String toString() {
+        return "Aggregator[ " + getExpression() + " -> " + getOutputs() + "]";
+    }
+
+    @Override
+    public void addRoutes(RouteContext routeContext, Collection<Route> routes) throws Exception {
+        Endpoint from = routeContext.getEndpoint();
+        final Processor processor = routeContext.createProcessor(this);
+        final Aggregator service = new Aggregator(from, processor, getExpression().createExpression(routeContext), aggregationStrategy);
+
+        Route route = new Route<Exchange>(from, service) {
+
+            @Override
+            public String toString() {
+                return "AggregatorRoute[" + getEndpoint() + " -> " + processor + "]";
+            }
+        };
+
+        routes.add(route);
+    }
+
+    public AggregationStrategy getAggregationStrategy() {
+        return aggregationStrategy;
+    }
+
+    public void setAggregationStrategy(AggregationStrategy aggregationStrategy) {
+        this.aggregationStrategy = aggregationStrategy;
+    }
+}
\ No newline at end of file

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/AggregatorType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayerType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayerType.java?view=auto&rev=560889
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayerType.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayerType.java Mon Jul 30 01:41:10 2007
@@ -0,0 +1,75 @@
+/**
+ *
+ * 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.model;
+
+import org.apache.camel.Expression;
+import org.apache.camel.Processor;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.RouteContext;
+import org.apache.camel.model.language.ExpressionType;
+import org.apache.camel.processor.Delayer;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+@XmlRootElement(name = "delayer")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class DelayerType extends ExpressionNode {
+    private Long delay = 0L;
+
+    public DelayerType() {
+    }
+
+    public DelayerType(Expression processAtExpression) {
+        super(processAtExpression);
+    }
+
+    public DelayerType(ExpressionType processAtExpression) {
+        super(processAtExpression);
+    }
+
+    public DelayerType(Expression processAtExpression, long delay) {
+        super(processAtExpression);
+        this.delay = delay;
+    }
+
+    @Override
+    public String toString() {
+        return "Delayer[ " + getExpression() + " -> " + getOutputs() + "]";
+    }
+
+    public Long getDelay() {
+        return delay;
+    }
+
+    public void setDelay(Long delay) {
+        this.delay = delay;
+    }
+
+    @Override
+    public Processor createProcessor(RouteContext routeContext) throws Exception {
+        Processor childProcessor = routeContext.createProcessor(this);
+        Expression processAtExpression = getExpression().createExpression(routeContext);
+        return new Delayer(childProcessor, processAtExpression, delay);
+
+    }
+}
\ No newline at end of file

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayerType.java
------------------------------------------------------------------------------
    svn:eol-style = native

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?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- 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 Jul 30 01:41:10 2007
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.model;
 
+import org.apache.camel.Expression;
+import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.RouteContext;
 import org.apache.camel.model.language.ExpressionType;
@@ -41,6 +43,21 @@
     private ExpressionType expression;
     @XmlElementRef
     private List<ProcessorType> outputs = new ArrayList<ProcessorType>();
+
+    public ExpressionNode() {
+    }
+
+    public ExpressionNode(ExpressionType expression) {
+        this.expression = expression;
+    }
+
+    public ExpressionNode(Expression expression) {
+        setExpression(new ExpressionType(expression));
+    }
+
+    public ExpressionNode(Predicate predicate) {
+        setExpression(new ExpressionType(predicate));
+    }
 
     public List<InterceptorRef> getInterceptors() {
         return interceptors;

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FilterType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FilterType.java?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FilterType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FilterType.java Mon Jul 30 01:41:10 2007
@@ -17,16 +17,32 @@
  */
 package org.apache.camel.model;
 
+import org.apache.camel.Predicate;
 import org.apache.camel.impl.RouteContext;
+import org.apache.camel.model.language.ExpressionType;
 import org.apache.camel.processor.FilterProcessor;
 
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlRootElement;
 
 /**
  * @version $Revision: 1.1 $
  */
 @XmlRootElement(name = "filter")
+@XmlAccessorType(XmlAccessType.FIELD)
 public class FilterType extends ExpressionNode {
+    public FilterType() {
+    }
+
+    public FilterType(ExpressionType expression) {
+        super(expression);
+    }
+
+    public FilterType(Predicate predicate) {
+        super(predicate);
+    }
+
     @Override
     public String toString() {
         return "Filter[ " + getExpression() + " -> " + getOutputs() + "]";

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromType.java?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FromType.java Mon Jul 30 01:41:10 2007
@@ -23,6 +23,7 @@
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
 
 /**
  * Represents an XML &lt;to/&gt; element
@@ -36,6 +37,8 @@
     private String uri;
     @XmlAttribute
     private String ref;
+    @XmlTransient
+    private Endpoint endpoint;
 
     public FromType() {
     }
@@ -46,11 +49,14 @@
 
     @Override
     public String toString() {
-        return "From[" + description(getUri(), getRef()) + "]";
+        return "From[" + description(getUri(), getRef(), getEndpoint()) + "]";
     }
 
     public Endpoint resolveEndpoint(RouteContext context) {
-        return context.resolveEndpoint(getUri(), getRef());
+        if (endpoint == null) {
+            endpoint = context.resolveEndpoint(getUri(), getRef());
+        }
+        return endpoint;
     }
 
     // Properties
@@ -81,10 +87,21 @@
         this.ref = ref;
     }
 
+    public Endpoint getEndpoint() {
+        return endpoint;
+    }
+
+    public void setEndpoint(Endpoint endpoint) {
+        this.endpoint = endpoint;
+    }
+
     // Implementation methods
     //-----------------------------------------------------------------------
-    protected static String description(String uri, String ref) {
-        if (uri != null) {
+    protected static String description(String uri, String ref, Endpoint endpoint) {
+        if (endpoint != null) {
+            return endpoint.getEndpointUri();
+        }
+        else if (uri != null) {
             return uri;
         }
         else if (ref != null) {

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/IdempotentConsumerType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/IdempotentConsumerType.java?view=auto&rev=560889
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/IdempotentConsumerType.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/IdempotentConsumerType.java Mon Jul 30 01:41:10 2007
@@ -0,0 +1,85 @@
+/**
+ *
+ * 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.model;
+
+import org.apache.camel.Expression;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.RouteContext;
+import org.apache.camel.processor.idempotent.IdempotentConsumer;
+import org.apache.camel.processor.idempotent.MessageIdRepository;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+@XmlRootElement(name = "idempotentConsumer")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class IdempotentConsumerType extends ExpressionNode {
+    @XmlAttribute
+    private String messageIdRepositoryRef;
+    @XmlTransient
+    private MessageIdRepository messageIdRepository;
+
+    public IdempotentConsumerType() {
+    }
+
+    public IdempotentConsumerType(Expression messageIdExpression, MessageIdRepository messageIdRepository) {
+        super(messageIdExpression);
+        this.messageIdRepository = messageIdRepository;
+    }
+
+    @Override
+    public String toString() {
+        return "IdempotentConsumer[ " + getExpression() + " -> " + getOutputs() + "]";
+    }
+
+    public String getMessageIdRepositoryRef() {
+        return messageIdRepositoryRef;
+    }
+
+    public void setMessageIdRepositoryRef(String messageIdRepositoryRef) {
+        this.messageIdRepositoryRef = messageIdRepositoryRef;
+    }
+
+    public MessageIdRepository getMessageIdRepository() {
+        return messageIdRepository;
+    }
+
+    public void setMessageIdRepository(MessageIdRepository messageIdRepository) {
+        this.messageIdRepository = messageIdRepository;
+    }
+
+    @Override
+    public Processor createProcessor(RouteContext routeContext) throws Exception {
+        Processor childProcessor = routeContext.createProcessor(this);
+        MessageIdRepository messageIdRepository = resolveMessageIdRepository(routeContext);
+        return new IdempotentConsumer(getExpression().createExpression(routeContext), messageIdRepository, childProcessor);
+    }
+
+    public MessageIdRepository resolveMessageIdRepository(RouteContext routeContext) {
+        if (messageIdRepository == null) {
+            messageIdRepository = routeContext.lookup(messageIdRepositoryRef, MessageIdRepository.class);
+        }
+        return messageIdRepository;
+    }
+}
\ No newline at end of file

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/IdempotentConsumerType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorRef.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorRef.java?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorRef.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorRef.java Mon Jul 30 01:41:10 2007
@@ -20,22 +20,35 @@
 import org.apache.camel.Processor;
 import org.apache.camel.impl.RouteContext;
 
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
 
 /**
  * @version $Revision: 1.1 $
  */
 @XmlRootElement(name = "process")
+@XmlAccessorType(XmlAccessType.FIELD)
 public class ProcessorRef extends OutputType {
+    @XmlAttribute(required = true)
     private String ref;
+    @XmlTransient
+    private Processor processor;
+
+    public ProcessorRef() {
+    }
+
+    public ProcessorRef(Processor processor) {
+        this.processor = processor;
+    }
 
     @Override
     public String toString() {
         return "Processor[ref:  " + ref + "]";
     }
 
-    @XmlAttribute(required = true)
     public String getRef() {
         return ref;
     }
@@ -46,6 +59,9 @@
 
     @Override
     public Processor createProcessor(RouteContext routeContext) {
-        return routeContext.lookup(getRef(), Processor.class);
+        if (processor == null) {
+            processor = routeContext.lookup(getRef(), Processor.class);
+        }
+        return processor;
     }
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RecipientListType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RecipientListType.java?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RecipientListType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RecipientListType.java Mon Jul 30 01:41:10 2007
@@ -18,6 +18,8 @@
 package org.apache.camel.model;
 
 import org.apache.camel.Processor;
+import org.apache.camel.Expression;
+import org.apache.camel.model.language.ExpressionType;
 import org.apache.camel.processor.Splitter;
 import org.apache.camel.processor.RecipientList;
 import org.apache.camel.impl.RouteContext;
@@ -32,6 +34,16 @@
 @XmlRootElement(name = "recipientList")
 @XmlAccessorType(XmlAccessType.FIELD)
 public class RecipientListType extends ExpressionNode {
+    public RecipientListType() {
+    }
+
+    public RecipientListType(ExpressionType expression) {
+        super(expression);
+    }
+
+    public RecipientListType(Expression expression) {
+        super(expression);
+    }
 
     @Override
     public String toString() {

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?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- 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 Jul 30 01:41:10 2007
@@ -19,13 +19,18 @@
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
 import org.apache.camel.Processor;
 import org.apache.camel.Route;
-import org.apache.camel.Service;
 import org.apache.camel.impl.RouteContext;
+import org.apache.camel.model.language.ExpressionType;
 import org.apache.camel.processor.Resequencer;
 
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementRef;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
@@ -33,19 +38,54 @@
  * @version $Revision: 1.1 $
  */
 @XmlRootElement(name = "resequencer")
-public class ResequencerType extends ExpressionNode {
+public class ResequencerType extends ProcessorType {
+    @XmlElement(required = false)
+    private List<InterceptorRef> interceptors = new ArrayList<InterceptorRef>();
+    @XmlElementRef
+    private List<ExpressionType> expressions = new ArrayList<ExpressionType>();
+    @XmlElementRef
+    private List<ProcessorType> outputs = new ArrayList<ProcessorType>();
+    @XmlTransient
+    private List<Expression> expressionList;
+
+    public ResequencerType() {
+    }
+
+    public ResequencerType(List<Expression> expressions) {
+        this.expressionList = expressions;
+    }
+
     @Override
     public String toString() {
-        return "Resequencer[ " + getExpression() + " -> " + getOutputs() + "]";
+        return "Resequencer[ " + getExpressions() + " -> " + getOutputs() + "]";
+    }
+
+    public List<ExpressionType> getExpressions() {
+        return expressions;
+    }
+
+    public List<InterceptorRef> getInterceptors() {
+        return interceptors;
+    }
+
+    public void setInterceptors(List<InterceptorRef> interceptors) {
+        this.interceptors = interceptors;
+    }
+
+    public List<ProcessorType> getOutputs() {
+        return outputs;
+    }
+
+    public void setOutputs(List<ProcessorType> outputs) {
+        this.outputs = outputs;
     }
 
     public void addRoutes(RouteContext routeContext, Collection<Route> routes) throws Exception {
         Endpoint from = routeContext.getEndpoint();
         final Processor processor = routeContext.createProcessor(this);
-        final Resequencer resequencer = new Resequencer(from, processor, getExpression().createExpression(routeContext));
+        final Resequencer resequencer = new Resequencer(from, processor, resolveExpressionList(routeContext));
 
         Route route = new Route<Exchange>(from, resequencer) {
-
             @Override
             public String toString() {
                 return "ResequencerRoute[" + getEndpoint() + " -> " + processor + "]";
@@ -53,5 +93,18 @@
         };
 
         routes.add(route);
+    }
+
+    private List<Expression> resolveExpressionList(RouteContext routeContext) {
+        if (expressionList == null) {
+            expressionList = new ArrayList<Expression>();
+            for (ExpressionType expression : expressions) {
+                expressionList.add(expression.createExpression(routeContext));
+            }
+        }
+        if (expressionList.isEmpty()) {
+            throw new IllegalArgumentException("No expressions configured for: " + this);
+        }
+        return expressionList;
     }
 }

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?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- 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 Jul 30 01:41:10 2007
@@ -19,10 +19,27 @@
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
 import org.apache.camel.Endpoint;
-import org.apache.camel.Route;
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
+import org.apache.camel.Route;
+import org.apache.camel.builder.Builder;
+import org.apache.camel.builder.ErrorHandlerBuilder;
+import org.apache.camel.builder.FromBuilder;
+import org.apache.camel.builder.InterceptorBuilder;
+import org.apache.camel.builder.PolicyBuilder;
+import org.apache.camel.builder.ProcessorBuilder;
+import org.apache.camel.builder.ResequencerBuilder;
 import org.apache.camel.impl.RouteContext;
-import org.apache.camel.impl.EventDrivenConsumerRoute;
+import org.apache.camel.processor.DelegateProcessor;
+import org.apache.camel.processor.MulticastProcessor;
+import org.apache.camel.processor.Pipeline;
+import org.apache.camel.processor.RecipientList;
+import org.apache.camel.processor.aggregate.AggregationStrategy;
+import org.apache.camel.processor.idempotent.IdempotentConsumer;
+import org.apache.camel.processor.idempotent.MessageIdRepository;
+import org.apache.camel.spi.Policy;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -33,6 +50,7 @@
 import javax.xml.bind.annotation.XmlType;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -43,8 +61,9 @@
 @XmlRootElement(name = "route")
 @XmlType(propOrder = {"interceptors", "inputs", "outputs"})
 public class RouteType extends ProcessorType implements CamelContextAware {
+    public static final String DEFAULT_TRACE_CATEGORY = "org.apache.camel.TRACE";
+
     private static final transient Log log = LogFactory.getLog(RouteType.class);
-    
     private CamelContext camelContext;
     private List<InterceptorRef> interceptors = new ArrayList<InterceptorRef>();
     private List<FromType> inputs = new ArrayList<FromType>();
@@ -79,6 +98,425 @@
         return answer;
     }
 
+    // Fluent API
+    //-----------------------------------------------------------------------
+    public RouteType from(String uri) {
+        getInputs().add(new FromType(uri));
+        return this;
+    }
+
+    /**
+     * Sends the exchange to the given endpoint URI
+     */
+    public RouteType to(String uri) {
+        getOutputs().add(new ToType(uri));
+        return this;
+    }
+
+    /**
+     * Sends the exchange to the given endpoint
+     */
+    public RouteType to(Endpoint endpoint) {
+        getOutputs().add(new ToType(endpoint));
+        return this;
+    }
+
+    /**
+     * Sends the exchange to a list of endpoints using the {@link MulticastProcessor} pattern
+     */
+    public RouteType to(String... uris) {
+        for (String uri : uris) {
+            getOutputs().add(new ToType(uri));
+        }
+        return this;
+    }
+
+    /**
+     * Sends the exchange to a list of endpoints using the {@link MulticastProcessor} pattern
+     */
+    public RouteType to(Endpoint... endpoints) {
+        for (Endpoint endpoint : endpoints) {
+            getOutputs().add(new ToType(endpoint));
+        }
+        return this;
+    }
+
+    /**
+     * Sends the exchange to a list of endpoint using the {@link MulticastProcessor} pattern
+     */
+    public RouteType to(Collection<Endpoint> endpoints) {
+        for (Endpoint endpoint : endpoints) {
+            getOutputs().add(new ToType(endpoint));
+        }
+        return this;
+    }
+
+    /**
+     * Creates a {@link Pipeline} of the list of endpoints so that the message 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 RouteType pipeline(String... uris) {
+        // TODO pipeline v mulicast
+        return to(uris);
+    }
+
+    /**
+     * Creates a {@link Pipeline} of the list of endpoints so that the message 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 RouteType pipeline(Endpoint... endpoints) {
+        // TODO pipeline v mulicast
+        return to(endpoints);
+    }
+
+    /**
+     * Creates a {@link Pipeline} of the list of endpoints so that the message 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 RouteType pipeline(Collection<Endpoint> endpoints) {
+        // TODO pipeline v mulicast
+        return to(endpoints);
+    }
+
+    /**
+     * Creates an {@link IdempotentConsumer} to avoid duplicate messages
+     */
+    public IdempotentConsumerType idempotentConsumer(Expression messageIdExpression, MessageIdRepository messageIdRepository) {
+        IdempotentConsumerType answer = new IdempotentConsumerType(messageIdExpression, messageIdRepository);
+        getOutputs().add(answer);
+        return answer;
+    }
+
+    /**
+     * Creates a predicate which is applied and only if it is true then
+     * the exchange is forwarded to the destination
+     *
+     * @return the builder for a predicate
+     */
+    public FilterType filter(Predicate predicate) {
+        FilterType filter = new FilterType(predicate);
+        getOutputs().add(filter);
+        return filter;
+    }
+
+    /**
+     * Creates a choice of one or more predicates with an otherwise clause
+     *
+     * @return the builder for a choice expression
+     */
+    public ChoiceType choice() {
+        ChoiceType answer = new ChoiceType();
+        getOutputs().add(answer);
+        return answer;
+    }
+
+    /**
+     * Creates a dynamic <a href="http://activemq.apache.org/camel/recipient-list.html">Recipient List</a> pattern.
+     *
+     * @param receipients is the builder of the expression used in the {@link RecipientList} to decide the destinations
+     */
+    public RouteType recipientList(Expression receipients) {
+        RecipientListType answer = new RecipientListType(receipients);
+        getOutputs().add(answer);
+        return this;
+    }
+
+    /**
+     * A builder for the <a href="http://activemq.apache.org/camel/splitter.html">Splitter</a> pattern
+     * where an expression is evaluated to iterate through each of the parts of a message and then each part is then send to some endpoint.
+     *
+     * @param receipients the expression on which to split
+     * @return the builder
+     */
+    public SplitterType splitter(Expression receipients) {
+        SplitterType answer = new SplitterType(receipients);
+        getOutputs().add(answer);
+        return answer;
+    }
+
+    /**
+     * A builder for the <a href="http://activemq.apache.org/camel/resequencer.html">Resequencer</a> pattern
+     * where an expression is evaluated to be able to compare the message exchanges to reorder them. e.g. you
+     * may wish to sort by some header
+     *
+     * @param expression the expression on which to compare messages in order
+     * @return the builder
+     */
+    public ResequencerType resequencer(Expression<Exchange> expression) {
+        return resequencer(Collections.<Expression>singletonList(expression));
+    }
+
+    /**
+     * A builder for the <a href="http://activemq.apache.org/camel/resequencer.html">Resequencer</a> pattern
+     * where a list of expressions are evaluated to be able to compare the message exchanges to reorder them. e.g. you
+     * may wish to sort by some headers
+     *
+     * @param expressions the expressions on which to compare messages in order
+     * @return the builder
+     */
+    public ResequencerType resequencer(List<Expression> expressions) {
+        ResequencerType answer = new ResequencerType(expressions);
+        getOutputs().add(answer);
+        return answer;
+    }
+
+    /**
+     * A builder for the <a href="http://activemq.apache.org/camel/resequencer.html">Resequencer</a> pattern
+     * where a list of expressions are evaluated to be able to compare the message exchanges to reorder them. e.g. you
+     * may wish to sort by some headers
+     *
+     * @param expressions the expressions on which to compare messages in order
+     * @return the builder
+     */
+    public ResequencerType resequencer(Expression... expressions) {
+        List<Expression> list = new ArrayList<Expression>();
+        for (Expression expression : expressions) {
+            list.add(expression);
+        }
+        return resequencer(list);
+    }
+
+    /**
+     * A builder for the <a href="http://activemq.apache.org/camel/aggregator.html">Aggregator</a> pattern
+     * where a batch of messages are processed (up to a maximum amount or until some timeout is reached)
+     * and messages for the same correlation key are combined together using some kind of
+     * {@link AggregationStrategy ) (by default the latest message is used) to compress many message exchanges
+     * into a smaller number of exchanges.
+     * <p/>
+     * A good example of this is stock market data; you may be receiving 30,000 messages/second and you may want to
+     * throttle it right down so that multiple messages for the same stock are combined (or just the latest
+     * message is used and older prices are discarded). Another idea is to combine line item messages together
+     * into a single invoice message.
+     *
+     * @param correlationExpression the expression used to calculate the correlation key. For a JMS message this could
+     *                              be the expression <code>header("JMSDestination")</code> or  <code>header("JMSCorrelationID")</code>
+     */
+    public AggregatorType aggregator(Expression correlationExpression) {
+        AggregatorType answer = new AggregatorType(correlationExpression);
+        getOutputs().add(answer);
+        return answer;
+    }
+
+    /**
+     * A builder for the <a href="http://activemq.apache.org/camel/aggregator.html">Aggregator</a> pattern
+     * where a batch of messages are processed (up to a maximum amount or until some timeout is reached)
+     * and messages for the same correlation key are combined together using some kind of
+     * {@link AggregationStrategy ) (by default the latest message is used) to compress many message exchanges
+     * into a smaller number of exchanges.
+     * <p/>
+     * A good example of this is stock market data; you may be receiving 30,000 messages/second and you may want to
+     * throttle it right down so that multiple messages for the same stock are combined (or just the latest
+     * message is used and older prices are discarded). Another idea is to combine line item messages together
+     * into a single invoice message.
+     *
+     * @param correlationExpression the expression used to calculate the correlation key. For a JMS message this could
+     *                              be the expression <code>header("JMSDestination")</code> or  <code>header("JMSCorrelationID")</code>
+     */
+    public AggregatorType aggregator(Expression correlationExpression, AggregationStrategy aggregationStrategy) {
+        AggregatorType answer = new AggregatorType(correlationExpression, aggregationStrategy);
+        getOutputs().add(answer);
+        return answer;
+    }
+
+    /**
+     * A builder for the <a href="http://activemq.apache.org/camel/delayer.html">Delayer</a> pattern
+     * where an expression is used to calculate the time which the message will be dispatched on
+     *
+     * @param processAtExpression an expression to calculate the time at which the messages should be processed
+     * @return the builder
+     */
+    public DelayerType delayer(Expression<Exchange> processAtExpression) {
+        return delayer(processAtExpression, 0L);
+    }
+
+    /**
+     * A builder for the <a href="http://activemq.apache.org/camel/delayer.html">Delayer</a> pattern
+     * where an expression is used to calculate the time which the message will be dispatched on
+     *
+     * @param processAtExpression an expression to calculate the time at which the messages should be processed
+     * @param delay               the delay in milliseconds which is added to the processAtExpression to determine the time the
+     *                            message should be processed
+     * @return the builder
+     */
+    public DelayerType delayer(Expression<Exchange> processAtExpression, long delay) {
+        DelayerType answer = new DelayerType(processAtExpression, delay);
+        getOutputs().add(answer);
+        return answer;
+    }
+
+    /**
+     * A builder for the <a href="http://activemq.apache.org/camel/delayer.html">Delayer</a> pattern
+     * where a fixed amount of milliseconds are used to delay processing of a message exchange
+     *
+     * @param delay the default delay in milliseconds
+     * @return the builder
+     */
+    public DelayerType delayer(long delay) {
+        return delayer(null, delay);
+    }
+
+    /**
+     * A builder for the <a href="http://activemq.apache.org/camel/delayer.html">Delayer</a> pattern
+     * where an expression is used to calculate the time which the message will be dispatched on
+     *
+     * @return the builder
+     */
+    public ThrottlerType throttler(long maximumRequestCount) {
+        ThrottlerType answer = new ThrottlerType(maximumRequestCount);
+        getOutputs().add(answer);
+        return answer;
+    }
+
+    /**
+     * Installs the given error handler builder
+     *
+     * @param errorHandlerBuilder the error handler to be used by default for all child routes
+     * @return the current builder with the error handler configured
+     */
+    public RouteType errorHandler(ErrorHandlerBuilder errorHandlerBuilder) {
+        setErrorHandlerBuilder(errorHandlerBuilder);
+        return this;
+    }
+
+    /**
+     * Configures whether or not the error handler is inherited by every processing node (or just the top most one)
+     *
+     * @param condition the falg as to whether error handlers should be inherited or not
+     * @return the current builder
+     */
+    public RouteType inheritErrorHandler(boolean condition) {
+        setInheritErrorHandlerFlag(condition);
+        return this;
+    }
+
+
+    /**
+     * Trace logs the exchange before it goes to the next processing step using the {@link #DEFAULT_TRACE_CATEGORY} logging
+     * category.
+     *
+     * @return
+     */
+    public FromBuilder trace() {
+        return trace(DEFAULT_TRACE_CATEGORY);
+    }
+
+    /**
+     * Trace logs the exchange before it goes to the next processing step using the specified logging
+     * category.
+     *
+     * @param category the logging category trace messages will sent to.
+     * @return
+     */
+    public FromBuilder trace(String category) {
+        final Log log = LogFactory.getLog(category);
+        return intercept(new DelegateProcessor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                log.trace(exchange);
+                processNext(exchange);
+            }
+        });
+    }
+
+    public PolicyBuilder policies() {
+        throw new UnsupportedOperationException();
+/*
+        PolicyBuilder answer = new PolicyBuilder(this);
+        addProcessBuilder(answer);
+        return answer;
+*/
+    }
+
+    public FromBuilder policy(Policy policy) {
+        throw new UnsupportedOperationException();
+/*
+        PolicyBuilder answer = new PolicyBuilder(this);
+        answer.add(policy);
+        addProcessBuilder(answer);
+        return answer.target();
+*/
+    }
+
+    public InterceptorBuilder intercept() {
+        throw new UnsupportedOperationException();
+/*
+        InterceptorBuilder answer = new InterceptorBuilder(this);
+        addProcessBuilder(answer);
+        return answer;
+*/
+    }
+
+    public FromBuilder intercept(DelegateProcessor interceptor) {
+        throw new UnsupportedOperationException();
+/*
+        InterceptorBuilder answer = new InterceptorBuilder(this);
+        answer.add(interceptor);
+        addProcessBuilder(answer);
+        return answer.target();
+*/
+    }
+
+    // Transformers
+    //-------------------------------------------------------------------------
+
+    /**
+     * Adds the custom processor to this destination which could be a final destination, or could be a transformation in a pipeline
+     */
+    public RouteType process(Processor processor) {
+        ProcessorRef answer = new ProcessorRef(processor);
+        getOutputs().add(answer);
+        return this;
+    }
+
+    /**
+     * Adds a processor which sets the body on the IN message
+     */
+    public RouteType setBody(Expression expression) {
+        return process(ProcessorBuilder.setBody(expression));
+    }
+
+    /**
+     * Adds a processor which sets the body on the OUT message
+     */
+    public RouteType setOutBody(Expression expression) {
+        return process(ProcessorBuilder.setOutBody(expression));
+    }
+
+    /**
+     * Adds a processor which sets the header on the IN message
+     */
+    public RouteType setHeader(String name, Expression expression) {
+        return process(ProcessorBuilder.setHeader(name, expression));
+    }
+
+    /**
+     * Adds a processor which sets the header on the OUT message
+     */
+    public RouteType setOutHeader(String name, Expression expression) {
+        return process(ProcessorBuilder.setOutHeader(name, expression));
+    }
+
+    /**
+     * Adds a processor which sets the exchange property
+     */
+    public RouteType setProperty(String name, Expression expression) {
+        return process(ProcessorBuilder.setProperty(name, expression));
+    }
+
+    /**
+     * Converts the IN message body to the specified type
+     */
+    public RouteType convertBodyTo(Class type) {
+        return process(ProcessorBuilder.setBody(Builder.body().convertTo(type)));
+    }
+
+    /**
+     * Converts the OUT message body to the specified type
+     */
+    public RouteType convertOutBodyTo(Class type) {
+        return process(ProcessorBuilder.setOutBody(Builder.outBody().convertTo(type)));
+    }
+
     // Properties
     //-----------------------------------------------------------------------
 
@@ -124,12 +562,8 @@
         this.camelContext = camelContext;
     }
 
-    // Fluent API
-    //-----------------------------------------------------------------------
-    public RouteType from(String uri) {
-        getInputs().add(new FromType(uri));
-        return this;
-    }
+    // Implementation methods
+    //-------------------------------------------------------------------------
 
     protected void addRoutes(Collection<Route> routes, FromType fromType) throws Exception {
         RouteContext routeContext = new RouteContext(this, fromType, routes);

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SplitterType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SplitterType.java?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SplitterType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SplitterType.java Mon Jul 30 01:41:10 2007
@@ -18,6 +18,8 @@
 package org.apache.camel.model;
 
 import org.apache.camel.Processor;
+import org.apache.camel.Expression;
+import org.apache.camel.model.language.ExpressionType;
 import org.apache.camel.impl.RouteContext;
 import org.apache.camel.processor.Splitter;
 
@@ -31,6 +33,17 @@
 @XmlRootElement(name = "splitter")
 @XmlAccessorType(XmlAccessType.FIELD)
 public class SplitterType extends ExpressionNode {
+    public SplitterType() {
+    }
+
+    public SplitterType(Expression expression) {
+        super(expression);
+    }
+
+    public SplitterType(ExpressionType expression) {
+        super(expression);
+    }
+
     @Override
     public String toString() {
         return "Splitter[ " + getExpression() + " -> " + getOutputs() + "]";

Added: 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?view=auto&rev=560889
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java Mon Jul 30 01:41:10 2007
@@ -0,0 +1,97 @@
+/**
+ *
+ * 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.model;
+
+import org.apache.camel.Processor;
+import org.apache.camel.impl.RouteContext;
+import org.apache.camel.processor.Throttler;
+
+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.XmlElement;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+@XmlRootElement(name = "throttler")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class ThrottlerType extends ProcessorType {
+    @XmlAttribute
+    private Long maximumRequestsPerPeriod;
+    @XmlAttribute
+    private long timePeriodMillis = 1000;
+    @XmlElement(required = false)
+    private List<InterceptorRef> interceptors = new ArrayList<InterceptorRef>();
+    @XmlElementRef
+    private List<ProcessorType> outputs = new ArrayList<ProcessorType>();
+
+    public ThrottlerType() {
+    }
+
+    public ThrottlerType(long maximumRequestsPerPeriod) {
+        this.maximumRequestsPerPeriod = maximumRequestsPerPeriod;
+    }
+
+    @Override
+    public String toString() {
+        return "Throttler[" + getMaximumRequestsPerPeriod() + " request per " + getTimePeriodMillis() + " millis -> " + getOutputs() + "]";
+    }
+
+    public Long getMaximumRequestsPerPeriod() {
+        return maximumRequestsPerPeriod;
+    }
+
+    public void setMaximumRequestsPerPeriod(Long maximumRequestsPerPeriod) {
+        this.maximumRequestsPerPeriod = maximumRequestsPerPeriod;
+    }
+
+    public long getTimePeriodMillis() {
+        return timePeriodMillis;
+    }
+
+    public void setTimePeriodMillis(long timePeriodMillis) {
+        this.timePeriodMillis = timePeriodMillis;
+    }
+
+    public List<InterceptorRef> getInterceptors() {
+        return interceptors;
+    }
+
+    public void setInterceptors(List<InterceptorRef> interceptors) {
+        this.interceptors = interceptors;
+    }
+
+    public List<ProcessorType> getOutputs() {
+        return outputs;
+    }
+
+    public void setOutputs(List<ProcessorType> outputs) {
+        this.outputs = outputs;
+    }
+
+    @Override
+    public Processor createProcessor(RouteContext routeContext) throws Exception {
+        Processor childProcessor = routeContext.createProcessor(this);
+        return new Throttler(childProcessor, maximumRequestsPerPeriod, timePeriodMillis);
+    }
+}
\ No newline at end of file

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java
------------------------------------------------------------------------------
    svn:eol-style = native

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?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- 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 Jul 30 01:41:10 2007
@@ -26,7 +26,7 @@
 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 java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -45,10 +45,23 @@
     private String ref;
     @XmlElement(required = false)
     private List<InterceptorRef> interceptors = new ArrayList<InterceptorRef>();
+    @XmlTransient
+    private Endpoint endpoint;
+
+    public ToType() {
+    }
+
+    public ToType(String uri) {
+        setUri(uri);
+    }
+
+    public ToType(Endpoint endpoint) {
+        setEndpoint(endpoint);
+    }
 
     @Override
     public String toString() {
-        return "To[" + FromType.description(getUri(), getRef()) + "]";
+        return "To[" + FromType.description(getUri(), getRef(), getEndpoint()) + "]";
     }
 
     @Override
@@ -58,7 +71,10 @@
     }
 
     public Endpoint resolveEndpoint(RouteContext context) {
-        return context.resolveEndpoint(getUri(), getRef());
+        if (endpoint == null) {
+            endpoint = context.resolveEndpoint(getUri(), getRef());
+        }
+        return endpoint;
     }
 
     // Properties
@@ -87,6 +103,14 @@
      */
     public void setRef(String ref) {
         this.ref = ref;
+    }
+
+    public Endpoint getEndpoint() {
+        return endpoint;
+    }
+
+    public void setEndpoint(Endpoint endpoint) {
+        this.endpoint = endpoint;
     }
 
     public List<ProcessorType> getOutputs() {

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?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- 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 Jul 30 01:41:10 2007
@@ -19,6 +19,8 @@
 
 import org.apache.camel.impl.RouteContext;
 import org.apache.camel.processor.FilterProcessor;
+import org.apache.camel.Predicate;
+import org.apache.camel.model.language.ExpressionType;
 
 import javax.xml.bind.annotation.XmlRootElement;
 
@@ -27,6 +29,17 @@
  */
 @XmlRootElement(name = "when")
 public class WhenType extends ExpressionNode {
+    public WhenType() {
+    }
+
+    public WhenType(Predicate predicate) {
+        super(predicate);
+    }
+
+    public WhenType(ExpressionType expression) {
+        super(expression);
+    }
+
     @Override
     public String toString() {
         return "When[ " + getExpression() + " -> " + getOutputs() + "]";

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/ExpressionType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/ExpressionType.java?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/ExpressionType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/ExpressionType.java Mon Jul 30 01:41:10 2007
@@ -28,6 +28,7 @@
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlValue;
 import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
@@ -40,38 +41,58 @@
  */
 @XmlType(name = "expressionType")
 @XmlAccessorType(XmlAccessType.FIELD)
-public abstract class ExpressionType {
+public class ExpressionType {
     @XmlAttribute
     @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
     @XmlID
     private String id;
     @XmlValue
     private String expression;
+    @XmlTransient
+    private Predicate predicate;
+    @XmlTransient
+    private Expression expressionValue;
 
-    public abstract String getLanguage();
-
-    protected ExpressionType() {
+    public ExpressionType() {
     }
 
-    protected ExpressionType(String expression) {
+    public ExpressionType(String expression) {
         this.expression = expression;
     }
 
+    public ExpressionType(Predicate predicate) {
+        this.predicate = predicate;
+    }
+
+    public ExpressionType(Expression expression) {
+        this.expressionValue = expression;
+    }
+
     @Override
     public String toString() {
         return getLanguage() + "Expression[" + getExpression() + "]";
     }
 
+    public String getLanguage() {
+        return "";
+    }
+
     public Predicate<Exchange> createPredicate(RouteContext route) {
-        CamelContext camelContext = route.getCamelContext();
-        Language language = camelContext.resolveLanguage(getLanguage());
-        return language.createPredicate(getExpression());
+        if (predicate == null) {
+            CamelContext camelContext = route.getCamelContext();
+            Language language = camelContext.resolveLanguage(getLanguage());
+            predicate = language.createPredicate(getExpression());
+        }
+        return predicate;
     }
 
     public Expression createExpression(RouteContext routeContext) {
-        CamelContext camelContext = routeContext.getCamelContext();
-        Language language = camelContext.resolveLanguage(getLanguage());
-        return language.createExpression(getExpression());
+        if (expressionValue == null) {
+            CamelContext camelContext = routeContext.getCamelContext();
+            Language language = camelContext.resolveLanguage(getLanguage());
+            expressionValue = language.createExpression(getExpression());
+        }
+        return expressionValue;
     }
 
     public String getExpression() {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Resequencer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Resequencer.java?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Resequencer.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Resequencer.java Mon Jul 30 01:41:10 2007
@@ -40,7 +40,7 @@
         this(endpoint, processor, createSet(expression));
     }
 
-    public Resequencer(Endpoint endpoint, Processor processor, List<Expression<Exchange>> expressions) {
+    public Resequencer(Endpoint endpoint, Processor processor, List<Expression> expressions) {
         this(endpoint, processor, createSet(expressions));
     }
 
@@ -60,11 +60,11 @@
         return createSet(new ExpressionComparator<Exchange>(expression));
     }
 
-    protected static Set<Exchange> createSet(List<Expression<Exchange>> expressions) {
+    protected static Set<Exchange> createSet(List<Expression> expressions) {
         if (expressions.size() == 1) {
             return createSet(expressions.get(0));
         }
-        return createSet(new ExpressionListComparator<Exchange>(expressions));
+        return createSet(new ExpressionListComparator(expressions));
     }
 
     protected static Set<Exchange> createSet(Comparator<? super Exchange> comparator) {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionListComparator.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionListComparator.java?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionListComparator.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExpressionListComparator.java Mon Jul 30 01:41:10 2007
@@ -30,15 +30,15 @@
  *
  * @version $Revision: 1.1 $
  */
-public class ExpressionListComparator<E extends Exchange> implements Comparator<E> {
-    private final List<Expression<E>> expressions;
+public class ExpressionListComparator implements Comparator<Exchange> {
+    private final List<Expression> expressions;
 
-    public ExpressionListComparator(List<Expression<E>> expressions) {
+    public ExpressionListComparator(List<Expression> expressions) {
         this.expressions = expressions;
     }
 
-    public int compare(E e1, E e2) {
-        for (Expression<E> expression : expressions) {
+    public int compare(Exchange e1, Exchange e2) {
+        for (Expression expression : expressions) {
             Object o1 = expression.evaluate(e1);
             Object o2 = expression.evaluate(e2);
             int answer = ObjectHelper.compare(o1, o2);

Modified: activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index?view=diff&rev=560889&r1=560888&r2=560889
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index (original)
+++ activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index Mon Jul 30 01:41:10 2007
@@ -1,6 +1,9 @@
+AggregatorType
 ChoiceType
+DelayerType
 FilterType
 FromType
+IdempotentConsumerType
 OtherwiseType
 ProcessorRef
 RecipientListType
@@ -8,5 +11,6 @@
 RouteType
 RoutesType
 SplitterType
+ThrottlerType
 ToType
 WhenType