You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/03/28 07:52:21 UTC

[2/3] camel git commit: CAMEL-8562: Removing a route - Should check if the route input endpoint is static and used by other routes

CAMEL-8562: Removing a route - Should check if the route input endpoint is static and used by other routes


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9e807e0a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9e807e0a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9e807e0a

Branch: refs/heads/camel-2.15.x
Commit: 9e807e0a6d6fee36702ee9ef3028f7ee3a3d87c5
Parents: b18addd
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Mar 27 18:47:35 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Mar 28 07:54:23 2015 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/camel/impl/RouteService.java       | 5 +++++
 .../Endpoint2MustBeStartedBeforeSendProcessorTest.java          | 2 ++
 .../processor/EndpointMustBeStartedBeforeSendProcessorTest.java | 2 ++
 3 files changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9e807e0a/camel-core/src/main/java/org/apache/camel/impl/RouteService.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/RouteService.java b/camel-core/src/main/java/org/apache/camel/impl/RouteService.java
index ed4f947..462fb5e 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/RouteService.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/RouteService.java
@@ -142,6 +142,11 @@ public class RouteService extends ChildServiceSupport {
             // endpoints should only be started once as they can be reused on other routes
             // and whatnot, thus their lifecycle is to start once, and only to stop when Camel shutdown
             for (Route route : routes) {
+                // ensure endpoints is registered in the registry
+                String uri = route.getEndpoint().getEndpointUri();
+                if (camelContext.hasEndpoint(uri) == null) {
+                    camelContext.addEndpoint(uri, route.getEndpoint());
+                }
                 // ensure endpoint is started first (before the route services, such as the consumer)
                 ServiceHelper.startService(route.getEndpoint());
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/9e807e0a/camel-core/src/test/java/org/apache/camel/processor/Endpoint2MustBeStartedBeforeSendProcessorTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/Endpoint2MustBeStartedBeforeSendProcessorTest.java b/camel-core/src/test/java/org/apache/camel/processor/Endpoint2MustBeStartedBeforeSendProcessorTest.java
index 29cfb68..637c80a 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/Endpoint2MustBeStartedBeforeSendProcessorTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/Endpoint2MustBeStartedBeforeSendProcessorTest.java
@@ -95,6 +95,8 @@ public class Endpoint2MustBeStartedBeforeSendProcessorTest extends ContextTestSu
         });
         context.start();
 
+        assertTrue("Should be static endpoint", context.getEndpointRegistry().isStatic(myendpoint.getEndpointKey()));
+
         assertEquals("EndpointProducerConsumer", order);
         order = "";
 

http://git-wip-us.apache.org/repos/asf/camel/blob/9e807e0a/camel-core/src/test/java/org/apache/camel/processor/EndpointMustBeStartedBeforeSendProcessorTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/EndpointMustBeStartedBeforeSendProcessorTest.java b/camel-core/src/test/java/org/apache/camel/processor/EndpointMustBeStartedBeforeSendProcessorTest.java
index 19cd537..0e3a347 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/EndpointMustBeStartedBeforeSendProcessorTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/EndpointMustBeStartedBeforeSendProcessorTest.java
@@ -95,6 +95,8 @@ public class EndpointMustBeStartedBeforeSendProcessorTest extends ContextTestSup
         });
         context.start();
 
+        assertTrue("Should be static endpoint", context.getEndpointRegistry().isStatic(myendpoint.getEndpointKey()));
+
         assertEquals("EndpointProducerConsumer", order);
         order = "";