You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2016/10/25 06:46:55 UTC
camel git commit: CAMEL-10411 - camel-blueprint. prevent automated
restart in case of errors
Repository: camel
Updated Branches:
refs/heads/camel-2.17.x 530507251 -> 8a3ade968
CAMEL-10411 - camel-blueprint. prevent automated restart in case of errors
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8a3ade96
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8a3ade96
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8a3ade96
Branch: refs/heads/camel-2.17.x
Commit: 8a3ade96812bdb99b606da8c4babf2e33cc8c61b
Parents: 5305072
Author: Paolo Antinori <pa...@redhat.com>
Authored: Mon Oct 24 17:31:40 2016 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Tue Oct 25 08:46:32 2016 +0200
----------------------------------------------------------------------
.../apache/camel/blueprint/BlueprintCamelContext.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/8a3ade96/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 02c9082..865328a 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
@@ -19,7 +19,9 @@ package org.apache.camel.blueprint;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.TypeConverter;
import org.apache.camel.blueprint.handler.CamelNamespaceHandler;
import org.apache.camel.core.osgi.OsgiCamelContextHelper;
@@ -54,6 +56,7 @@ public class BlueprintCamelContext extends DefaultCamelContext implements Servic
private BundleContext bundleContext;
private BlueprintContainer blueprintContainer;
private ServiceRegistration<?> registration;
+ protected final AtomicBoolean routeDefinitionValid = new AtomicBoolean(true);
public BlueprintCamelContext() {
}
@@ -183,7 +186,10 @@ public class BlueprintCamelContext extends DefaultCamelContext implements Servic
// let's set a more suitable TCCL while starting the context
Thread.currentThread().setContextClassLoader(getApplicationContextClassLoader());
super.start();
- } finally {
+ } catch (FailedToCreateRouteException e){
+ routeDefinitionValid.set(false);
+ }
+ finally {
Thread.currentThread().setContextClassLoader(original);
}
}
@@ -191,6 +197,11 @@ public class BlueprintCamelContext extends DefaultCamelContext implements Servic
private void maybeStart() throws Exception {
LOG.trace("maybeStart: {}", this);
+ if(!routeDefinitionValid.get()){
+ LOG.trace("maybeStart: {} is skipping since CamelRoute definition is not correct.", this);
+ return;
+ }
+
// 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"));