camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-9339: If starting camel-cdi main and no camel found then log a WARN
Date Fri, 19 Feb 2016 13:22:36 GMT
Repository: camel
Updated Branches:
  refs/heads/master 38c1f6f7f -> 3b2d9294c


CAMEL-9339: If starting camel-cdi main and no camel found then log a WARN


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

Branch: refs/heads/master
Commit: 3b2d9294ce8920cde4f5cf172bb605853607beee
Parents: 38c1f6f
Author: Antonin Stefanutti <antonin@stefanutti.fr>
Authored: Fri Feb 19 12:34:12 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Feb 19 14:21:45 2016 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/camel/cdi/Main.java    | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3b2d9294/components/camel-cdi/src/main/java/org/apache/camel/cdi/Main.java
----------------------------------------------------------------------
diff --git a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Main.java b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Main.java
index 69c9bfe..ebdae5b 100644
--- a/components/camel-cdi/src/main/java/org/apache/camel/cdi/Main.java
+++ b/components/camel-cdi/src/main/java/org/apache/camel/cdi/Main.java
@@ -18,6 +18,7 @@ package org.apache.camel.cdi;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 import javax.enterprise.inject.UnsatisfiedResolutionException;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
@@ -27,6 +28,8 @@ import org.apache.camel.ProducerTemplate;
 import org.apache.camel.main.MainSupport;
 import org.apache.deltaspike.cdise.api.CdiContainer;
 import org.apache.deltaspike.cdise.api.CdiContainerLoader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Camel CDI boot integration. Allows Camel and CDI to be booted up on the command line as
a JVM process.
@@ -42,6 +45,8 @@ public class Main extends MainSupport {
         System.setProperty("org.jboss.weld.se.shutdownHook", String.valueOf(Boolean.FALSE));
     }
 
+    private static final Logger LOG = LoggerFactory.getLogger(Main.class);
+
     private static Main instance;
 
     private CdiContainer cdiContainer;
@@ -92,6 +97,17 @@ public class Main extends MainSupport {
         cdiContainer = container;
         super.doStart();
         postProcessContext();
+        warnIfNoCamelFound();
+    }
+
+    private void warnIfNoCamelFound() {
+        BeanManager manager = cdiContainer.getBeanManager();
+        Set<Bean<?>> contexts = manager.getBeans(CamelContext.class);
+        // Warn if the default CDI Camel context has no routes
+        if (contexts.size() == 1 && BeanManagerHelper.getReference(manager, CamelContext.class,
contexts.iterator().next()).getRoutes().isEmpty()) {
+            LOG.warn("Camel CDI main has started with no Camel routes! "
+                   + "You may add some RouteBuilder beans to your project.");
+        }
     }
 
     @Override


Mime
View raw message