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 2014/08/26 09:58:57 UTC

[1/5] git commit: CAMEL-7745: EndpointInject using ref should be enlisted in JMX when using OSGi such as blueprint.

Repository: camel
Updated Branches:
  refs/heads/camel-2.12.x f341506ea -> 6f3b86cf8
  refs/heads/camel-2.13.x 48567a23d -> 2c1f12dc0
  refs/heads/master 2f8bc8045 -> e1f9e26e6


CAMEL-7745: EndpointInject using ref should be enlisted in JMX when using OSGi such as blueprint.


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

Branch: refs/heads/master
Commit: e1f9e26e6aaf9f92e93f5851bf7189f01e819aa0
Parents: 2e43bd6
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Aug 26 09:51:40 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Aug 26 09:56:45 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/e1f9e26e/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 ae31c51..23ba36d 100644
--- a/camel-core/src/main/java/org/apache/camel/CamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/CamelContext.java
@@ -397,6 +397,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 <tt>false</tt> to start the process, call again with <tt>true</tt> 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
@@ -707,6 +715,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.
+     * <p/>
+     * This can be useful to know by {@link LifecycleStrategy} or the likes, in case
+     * they need to react differently.
+     * <p/>
+     * 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 <tt>true</tt> if current thread is setting up route(s), or <tt>false</tt> if not.
+     */
+    boolean isSetupRoutes();
+
     // Properties
     //-----------------------------------------------------------------------
 

http://git-wip-us.apache.org/repos/asf/camel/blob/e1f9e26e/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 abf0c9a..666ee4a 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
@@ -186,6 +186,7 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
     private volatile boolean firstStartDone;
     private volatile boolean doNotStartRoutesOnFirstStart;
     private final ThreadLocal<Boolean> isStartingRoutes = new ThreadLocal<Boolean>();
+    private final ThreadLocal<Boolean> isSetupRoutes = new ThreadLocal<Boolean>();
     private Boolean autoStartup = Boolean.TRUE;
     private Boolean trace = Boolean.FALSE;
     private Boolean messageHistory = Boolean.TRUE;
@@ -803,6 +804,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));
     }
@@ -1423,6 +1429,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<RouteDefinition> getRouteDefinitions() {
         return routeDefinitions;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/e1f9e26e/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 7eb1452..3e44b60 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
@@ -862,6 +862,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/e1f9e26e/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 1b0fdd1..4dec4fd 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
@@ -310,6 +310,9 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
         if (routesSetupDone.compareAndSet(false, true)) {
             LOG.debug("Setting up routes");
 
+            // mark that we are setting up routes
+            getContext().setupRoutes(false);
+
             // must init route refs before we prepare the routes below
             initRouteRefs();
 
@@ -331,6 +334,9 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
 
             // and add the rests
             getContext().addRestDefinitions(getRests());
+
+            // and we are now finished setting up the routes
+            getContext().setupRoutes(true);
         }
     }
 


[4/5] git commit: CAMEL-7745: EndpointInject using ref should be enlisted in JMX when using OSGi such as blueprint.

Posted by da...@apache.org.
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/2c1f12dc
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2c1f12dc
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2c1f12dc

Branch: refs/heads/camel-2.13.x
Commit: 2c1f12dc04d2064fbfadbdd1f08eeaa6e2a17929
Parents: 48567a2
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Aug 26 09:51:40 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Aug 26 09:58:04 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/2c1f12dc/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 15c5436..40dd7cd 100644
--- a/camel-core/src/main/java/org/apache/camel/CamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/CamelContext.java
@@ -368,6 +368,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 <tt>false</tt> to start the process, call again with <tt>true</tt> 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
@@ -646,6 +654,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.
+     * <p/>
+     * This can be useful to know by {@link LifecycleStrategy} or the likes, in case
+     * they need to react differently.
+     * <p/>
+     * 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 <tt>true</tt> if current thread is setting up route(s), or <tt>false</tt> if not.
+     */
+    boolean isSetupRoutes();
+
     // Properties
     //-----------------------------------------------------------------------
 

http://git-wip-us.apache.org/repos/asf/camel/blob/2c1f12dc/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 e38bc71..deec2e9 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
@@ -178,6 +178,7 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
     private volatile boolean firstStartDone;
     private volatile boolean doNotStartRoutesOnFirstStart;
     private final ThreadLocal<Boolean> isStartingRoutes = new ThreadLocal<Boolean>();
+    private final ThreadLocal<Boolean> isSetupRoutes = new ThreadLocal<Boolean>();
     private Boolean autoStartup = Boolean.TRUE;
     private Boolean trace = Boolean.FALSE;
     private Boolean messageHistory = Boolean.TRUE;
@@ -792,6 +793,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));
     }
