You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2017/07/19 06:38:19 UTC

camel git commit: Revert "CAMEL-11547: camel-core: load route definitions from registry"

Repository: camel
Updated Branches:
  refs/heads/master 1b8c168c8 -> f39f9d0a8


Revert "CAMEL-11547: camel-core: load route definitions from registry"

This reverts commit 1b8c168c8aedd4f17179ca0d187c0df43352b9aa.


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

Branch: refs/heads/master
Commit: f39f9d0a8ad13fc771b16ddcb1eecea72c42ac93
Parents: 1b8c168
Author: lburgazzoli <lb...@gmail.com>
Authored: Wed Jul 19 08:37:34 2017 +0200
Committer: lburgazzoli <lb...@gmail.com>
Committed: Wed Jul 19 08:37:34 2017 +0200

----------------------------------------------------------------------
 .../apache/camel/impl/DefaultCamelContext.java  | 19 ----
 .../camel/model/RouteDefinitionHelper.java      | 20 ----
 .../camel/impl/RoutesFromRegistryTest.java      | 98 --------------------
 .../spring/boot/RoutesFromRegistryTest.java     | 87 -----------------
 4 files changed, 224 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f39f9d0a/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 bfb41be..3ebad6d 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
@@ -229,7 +229,6 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
     private ManagementStrategy managementStrategy;
     private ManagementMBeanAssembler managementMBeanAssembler;
     private final List<RouteDefinition> routeDefinitions = new ArrayList<RouteDefinition>();
-    private final Map<String, RouteDefinition> routeDefinitionsFromRegistry = new HashMap<>();
     private final List<RestDefinition> restDefinitions = new ArrayList<RestDefinition>();
     private Map<String, RestConfiguration> restConfigurations = new ConcurrentHashMap<>();
     private Map<String, ServiceCallConfigurationDefinition> serviceCallConfigurations = new ConcurrentHashMap<>();
@@ -3305,24 +3304,6 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
         // start components
         startServices(components.values());
 
-        // Remove routes definition previously found on the registry so in case
-        // context restart new routes eventually removed from the registry won't
-        // stay as zombie.
-        removeRouteDefinitions(routeDefinitionsFromRegistry.values());
-
-        Map<String, RouteDefinition> defs = getRegistry().findByTypeWithName(RouteDefinition.class);
-        if (!defs.isEmpty()) {
-            routeDefinitionsFromRegistry.putAll(defs);
-            for (Map.Entry<String, RouteDefinition> entry: defs.entrySet()) {
-                if (ObjectHelper.isEmpty(entry.getValue().getId())) {
-                    // If routes do not have an id, use the bean name
-                    entry.getValue().setId(entry.getKey());
-                }
-            }
-
-            addRouteDefinitions(defs.values());
-        }
-
         // start the route definitions before the routes is started
         startRouteDefinitions(routeDefinitions);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/f39f9d0a/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java b/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
index 0e48c565..fccc918 100644
--- a/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
@@ -26,7 +26,6 @@ import java.util.List;
 import java.util.Set;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
 import org.apache.camel.builder.ErrorHandlerBuilder;
 import org.apache.camel.util.CamelContextHelper;
 import org.apache.camel.util.EndpointHelper;
@@ -644,23 +643,4 @@ public final class RouteDefinitionHelper {
         }
     }
 
