Class DefaultServiceTracker

  • All Implemented Interfaces:
    ServiceTracker

    public class DefaultServiceTracker
    extends Object
    implements ServiceTracker
    Maintains sessions for each service being tracked. Most of the work is delegated to the FilterWatcher: when the results of a filter change, we re-evaluate the state and issue callback accordingly.
    Author:
    jwhite
    • Constructor Detail

      • DefaultServiceTracker

        public DefaultServiceTracker()
    • Method Detail

      • trackServiceMatchingFilterRule

        public Closeable trackServiceMatchingFilterRule​(String serviceName,
                                                        String filterRule,
                                                        ServiceTracker.ServiceListener listener)
        Description copied from interface: ServiceTracker
        Issues callbacks to the given listener for services that: 1) Have the given service name 2) Match the given filter rule Callbacks are expected to be issued immediately for all existing services that match the criteria. Additional callback will be made as services are added/removed.
        Specified by:
        trackServiceMatchingFilterRule in interface ServiceTracker
        Parameters:
        serviceName - only interfaces with the given service name attached will be considered
        filterRule - only interfaces that match the given filter will be considered if null, or empty the filter will match everything
        listener - used for callbacks
        Returns:
        close when done watching
      • trackService

        public Closeable trackService​(String serviceName,
                                      ServiceTracker.ServiceListener listener)
        Description copied from interface: ServiceTracker
        Issues callbacks to the given listener for services that: 1) Have the given service name Callbacks are expected to be issued immediately for all existing services that match the criteria. Additional callback will be made as services are added/removed.
        Specified by:
        trackService in interface ServiceTracker
        Parameters:
        serviceName - only interfaces with the given service name attached will be considered
        listener - used for callbacks
        Returns:
        close when done watching
      • setFilterWatcher

        public void setFilterWatcher​(FilterWatcher filterWatcher)