camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r745501 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/component/seda/ camel-core/src/main/java/org/apache/camel/model/ camel-core/src/test/java/org/apache/camel/impl/ compone...
Date Wed, 18 Feb 2009 12:48:07 GMT
Author: davsclaus
Date: Wed Feb 18 12:48:07 2009
New Revision: 745501

URL: http://svn.apache.org/viewvc?rev=745501&view=rev
Log:
CAMEL-1229: Added nice DSL for multiple inputs to a route, eg from(x, y, z).to(foo).

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromMultipleEndpointTest.java
      - copied, changed from r745457, camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromEndpointTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFromEndpointTest.java
      - copied, changed from r745457, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFilterTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFromMultipleEndpointTest.java
  (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/fromEndpointTest.xml
      - copied, changed from r745457, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/filter.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/fromMultipleEndpointTest.xml
  (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesType.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromEndpointTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java?rev=745501&r1=745500&r2=745501&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java Wed Feb
18 12:48:07 2009
@@ -94,6 +94,30 @@
     }
 
     /**
+     * Creates a new route from the given URIs input
+     *
+     * @param uris  the from uris
+     * @return the builder
+     */
+    public RouteType from(String... uris) {
+        RouteType answer = routeCollection.from(uris);
+        configureRoute(answer);
+        return answer;
+    }
+
+    /**
+     * Creates a new route from the given endpoint
+     *
+     * @param endpoints  the from endpoints
+     * @return the builder
+     */
+    public RouteType from(Endpoint... endpoints) {
+        RouteType answer = routeCollection.from(endpoints);
+        configureRoute(answer);
+        return answer;
+    }
+
+    /**
      * Installs the given <a href="http://camel.apache.org/error-handler.html">error
handler</a> builder
      *
      * @param errorHandlerBuilder  the error handler to be used by default for all child
routes

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java?rev=745501&r1=745500&r2=745501&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/seda/SedaConsumer.java
Wed Feb 18 12:48:07 2009
@@ -62,8 +62,8 @@
             try {
                 exchange = queue.poll(1000, TimeUnit.MILLISECONDS);
             } catch (InterruptedException e) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Interupted: " + e, e);
+                if (LOG.isTraceEnabled()) {
+                    LOG.trace("Interupted: " + e, e);
                 }
                 continue;
             }
@@ -82,8 +82,8 @@
                     try {
                         queue.put(exchange);
                     } catch (InterruptedException e) {
-                        if (LOG.isDebugEnabled()) {
-                            LOG.debug("Interupted: " + e, e);
+                        if (LOG.isTraceEnabled()) {
+                            LOG.trace("Interupted: " + e, e);
                         }
                     }
                 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java?rev=745501&r1=745500&r2=745501&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java Wed Feb 18
12:48:07 2009
@@ -122,6 +122,32 @@
     }
 
     /**
+     * Creates inputs to the route
+     *
+     * @param uris  the from uris
+     * @return the builder
+     */
+    public RouteType from(String... uris) {
+        for (String uri : uris) {
+            getInputs().add(new FromType(uri));
+        }
+        return this;
+    }
+
+    /**
+     * Creates inputs to the route
+     *
+     * @param endpoints  the from endpoints
+     * @return the builder
+     */
+    public RouteType from(Endpoint... endpoints) {
+        for (Endpoint endpoint : endpoints) {
+            getInputs().add(new FromType(endpoint));
+        }
+        return this;
+    }
+
+    /**
      * Set the group name for this route
      *
      * @param name  the group name

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesType.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesType.java?rev=745501&r1=745500&r2=745501&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesType.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesType.java Wed Feb 18
12:48:07 2009
@@ -161,6 +161,30 @@
     }
 
     /**
+     * Creates a new route from the given URI inputs
+     *
+     * @param uris  the from uri
+     * @return the builder
+     */
+    public RouteType from(String... uris) {
+        RouteType route = createRoute();
+        route.from(uris);
+        return route(route);
+    }
+
+    /**
+     * Creates a new route from the given endpoints
+     *
+     * @param endpoints  the from endpoints
+     * @return the builder
+     */
+    public RouteType from(Endpoint... endpoints) {
+        RouteType route = createRoute();
+        route.from(endpoints);
+        return route(route);
+    }
+
+    /**
      * Creates a new route using the given route
      *
      * @param route the route

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromEndpointTest.java?rev=745501&r1=745500&r2=745501&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromEndpointTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromEndpointTest.java Wed Feb
18 12:48:07 2009
@@ -37,7 +37,7 @@
 
         template.sendBody("direct:start", expectedBody);
 
-        results.assertIsNotSatisfied();
+        results.assertIsSatisfied();
         List<Exchange> list = results.getReceivedExchanges();
         Exchange exchange = list.get(0);
         Endpoint fromEndpoint = exchange.getFromEndpoint();

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromMultipleEndpointTest.java
(from r745457, camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromEndpointTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromMultipleEndpointTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromMultipleEndpointTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromEndpointTest.java&r1=745457&r2=745501&rev=745501&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromEndpointTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/FromMultipleEndpointTest.java
Wed Feb 18 12:48:07 2009
@@ -23,26 +23,30 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.processor.interceptor.Tracer;
 
 /**
  * @version $Revision$
  */
-public class FromEndpointTest extends ContextTestSupport {
-    private MockEndpoint results;
-    private Object expectedBody = "<hello>world!</hello>";
-
-    public void testReceivedMessageHasFromEndpointSet() throws Exception {
-        results = getMockEndpoint("mock:results");
-        results.expectedBodiesReceived(expectedBody);
+public class FromMultipleEndpointTest extends ContextTestSupport {
 
-        template.sendBody("direct:start", expectedBody);
+    public void testMultipleFromEndpoint() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:results");
+        mock.expectedMessageCount(3);
+
+        template.sendBody("direct:foo", "foo");
+        template.sendBody("seda:bar", "bar");
+
+        mock.assertIsSatisfied();
+        List<Exchange> list = mock.getReceivedExchanges();
 
-        results.assertIsNotSatisfied();
-        List<Exchange> list = results.getReceivedExchanges();
         Exchange exchange = list.get(0);
         Endpoint fromEndpoint = exchange.getFromEndpoint();
-        assertNotNull("exchange.fromEndpoint() is null!", fromEndpoint);
-        assertEquals("fromEndpoint URI", "direct:start", fromEndpoint.getEndpointUri());
+        assertEquals("fromEndpoint URI", "direct:foo", fromEndpoint.getEndpointUri());
+
+        exchange = list.get(1);
+        fromEndpoint = exchange.getFromEndpoint();
+        assertEquals("fromEndpoint URI", "seda:bar", fromEndpoint.getEndpointUri());
     }
 
     @Override
@@ -50,9 +54,11 @@
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:start").to("mock:results");
+                getContext().addInterceptStrategy(new Tracer());
+
+                from("direct:foo", "seda:bar", "timer://baz?delay=500&period=1000").to("mock:results");
             }
         };
 
     }
