Class BaseTracker<S>

java.lang.Object
org.osgi.util.tracker.ServiceTracker<S,ConfigurationMap<?>>
org.apache.felix.cm.impl.helper.BaseTracker<S>
All Implemented Interfaces:
org.osgi.util.tracker.ServiceTrackerCustomizer<S,ConfigurationMap<?>>
Direct Known Subclasses:
ManagedServiceFactoryTracker, ManagedServiceTracker

public abstract class BaseTracker<S> extends org.osgi.util.tracker.ServiceTracker<S,ConfigurationMap<?>>
The BaseTracker is the base class for tracking ManagedService and ManagedServiceFactory services. It maps their ServiceRegistration to the ConfigurationMap mapping their service PIDs to provided configuration.
  • Field Details

    • cm

      protected final org.apache.felix.cm.impl.ConfigurationManager cm
  • Constructor Details

    • BaseTracker

      protected BaseTracker(org.apache.felix.cm.impl.ConfigurationManager cm, boolean managedServiceFactory)
  • Method Details

    • addingService

      public ConfigurationMap<?> addingService(org.osgi.framework.ServiceReference<S> reference)
      Specified by:
      addingService in interface org.osgi.util.tracker.ServiceTrackerCustomizer<S,ConfigurationMap<?>>
      Overrides:
      addingService in class org.osgi.util.tracker.ServiceTracker<S,ConfigurationMap<?>>
    • modifiedService

      public void modifiedService(org.osgi.framework.ServiceReference<S> reference, ConfigurationMap<?> service)
      Specified by:
      modifiedService in interface org.osgi.util.tracker.ServiceTrackerCustomizer<S,ConfigurationMap<?>>
      Overrides:
      modifiedService in class org.osgi.util.tracker.ServiceTracker<S,ConfigurationMap<?>>
    • removedService

      public void removedService(org.osgi.framework.ServiceReference<S> reference, ConfigurationMap<?> service)
      Specified by:
      removedService in interface org.osgi.util.tracker.ServiceTrackerCustomizer<S,ConfigurationMap<?>>
      Overrides:
      removedService in class org.osgi.util.tracker.ServiceTracker<S,ConfigurationMap<?>>
    • getServices

      public final List<org.osgi.framework.ServiceReference<S>> getServices(TargetedPID pid)
    • createConfigurationMap

      protected abstract ConfigurationMap<?> createConfigurationMap(String[] pids)
    • getServicePid

      public abstract String getServicePid(org.osgi.framework.ServiceReference<S> service, TargetedPID pid)
      Returns the String to be used as the PID of the service PID for the pid retrieved from the configuration.

      This method will return TargetedPID.getServicePid() most of the time except if the service PID used for the consumer's service registration contains one or more pipe symbols (|). In this case TargetedPID.getRawPid() might be returned.

      Parameters:
      service - The reference ot the service for which the service PID is to be returned.
      pid - The TargetedPID for which to return the service PID.
      Returns:
      The service PID or null if the service does not respond to the targeted PID at all.
    • provideConfiguration

      public abstract void provideConfiguration(org.osgi.framework.ServiceReference<S> service, TargetedPID configPid, TargetedPID factoryPid, Dictionary<String,?> properties, long revision, ConfigurationMap<?> configurationMap)
      Updates the given service with the provided configuration.

      See the implementations of this method for more information.

      Parameters:
      service - The reference to the service to update
      configPid - The targeted configuration PID
      factoryPid - The targeted factory PID or null for a non-factory configuration
      properties - The configuration properties, which may be null if this is the provisioning call upon service registration of a ManagedService
      revision - The configuration revision or -1 if there is no configuration actually to provide.
      configurationMap - The PID to configuration map for PIDs used by the service to update
      See Also:
    • removeConfiguration

      public abstract void removeConfiguration(org.osgi.framework.ServiceReference<S> service, TargetedPID configPid, TargetedPID factoryPid)
      Remove the configuration indicated by the configPid from the service.
      Parameters:
      service - The reference to the service from which the configuration is to be removed.
      configPid - The TargetedPID of the configuration
      factoryPid - The factory PID of the configuration. This may be null for a non-factory configuration.
    • getRealService

      protected final S getRealService(org.osgi.framework.ServiceReference<S> reference)
    • ungetRealService

      protected final void ungetRealService(org.osgi.framework.ServiceReference<S> reference)
    • getProperties

      protected final Dictionary<String,Object> getProperties(Dictionary<String,?> rawProperties, org.osgi.framework.ServiceReference<?> service, String configPid, String factoryPid)
    • handleCallBackError

      protected final void handleCallBackError(Throwable error, org.osgi.framework.ServiceReference target, TargetedPID pid)
    • getAccessControlContext

      public static AccessControlContext getAccessControlContext(org.osgi.framework.Bundle bundle)