Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A2E45115DD for ; Tue, 26 Aug 2014 07:58:58 +0000 (UTC) Received: (qmail 14002 invoked by uid 500); 26 Aug 2014 07:58:58 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 13946 invoked by uid 500); 26 Aug 2014 07:58:58 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 13837 invoked by uid 99); 26 Aug 2014 07:58:58 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Aug 2014 07:58:58 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 41AF0A05A43; Tue, 26 Aug 2014 07:58:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Date: Tue, 26 Aug 2014 07:59:01 -0000 Message-Id: <943a64d083bc408c939d2f149f3aa1c0@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [5/5] git commit: CAMEL-7745: EndpointInject using ref should be enlisted in JMX when using OSGi such as blueprint. CAMEL-7745: EndpointInject using ref should be enlisted in JMX when using OSGi such as blueprint. Conflicts: components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6f3b86cf Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6f3b86cf Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6f3b86cf Branch: refs/heads/camel-2.12.x Commit: 6f3b86cf8217277edd94cff473e3c747a33b39bc Parents: f341506 Author: Claus Ibsen Authored: Tue Aug 26 09:51:40 2014 +0200 Committer: Claus Ibsen Committed: Tue Aug 26 09:58:34 2014 +0200 ---------------------------------------------------------------------- .../java/org/apache/camel/CamelContext.java | 23 ++++++++++++++++++++ .../apache/camel/impl/DefaultCamelContext.java | 14 ++++++++++++ .../DefaultManagementLifecycleStrategy.java | 5 +++++ .../xml/AbstractCamelContextFactoryBean.java | 6 +++++ 4 files changed, 48 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/6f3b86cf/camel-core/src/main/java/org/apache/camel/CamelContext.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/CamelContext.java b/camel-core/src/main/java/org/apache/camel/CamelContext.java index 319e3a0..56aebd6 100644 --- a/camel-core/src/main/java/org/apache/camel/CamelContext.java +++ b/camel-core/src/main/java/org/apache/camel/CamelContext.java @@ -367,6 +367,14 @@ public interface CamelContext extends SuspendableService, RuntimeConfiguration { //----------------------------------------------------------------------- /** + * Method to signal to {@link CamelContext} that the process to initialize setup routes is in progress. + * + * @param done false to start the process, call again with true to signal its done. + * @see #isSetupRoutes() + */ + void setupRoutes(boolean done); + + /** * Returns a list of the current route definitions * * @return list of the current route definitions @@ -645,6 +653,21 @@ public interface CamelContext extends SuspendableService, RuntimeConfiguration { */ boolean isStartingRoutes(); + /** + * Indicates whether current thread is setting up route(s) as part of starting Camel from spring/blueprint. + *

+ * This can be useful to know by {@link LifecycleStrategy} or the likes, in case + * they need to react differently. + *

+ * As the startup procedure of {@link CamelContext} is slightly different when using plain Java versus + * Spring or Blueprint, then we need to know when Spring/Blueprint is setting up the routes, which + * can happen after the {@link CamelContext} itself is in started state, due the asynchronous event nature + * of especially Blueprint. + * + * @return true if current thread is setting up route(s), or false if not. + */ + boolean isSetupRoutes(); + // Properties //----------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/6f3b86cf/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 bbb8bde..0f2f3a9 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 @@ -176,6 +176,7 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon private volatile boolean firstStartDone; private volatile boolean doNotStartRoutesOnFirstStart; private final ThreadLocal isStartingRoutes = new ThreadLocal(); + private final ThreadLocal isSetupRoutes = new ThreadLocal(); private Boolean autoStartup = Boolean.TRUE; private Boolean trace = Boolean.FALSE; private Boolean messageHistory = Boolean.TRUE; @@ -790,6 +791,11 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon return answer != null && answer; } + public boolean isSetupRoutes() { + Boolean answer = isSetupRoutes.get(); + return answer != null && answer; + } + public void stopRoute(RouteDefinition route) throws Exception { stopRoute(route.idOrCreate(nodeIdFactory)); } @@ -1294,6 +1300,14 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon this.lifecycleStrategies.add(lifecycleStrategy); } + public void setupRoutes(boolean done) { + if (done) { + isSetupRoutes.remove(); + } else { + isSetupRoutes.set(true); + } + } + public synchronized List getRouteDefinitions() { return routeDefinitions; } http://git-wip-us.apache.org/repos/asf/camel/blob/6f3b86cf/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java b/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java index 2528715..976993e 100644 --- a/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java +++ b/camel-core/src/main/java/org/apache/camel/management/DefaultManagementLifecycleStrategy.java @@ -854,6 +854,11 @@ public class DefaultManagementLifecycleStrategy extends ServiceSupport implement return true; } + // always register if we are setting up routes + if (getCamelContext().isSetupRoutes()) { + return true; + } + // register if always is enabled if (agent.getRegisterAlways()) { return true; http://git-wip-us.apache.org/repos/asf/camel/blob/6f3b86cf/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java ---------------------------------------------------------------------- diff --git a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java index 84f6b5a..102db5a 100644 --- a/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java +++ b/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java @@ -288,6 +288,9 @@ public abstract class AbstractCamelContextFactoryBean