-}
+}
\ No newline at end of file

Copied: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFromEndpointTest.java
(from r745457, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFilterTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFromEndpointTest.java?p2=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFromEndpointTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFilterTest.java&r1=745457&r2=745501&rev=745501&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFilterTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFromEndpointTest.java
Wed Feb 18 12:48:07 2009
@@ -17,15 +17,15 @@
 package org.apache.camel.spring.processor;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.processor.FilterTest;
+import org.apache.camel.impl.FromEndpointTest;
 import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
 
 /**
  * @version $Revision$
  */
-public class SpringFilterTest extends FilterTest {
+public class SpringFromEndpointTest extends FromEndpointTest {
     @Override
     protected CamelContext createCamelContext() throws Exception {
-        return createSpringCamelContext(this, "org/apache/camel/spring/processor/filter.xml");
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/fromEndpointTest.xml");
     }
-}
+}
\ No newline at end of file

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFromMultipleEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFromMultipleEndpointTest.java?rev=745501&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFromMultipleEndpointTest.java
(added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFromMultipleEndpointTest.java
Wed Feb 18 12:48:07 2009
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.FromMultipleEndpointTest;
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class SpringFromMultipleEndpointTest extends FromMultipleEndpointTest {
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/fromMultipleEndpointTest.xml");
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFromMultipleEndpointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringFromMultipleEndpointTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/fromEndpointTest.xml
(from r745457, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/filter.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/fromEndpointTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/fromEndpointTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/filter.xml&r1=745457&r2=745501&rev=745501&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/filter.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/fromEndpointTest.xml
Wed Feb 18 12:48:07 2009
@@ -22,16 +22,11 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-  <!-- START SNIPPET: example -->
-  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
-    <route>
-      <from uri="direct:start"/>
-      <filter>
-        <xpath>$foo = 'bar'</xpath>
-        <to uri="mock:result"/>
-      </filter>
-    </route>
-  </camelContext>
-  <!-- END SNIPPET: example -->
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="direct:start"/>
+            <to uri="mock:results"/>
+        </route>
+    </camelContext>
 
 </beans>

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/fromMultipleEndpointTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/fromMultipleEndpointTest.xml?rev=745501&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/fromMultipleEndpointTest.xml
(added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/fromMultipleEndpointTest.xml
Wed Feb 18 12:48:07 2009
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+        <!-- START SNIPPET: e1 -->
+        <route>
+            <from uri="direct:foo"/>
+            <from uri="seda:bar"/>
+            <from uri="timer://baz?delay=500&amp;period=1000"/>
+            <to uri="mock:results"/>
+        </route>
+        <!-- END SNIPPET: e1 -->
+    </camelContext>
+
+</beans>

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/fromMultipleEndpointTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/fromMultipleEndpointTest.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/fromMultipleEndpointTest.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message