camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r788067 - in /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/main/java/org/apache/camel/model/ camel-core/src/main/ja...
Date Wed, 24 Jun 2009 16:06:59 GMT
Author: davsclaus
Date: Wed Jun 24 16:06:58 2009
New Revision: 788067

URL: http://svn.apache.org/viewvc?rev=788067&view=rev
Log:
CAMEL-1127: A bit cleanup in the routes API. Routes renamed to RoutesBuilder and having a
more precise interface. Also trace logging start/stop services. And letting RouteService handle
the doStop as well.

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/RoutesBuilder.java   (contents,
props changed)
      - copied, changed from r787997, camel/trunk/camel-core/src/main/java/org/apache/camel/Routes.java
Removed:
    camel/trunk/camel-core/src/main/java/org/apache/camel/Routes.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteService.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteBuilderDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/ServiceHelper.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
    camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/ProcessBuilder.java
    camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/CamelModule.java
    camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/CamelModuleWithMatchingRoutes.java
    camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/CamelModuleWithRouteTypes.java
    camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/GuiceCamelContext.java
    camel/trunk/components/camel-guice/src/test/java/org/apache/camel/guice/CollectionOfCustomRoutesTest.java
    camel/trunk/components/camel-guice/src/test/java/org/apache/camel/guice/EndpointInjectionTest.java
    camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiPackageScanClassResolverTest.java
    camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala
    camel/trunk/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/CamelConfiguration.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/RouteBuilderFinder.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RouteRefCamelContextFactoryBeanTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java Wed Jun 24 16:06:58
2009
@@ -217,7 +217,7 @@
      * @param builder the builder which will create the routes and add them to this context
      * @throws Exception if the routes could not be created for whatever reason
      */
-    void addRoutes(Routes builder) throws Exception;
+    void addRoutes(RoutesBuilder builder) throws Exception;
 
     /**
      * Adds a collection of route definitions to the context

Copied: camel/trunk/camel-core/src/main/java/org/apache/camel/RoutesBuilder.java (from r787997,
camel/trunk/camel-core/src/main/java/org/apache/camel/Routes.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/RoutesBuilder.java?p2=camel/trunk/camel-core/src/main/java/org/apache/camel/RoutesBuilder.java&p1=camel/trunk/camel-core/src/main/java/org/apache/camel/Routes.java&r1=787997&r2=788067&rev=788067&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/Routes.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/RoutesBuilder.java Wed Jun 24 16:06:58
2009
@@ -14,28 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel;
 
-import java.util.List;
-
 /**
- * Routes defined in the camel context.
+ * A routes builder is capable of building routes using the builder and model classes.
+ * <p/>
+ * Eventually the routes is added to a {@link org.apache.camel.CamelContext} where they
+ * run inside.
  */
