3 Replies Latest reply on Apr 12, 2011 11:13 AM by bosschaert

    Registering services with other bundles

    bosschaert

      When playing with Blueprint last week I found out that registering a blueprint component was causing an exception. I captured this in JBOSGI-438.

       

      For each Blueprint Component found, the Blueprint Extender registers a service with that component's BundleContext and this service implements the org.osgi.service.blueprint.container.BlueprintContainer interface. The problem is that the blueprint component bundle doesn't normally import the org.osgi.service.blueprint.container package.

       

      This causes issues with JBoss OSGi because it attempts to satisfy the following requirement from the spec by trying to load the service class from the bundle that the service is registered with.

      The 4.2 core 5.2.3 says:

      "The names of the service interfaces under which a bundle wants to register

      its service are provided as arguments to the registerService methods. The

      Framework must ensure that the service object actually is an instance of

      each specified service interfaces, unless the object is a Service Factory. See

      Service Factory on page 134.

      To perform this check, the Framework must load the Class object for each

      specified service interface from either the bundle or a shared package. For

      each Class object, Class.isInstance must be called and return true on the

      Class object with the service object as the argument."

       

      After some discussion on the OSGi EEG mailing list the following message was sent by BJ Hargrave, CTO of the OSGi Alliance:

      "It is valid per the spec. The spec does not prohibit registering services. It only make certain class space consistency guarantees when both the provide and the consumer reference the same package for a service."

       

      So I made a change to the code to allow this kind of situation in JBoss. See here: https://github.com/bosschaert/jbosgi-framework/tree/jbosgi_438

       

      Anyone any thoughs?