Interface ServiceListener

All Superinterfaces:
EventListener
All Known Subinterfaces:
AllServiceListener, UnfilteredServiceListener
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@ConsumerType @FunctionalInterface public interface ServiceListener extends EventListener
A ServiceEvent listener. ServiceListener is a listener interface that may be implemented by a bundle developer. When a ServiceEvent is fired, it is synchronously delivered to a ServiceListener. The Framework may deliver ServiceEvent objects to a ServiceListener out of order and may concurrently call and/or reenter a ServiceListener.

A ServiceListener object is registered with the Framework using the BundleContext.addServiceListener method. ServiceListener objects are called with a ServiceEvent object when a service is registered, modified, or is in the process of unregistering.

ServiceEvent object delivery to ServiceListener objects is filtered by the filter specified when the listener was registered. If the Java Runtime Environment supports permissions, then additional filtering is done. ServiceEvent objects are only delivered to the listener if the bundle which defines the listener object's class has the appropriate ServicePermission to get the service using at least one of the named classes under which the service was registered.

ServiceEvent object delivery to ServiceListener objects is further filtered according to package sources as defined in ServiceReference.isAssignableTo(Bundle, String).

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Receives notification that a service has had a lifecycle change.
  • Method Details

    • serviceChanged

      void serviceChanged(ServiceEvent event)
      Receives notification that a service has had a lifecycle change.
      Parameters:
      event - The ServiceEvent object.