-public interface Routes {
+public interface RoutesBuilder {
 
     /**
-     * Gets the Camel context used.
+     * Adds the routes from this Route Builder to the CamelContext.
+     *
+     * @param context the Camel context
      */
-    CamelContext getContext();
+    void addRoutesToCamelContext(CamelContext context) throws Exception;
 
-    /**
-     * 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;
 }

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

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/RoutesBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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=788067&r1=788066&r2=788067&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 Jun
24 16:06:58 2009
@@ -23,7 +23,7 @@
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Route;
-import org.apache.camel.Routes;
+import org.apache.camel.RoutesBuilder;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.model.InterceptDefinition;
 import org.apache.camel.model.InterceptFromDefinition;
@@ -39,7 +39,7 @@
  *
  * @version $Revision$
  */
-public abstract class RouteBuilder extends BuilderSupport implements Routes {
+public abstract class RouteBuilder extends BuilderSupport implements RoutesBuilder {
     private AtomicBoolean initialized = new AtomicBoolean(false);
     private RoutesDefinition routeCollection = new RoutesDefinition();
     private List<Route> routes = new ArrayList<Route>();
@@ -236,12 +236,9 @@
         return context;
     }
 
-    /**
-     * Uses {@link org.apache.camel.CamelContext#getRoutes()} to return the routes in the
context.
-     */
-    public List<Route> getRouteList() throws Exception {
+    public void addRoutesToCamelContext(CamelContext context) throws Exception {
+        setContext(context);
         checkInitialized();
-        return routes;
     }
 
     @Override
@@ -260,11 +257,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("CamelContext has not been injected!");
@@ -297,7 +294,7 @@
      *
      * @throws Exception if the routes could not be created for whatever reason
      */
-    protected void addRoutes(Routes routes) throws Exception {
+    protected void addRoutes(RoutesBuilder routes) throws Exception {
         getContext().addRoutes(routes);
     }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Wed
Jun 24 16:06:58 2009
@@ -38,7 +38,7 @@
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.ResolveEndpointFailedException;
 import org.apache.camel.Route;
-import org.apache.camel.Routes;
+import org.apache.camel.RoutesBuilder;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.Service;
 import org.apache.camel.ServiceStatus;
@@ -478,25 +478,15 @@
 
         if (routes != null) {
             this.routes.addAll(routes);
-/*
-            TODO we should have notified the lifecycle strategy via the RouteService
-
-            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);
-        List<Route> routeList = builder.getRouteList();
+    public void addRoutes(RoutesBuilder builder) throws Exception {
         if (LOG.isDebugEnabled()) {
-            LOG.debug("Adding routes from: " + builder + " routes: " + routeList);
+            LOG.debug("Adding routes from builder: " + builder);
         }
-        //addRouteCollection(routeList);
+        // lets now add the routes from the builder
+        builder.addRoutesToCamelContext(this);
     }
 
     public void addRouteDefinitions(Collection<RouteDefinition> routeDefinitions) throws
Exception {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteService.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteService.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteService.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/RouteService.java Wed Jun 24
16:06:58 2009
@@ -83,7 +83,15 @@
 
     protected void doStop() throws Exception {
         camelContext.removeRouteCollection(routes);
-        // TODO should we stop the actual Route objects??
+
+        // there is no lifecycyle for routesRemove
+
+        for (Route route : routes) {
+            List<Service> services = route.getServicesForRoute();
+            for (Service service : services) {
+                stopChildService(service);
+            }
+        }
     }
 
     protected LifecycleStrategy getLifecycleStrategy() {
@@ -95,4 +103,10 @@
         service.start();
         addChildService(service);
     }
+
+    protected void stopChildService(Service service) throws Exception {
+        service.stop();
+        removeChildService(service);
+    }
+
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteBuilderDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteBuilderDefinition.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteBuilderDefinition.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteBuilderDefinition.java
Wed Jun 24 16:06:58 2009
@@ -22,7 +22,7 @@
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.Routes;
+import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.util.CamelContextHelper;
 import org.apache.camel.util.ObjectHelper;
@@ -64,9 +64,9 @@
         return CamelContextHelper.lookup(camelContext, ref, RouteBuilder.class);        
     }
     
-    public Routes createRoutes(CamelContext camelContext) {
+    public RoutesBuilder createRoutes(CamelContext camelContext) {
         ObjectHelper.notNull(camelContext, "camelContext", this);
         ObjectHelper.notNull(ref, "ref", this);
-        return CamelContextHelper.lookup(camelContext, ref, Routes.class);
+        return CamelContextHelper.lookup(camelContext, ref, RoutesBuilder.class);
     }
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/ServiceHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ServiceHelper.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/ServiceHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/ServiceHelper.java Wed Jun
24 16:06:58 2009
@@ -39,6 +39,9 @@
     public static void startService(Object value) throws Exception {
         if (value instanceof Service) {
             Service service = (Service)value;
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Starting service: " + service);
+            }
             service.start();
         } else if (value instanceof Collection) {
             startServices((Collection)value);
@@ -61,6 +64,9 @@
         for (Object value : services) {
             if (value instanceof Service) {
                 Service service = (Service)value;
+                if (LOG.isTraceEnabled()) {
+                    LOG.trace("Starting service: " + service);
+                }
                 service.start();
             }
         }
@@ -75,6 +81,9 @@
             if (value instanceof Service) {
                 Service service = (Service)value;
                 try {
+                    if (LOG.isTraceEnabled()) {
+                        LOG.trace("Stopping service: " + service);
+                    }
                     service.stop();
                 } catch (Exception e) {
                     LOG.debug("Caught exception shutting down: " + e, e);
@@ -107,6 +116,9 @@
             if (value instanceof Service) {
                 Service service = (Service)value;
                 try {
+                    if (LOG.isTraceEnabled()) {
+                        LOG.trace("Stopping service: " + service);
+                    }
                     service.stop();
                 } catch (Exception e) {
                     LOG.debug("Caught exception shutting down: " + e, e);

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java Wed Jun
24 16:06:58 2009
@@ -82,10 +82,10 @@
                 context.addRoutes(builder);
             }
             startCamelContext();
+            log.debug("Routing Rules are: " + context.getRoutes());
         } else {
-            log.debug("Using route builder from the created context: " + context);
+            log.debug("isUseRouteBuilder() is false");
         }
-        log.debug("Routing Rules are: " + context.getRoutes());
     }
 
     @Override

Modified: camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/ProcessBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/ProcessBuilder.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/ProcessBuilder.java
(original)
+++ camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/ProcessBuilder.java
Wed Jun 24 16:06:58 2009
@@ -22,7 +22,6 @@
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Processor;
-import org.apache.camel.Route;
 import org.apache.camel.bam.model.ActivityDefinition;
 import org.apache.camel.bam.model.ProcessDefinition;
 import org.apache.camel.bam.model.ProcessInstance;
@@ -139,7 +138,7 @@
 
     // Implementation methods
     // -------------------------------------------------------------------------
-    protected void populateRoutes(List<Route> routes) throws Exception {
+    protected void populateRoutes() throws Exception {
 
         // lets add the monitoring service - should there be an easier way??
         if (engine == null) {
@@ -155,8 +154,8 @@
         for (ActivityBuilder builder : activityBuilders) {
             from(builder.getEndpoint()).process(builder.getProcessor());
         }
-        super.populateRoutes(routes);
 
+        super.populateRoutes();
     }
 
     // Implementation methods

Modified: camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/CamelModule.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/CamelModule.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/CamelModule.java
(original)
+++ camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/CamelModule.java
Wed Jun 24 16:06:58 2009
@@ -20,7 +20,6 @@
 import org.apache.camel.Consume;
 import org.apache.camel.EndpointInject;
 import org.apache.camel.Produce;
-import org.apache.camel.Routes;
 import org.apache.camel.guice.impl.ConsumerInjection;
 import org.apache.camel.guice.impl.EndpointInjector;
 import org.apache.camel.guice.impl.ProduceInjector;
@@ -37,10 +36,10 @@
  *   Set&lt;Routes&gt; routes(Injector injector) { ... }
  * }
  * </pre></code>
- * If you wish to bind all of the bound {@link Routes} implementations available - maybe
with some filter applied - then
+ * If you wish to bind all of the bound {@link org.apache.camel.RoutesBuilder} implementations
available - maybe with some filter applied - then
  * please use the {@link org.apache.camel.guice.CamelModuleWithMatchingRoutes}.
  * <p>
- * Otherwise if you wish to list all of the classes of the {@link Routes} implementations
then use the
+ * Otherwise if you wish to list all of the classes of the {@link org.apache.camel.RoutesBuilder}
implementations then use the
  * {@link org.apache.camel.guice.CamelModuleWithRouteTypes} module instead.
  *
  * @version $Revision$

Modified: camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/CamelModuleWithMatchingRoutes.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/CamelModuleWithMatchingRoutes.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/CamelModuleWithMatchingRoutes.java
(original)
+++ camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/CamelModuleWithMatchingRoutes.java
Wed Jun 24 16:06:58 2009
@@ -22,15 +22,14 @@
 import com.google.inject.Provides;
 import com.google.inject.matcher.Matcher;
 import com.google.inject.matcher.Matchers;
-
-import org.apache.camel.Routes;
+import org.apache.camel.RoutesBuilder;
 import org.guiceyfruit.Injectors;
 
 /**
  * A Guice Module which injects the CamelContext with all available implementations
- * of {@link Routes} which are bound to Guice with an optional {@link Matcher} to filter
out the classes required.
+ * of {@link org.apache.camel.RoutesBuilder} which are bound to Guice with an optional {@link
Matcher} to filter out the classes required.
  * <p>
- * Or if you would like to specify exactly which {@link Routes} to bind then use the {@link
CamelModule} and create a provider
+ * Or if you would like to specify exactly which {@link org.apache.camel.RoutesBuilder} to
bind then use the {@link CamelModule} and create a provider
  * method annotated with @Provides and returning Set<Routes> such as
  * <code><pre>
  * public class MyModule extends CamelModule {
@@ -45,7 +44,7 @@
     private final Matcher<Class> matcher;
 
     public CamelModuleWithMatchingRoutes() {
-        this(Matchers.subclassesOf(Routes.class));
+        this(Matchers.subclassesOf(RoutesBuilder.class));
     }
 
     public CamelModuleWithMatchingRoutes(Matcher<Class> matcher) {
@@ -53,7 +52,7 @@
     }
 
     @Provides
-    Set<Routes> routes(Injector injector) {
+    Set<RoutesBuilder> routes(Injector injector) {
         return Injectors.getInstancesOf(injector, matcher);
     }
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/CamelModuleWithRouteTypes.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/CamelModuleWithRouteTypes.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/CamelModuleWithRouteTypes.java
(original)
+++ camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/CamelModuleWithRouteTypes.java
Wed Jun 24 16:06:58 2009
@@ -23,16 +23,15 @@
 import com.google.inject.Provides;
 import com.google.inject.internal.Sets;
 
-import org.apache.camel.Routes;
-
+import org.apache.camel.RoutesBuilder;
 
 /**
- * A Guice Module which injects the CamelContext with the specified {@link Routes} types
- which are then injected by Guice.
+ * A Guice Module which injects the CamelContext with the specified {@link org.apache.camel.RoutesBuilder}
types - which are then injected by Guice.
  * <p>
- * If you wish to bind all of the bound {@link Routes} implementations available - maybe
with some filter applied - then
+ * If you wish to bind all of the bound {@link org.apache.camel.RoutesBuilder} implementations
available - maybe with some filter applied - then
  * please use the {@link org.apache.camel.guice.CamelModuleWithMatchingRoutes}.
  * <p>
- * Or if you would like to specify exactly which {@link Routes} to bind then use the {@link
CamelModule} and create a provider
+ * Or if you would like to specify exactly which {@link org.apache.camel.RoutesBuilder} to
bind then use the {@link CamelModule} and create a provider
  * method annotated with @Provides and returning Set<Routes> such as
  * <code><pre>
  * public class MyModule extends CamelModule {
@@ -45,24 +44,24 @@
  * @version $Revision$
  */
 public class CamelModuleWithRouteTypes extends CamelModule {
-    private Set<Class<? extends Routes>> routes;
+    private Set<Class<? extends RoutesBuilder>> routes;
 
-    public CamelModuleWithRouteTypes(Class<? extends Routes>... routeTypes) {
-        this.routes = new HashSet<Class<? extends Routes>>();
-        for (Class<? extends Routes> route : routeTypes) {
+    public CamelModuleWithRouteTypes(Class<? extends RoutesBuilder>... routeTypes)
{
+        this.routes = new HashSet<Class<? extends RoutesBuilder>>();
+        for (Class<? extends RoutesBuilder> route : routeTypes) {
             routes.add(route);
         }
     }
 
-    public CamelModuleWithRouteTypes(Set<Class<? extends Routes>> routes) {
+    public CamelModuleWithRouteTypes(Set<Class<? extends RoutesBuilder>> routes)
{
         this.routes = routes;
     }
 
     @Provides
-    Set<Routes> routes(Injector injector) {
-        Set<Routes> answer = Sets.newHashSet();
-        for (Class<? extends Routes> type : routes) {
-            Routes route = injector.getInstance(type);
+    Set<RoutesBuilder> routes(Injector injector) {
+        Set<RoutesBuilder> answer = Sets.newHashSet();
+        for (Class<? extends RoutesBuilder> type : routes) {
+            RoutesBuilder route = injector.getInstance(type);
             answer.add(route);
         }
         return answer;

Modified: camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/GuiceCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/GuiceCamelContext.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/GuiceCamelContext.java
(original)
+++ camel/trunk/components/camel-guice/src/main/java/org/apache/camel/guice/GuiceCamelContext.java
Wed Jun 24 16:06:58 2009
@@ -28,7 +28,7 @@
 import com.google.inject.Inject;
 
 import org.apache.camel.Route;
-import org.apache.camel.Routes;
+import org.apache.camel.RoutesBuilder;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.TypeConverter;
 import org.apache.camel.builder.ErrorHandlerBuilder;
@@ -73,9 +73,9 @@
     }
 
     @Inject
-    public void setRouteBuilders(Set<Routes> routeBuilders) throws Exception {
-        for (Routes routeBuilder : routeBuilders) {
-            addRoutes(routeBuilder);
+    public void setRouteBuilders(Set<RoutesBuilder> routeBuilders) throws Exception
{
+        for (RoutesBuilder builder : routeBuilders) {
+            addRoutes(builder);
         }
     }
 

Modified: camel/trunk/components/camel-guice/src/test/java/org/apache/camel/guice/CollectionOfCustomRoutesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-guice/src/test/java/org/apache/camel/guice/CollectionOfCustomRoutesTest.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/components/camel-guice/src/test/java/org/apache/camel/guice/CollectionOfCustomRoutesTest.java
(original)
+++ camel/trunk/components/camel-guice/src/test/java/org/apache/camel/guice/CollectionOfCustomRoutesTest.java
Wed Jun 24 16:06:58 2009
@@ -19,8 +19,6 @@
 import java.util.Collection;
 import java.util.List;
 
-import junit.framework.TestCase;
-
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.Provides;
@@ -29,7 +27,7 @@
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Route;
-import org.apache.camel.Routes;
+import org.apache.camel.RoutesBuilder;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -41,20 +39,17 @@
 public class CollectionOfCustomRoutesTest extends Assert {
 
     public static class MyModule extends CamelModuleWithMatchingRoutes {
-
         @Provides
         @Named("foo")
-        protected Collection<? extends Routes> myRoutes() {
+        protected Collection<? extends RoutesBuilder> myRoutes() {
             return Lists.newArrayList(new MyConfigurableRoute2("direct:a", "direct:b"), new
MyConfigurableRoute2("direct:c", "direct:d"));
         }
     }
 
     @Test
     public void testDummy() throws Exception {
-
     }
 
-
     public void xtestGuice() throws Exception {
         Injector injector = Guice.createInjector(new MyModule());
 
@@ -63,8 +58,6 @@
         assertEquals("size of " + list, 2, list.size());
 
         GuiceTest.assertCamelContextRunningThenCloseInjector(injector);
-
     }
 
-
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-guice/src/test/java/org/apache/camel/guice/EndpointInjectionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-guice/src/test/java/org/apache/camel/guice/EndpointInjectionTest.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/components/camel-guice/src/test/java/org/apache/camel/guice/EndpointInjectionTest.java
(original)
+++ camel/trunk/components/camel-guice/src/test/java/org/apache/camel/guice/EndpointInjectionTest.java
Wed Jun 24 16:06:58 2009
@@ -18,8 +18,6 @@
 
 import java.util.Collection;
 
-import junit.framework.TestCase;
-
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.Provides;
@@ -27,13 +25,11 @@
 import com.google.inject.name.Named;
 
 import org.apache.camel.EndpointInject;
-import org.apache.camel.Routes;
+import org.apache.camel.RoutesBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.Assert;
 import org.junit.Test;
 
-
-
 /**
  * Create a collection of routes via a provider method
  *
@@ -46,13 +42,12 @@
         @Override
         protected void configure() {
             super.configure();
-
             bind(MyBean.class);
         }
 
         @Provides
         @Named("foo")
-        protected Collection<? extends Routes> myRoutes() {
+        protected Collection<? extends RoutesBuilder> myRoutes() {
             return Lists.newArrayList(new MyConfigurableRoute2("direct:a", "direct:b"), new
MyConfigurableRoute2("direct:c", "direct:d"));
         }
     }
@@ -71,8 +66,6 @@
         assertEquals("bean.endpoint.uri", "mock:foo", bean.endpoint.getEndpointUri());
 
         GuiceTest.assertCamelContextRunningThenCloseInjector(injector);
-
     }
 
-
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiPackageScanClassResolverTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiPackageScanClassResolverTest.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiPackageScanClassResolverTest.java
(original)
+++ camel/trunk/components/camel-osgi/src/test/java/org/apache/camel/osgi/OsgiPackageScanClassResolverTest.java
Wed Jun 24 16:06:58 2009
@@ -20,7 +20,7 @@
 import java.util.Set;
 
 import org.apache.camel.Converter;
-import org.apache.camel.Routes;
+import org.apache.camel.RoutesBuilder;
 import org.apache.camel.osgi.test.MyRouteBuilder;
 import org.apache.camel.osgi.test.MyTypeConverter;
 import org.junit.Test;
@@ -43,7 +43,7 @@
         BundleContext  context = getActivator().getBundle().getBundleContext();
         OsgiPackageScanClassResolver resolver  = new OsgiPackageScanClassResolver(context);
         String[] packageNames = {"org.apache.camel.osgi.test"};
-        Set<Class> classes = resolver.findImplementations(Routes.class, packageNames);
+        Set<Class> classes = resolver.findImplementations(RoutesBuilder.class, packageNames);
         assertEquals("There should find a class", classes.size(), 1);
         assertTrue("Find a wrong class", classes.contains(MyRouteBuilder.class));
     }

Modified: camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala
(original)
+++ camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/builder/RouteBuilder.scala
Wed Jun 24 16:06:58 2009
@@ -20,7 +20,7 @@
 import org.apache.camel.model.DataFormatDefinition;
 import org.apache.camel.spi.Policy
 import org.apache.camel.processor.aggregate.AggregationStrategy
-import org.apache.camel.Routes
+import org.apache.camel.RoutesBuilder
 
 import collection.mutable.Stack
 import _root_.scala.reflect.Manifest
@@ -32,7 +32,7 @@
 /**
  * Scala RouteBuilder implementation
  */
-class RouteBuilder extends Preamble with DSL with Routes with Languages {
+class RouteBuilder extends Preamble with DSL with RoutesBuilder with Languages {
 
   val builder = new org.apache.camel.builder.RouteBuilder {
     override def configure() =  {}
@@ -109,9 +109,7 @@
   def aggregate(expression: Exchange => Any) = stack.top.aggregate(expression)
 
   // implementing the Routes interface to allow RouteBuilder to be discovered by Spring
-  def getRouteList : java.util.List[Route[_ <: org.apache.camel.Exchange]] = builder.getRouteList()
-  def getContext = builder.getContext()
-  def setContext(context: CamelContext) = builder.setContext(context)
+  def addRoutesToCamelContext(context: CamelContext) = builder.addRoutesToCamelContext(context)
   
   val serialization = new org.apache.camel.model.dataformat.SerializationDataFormat
 

Modified: camel/trunk/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/CamelConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/CamelConfiguration.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/CamelConfiguration.java
(original)
+++ camel/trunk/components/camel-spring-javaconfig/src/main/java/org/apache/camel/spring/javaconfig/CamelConfiguration.java
Wed Jun 24 16:06:58 2009
@@ -19,7 +19,7 @@
 import java.util.List;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.Routes;
+import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.spring.CamelBeanPostProcessor;
 import org.apache.camel.spring.SpringCamelContext;
@@ -55,7 +55,7 @@
         SpringCamelContext camelContext = new SpringCamelContext();        
         setupCamelContext(camelContext);
         List<RouteBuilder> routes = routes();
-        for (Routes route : routes) {
+        for (RoutesBuilder route : routes) {
             camelContext.addRoutes(route);
         }        
         return camelContext;
@@ -63,10 +63,8 @@
     
     // maybe register the camel component, language here
     public void setupCamelContext(CamelContext camelContext) throws Exception {
-        
     }
 
-
     /**
      * Returns the list of routes to use in this configuration
      */

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
(original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
Wed Jun 24 16:06:58 2009
@@ -28,7 +28,7 @@
 import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.camel.CamelException;
-import org.apache.camel.Routes;
+import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.ErrorHandlerBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.DefaultLifecycleStrategy;
@@ -140,7 +140,7 @@
     @XmlTransient
     private RouteBuilder routeBuilder;
     @XmlTransient
-    private List<Routes> additionalBuilders = new ArrayList<Routes>();
+    private List<RoutesBuilder> additionalBuilders = new ArrayList<RoutesBuilder>();
     @XmlTransient
     private ApplicationContext applicationContext;
     @XmlTransient
@@ -169,7 +169,7 @@
         return contextClassLoaderOnStart;
     }
     
-    public List<Routes> getAdditionalBuilders() {
+    public List<RoutesBuilder> getAdditionalBuilders() {
         return additionalBuilders;
     }
 
@@ -760,7 +760,7 @@
                     builders.add(builder);
                 } else {
                     // support to get the route here
-                    Routes routes = builderRef.createRoutes(getContext());
+                    RoutesBuilder routes = builderRef.createRoutes(getContext());
                     if (routes != null) {
                         additionalBuilders.add(routes);
                     } else {
@@ -773,7 +773,7 @@
         }
 
         // install already configured routes
-        for (Routes routeBuilder : additionalBuilders) {
+        for (RoutesBuilder routeBuilder : additionalBuilders) {
             getContext().addRoutes(routeBuilder);
         }
 

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/RouteBuilderFinder.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/RouteBuilderFinder.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/RouteBuilderFinder.java
(original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/RouteBuilderFinder.java
Wed Jun 24 16:06:58 2009
@@ -21,7 +21,7 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.camel.Routes;
+import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.spi.PackageScanClassResolver;
 import org.apache.commons.logging.Log;
@@ -65,14 +65,14 @@
     /**
      * Appends all the {@link RouteBuilder} instances that can be found on the classpath
      */
-    public void appendBuilders(List<Routes> list) throws IllegalAccessException, InstantiationException
{
-        Set<Class> classes = resolver.findImplementations(Routes.class, packages);
+    public void appendBuilders(List<RoutesBuilder> list) throws IllegalAccessException,
InstantiationException {
+        Set<Class> classes = resolver.findImplementations(RoutesBuilder.class, packages);
         for (Class aClass : classes) {
             if (shouldIgnoreBean(aClass)) {
                 continue;
             }
             if (isValidClass(aClass)) {
-                Routes builder = instantiateBuilder(aClass);
+                RoutesBuilder builder = instantiateBuilder(aClass);
                 if (beanPostProcessor != null) {
                     // Inject the annotated resource
                     beanPostProcessor.postProcessBeforeInitialization(builder, builder.toString());
@@ -108,7 +108,7 @@
     }
 
     @SuppressWarnings("unchecked")
-    protected Routes instantiateBuilder(Class type) throws IllegalAccessException, InstantiationException
{
-        return (Routes) camelContext.getInjector().newInstance(type);
+    protected RoutesBuilder instantiateBuilder(Class type) throws IllegalAccessException,
InstantiationException {
+        return (RoutesBuilder) camelContext.getInjector().newInstance(type);
     }
 }

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RouteRefCamelContextFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RouteRefCamelContextFactoryBeanTest.java?rev=788067&r1=788066&r2=788067&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RouteRefCamelContextFactoryBeanTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RouteRefCamelContextFactoryBeanTest.java
Wed Jun 24 16:06:58 2009
@@ -16,18 +16,15 @@
  */
 package org.apache.camel.spring;
 
-import java.util.List;
-
 import org.apache.camel.CamelContext;
-import org.apache.camel.Route;
-import org.apache.camel.Routes;
+import org.apache.camel.RoutesBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 public class RouteRefCamelContextFactoryBeanTest extends RoutingUsingCamelContextFactoryTest
{
     
-    public static class MyRoutes implements Routes {
+    public static class MyRoutes implements RoutesBuilder {
         private RouteBuilder myRouteBuilder;
         
         public MyRoutes() {
@@ -39,18 +36,9 @@
             };
         }
 
-        public CamelContext getContext() {            
-            return myRouteBuilder.getContext();
-        }
-
-        public List<Route> getRouteList() throws Exception {
-            return myRouteBuilder.getRouteList();
+        public void addRoutesToCamelContext(CamelContext camelContext) throws Exception {
+            camelContext.addRoutes(myRouteBuilder);
         }
-
-        public void setContext(CamelContext context) {
-            myRouteBuilder.setContext(context);
-        }
-        
     }
     
     protected AbstractXmlApplicationContext createApplicationContext() {



Mime
View raw message