0 Replies Latest reply on Mar 24, 2010 11:30 AM by thomas.diesler

    Changing the semantics of getServiceReferences()

    thomas.diesler

      Contrary to common believe getServiceReferences() is not contraint to return references to services that the caller can actually use.

       

      Consider

       

      BundleA

      Export-Package: foo

       

      BundleB

      // no imports

       

      sreg = bundleA.registerService("foo.A", objA, null);
      sref = sreg.getReference();
      
      srefs = bundleB.getServiceReferences("foo.A", null)
      assertEquals(sref, srefs[0])
      assertClassLoadFails(bundleB, "foo.A")
      

       

      BundleA registers a service from a package that BundleB does not wire to (i.e. it does not import package foo).

      BundleB can see the foo.A service references despite the fact that it cannot use the service instance.

       

      This is a fundamental difference of how ServiceReferences must be handled by KernelController queries. i.e. you cannot do

       

      Class<?> type = getBundleManager().loadClassFailsafe(bundleB, className);
      controller.getContexts(type, ControllerState.INSTALLED);
      

       

      because this would limit the set of returned service references to the types that BundleB wires to.

       

      I changed the ServiceManagerPluginImpl accordingly, which immediatly makes another 20+ TCK tests pass. Refernences to non OSGi servies are also effected by this change (i.e. ServiceMixTestCase stopped working and is currently excluded)

       

      When documenting how the service mix should work (https://jira.jboss.org/jira/browse/JBOSGI-205) we need to make sure that this is in line with OSGi spec conform behavior.