svn commit: r697494 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/test/java/org/apache/camel/builder/ camel-core/...

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r697494 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/impl/ camel-core/src/test/java/org/apache/camel/builder/ camel-core/...

davsclaus-2
Author: davsclaus
Date: Sun Sep 21 05:43:54 2008
New Revision: 697494

URL: http://svn.apache.org/viewvc?rev=697494&view=rev
Log:
CAMEL-919: Removed unused routes. setRoutes not supported on CamelContext yet. Polished javadoc.

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Routes.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/CamelChoiceWithManagementTest.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/produce/MyListener.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/produce/MyListenerService.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/produce/ProduceTest.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Routes.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Routes.java?rev=697494&r1=697493&r2=697494&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Routes.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/Routes.java Sun Sep 21 05:43:54 2008
@@ -19,11 +19,23 @@
 
 import java.util.List;
 
+/**
+ * Routes defined in the camel context.
+ */
 public interface Routes {
 
+    /**
+     * Gets the Camel context used.
+     */
     CamelContext getContext();
 
+    /**
+     * Sets the Camel context to use.
+     */
     void setContext(CamelContext context);
 
+    /**
+     * Gets the list of routes currently in the camel context.
+     */
     List<Route> getRouteList() throws Exception;
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java?rev=697494&r1=697493&r2=697494&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java Sun Sep 21 05:43:54 2008
@@ -16,7 +16,6 @@
  */
 package org.apache.camel.builder;
 
-import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -44,7 +43,6 @@
 public abstract class RouteBuilder extends BuilderSupport implements Routes {
     private AtomicBoolean initialized = new AtomicBoolean(false);
     private RoutesType routeCollection = new RoutesType();
-    private List<Route> routes = new ArrayList<Route>();
 
     public RouteBuilder() {
         this(null);
@@ -149,11 +147,11 @@
     }
 
     /**
-     * Returns the routing map from inbound endpoints to processors
+     * Uses {@link org.apache.camel.CamelContext#getRoutes()} to return the routes in the context.
      */
     public List<Route> getRouteList() throws Exception {
         checkInitialized();
-        return routes;
+        return null;
     }
 
     @Override
@@ -179,11 +177,11 @@
                 setErrorHandlerBuilder(camelContext.getErrorHandlerBuilder());
             }
             configure();
-            populateRoutes(routes);
+            populateRoutes();
         }
     }
 
