camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [3/3] camel git commit: CAMEL-9166: Polished. This fixes #620.
Date Fri, 25 Sep 2015 14:51:15 GMT
CAMEL-9166: Polished. This fixes #620.


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

Branch: refs/heads/master
Commit: 651b7dda066a9b0949c8f2a0d313769b68e50593
Parents: 397a39b
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Sep 25 16:51:34 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Sep 25 16:51:59 2015 +0200

----------------------------------------------------------------------
 components/camel-scr/pom.xml                     |  1 -
 .../apache/camel/scr/AbstractCamelRunner.java    | 19 ++++++++++++-------
 2 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/651b7dda/components/camel-scr/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-scr/pom.xml b/components/camel-scr/pom.xml
index 1e47652..64e0b77 100644
--- a/components/camel-scr/pom.xml
+++ b/components/camel-scr/pom.xml
@@ -31,7 +31,6 @@
 
   <properties>
     <camel.osgi.export.pkg>org.apache.camel.scr</camel.osgi.export.pkg>
-    <camel.osgi.import.camel.version>version="[2.12,$(version;=+;${camel.osgi.version.clean}))"</camel.osgi.import.camel.version>
   </properties>
 
   <dependencies>

http://git-wip-us.apache.org/repos/asf/camel/blob/651b7dda/components/camel-scr/src/main/java/org/apache/camel/scr/AbstractCamelRunner.java
----------------------------------------------------------------------
diff --git a/components/camel-scr/src/main/java/org/apache/camel/scr/AbstractCamelRunner.java
b/components/camel-scr/src/main/java/org/apache/camel/scr/AbstractCamelRunner.java
index c4be591..478afe7 100644
--- a/components/camel-scr/src/main/java/org/apache/camel/scr/AbstractCamelRunner.java
+++ b/components/camel-scr/src/main/java/org/apache/camel/scr/AbstractCamelRunner.java
@@ -38,11 +38,12 @@ import org.apache.camel.RoutesBuilder;
 import org.apache.camel.component.properties.PropertiesComponent;
 import org.apache.camel.core.osgi.OsgiCamelContextPublisher;
 import org.apache.camel.core.osgi.OsgiDefaultCamelContext;
+import org.apache.camel.core.osgi.OsgiServiceRegistry;
 import org.apache.camel.core.osgi.utils.BundleDelegatingClassLoader;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.ExplicitCamelContextNameStrategy;
 import org.apache.camel.impl.SimpleRegistry;
-import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.spi.Registry;
 import org.apache.camel.util.ReflectionHelper;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -55,8 +56,8 @@ public abstract class AbstractCamelRunner implements Runnable {
     public static final String PROPERTY_PREFIX = "camel.scr.properties.prefix";
     
     protected Logger log = LoggerFactory.getLogger(getClass());
-    protected ModelCamelContext context;
-    protected SimpleRegistry registry = new SimpleRegistry();
+    protected CamelContext context;
+    protected Registry registry;
 
     // Configured fields
     private String camelContextId;
@@ -91,12 +92,14 @@ public abstract class AbstractCamelRunner implements Runnable {
 
     protected void createCamelContext(final BundleContext bundleContext, final Map<String,
String> props) {
         if (bundleContext != null) {
+            registry = new OsgiServiceRegistry(bundleContext);
             context = new OsgiDefaultCamelContext(bundleContext, registry);
             // Setup the application context classloader with the bundle classloader
             context.setApplicationContextClassLoader(new BundleDelegatingClassLoader(bundleContext.getBundle()));
             // and make sure the TCCL is our classloader
             Thread.currentThread().setContextClassLoader(context.getApplicationContextClassLoader());
         } else {
+            registry = new SimpleRegistry();
             context = new DefaultCamelContext(registry);
         }
         setupPropertiesComponent(context, props, log);
@@ -107,6 +110,7 @@ public abstract class AbstractCamelRunner implements Runnable {
         if (camelContextId != null) {
             context.setNameStrategy(new ExplicitCamelContextNameStrategy(camelContextId));
         }
+        // TODO: allow to configure these options and not hardcode
         context.setUseMDCLogging(true);
         context.setUseBreadcrumb(true);
 
@@ -129,11 +133,11 @@ public abstract class AbstractCamelRunner implements Runnable {
         }
 
         // Set property prefix
-        if (null != System.getProperty(PROPERTY_PREFIX)) {
+        if (System.getProperty(PROPERTY_PREFIX) != null) {
             pc.setPropertyPrefix(System.getProperty(PROPERTY_PREFIX) + ".");
         }
 
-        if (null != props) {
+        if (props != null) {
             Properties initialProps = new Properties();
             initialProps.putAll(props);
             log.debug(String.format("Added %d initial properties", props.size()));
@@ -197,6 +201,7 @@ public abstract class AbstractCamelRunner implements Runnable {
             context.start();
             started = true;
         } catch (Exception e) {
+            // LOL so the best we can do is to try to start every 5th second and cross our
fingers - yeah OSGi is lovely ;(
             log.warn("Failed to start Camel context. Will try again when more Camel components
have been registered.", e);
         }
     }
@@ -208,7 +213,7 @@ public abstract class AbstractCamelRunner implements Runnable {
         try {
             context.stop();
         } catch (Exception e) {
-            log.error("Failed to stop Camel context.", e);
+            log.warn("Failed to stop Camel context.", e);
         } finally {
             // Even if stopping failed we consider Camel context stopped
             started = false;
@@ -257,7 +262,7 @@ public abstract class AbstractCamelRunner implements Runnable {
                     log.debug("Configured field {} with value {}", field.getName(), propertyValue);
                 }
             } catch (Exception e) {
-                log.error("Error setting field " + field.getName() + " due: " + e.getMessage()
+ ". This exception is ignored.", e);
+                log.warn("Error setting field " + field.getName() + " due: " + e.getMessage()
+ ". This exception is ignored.", e);
             }
         }
         return target;


Mime
View raw message