camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [1/4] camel git commit: CAMEL-8857: camel-scr should publish the Camel to osgi so the karaf commands works and also what blueprint/spring-dm does.
Date Wed, 05 Aug 2015 13:01:16 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.15.x 0c268d4a4 -> 18859fb05
  refs/heads/master c1b33e990 -> 371f90e75


CAMEL-8857: camel-scr should publish the Camel to osgi so the karaf commands works and also
what blueprint/spring-dm does.


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

Branch: refs/heads/master
Commit: aa59cec696c46d4f9398ae91410998bd40fabbaa
Parents: c1b33e9
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Aug 5 15:05:26 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Aug 5 15:06:00 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/scr/AbstractCamelRunner.java   | 21 +++++++++++---------
 .../camel/scr/AbstractCamelRunnerTest.java      |  1 +
 2 files changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/aa59cec6/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 fbd9431..c1a10e5 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
@@ -36,6 +36,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.camel.CamelContext;
 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.utils.BundleDelegatingClassLoader;
 import org.apache.camel.impl.DefaultCamelContext;
@@ -57,15 +58,11 @@ public abstract class AbstractCamelRunner implements Runnable {
     protected ModelCamelContext context;
     protected SimpleRegistry registry = new SimpleRegistry();
 
-    // Configured fields
-    private String camelContextId = "camel-runner-default";
-    private boolean active;   
-
     private ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
     private ScheduledFuture starter;
     private volatile boolean activated;
     private volatile boolean started;
-
+    protected volatile boolean active;
 
     public synchronized void activate(final BundleContext bundleContext, final Map<String,
String> props) throws Exception {
         if (activated) {
@@ -86,7 +83,7 @@ public abstract class AbstractCamelRunner implements Runnable {
         // Configure fields from properties
         configure(context, this, log, true);
 
-        setupCamelContext(bundleContext, camelContextId);
+        setupCamelContext(bundleContext);
     }
 
     protected void createCamelContext(final BundleContext bundleContext, final Map<String,
String> props) {
@@ -100,11 +97,18 @@ public abstract class AbstractCamelRunner implements Runnable {
             context = new DefaultCamelContext(registry);
         }
         setupPropertiesComponent(context, props, log);
+
+        String name = props.remove("camelContextId");
+        if (name != null) {
+            context.setNameStrategy(new ExplicitCamelContextNameStrategy(name));
+        }
+
+        // ensure we publish this CamelContext to the OSGi service registry
+        context.getManagementStrategy().addEventNotifier(new OsgiCamelContextPublisher(bundleContext));
     }
     
-    protected void setupCamelContext(final BundleContext bundleContext, final String camelContextId)
throws Exception {
+    protected void setupCamelContext(final BundleContext bundleContext) throws Exception
{
         // Set up CamelContext
-        context.setNameStrategy(new ExplicitCamelContextNameStrategy(camelContextId));
         context.setUseMDCLogging(true);
         context.setUseBreadcrumb(true);
 
@@ -188,7 +192,6 @@ public abstract class AbstractCamelRunner implements Runnable {
         try {
             if (!active) {
                 context.setAutoStartup(false);
-                log.info(camelContextId + " autoStartup disabled (active property is false)");
             }
             context.start();
             started = true;

http://git-wip-us.apache.org/repos/asf/camel/blob/aa59cec6/components/camel-scr/src/test/java/org/apache/camel/scr/AbstractCamelRunnerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-scr/src/test/java/org/apache/camel/scr/AbstractCamelRunnerTest.java
b/components/camel-scr/src/test/java/org/apache/camel/scr/AbstractCamelRunnerTest.java
index c8fb1ce..5b10b15 100644
--- a/components/camel-scr/src/test/java/org/apache/camel/scr/AbstractCamelRunnerTest.java
+++ b/components/camel-scr/src/test/java/org/apache/camel/scr/AbstractCamelRunnerTest.java
@@ -49,6 +49,7 @@ public class AbstractCamelRunnerTest {
     @Test
     public void testDeepConfigure() throws Exception {
         ConcreteCamelRunner integration = new ConcreteCamelRunner();
+
         integration.activate(null, integration.getDefaultProperties());
         assertEquals("Overriding camelContextId failed (deep configure)", integration.getDefaultProperties().get("camelContextId"),
integration.getContext().getName());
     }


Mime
View raw message