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/31 10:53:29 UTC

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

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

This reverts commit 9445f4c7656a90a212bb32c29e81795af25b0824.


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

Branch: refs/heads/camel-2.15.x
Commit: 360499fad1e8878dcacd81da5a0adbf7cf98ec6a
Parents: 0977cef
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Mar 31 09:59:29 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Mar 31 10:55:28 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/impl/DefaultCamelContext.java  |   3 +-
 .../org/apache/camel/impl/RouteService.java     |   5 +-
 ...ointRegistryKeepRouteInputEndpointsTest.java | 132 -------------------
 3 files changed, 4 insertions(+), 136 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/360499fa/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
index 0622af6..9ac71b6 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
@@ -1002,8 +1002,7 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
                     }
                 }
                 for (Endpoint endpoint : toRemove) {
-                    log.debug("Stopping and removing: {} which was only in use by route: {}", endpoint, routeId);
-                    ServiceHelper.stopAndShutdownService(endpoint);
+                    log.debug("Removing: {} which was only in use by route: {}", endpoint, routeId);
                     removeEndpoint(endpoint);
                 }
                 return true;

http://git-wip-us.apache.org/repos/asf/camel/blob/360499fa/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 462fb5e..32bb3f5 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
@@ -105,8 +105,6 @@ public class RouteService extends ChildServiceSupport {
     public Set<Endpoint> gatherEndpoints() {
         Set<Endpoint> answer = new LinkedHashSet<Endpoint>();
         for (Route route : routes) {
-            // the input endpoint itself
-            answer.add(route.getEndpoint());
             Set<Service> services = gatherChildServices(route, true);
             for (Service service : services) {
                 if (service instanceof EndpointAware) {
@@ -280,6 +278,9 @@ public class RouteService extends ChildServiceSupport {
             // shutdown the route itself
             ServiceHelper.stopAndShutdownServices(route);
 
+            // endpoints should only be stopped when Camel is shutting down
+            // see more details in the warmUp method
+            ServiceHelper.stopAndShutdownServices(route.getEndpoint());
             // invoke callbacks on route policy
             if (route.getRouteContext().getRoutePolicyList() != null) {
                 for (RoutePolicy routePolicy : route.getRouteContext().getRoutePolicyList()) {

http://git-wip-us.apache.org/repos/asf/camel/blob/360499fa/camel-core/src/test/java/org/apache/camel/impl/EndpointRegistryKeepRouteInputEndpointsTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/EndpointRegistryKeepRouteInputEndpointsTest.java b/camel-core/src/test/java/org/apache/camel/impl/EndpointRegistryKeepRouteInputEndpointsTest.java
deleted file mode 100644
index 1a1434b..0000000
--- a/camel-core/src/test/java/org/apache/camel/impl/EndpointRegistryKeepRouteInputEndpointsTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/**
- * 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.impl;
-
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Endpoint;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.support.ServiceSupport;
-
-public class EndpointRegistryKeepRouteInputEndpointsTest extends ContextTestSupport {
-
-    public void testEndpointRegistryKeepRouteEndpoints() throws Exception {
-        Endpoint seda = context.hasEndpoint("seda://start?multipleConsumers=true");
-        assertNotNull(seda);
-        assertTrue("Should be started", ((ServiceSupport) seda).isStarted());
-
-        assertTrue(context.hasEndpoint("seda://start?multipleConsumers=true") != null);
-        assertTrue(context.hasEndpoint("log://foo") != null);
-        assertTrue(context.hasEndpoint("log://bar") != null);
-        assertTrue(context.hasEndpoint("mock://result") != null);
-        assertTrue(context.hasEndpoint("seda://stop") != null);
-        assertTrue(context.hasEndpoint("mock://stop") != null);
-
-        // stop and remove bar route
-        context.stopRoute("bar");
-        context.removeRoute("bar");
-
-        assertTrue(context.hasEndpoint("seda://start?multipleConsumers=true") != null);
-        assertTrue(context.hasEndpoint("log://foo") != null);
-        assertFalse(context.hasEndpoint("log://bar") != null);
-        assertTrue(context.hasEndpoint("mock://result") != null);
-        assertTrue(context.hasEndpoint("seda://stop") != null);
-        assertTrue(context.hasEndpoint("mock://stop") != null);
-
-        // stop and remove baz route
-        context.stopRoute("baz");
-        context.removeRoute("baz");
-
-        assertTrue(context.hasEndpoint("seda://start?multipleConsumers=true") != null);
-        assertTrue(context.hasEndpoint("log://foo") != null);
-        assertFalse(context.hasEndpoint("log://bar") != null);
-        assertTrue(context.hasEndpoint("mock://result") != null);
-        assertFalse(context.hasEndpoint("seda://stop") != null);
-        assertFalse(context.hasEndpoint("mock://stop") != null);
-
-        // stop and remove foo route
-        context.stopRoute("foo");
-        context.removeRoute("foo");
-
-        assertFalse(context.hasEndpoint("seda://start?multipleConsumers=true") != null);
-        assertFalse(context.hasEndpoint("log://foo") != null);
-        assertFalse(context.hasEndpoint("log://bar") != null);
-        assertFalse(context.hasEndpoint("mock://result") != null);
-        assertFalse(context.hasEndpoint("seda://stop") != null);
-        assertFalse(context.hasEndpoint("mock://stop") != null);
-
-        assertFalse("Should not be started", ((ServiceSupport) seda).isStarted());
-    }
-
-    public void testEndpointRegistryKeepRouteEndpointsContextStop() throws Exception {
-        Endpoint seda = context.hasEndpoint("seda://start?multipleConsumers=true");
-        assertNotNull(seda);
-        assertTrue("Should be started", ((ServiceSupport) seda).isStarted());
-
-        assertTrue(context.hasEndpoint("seda://start?multipleConsumers=true") != null);
-        assertTrue(context.hasEndpoint("log://foo") != null);
-        assertTrue(context.hasEndpoint("log://bar") != null);
-        assertTrue(context.hasEndpoint("mock://result") != null);
-        assertTrue(context.hasEndpoint("seda://stop") != null);
-        assertTrue(context.hasEndpoint("mock://stop") != null);
-
-        // stop and remove bar route
-        context.stopRoute("bar");
-        context.removeRoute("bar");
-
-        assertTrue(context.hasEndpoint("seda://start?multipleConsumers=true") != null);
-        assertTrue(context.hasEndpoint("log://foo") != null);
-        assertFalse(context.hasEndpoint("log://bar") != null);
-        assertTrue(context.hasEndpoint("mock://result") != null);
-        assertTrue(context.hasEndpoint("seda://stop") != null);
-        assertTrue(context.hasEndpoint("mock://stop") != null);
-
-        // stop and remove baz route
-        context.stopRoute("baz");
-        context.removeRoute("baz");
-
-        assertTrue(context.hasEndpoint("seda://start?multipleConsumers=true") != null);
-        assertTrue(context.hasEndpoint("log://foo") != null);
-        assertFalse(context.hasEndpoint("log://bar") != null);
-        assertTrue(context.hasEndpoint("mock://result") != null);
-        assertFalse(context.hasEndpoint("seda://stop") != null);
-        assertFalse(context.hasEndpoint("mock://stop") != null);
-
-        // stop camel which should stop the endpoint
-
-        context.stop();
-
-        assertFalse("Should not be started", ((ServiceSupport) seda).isStarted());
-    }
-
-    @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            @Override
-            public void configure() throws Exception {
-                from("seda:start?multipleConsumers=true").routeId("foo")
-                    .to("log:foo").to("mock:result");
-
-                from("seda:start?multipleConsumers=true").routeId("bar")
-                    .to("log:bar").to("log:bar").to("mock:result");
-
-                from("seda:stop").routeId("baz")
-                    .to("mock:stop");
-            }
-        };
-    }
-
-}