-    protected void populateRoutes(List<Route> routes) throws Exception {
+    protected void populateRoutes() throws Exception {
         CamelContext camelContext = getContext();
         if (camelContext == null) {
             throw new IllegalArgumentException("No CamelContext has been injected!");

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=697494&r1=697493&r2=697494&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Sun Sep 21 05:43:54 2008
@@ -328,25 +328,31 @@
 
     public void setRoutes(List<Route> routes) {
         this.routes = routes;
+        throw new UnsupportedOperationException("overriding existing routes is not supported yet, use addRoutes instead");
     }
 
     public void addRoutes(Collection<Route> routes) throws Exception {
         if (this.routes == null) {
-            this.routes = new ArrayList<Route>(routes);
-        } else {
-            this.routes.addAll(routes);
+            this.routes = new ArrayList<Route>();
         }
-        lifecycleStrategy.onRoutesAdd(routes);
-        if (shouldStartRoutes()) {
-            startRoutes(routes);
+
+        if (routes != null) {
+            this.routes.addAll(routes);
+
+            lifecycleStrategy.onRoutesAdd(routes);
+            if (shouldStartRoutes()) {
+                startRoutes(routes);
+            }
         }
     }
 
     public void addRoutes(Routes builder) throws Exception {
         // lets now add the routes from the builder
-        builder.setContext(this);        
+        builder.setContext(this);
         List<Route> routeList = builder.getRouteList();
-        LOG.debug("Adding routes from: " + builder + " routes: " + routeList);
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Adding routes from: " + builder + " routes: " + routeList);
+        }
         addRoutes(routeList);
     }
 

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java?rev=697494&r1=697493&r2=697494&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/RouteBuilderTest.java Sun Sep 21 05:43:54 2008
@@ -25,6 +25,7 @@
 import org.apache.camel.Producer;
 import org.apache.camel.Route;
 import org.apache.camel.TestSupport;
+import org.apache.camel.model.RoutesType;
 import org.apache.camel.impl.EventDrivenConsumerRoute;
 import org.apache.camel.management.InstrumentationProcessor;
 import org.apache.camel.management.JmxSystemPropertyKeys;
@@ -268,11 +269,6 @@
         RouteBuilder builder = new RouteBuilder() {
             public void configure() {
                 from("seda:a").intercept(interceptor1).intercept(interceptor2).to("seda:d");
-                /*
-                 *
-                 * TODO keep old DSL? .intercept() .add(interceptor1)
-                 * .add(interceptor2) .target().to("seda:d");
-                 */
             }
         };
         // END SNIPPET: e7
@@ -499,4 +495,18 @@
             return processor;
         }
     }
+
+    public void testCorrectNumberOfRoutes() throws Exception {
+        RouteBuilder builder = new RouteBuilder() {
+            public void configure() throws Exception {
+                from("direct:start").to("seda:in");
+
+                from("seda:in").to("mock:result");
+            }
+        };
+
+        List<Route> routes = getRouteList(builder);
+
+        assertEquals(2, routes.size());
+    }
 }

Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/CamelChoiceWithManagementTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/CamelChoiceWithManagementTest.java?rev=697494&r1=697493&r2=697494&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/CamelChoiceWithManagementTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/management/CamelChoiceWithManagementTest.java Sun Sep 21 05:43:54 2008
@@ -34,6 +34,7 @@
     private MockEndpoint d;
     private MockEndpoint e;
 
+
     protected void setUp() throws Exception {
         context = createCamelContext();
         assertValidContext(context);
@@ -73,7 +74,6 @@
         });
 
         assertMockEndpointsSatisfied();
-
     }
 
     public void testOtherwise() throws Exception {

Modified: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/produce/MyListener.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/produce/MyListener.java?rev=697494&r1=697493&r2=697494&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/produce/MyListener.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/produce/MyListener.java Sun Sep 21 05:43:54 2008
@@ -20,5 +20,7 @@
  * @version $Revision$
  */
 public interface MyListener {
+
     String sayHello(String name);
+
 }

Modified: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/produce/MyListenerService.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/produce/MyListenerService.java?rev=697494&r1=697493&r2=697494&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/produce/MyListenerService.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/produce/MyListenerService.java Sun Sep 21 05:43:54 2008
@@ -17,6 +17,8 @@
 package org.apache.camel.spring.produce;
 
 import org.apache.camel.Consume;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.springframework.stereotype.Service;
 
 /**
@@ -25,13 +27,15 @@
 @Service
 public class MyListenerService implements MyListener {
 
+    private static final Log LOG = LogFactory.getLog(MyListenerService.class);
+
     public MyListenerService() {
-        System.out.println("Instantiated service: " + this);
+        LOG.debug("Instantiated service: " + this);
     }
 
     @Consume(uri = "direct:myService")
     public String sayHello(String name) {
-        System.out.println("Invoked sayHello with: " + name);
+        LOG.debug("Invoked sayHello with: " + name);
         return "Hello " + name;
     }
 }

Modified: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/produce/ProduceTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/produce/ProduceTest.java?rev=697494&r1=697493&r2=697494&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/produce/ProduceTest.java (original)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/produce/ProduceTest.java Sun Sep 21 05:43:54 2008
@@ -36,6 +36,5 @@
         // lets send a message
         String actual = producer.sayHello("James");
         assertEquals("response", "Hello James", actual);
-
     }
 }
\ No newline at end of file