Class ServiceEvent

java.lang.Object
java.util.EventObject
org.osgi.framework.ServiceEvent
All Implemented Interfaces:
Serializable

public class ServiceEvent extends EventObject
An event from the Framework describing a service lifecycle change.

ServiceEvent objects are delivered to ServiceListeners and AllServiceListeners when a change occurs in this service's lifecycle. A type code is used to identify the event type for future extendability.

OSGi Alliance reserves the right to extend the set of types.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The properties of a registered service have been modified.
    static final int
    The properties of a registered service have been modified and the new properties no longer match the listener's filter.
    static final int
    This service has been registered.
    static final int
    This service is in the process of being unregistered.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ServiceEvent(int type, ServiceReference<?> reference)
    Creates a new service event object.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a reference to the service that had a change occur in its lifecycle.
    int
    Returns the type of event.

    Methods inherited from class java.util.EventObject

    getSource, toString

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • REGISTERED

      public static final int REGISTERED
      This service has been registered.

      This event is synchronously delivered after the service has been registered with the Framework.

      See Also:
    • MODIFIED

      public static final int MODIFIED
      The properties of a registered service have been modified.

      This event is synchronously delivered after the service properties have been modified.

      See Also:
    • UNREGISTERING

      public static final int UNREGISTERING
      This service is in the process of being unregistered.

      This event is synchronously delivered before the service has completed unregistering.

      If a bundle is using a service that is UNREGISTERING, the bundle should release its use of the service when it receives this event. If the bundle does not release its use of the service when it receives this event, the Framework will automatically release the bundle's use of the service while completing the service unregistration operation.

      See Also:
    • MODIFIED_ENDMATCH

      public static final int MODIFIED_ENDMATCH
      The properties of a registered service have been modified and the new properties no longer match the listener's filter.

      This event is synchronously delivered after the service properties have been modified. This event is only delivered to listeners which were added with a non-null filter where the filter matched the service properties prior to the modification but the filter does not match the modified service properties.

      Since:
      1.5
      See Also:
  • Constructor Details

    • ServiceEvent

      public ServiceEvent(int type, ServiceReference<?> reference)
      Creates a new service event object.
      Parameters:
      type - The event type.
      reference - A ServiceReference object to the service that had a lifecycle change.
  • Method Details

    • getServiceReference

      public ServiceReference<?> getServiceReference()
      Returns a reference to the service that had a change occur in its lifecycle.

      This reference is the source of the event.

      Returns:
      Reference to the service that had a lifecycle change.
    • getType

      public int getType()
      Returns the type of event. The event type values are:
      Returns:
      Type of service lifecycle change.