Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-5516

Allow to not dereference services internally

    XMLWordPrintableJSON

Details

    Description

      by default, DM always dereference Service References. But sometimes you simply don't want that. You just want to be injected with a ServiceReference, and depending on the
      service properties, then you may want to dereference yourself the service. Or if you want to use ServiceObjects API, then you want to take control and you don't want that DM
      always systematically dereference the service dependencies.

      It is possible to auto-detect if a service dependency callback only needs a ServiceReference, but internally this would require a lot of modification, especially in the sate machine.

      For now, the safest and simplest thing to do is simply to add a "dereference(boolean)" method in the ServiceDepenrency interface, which will allow the users to configure whether or not
      the service reference should or should not be automatically dereferenced by DM:

      public interface ServiceDependency {
          ...
          
          /**
           * Configures whether or not this dependency should internally obtain the service object for all tracked service references.
           * 
           * By default, DM internally dereferences all discovered service references (using 
           * <code>BundleContext.getService(ServiceReference ref)</code> methods. 
           * However, sometimes, your callback only needs the ServiceReference, and then you don't want to dereference the service.
           * So, in this case you can use the <code>dereference(false)</code> method in order to tell to DM 
           * that it should never internally dereference the service dependency internally. 
           */
          public ServiceDependency dereference(boolean dereferenceServiceInternally);
      

      Attachments

        Activity

          People

            pderop Pierre De Rop
            pderop Pierre De Rop
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: