Top Description Fields Constructors Methods
org.osgi.framework

public Class ServiceEvent

extends EventObject
Class Inheritance
Imports
java.util.Dictionary, .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.

Author
$Id: b27a941cb68e6416825b1b717090a2eb098733f3 $
See Also
ServiceListener, AllServiceListener

Field Summary

Modifier and TypeField and Description
public static final int
MODIFIED

The properties of a registered service have been modified.

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.

private final ServiceReference<?>
reference

Reference to the service that had a change occur in its lifecycle.

public static final int
REGISTERED

This service has been registered.

pack-priv static final long
private final int
type

Type of service lifecycle change.

public static final int
UNREGISTERING

This service is in the process of being unregistered.

Inherited from java.util.EventObject:
source

Constructor Summary

AccessConstructor and Description
public
ServiceEvent(int
The event type.
type
,
ServiceReference<?>
A ServiceReference object to the service that had a lifecycle change.
reference
)

Creates a new service event object.

Method Summary

Modifier and TypeMethod and Description
public ServiceReference<?>

Returns:

Reference to the service that had a lifecycle change.
getServiceReference
()

Returns a reference to the service that had a change occur in its lifecycle.

public int

Returns:

Type of service lifecycle change.
getType
()

Returns the type of event.

Inherited from java.util.EventObject:
getSourcetoString

Field Detail

MODIFIEDback to summary
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
ServiceRegistration#setProperties(Dictionary)
MODIFIED_ENDMATCHback to summary
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
ServiceRegistration#setProperties(Dictionary)
referenceback to summary
private final ServiceReference<?> reference

Reference to the service that had a change occur in its lifecycle.

REGISTEREDback to summary
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
BundleContext#registerService(String[], Object, Dictionary)
serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides java.util.EventObject.serialVersionUID.

typeback to summary
private final int type

Type of service lifecycle change.

UNREGISTERINGback to summary
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
ServiceRegistration#unregister(), BundleContext#ungetService(ServiceReference)

Constructor Detail

ServiceEventback to summary
public ServiceEvent(int type, ServiceReference<?> reference)

Creates a new service event object.

Parameters
type:int

The event type.

reference:ServiceReference<?>

A ServiceReference object to the service that had a lifecycle change.

Method Detail

getServiceReferenceback to summary
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:ServiceReference<?>

Reference to the service that had a lifecycle change.

getTypeback to summary
public int getType()

Returns the type of event. The event type values are:

Returns:int

Type of service lifecycle change.