You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2020/03/26 08:39:51 UTC
[camel] 01/02: [CAMEL-14712] Fix lightweight context wrt latest
lifecycle changes
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 2ca46fec0b8764fb218771be8315ab5d5a1f1b3b
Author: gnodet <gn...@gmail.com>
AuthorDate: Thu Mar 26 09:38:57 2020 +0100
[CAMEL-14712] Fix lightweight context wrt latest lifecycle changes
---
.../camel/impl/lw/LightweightCamelContext.java | 12 +++---------
.../java/org/apache/camel/ContextTestSupport.java | 22 ++++++----------------
2 files changed, 9 insertions(+), 25 deletions(-)
diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java
index 21919db..5096769 100644
--- a/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java
+++ b/core/camel-core-engine/src/main/java/org/apache/camel/impl/lw/LightweightCamelContext.java
@@ -224,11 +224,6 @@ public class LightweightCamelContext implements ExtendedCamelContext, CatalogCam
}
@Override
- public void init() {
- delegate.init();
- }
-
- @Override
public void suspend() {
delegate.suspend();
}
@@ -1658,12 +1653,11 @@ public class LightweightCamelContext implements ExtendedCamelContext, CatalogCam
// Immutable
//
- public void makeImmutable() {
+ public void init() {
if (delegate instanceof LightweightRuntimeCamelContext) {
- throw new IllegalStateException();
+ return;
}
- delegate.setAutoStartup(false);
- delegate.start();
+ delegate.init();
for (Route route : delegate.getRoutes()) {
clearModelReferences(route);
}
diff --git a/core/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java b/core/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
index 49029e0..1f8a87d4 100644
--- a/core/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
+++ b/core/camel-core/src/test/java/org/apache/camel/ContextTestSupport.java
@@ -107,21 +107,22 @@ public abstract class ContextTestSupport extends TestSupport {
}
assertValidContext(context);
+ context.build();
+
+ template = context.createProducerTemplate();
+ consumer = context.createConsumerTemplate();
+
if (isUseRouteBuilder()) {
RouteBuilder[] builders = createRouteBuilders();
for (RouteBuilder builder : builders) {
log.debug("Using created route builder: {}", builder);
context.addRoutes(builder);
}
- context.init();
} else {
log.debug("isUseRouteBuilder() is false");
}
-
- template = context.createProducerTemplate();
template.start();
- consumer = context.createConsumerTemplate();
consumer.start();
// create a default notifier when 1 exchange is done which is the most
@@ -183,18 +184,7 @@ public abstract class ContextTestSupport extends TestSupport {
if (camelContextService != null) {
camelContextService.start();
} else {
- if (context instanceof LightweightCamelContext) {
- LightweightCamelContext ctx = (LightweightCamelContext) context;
- Boolean autoStartup = ctx.isAutoStartup();
- ctx.setAutoStartup(false);
- ctx.start();
- ctx.makeImmutable();
- if (autoStartup != null && autoStartup) {
- ctx.startImmutable();
- }
- } else {
- context.start();
- }
+ context.start();
}
}