@@ -1389,6 +1395,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<RouteDefinition> getRouteDefinitions() {
         return routeDefinitions;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/2c1f12dc/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 38d8b65..721c539 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
@@ -858,6 +858,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/2c1f12dc/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 ead2bf0..00642d6 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
@@ -294,6 +294,9 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
         if (routesSetupDone.compareAndSet(false, true)) {
             LOG.debug("Setting up routes");
 
+            // mark that we are setting up routes
+            getContext().setupRoutes(false);
+
             // must init route refs before we prepare the routes below
             initRouteRefs();
 
@@ -309,6 +312,9 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
 
             findRouteBuilders();
             installRoutes();
+
+            // and we are now finished setting up the routes
+            getContext().setupRoutes(true);
         }
     }
 


[3/5] git commit: Polished

Posted by da...@apache.org.
Polished


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

Branch: refs/heads/master
Commit: 254d60f33ad462eb9ca04cdcf8c4e2d1747d7d0f
Parents: 2f8bc80
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Aug 26 08:45:49 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Aug 26 09:56:45 2014 +0200

----------------------------------------------------------------------
 .../org/apache/camel/blueprint/BlueprintPropertiesParser.java    | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/254d60f3/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java
----------------------------------------------------------------------
diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java
index d1bbde6..9c5a3f0 100644
--- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java
+++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintPropertiesParser.java
@@ -155,12 +155,12 @@ public class BlueprintPropertiesParser extends DefaultPropertiesParser {
             String delegateAnswer = delegate.parseProperty(key, answer != null ? answer : value, properties);
             if (delegateAnswer != null) {
                 answer = delegateAnswer;
-                log.debug("delegate property parser parsed the property key:{} as value: {}", key, answer);
+                log.debug("Delegate property parser parsed the property key: {} as value: {}", key, answer);
             }
         }
         
         if (answer == null) {
-            throw new IllegalArgumentException("Cannot parser the property key: " + key + " with value: " + value);
+            throw new IllegalArgumentException("Property placeholder key: " + key + " not found");
         }
 
         log.trace("Returning parsed property key: {} as value: {}", key, answer);


[2/5] git commit: Polished

Posted by da...@apache.org.
Polished


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

Branch: refs/heads/master
Commit: 2e43bd6a31ef3583340a1fc174ad91243118d2c2
Parents: 254d60f
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Aug 26 09:50:45 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Aug 26 09:56:45 2014 +0200

----------------------------------------------------------------------
 .../org/apache/camel/blueprint/BlueprintCamelContext.java    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2e43bd6a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
----------------------------------------------------------------------
diff --git a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
index a379505..5f3b33e 100644
--- a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
+++ b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java
@@ -183,13 +183,13 @@ public class BlueprintCamelContext extends DefaultCamelContext implements Servic
     private void maybeStart() throws Exception {
         LOG.trace("maybeStart: {}", this);
 
-        // allow to regsiter the BluerintCamelContext eager in the OSGi Service Registry, which ex is needed
+        // allow to register the BluerintCamelContext eager in the OSGi Service Registry, which ex is needed
         // for unit testing with camel-test-blueprint
         boolean eager = "true".equalsIgnoreCase(System.getProperty("registerBlueprintCamelContextEager"));
         if (eager) {
-            for (EventNotifier notifer : getManagementStrategy().getEventNotifiers()) {
-                if (notifer instanceof OsgiCamelContextPublisher) {
-                    OsgiCamelContextPublisher publisher = (OsgiCamelContextPublisher) notifer;
+            for (EventNotifier notifier : getManagementStrategy().getEventNotifiers()) {
+                if (notifier instanceof OsgiCamelContextPublisher) {
+                    OsgiCamelContextPublisher publisher = (OsgiCamelContextPublisher) notifier;
                     publisher.registerCamelContext(this);
                     break;
                 }


[5/5] git commit: CAMEL-7745: EndpointInject using ref should be enlisted in JMX when using OSGi such as blueprint.

Posted by da...@apache.org.
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 <da...@apache.org>
Authored: Tue Aug 26 09:51:40 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
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 <tt>false</tt> to start the process, call again with <tt>true</tt> 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.
+     * <p/>
+     * This can be useful to know by {@link LifecycleStrategy} or the likes, in case
+     * they need to react differently.
+     * <p/>
+     * 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 <tt>true</tt> if current thread is setting up route(s), or <tt>false</tt> 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<Boolean> isStartingRoutes = new ThreadLocal<Boolean>();
+    private final ThreadLocal<Boolean> isSetupRoutes = new ThreadLocal<Boolean>();
     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<RouteDefinition> 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<T extends ModelCamelContex
         if (routesSetupDone.compareAndSet(false, true)) {
             LOG.debug("Setting up routes");
 
+            // mark that we are setting up routes
+            getContext().setupRoutes(false);
+
             // must init route refs before we prepare the routes below
             initRouteRefs();
 
@@ -303,6 +306,9 @@ public abstract class AbstractCamelContextFactoryBean<T extends ModelCamelContex
 
             findRouteBuilders();
             installRoutes();
+
+            // and we are now finished setting up the routes
+            getContext().setupRoutes(true);
         }
     }