-    /**
-     * Creates a route definition from uri.
-     *
-     * @param uri the uri
-     * @return the route definition
-     */
-    public static RouteDefinition from(String uri) {
-        return new RouteDefinition().from(uri);
-    }
-
-    /**
-     * Creates a route definition from endpoint.
-     *
-     * @param endpoint the endpoint
-     * @return the route definition
-     */
-    public static RouteDefinition from(Endpoint endpoint) {
-        return new RouteDefinition().from(endpoint);
-    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/f39f9d0a/camel-core/src/test/java/org/apache/camel/impl/RoutesFromRegistryTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/RoutesFromRegistryTest.java b/camel-core/src/test/java/org/apache/camel/impl/RoutesFromRegistryTest.java
deleted file mode 100644
index aecaf79..0000000
--- a/camel-core/src/test/java/org/apache/camel/impl/RoutesFromRegistryTest.java
+++ /dev/null
@@ -1,98 +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.CamelContext;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.Route;
-import org.apache.camel.TestSupport;
-import org.apache.camel.component.mock.MockEndpoint;
-
-import static org.apache.camel.model.RouteDefinitionHelper.from;
-
-public class RoutesFromRegistryTest extends TestSupport {
-
-    public void testRoutes() throws Exception {
-        SimpleRegistry registry = new SimpleRegistry();
-        registry.put("start", from("direct:start").to("mock:stop"));
-        registry.put("begin", from("direct:begin").to("mock:end"));
-
-        CamelContext context = new DefaultCamelContext(registry);
-
-        try {
-            context.start();
-
-            Route start = context.getRoute("start");
-            assertNotNull(start);
-            assertEquals("start", start.getId());
-
-            Route begin = context.getRoute("begin");
-            assertNotNull(begin);
-            assertEquals("begin", begin.getId());
-
-            context.getEndpoint("mock:stop", MockEndpoint.class).expectedMessageCount(1);
-            context.getEndpoint("mock:stop", MockEndpoint.class).expectedBodiesReceived("start");
-            context.getEndpoint("mock:end", MockEndpoint.class).expectedMessageCount(1);
-            context.getEndpoint("mock:end", MockEndpoint.class).expectedBodiesReceived("begin");
-
-            ProducerTemplate template = context.createProducerTemplate();
-            template.sendBody("direct:start", "start");
-            template.sendBody("direct:begin", "begin");
-
-            MockEndpoint.assertIsSatisfied(context);
-        } finally {
-            context.stop();
-        }
-    }
-
-    public void testUpdateRoutes() throws Exception {
-        SimpleRegistry registry = new SimpleRegistry();
-        registry.put("start", from("direct:start").to("mock:stop"));
-        registry.put("begin", from("direct:begin").to("mock:end"));
-
-        CamelContext context = new DefaultCamelContext(registry);
-
-        try {
-            context.start();
-
-            Route start = context.getRoute("start");
-            assertNotNull(start);
-            assertEquals("start", start.getId());
-
-            Route begin = context.getRoute("begin");
-            assertNotNull(begin);
-            assertEquals("begin", begin.getId());
-
-            context.stop();
-
-            registry.remove("start");
-            registry.put("test", from("direct:test").to("mock:test"));
-
-            context.start();
-
-            start = context.getRoute("start");
-            assertNull(start);
-
-            Route test = context.getRoute("test");
-            assertNotNull(test);
-            assertEquals("test", test.getId());
-
-        } finally {
-            context.stop();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/f39f9d0a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/RoutesFromRegistryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/RoutesFromRegistryTest.java b/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/RoutesFromRegistryTest.java
deleted file mode 100644
index 6f7e113..0000000
--- a/components/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/RoutesFromRegistryTest.java
+++ /dev/null
@@ -1,87 +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.spring.boot;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.Route;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.model.RouteDefinition;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import static org.apache.camel.model.RouteDefinitionHelper.from;
-
-@DirtiesContext
-@RunWith(SpringRunner.class)
-@EnableAutoConfiguration
-@SpringBootTest(
-    classes = RoutesFromRegistryTest.TestConfiguration.class
-)
-public class RoutesFromRegistryTest {
-    @Autowired
-    private CamelContext context;
-    @Autowired
-    private ProducerTemplate template;
-
-    @Test
-    public void testRoutes() throws Exception {
-        Route start = context.getRoute("start");
-        Assert.assertNotNull(start);
-        Assert.assertEquals("start", start.getId());
-
-        Route begin = context.getRoute("begin");
-        Assert.assertNotNull(begin);
-        Assert.assertEquals("begin", begin.getId());
-
-        context.getEndpoint("mock:stop", MockEndpoint.class).expectedMessageCount(1);
-        context.getEndpoint("mock:stop", MockEndpoint.class).expectedBodiesReceived("start");
-        context.getEndpoint("mock:end", MockEndpoint.class).expectedMessageCount(1);
-        context.getEndpoint("mock:end", MockEndpoint.class).expectedBodiesReceived("begin");
-
-        template.sendBody("direct:start", "trats");
-        template.sendBody("direct:begin", "nigeb");
-
-        MockEndpoint.assertIsSatisfied(context);
-    }
-
-    @Configuration
-    public static class TestConfiguration {
-        @Bean
-        public RouteDefinition start() {
-            return from("direct:start")
-                .transform()
-                    .body(String.class, b -> new StringBuilder(b).reverse().toString())
-                .to("mock:stop");
-        }
-        @Bean
-        public RouteDefinition begin() {
-            return from("direct:begin")
-                .transform()
-                    .body(String.class, b -> new StringBuilder(b).reverse().toString())
-                .to("mock:end");
-        }
-    }
-}