camel git commit: [CAMEL-9048] Do not load classes to probe for interface availability
Repository: camel Updated Branches: refs/heads/master 1cb9bdeb7 - 1a73fa61a [CAMEL-9048] Do not load classes to probe for interface availability Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1a73fa61 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1a73fa61 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1a73fa61 Branch: refs/heads/master Commit: 1a73fa61a6e0f1125e516798d0cabc1198328684 Parents: 1cb9bde Author: Christian Schneider ch...@die-schneider.net Authored: Tue Aug 4 16:15:21 2015 +0200 Committer: Christian Schneider ch...@die-schneider.net Committed: Tue Aug 4 16:15:21 2015 +0200 -- .../org/apache/camel/impl/osgi/Activator.java | 61 ++-- 1 file changed, 44 insertions(+), 17 deletions(-) -- http://git-wip-us.apache.org/repos/asf/camel/blob/1a73fa61/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java -- diff --git a/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java b/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java index 12135cb..97729b5 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java +++ b/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java @@ -16,6 +16,8 @@ */ package org.apache.camel.impl.osgi; +import static org.osgi.framework.wiring.BundleRevision.PACKAGE_NAMESPACE; + import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; @@ -64,6 +66,7 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.BundleEvent; import org.osgi.framework.Constants; import org.osgi.framework.ServiceRegistration; +import org.osgi.framework.wiring.BundleCapability; import org.osgi.framework.wiring.BundleWire; import org.osgi.framework.wiring.BundleWiring; import org.slf4j.Logger; @@ -85,9 +88,13 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer { private BundleTracker tracker; private MapLong, ListBaseService resolvers = new ConcurrentHashMapLong, ListBaseService(); private long bundleId; + +// Map from package name to the capability we export for this package +private MapString, BundleCapability packageCapabilities = new HashMap(); public void start(BundleContext context) throws Exception { LOG.info(Camel activator starting); +cachePackageCapabilities(context); bundleId = context.getBundle().getBundleId(); BundleContext systemBundleContext = context.getBundle(0).getBundleContext(); tracker = new BundleTracker(systemBundleContext, Bundle.ACTIVE, this); @@ -100,6 +107,20 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer { tracker.close(); LOG.info(Camel activator stopped); } + +/** + * Caches the package capabilities that are needed for a set of interface classes + * + * @param classes interfaces we want to track + */ +private void cachePackageCapabilities(BundleContext context) { +BundleWiring ourWiring = context.getBundle().adapt(BundleWiring.class); +ListBundleCapability ourExports = ourWiring.getCapabilities(PACKAGE_NAMESPACE); +for (BundleCapability ourExport : ourExports) { +String ourPkgName = (String) ourExport.getAttributes().get(PACKAGE_NAMESPACE); +packageCapabilities.put(ourPkgName, ourExport); +} +} public Object addingBundle(Bundle bundle, BundleEvent event) { LOG.debug(Bundle started: {}, bundle.getSymbolicName()); @@ -152,7 +173,7 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer { } protected void registerComponents(Bundle bundle, ListBaseService resolvers) { -if (checkCompat(bundle, Component.class)) { +if (canSee(bundle, Component.class)) { MapString, String components = new HashMapString, String(); for (Enumeration? e = bundle.getEntryPaths(META_INF_COMPONENT); e != null e.hasMoreElements();) { String path = (String) e.nextElement(); @@ -167,7 +188,7 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer { } protected void registerLanguages(Bundle bundle, ListBaseService resolvers) { -if (checkCompat(bundle, Language.class)) { +if (canSee(bundle, Language.class)) { MapString, String languages = new HashMapString, String(); for (Enumeration? e = bundle.getEntryPaths(META_INF_LANGUAGE); e != null e.hasMoreElements();) { String path = (String) e.nextElement(); @@ -188,7 +209,7 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer { }
camel git commit: [CAMEL-9048] Do not load classes to probe for interface availability
Repository: camel Updated Branches: refs/heads/camel-2.15.x 79c5ed6a7 - 9166b94d6 [CAMEL-9048] Do not load classes to probe for interface availability Conflicts: camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/9166b94d Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/9166b94d Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/9166b94d Branch: refs/heads/camel-2.15.x Commit: 9166b94d63d8129ac1cb4366000a9624af4ed1fe Parents: 79c5ed6 Author: Christian Schneider ch...@die-schneider.net Authored: Tue Aug 4 16:15:21 2015 +0200 Committer: Christian Schneider ch...@die-schneider.net Committed: Tue Aug 4 22:29:24 2015 +0200 -- .../org/apache/camel/impl/osgi/Activator.java | 62 ++-- 1 file changed, 45 insertions(+), 17 deletions(-) -- http://git-wip-us.apache.org/repos/asf/camel/blob/9166b94d/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java -- diff --git a/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java b/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java index d73f6c6..df58189 100644 --- a/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java +++ b/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java @@ -16,6 +16,8 @@ */ package org.apache.camel.impl.osgi; +import static org.osgi.framework.wiring.BundleRevision.PACKAGE_NAMESPACE; + import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; @@ -64,6 +66,9 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.BundleEvent; import org.osgi.framework.Constants; import org.osgi.framework.ServiceRegistration; +import org.osgi.framework.wiring.BundleCapability; +import org.osgi.framework.wiring.BundleWire; +import org.osgi.framework.wiring.BundleWiring; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -80,10 +85,14 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer { private BundleTracker tracker; private MapLong, ListBaseService resolvers = new ConcurrentHashMapLong, ListBaseService(); + +// Map from package name to the capability we export for this package +private MapString, BundleCapability packageCapabilities = new HashMap(); public void start(BundleContext context) throws Exception { LOG.info(Camel activator starting); tracker = new BundleTracker(context, Bundle.ACTIVE, this); +cachePackageCapabilities(context); tracker.open(); LOG.info(Camel activator started); } @@ -93,6 +102,19 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer { tracker.close(); LOG.info(Camel activator stopped); } + +/** + * Caches the package capabilities that are needed for a set of interface classes + * + */ +private void cachePackageCapabilities(BundleContext context) { +BundleWiring ourWiring = context.getBundle().adapt(BundleWiring.class); +ListBundleCapability ourExports = ourWiring.getCapabilities(PACKAGE_NAMESPACE); +for (BundleCapability ourExport : ourExports) { +String ourPkgName = (String) ourExport.getAttributes().get(PACKAGE_NAMESPACE); +packageCapabilities.put(ourPkgName, ourExport); +} +} public Object addingBundle(Bundle bundle, BundleEvent event) { LOG.debug(Bundle started: {}, bundle.getSymbolicName()); @@ -122,7 +144,7 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer { } protected void registerComponents(Bundle bundle, ListBaseService resolvers) { -if (checkCompat(bundle, Component.class)) { +if (canSee(bundle, Component.class)) { MapString, String components = new HashMapString, String(); for (Enumeration? e = bundle.getEntryPaths(META_INF_COMPONENT); e != null e.hasMoreElements();) { String path = (String) e.nextElement(); @@ -137,7 +159,7 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer { } protected void registerLanguages(Bundle bundle, ListBaseService resolvers) { -if (checkCompat(bundle, Language.class)) { +if (canSee(bundle, Language.class)) { MapString, String languages = new HashMapString, String(); for (Enumeration? e = bundle.getEntryPaths(META_INF_LANGUAGE); e != null e.hasMoreElements();) { String path = (String) e.nextElement(); @@ -158,7 +180,7 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer { } protected void