You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2018/12/11 13:22:20 UTC

[camel] branch camel-2.22.x updated (fae4d5d -> 84e4040)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch camel-2.22.x
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from fae4d5d  CAMEL-12985 - Fixed CS
     new 824ade5  CAMEL-12987: Ensure onContextStop is called on the OsgiServiceRegistry. (#2660)
     new 84e4040  CAMEL-12987: Fixed CS

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/core/osgi/OsgiCamelContextHelper.java     | 21 +++++++++++++++------
 .../camel/core/osgi/OsgiDefaultCamelContext.java    | 12 +-----------
 2 files changed, 16 insertions(+), 17 deletions(-)


[camel] 01/02: CAMEL-12987: Ensure onContextStop is called on the OsgiServiceRegistry. (#2660)

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.22.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 824ade52c064d72cdf6196a01f05159653f591da
Author: Bob Paulin <bo...@bobpaulin.com>
AuthorDate: Sun Dec 9 03:52:27 2018 -0600

    CAMEL-12987: Ensure onContextStop is called on the OsgiServiceRegistry. (#2660)
---
 .../camel/core/osgi/OsgiCamelContextHelper.java     | 21 +++++++++++++++------
 .../camel/core/osgi/OsgiDefaultCamelContext.java    | 12 +-----------
 2 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextHelper.java b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextHelper.java
index 08ff669..2b9b1fc 100644
--- a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextHelper.java
+++ b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextHelper.java
@@ -56,14 +56,23 @@ public final class OsgiCamelContextHelper {
     public static Registry wrapRegistry(CamelContext camelContext, Registry registry, BundleContext bundleContext) {
         ObjectHelper.notNull(bundleContext, "BundleContext");
 
-        LOG.debug("Setting up OSGi ServiceRegistry");
-        OsgiServiceRegistry osgiServiceRegistry = new OsgiServiceRegistry(bundleContext);
+        OsgiServiceRegistry osgiServiceRegistry = null;
+        Registry resultingRegistry = registry;
+        if(registry instanceof OsgiServiceRegistry) {
+            osgiServiceRegistry = (OsgiServiceRegistry)registry;
+        } else {
+            LOG.debug("Wrapping Registry in OsgiServiceRegistry");
+            osgiServiceRegistry = new OsgiServiceRegistry(bundleContext);
+            CompositeRegistry compositeRegistry = new CompositeRegistry();
+            compositeRegistry.addRegistry(osgiServiceRegistry);
+            compositeRegistry.addRegistry(registry);
+            resultingRegistry = compositeRegistry;
+        }
+        
         // Need to clean up the OSGi service when camel context is closed.
         camelContext.addLifecycleStrategy(osgiServiceRegistry);
-        CompositeRegistry compositeRegistry = new CompositeRegistry();
-        compositeRegistry.addRegistry(osgiServiceRegistry);
-        compositeRegistry.addRegistry(registry);
-        return compositeRegistry;
+        
+        return resultingRegistry;
     }
 
 }
diff --git a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java
index 20e3a21..821ef5d 100644
--- a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java
+++ b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiDefaultCamelContext.java
@@ -32,7 +32,6 @@ import org.osgi.framework.BundleContext;
 public class OsgiDefaultCamelContext extends DefaultCamelContext {
 
     private final BundleContext bundleContext;
-    private final Registry registry;
 
     public OsgiDefaultCamelContext(BundleContext bundleContext) {
         this(bundleContext, new OsgiServiceRegistry(bundleContext));
@@ -41,7 +40,7 @@ public class OsgiDefaultCamelContext extends DefaultCamelContext {
     public OsgiDefaultCamelContext(BundleContext bundleContext, Registry registry) {
         super(registry);
         this.bundleContext = bundleContext;
-        this.registry = registry;
+        setRegistry(OsgiCamelContextHelper.wrapRegistry(this, registry, bundleContext));
         OsgiCamelContextHelper.osgiUpdate(this, bundleContext);
         // setup the application context classloader with the bundle classloader
         setApplicationContextClassLoader(new BundleDelegatingClassLoader(bundleContext.getBundle()));
@@ -53,15 +52,6 @@ public class OsgiDefaultCamelContext extends DefaultCamelContext {
     }
 
     @Override
-    protected Registry createRegistry() {
-        if (registry != null) {
-            return OsgiCamelContextHelper.wrapRegistry(this, registry, bundleContext);
-        } else {
-            return OsgiCamelContextHelper.wrapRegistry(this, super.createRegistry(), bundleContext);
-        }
-    }
-
-    @Override
     protected TypeConverter createTypeConverter() {
         // CAMEL-3614: make sure we use a bundle context which imports org.apache.camel.impl.converter package
         BundleContext ctx = BundleContextUtils.getBundleContext(getClass());


[camel] 02/02: CAMEL-12987: Fixed CS

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.22.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 84e40409d72b4b32c1e77c75241397231702373e
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Dec 9 10:53:35 2018 +0100

    CAMEL-12987: Fixed CS
---
 .../main/java/org/apache/camel/core/osgi/OsgiCamelContextHelper.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextHelper.java b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextHelper.java
index 2b9b1fc..80eb64d 100644
--- a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextHelper.java
+++ b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextHelper.java
@@ -58,7 +58,7 @@ public final class OsgiCamelContextHelper {
 
         OsgiServiceRegistry osgiServiceRegistry = null;
         Registry resultingRegistry = registry;
-        if(registry instanceof OsgiServiceRegistry) {
+        if (registry instanceof OsgiServiceRegistry) {
             osgiServiceRegistry = (OsgiServiceRegistry)registry;
         } else {
             LOG.debug("Wrapping Registry in OsgiServiceRegistry");