Repository: camel Updated Branches: refs/heads/master f554c483e -> 7693b4c19
CAMEL-10421: camel-spring-boot should exclude non singletons by default when it scans for RouteBuilder classes which is how camel-spring works. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6cb5b706 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6cb5b706 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6cb5b706 Branch: refs/heads/master Commit: 6cb5b70609ca7b8d0192cb64198af61077348365 Parents: f554c48 Author: Claus Ibsen <davscl...@apache.org> Authored: Sat Oct 29 18:55:29 2016 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Sat Oct 29 18:55:29 2016 +0200 ---------------------------------------------------------------------- .../boot/CamelConfigurationProperties.java | 21 ++++++++++++++++---- .../camel/spring/boot/RoutesCollector.java | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/6cb5b706/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java index 100aa18..b6bafe0 100644 --- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java +++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java @@ -5,9 +5,9 @@ * 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 - * + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> * 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. @@ -17,7 +17,6 @@ package org.apache.camel.spring.boot; import org.apache.camel.ManagementStatisticsLevel; -import org.apache.camel.api.management.ManagedAttribute; import org.springframework.boot.context.properties.ConfigurationProperties; @ConfigurationProperties(prefix = "camel.springboot") @@ -83,6 +82,12 @@ public class CamelConfigurationProperties { private boolean mainRunController; /** + * Whether to include non-singleton beans (prototypes) when scanning for RouteBuilder instances. + * By default only singleton beans is included in the context scan. + */ + private boolean includeNonSingletons; + + /** * Is used to limit the maximum length of the logging Camel message bodies. If the message body * is longer than the limit, the log message is clipped. Use a value of 0 or negative to have unlimited length. * Use for example 1000 to log at at most 1000 chars. @@ -679,4 +684,12 @@ public class CamelConfigurationProperties { public void setTracerFormatterMaxChars(Integer tracerFormatterMaxChars) { this.tracerFormatterMaxChars = tracerFormatterMaxChars; } + + public boolean isIncludeNonSingletons() { + return includeNonSingletons; + } + + public void setIncludeNonSingletons(boolean includeNonSingletons) { + this.includeNonSingletons = includeNonSingletons; + } } http://git-wip-us.apache.org/repos/asf/camel/blob/6cb5b706/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java ---------------------------------------------------------------------- diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java index 5624d36..d5a90d0 100644 --- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java +++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java @@ -75,7 +75,7 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven // only add and start Camel if its stopped (initial state) if (camelContext.getStatus().isStopped()) { LOG.debug("Post-processing CamelContext bean: {}", camelContext.getName()); - for (RoutesBuilder routesBuilder : applicationContext.getBeansOfType(RoutesBuilder.class).values()) { + for (RoutesBuilder routesBuilder : applicationContext.getBeansOfType(RoutesBuilder.class, configurationProperties.isIncludeNonSingletons(), true).values()) { // filter out abstract classes boolean abs = Modifier.isAbstract(routesBuilder.getClass().getModifiers()); // filter out FatJarRouter which can be in the spring app context