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 2019/12/11 07:44:25 UTC
[camel] 01/03: CAMEL-14287: getComponent on CamelContext should
initialize component
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-3.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 27eb20548fe32f11d6ed244725e77fd292a635c3
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Dec 11 05:40:27 2019 +0100
CAMEL-14287: getComponent on CamelContext should initialize component
---
.../camel/impl/engine/AbstractCamelContext.java | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 9c3681c..43dd4da 100644
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -475,10 +475,10 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext
@Override
public Component getComponent(String name, boolean autoCreateComponents, boolean autoStart) {
+ // ensure CamelContext are initialized before we can get a component
init();
- // Check if the named component is already being created, that would
- // mean
+ // Check if the named component is already being created, that would mean
// that the initComponent has triggered a new getComponent
if (componentsInCreation.get().contains(name)) {
throw new IllegalStateException("Circular dependency detected, the component " + name + " is already being created");
@@ -497,10 +497,8 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext
}
});
- // Start the component after its creation as if it is a component
- // proxy
- // that creates/start a delegated component, we may end up in a
- // deadlock
+ // Start the component after its creation as if it is a component proxy
+ // that creates/start a delegated component, we may end up in a deadlock
if (component != null && created.get() && autoStart && (isStarted() || isStarting())) {
// If the component is looked up after the context is started,
// lets start it up.
@@ -532,12 +530,10 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext
// requests.
//
// In spring apps, the component resolver may trigger a new
- // getComponent
- // because of the underlying bean factory and as the endpoints
- // are
- // registered as singleton, the spring factory creates the bean
- // and then check the type so the getComponent is always
- // triggered.
+ // getComponent because of the underlying bean factory and as
+ // the endpoints are registered as singleton, the spring factory
+ // creates the bean and then check the type so the getComponent
+ // is always triggered.
//
// Simple circular dependency:
//
@@ -568,6 +564,7 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext
component = getComponentResolver().resolveComponent(name, this);
if (component != null) {
component.setCamelContext(this);
+ ServiceHelper.initService(component);
postInitComponent(name, component);
}
} catch (Exception e) {
@@ -708,6 +705,7 @@ public abstract class AbstractCamelContext extends ServiceSupport implements Ext
@Override
public Endpoint getEndpoint(String uri) {
+ // ensure CamelContext are initialized before we can get an endpoint
init();
StringHelper.notEmpty(uri, "uri");