camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: camel git commit: CAMEL-8647: Make Camel OSGI Extender Subsystem-Aware - With thanks to Manuel Holzleitner
Date Sun, 19 Apr 2015 05:50:59 GMT
Hi

I wonder if this may cause master branch to fail in the
camel-test-blueprint module?

https://builds.apache.org/job/Camel.trunk.fulltest/org.apache.camel$camel-test-blueprint/2274/testReport/junit/org.apache.camel.test.blueprint/CustomIdIssuesTest/testCustomId/

I get same errors running it locally on my laptop



On Fri, Apr 17, 2015 at 4:52 PM,  <cschneider@apache.org> wrote:
> Repository: camel
> Updated Branches:
>   refs/heads/master 96cfe14c9 -> a5a0cd7e7
>
>
> CAMEL-8647: Make Camel OSGI Extender Subsystem-Aware - With thanks to Manuel Holzleitner
>
>
> Project: http://git-wip-us.apache.org/repos/asf/camel/repo
> Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a5a0cd7e
> Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a5a0cd7e
> Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a5a0cd7e
>
> Branch: refs/heads/master
> Commit: a5a0cd7e7dcc9b3c41ee96f5da0975f48c98ca7b
> Parents: 96cfe14
> Author: Christian Schneider <chris@die-schneider.net>
> Authored: Fri Apr 17 15:42:33 2015 +0200
> Committer: Christian Schneider <chris@die-schneider.net>
> Committed: Fri Apr 17 16:52:16 2015 +0200
>
> ----------------------------------------------------------------------
>  .../org/apache/camel/impl/osgi/Activator.java   | 48 ++++++++++++++++----
>  parent/pom.xml                                  |  3 +-
>  2 files changed, 40 insertions(+), 11 deletions(-)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/camel/blob/a5a0cd7e/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..2eddc25 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
> @@ -64,6 +64,8 @@ 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.BundleWire;
> +import org.osgi.framework.wiring.BundleWiring;
>  import org.slf4j.Logger;
>  import org.slf4j.LoggerFactory;
>
> @@ -75,15 +77,20 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer
{
>      public static final String META_INF_DATAFORMAT = "META-INF/services/org/apache/camel/dataformat/";
>      public static final String META_INF_TYPE_CONVERTER = "META-INF/services/org/apache/camel/TypeConverter";
>      public static final String META_INF_FALLBACK_TYPE_CONVERTER = "META-INF/services/org/apache/camel/FallbackTypeConverter";
> +    public static final String EXTENDER_NAMESPACE = "osgi.extender";
> +    public static final String CAMEL_EXTENDER = "org.apache.camel";
>
>      private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
>
>      private BundleTracker tracker;
>      private Map<Long, List<BaseService>> resolvers = new ConcurrentHashMap<Long,
List<BaseService>>();
> +    private long bundleId;
>
>      public void start(BundleContext context) throws Exception {
>          LOG.info("Camel activator starting");
> -        tracker = new BundleTracker(context, Bundle.ACTIVE, this);
> +        bundleId = context.getBundle().getBundleId();
> +        BundleContext systemBundleContext = context.getBundle(Constants.SYSTEM_BUNDLE_LOCATION).getBundleContext();
> +        tracker = new BundleTracker(systemBundleContext, Bundle.ACTIVE, this);
>          tracker.open();
>          LOG.info("Camel activator started");
>      }
> @@ -96,18 +103,38 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer
{
>
>      public Object addingBundle(Bundle bundle, BundleEvent event) {
>          LOG.debug("Bundle started: {}", bundle.getSymbolicName());
> -        List<BaseService> r = new ArrayList<BaseService>();
> -        registerComponents(bundle, r);
> -        registerLanguages(bundle, r);
> -        registerDataFormats(bundle, r);
> -        registerTypeConverterLoader(bundle, r);
> -        for (BaseService service : r) {
> -            service.register();
> -        }
> -        resolvers.put(bundle.getBundleId(), r);
> +        if (extenderCapabilityWired(bundle)) {
> +            List<BaseService> r = new ArrayList<BaseService>();
> +            registerComponents(bundle, r);
> +            registerLanguages(bundle, r);
> +            registerDataFormats(bundle, r);
> +            registerTypeConverterLoader(bundle, r);
> +            for (BaseService service : r) {
> +                service.register();
> +            }
> +            resolvers.put(bundle.getBundleId(), r);
> +        }
> +
>          return bundle;
>      }
>
> +    private boolean extenderCapabilityWired(Bundle bundle) {
> +        BundleWiring wiring = bundle.adapt(BundleWiring.class);
> +        List<BundleWire> requiredWires = wiring.getRequiredWires(EXTENDER_NAMESPACE);
> +        for (BundleWire requiredWire : requiredWires) {
> +            if (CAMEL_EXTENDER.equals(requiredWire.getCapability().getAttributes().get(EXTENDER_NAMESPACE)))
{
> +                if (this.bundleId == requiredWire.getProviderWiring().getBundle().getBundleId())
{
> +                    LOG.debug("Camel extender requirement of bundle {} correctly wired
to this implementation", bundle.getBundleId());
> +                    return true;
> +                } else {
> +                    LOG.info("Not processing bundle {} as it requires a camel extender
but is not wired to the this implementation", bundle.getBundleId());
> +                    return false;
> +                }
> +            }
> +        }
> +        return true;
> +    }
> +
>      public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) {
>      }
>
> @@ -537,3 +564,4 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer
{
>
>  }
>
> +
>
> http://git-wip-us.apache.org/repos/asf/camel/blob/a5a0cd7e/parent/pom.xml
> ----------------------------------------------------------------------
> diff --git a/parent/pom.xml b/parent/pom.xml
> index 530371f..877c6ba 100644
> --- a/parent/pom.xml
> +++ b/parent/pom.xml
> @@ -521,7 +521,8 @@
>      <camel.osgi.import.strict.version>version="[$(version;===;${camel.osgi.version.clean}),$(version;==+;${camel.osgi.version.clean}))"</camel.osgi.import.strict.version>
>      <camel.osgi.import.default.version>[$(version;==;$(@)),$(version;+;$(@)))</camel.osgi.import.default.version>
>      <camel.osgi.import.defaults>
> -      org.osgi.framework*;version="[1.5,2)",
> +      org.osgi.framework;version="[1.5,2)",
> +      org.osgi.framework.wiring;version="[1.0,2)",
>        org.springframework.ws.*;version="[2,3)",
>        org.springframework.xml.*;version="[2,3)",
>        org.springframework.*;version="${spring-version-range}",
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

Mime
View raw message