Top Description Inners Fields Constructors Methods
org.osgi.util.tracker

public Class ServiceTracker<S, T>

extends Object
implements ServiceTrackerCustomizer<S, T>
Class Inheritance
All Implemented Interfaces
org.osgi.util.tracker.ServiceTrackerCustomizer
Type Parameters
<S>
The type of the service being tracked.
<T>
The type of the tracked object.
Imports
java.lang.reflect.Array, java.util.Collections, .SortedMap, .TreeMap, org.osgi.framework.AllServiceListener, .BundleContext, .Constants, .Filter, .InvalidSyntaxException, .ServiceEvent, .ServiceListener, .ServiceReference

The ServiceTracker class simplifies using services from the Framework's service registry.

A ServiceTracker object is constructed with search criteria and a ServiceTrackerCustomizer object. A ServiceTracker can use a ServiceTrackerCustomizer to customize the service objects to be tracked. The ServiceTracker can then be opened to begin tracking all services in the Framework's service registry that match the specified search criteria. The ServiceTracker correctly handles all of the details of listening to ServiceEvents and getting and ungetting services.

The getServiceReferences method can be called to get references to the services being tracked. The getService and getServices methods can be called to get the service objects for the tracked service.

The ServiceTracker class is thread-safe. It does not call a ServiceTrackerCustomizer while holding any locks. ServiceTrackerCustomizer implementations must also be thread-safe.

Author
$Id: a0af979aa9c88a89f220c1b2d8d7c060ced41006 $

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
ServiceTracker.AllTracked

Subclass of Tracked which implements the AllServiceListener interface.

private class
ServiceTracker.Tracked

Inner class which subclasses AbstractTracked.

Field Summary

Modifier and TypeField and Description
private volatile ServiceReference<S>
cachedReference

Cached ServiceReference for getServiceReference.

private volatile T
cachedService

Cached service object for getService.

protected final BundleContext
context

The Bundle Context used by this ServiceTracker.

pack-priv final ServiceTrackerCustomizer<S, T>
customizer

The ServiceTrackerCustomizer for this tracker.

pack-priv static final boolean
protected final Filter
filter

The Filter used by this ServiceTracker which specifies the search criteria for the services to track.

pack-priv final String
listenerFilter

Filter string for use when adding the ServiceListener.

private final String
trackClass

Class name to be tracked.

private volatile ServiceTracker<S, T>.Tracked
tracked

Tracked services: ServiceReference -> customized Object and ServiceListener object

private final ServiceReference<S>
trackReference

Reference to be tracked.

Constructor Summary

AccessConstructor and Description
public
ServiceTracker(final BundleContext
The BundleContext against which the tracking is done.
context
,
final ServiceReference<S>
The ServiceReference for the service to be tracked.
reference
,
final ServiceTrackerCustomizer<S, T>
The customizer object to call when services are added, modified, or removed in this ServiceTracker. If customizer is null, then this ServiceTracker will be used as the ServiceTrackerCustomizer and this ServiceTracker will call the ServiceTrackerCustomizer methods on itself.
customizer
)

Create a ServiceTracker on the specified ServiceReference .

public
ServiceTracker(final BundleContext
The BundleContext against which the tracking is done.
context
,
final String
The class name of the services to be tracked.
clazz
,
final ServiceTrackerCustomizer<S, T>
The customizer object to call when services are added, modified, or removed in this ServiceTracker. If customizer is null, then this ServiceTracker will be used as the ServiceTrackerCustomizer and this ServiceTracker will call the ServiceTrackerCustomizer methods on itself.
customizer
)

Create a ServiceTracker on the specified class name.

public
ServiceTracker(final BundleContext
The BundleContext against which the tracking is done.
context
,
final Filter
The Filter to select the services to be tracked.
filter
,
final ServiceTrackerCustomizer<S, T>
The customizer object to call when services are added, modified, or removed in this ServiceTracker. If customizer is null, then this ServiceTracker will be used as the ServiceTrackerCustomizer and this ServiceTracker will call the ServiceTrackerCustomizer methods on itself.
customizer
)

Create a ServiceTracker on the specified Filter object.

public
ServiceTracker(final BundleContext
The BundleContext against which the tracking is done.
context
,
final Class<S>
The class of the services to be tracked.
clazz
,
final ServiceTrackerCustomizer<S, T>
The customizer object to call when services are added, modified, or removed in this ServiceTracker. If customizer is null, then this ServiceTracker will be used as the ServiceTrackerCustomizer and this ServiceTracker will call the ServiceTrackerCustomizer methods on itself.
customizer
)

Create a ServiceTracker on the specified class.

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

The service object to be tracked for the service added to this ServiceTracker.
addingService
(ServiceReference<S>
The reference to the service being added to this ServiceTracker.
reference
)

Implements org.osgi.util.tracker.ServiceTrackerCustomizer.addingService.

Default implementation of the ServiceTrackerCustomizer.addingService method.

public void
close()

Close this ServiceTracker.

private ServiceReference<S>[]

Returns:

The list of initial ServiceReferences.
getInitialReferences
(boolean
If true, use getAllServiceReferences.
trackAllServices
,
String
The class name with which the service was registered, or null for all services.
className
,
String
The filter criteria or null for all services.
filterString
)

Returns the list of initial ServiceReferences that will be tracked by this ServiceTracker.

public T

Returns:

A service object or null if the service referenced by the specified ServiceReference is not being tracked.
getService
(ServiceReference<S>
The reference to the desired service.
reference
)

Returns the service object for the specified ServiceReference if the specified referenced service is being tracked by this ServiceTracker.

public T

Returns:

A service object or null if no services are being tracked.
getService
()

Returns a service object for one of the services being tracked by this ServiceTracker.

public ServiceReference<S>

Returns:

A ServiceReference or null if no services are being tracked.
getServiceReference
()

Returns a ServiceReference for one of the services being tracked by this ServiceTracker.

public ServiceReference<S>[]

Returns:

Array of ServiceReferences or null if no services are being tracked.
getServiceReferences
()

Return an array of ServiceReferences for all services being tracked by this ServiceTracker.

public Object[]

Returns:

An array of service objects or null if no services are being tracked.
getServices
()

Return an array of service objects for all services being tracked by this ServiceTracker.

public T[]

Returns:

An array of service objects being tracked. If the specified array is large enough to hold the result, then the specified array is returned. If the specified array is longer then necessary to hold the result, the array element after the last service object is set to null. If the specified array is not large enough to hold the result, a new array is created and returned.
getServices
(T[]
An array into which the tracked service objects will be stored, if the array is large enough.
array
)

Return an array of service objects for all services being tracked by this ServiceTracker.

public SortedMap<ServiceReference<S>, T>

Returns:

A SortedMap with the ServiceReferences and service objects for all services being tracked by this ServiceTracker. If no services are being tracked, then the returned map is empty.
getTracked
()

Return a SortedMap of the ServiceReferences and service objects for all services being tracked by this ServiceTracker.

public int

Returns:

The tracking count for this ServiceTracker or -1 if this ServiceTracker is not open.
getTrackingCount
()

Returns the tracking count for this ServiceTracker.

public boolean

Returns:

true if this ServiceTracker is not tracking any services.
isEmpty
()

Return if this ServiceTracker is empty.

pack-priv void
modified()

Called by the Tracked object whenever the set of tracked services is modified.

public void
modifiedService(ServiceReference<S>
The reference to modified service.
reference
,
T
The service object for the modified service.
service
)

Implements org.osgi.util.tracker.ServiceTrackerCustomizer.modifiedService.

Default implementation of the ServiceTrackerCustomizer.modifiedService method.

public void
open()

Open this ServiceTracker and begin tracking services.

public void
open(boolean
If true, then this ServiceTracker will track all matching services regardless of class loader accessibility. If false, then this ServiceTracker will only track matching services which are class loader accessible to the bundle whose BundleContext is used by this ServiceTracker.
trackAllServices
)

Open this ServiceTracker and begin tracking services.

public void
remove(ServiceReference<S>
The reference to the service to be removed.
reference
)

Remove a service from this ServiceTracker.

public void
removedService(ServiceReference<S>
The reference to removed service.
reference
,
T
The service object for the removed service.
service
)

Implements org.osgi.util.tracker.ServiceTrackerCustomizer.removedService.

Default implementation of the ServiceTrackerCustomizer.removedService method.

public int

Returns:

The number of services being tracked.
size
()

Return the number of services being tracked by this ServiceTracker.

private ServiceTracker<S, T>.Tracked

Returns:

The current Tracked object.
tracked
()

Accessor method for the current Tracked object.

public T

Returns:

Returns the result of getService().
waitForService
(long
The time interval in milliseconds to wait. If zero, the method will wait indefinitely.
timeout
)

Wait for at least one service to be tracked by this ServiceTracker.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cachedReferenceback to summary
private volatile ServiceReference<S> cachedReference

Cached ServiceReference for getServiceReference. This field is volatile since it is accessed by multiple threads.

cachedServiceback to summary
private volatile T cachedService

Cached service object for getService. This field is volatile since it is accessed by multiple threads.

contextback to summary
protected final BundleContext context

The Bundle Context used by this ServiceTracker.

customizerback to summary
pack-priv final ServiceTrackerCustomizer<S, T> customizer

The ServiceTrackerCustomizer for this tracker.

DEBUGback to summary
pack-priv static final boolean DEBUG
filterback to summary
protected final Filter filter

The Filter used by this ServiceTracker which specifies the search criteria for the services to track.

Since
1.1
listenerFilterback to summary
pack-priv final String listenerFilter

Filter string for use when adding the ServiceListener. If this field is set, then certain optimizations can be taken since we don't have a user supplied filter.

trackClassback to summary
private final String trackClass

Class name to be tracked. If this field is set, then we are tracking by class name.

trackedback to summary
private volatile ServiceTracker<S, T>.Tracked tracked

Tracked services: ServiceReference -> customized Object and ServiceListener object

trackReferenceback to summary
private final ServiceReference<S> trackReference

Reference to be tracked. If this field is set, then we are tracking a single ServiceReference.

Constructor Detail

ServiceTrackerback to summary
public ServiceTracker(final BundleContext context, final ServiceReference<S> reference, final ServiceTrackerCustomizer<S, T> customizer)

Create a ServiceTracker on the specified ServiceReference .

The service referenced by the specified ServiceReference will be tracked by this ServiceTracker.

Parameters
context:BundleContext

The BundleContext against which the tracking is done.

reference:ServiceReference<S>

The ServiceReference for the service to be tracked.

customizer:ServiceTrackerCustomizer<S, T>

The customizer object to call when services are added, modified, or removed in this ServiceTracker. If customizer is null, then this ServiceTracker will be used as the ServiceTrackerCustomizer and this ServiceTracker will call the ServiceTrackerCustomizer methods on itself.

ServiceTrackerback to summary
public ServiceTracker(final BundleContext context, final String clazz, final ServiceTrackerCustomizer<S, T> customizer)

Create a ServiceTracker on the specified class name.

Services registered under the specified class name will be tracked by this ServiceTracker.

Parameters
context:BundleContext

The BundleContext against which the tracking is done.

clazz:String

The class name of the services to be tracked.

customizer:ServiceTrackerCustomizer<S, T>

The customizer object to call when services are added, modified, or removed in this ServiceTracker. If customizer is null, then this ServiceTracker will be used as the ServiceTrackerCustomizer and this ServiceTracker will call the ServiceTrackerCustomizer methods on itself.

ServiceTrackerback to summary
public ServiceTracker(final BundleContext context, final Filter filter, final ServiceTrackerCustomizer<S, T> customizer)

Create a ServiceTracker on the specified Filter object.

Services which match the specified Filter object will be tracked by this ServiceTracker.

Parameters
context:BundleContext

The BundleContext against which the tracking is done.

filter:Filter

The Filter to select the services to be tracked.

customizer:ServiceTrackerCustomizer<S, T>

The customizer object to call when services are added, modified, or removed in this ServiceTracker. If customizer is null, then this ServiceTracker will be used as the ServiceTrackerCustomizer and this ServiceTracker will call the ServiceTrackerCustomizer methods on itself.

Since
1.1
ServiceTrackerback to summary
public ServiceTracker(final BundleContext context, final Class<S> clazz, final ServiceTrackerCustomizer<S, T> customizer)

Create a ServiceTracker on the specified class.

Services registered under the name of the specified class will be tracked by this ServiceTracker.

Parameters
context:BundleContext

The BundleContext against which the tracking is done.

clazz:Class<S>

The class of the services to be tracked.

customizer:ServiceTrackerCustomizer<S, T>

The customizer object to call when services are added, modified, or removed in this ServiceTracker. If customizer is null, then this ServiceTracker will be used as the ServiceTrackerCustomizer and this ServiceTracker will call the ServiceTrackerCustomizer methods on itself.

Since
1.5

Method Detail

addingServiceback to summary
public T addingService(ServiceReference<S> reference)

Implements org.osgi.util.tracker.ServiceTrackerCustomizer.addingService.

Default implementation of the ServiceTrackerCustomizer.addingService method.

This method is only called when this ServiceTracker has been constructed with a null ServiceTrackerCustomizer argument.

This implementation returns the result of calling getService on the BundleContext with which this ServiceTracker was created passing the specified ServiceReference.

This method can be overridden in a subclass to customize the service object to be tracked for the service being added. In that case, take care not to rely on the default implementation of removedService to unget the service.

Parameters
reference:ServiceReference<S>

The reference to the service being added to this ServiceTracker.

Returns:T

The service object to be tracked for the service added to this ServiceTracker.

See Also
ServiceTrackerCustomizer#addingService(ServiceReference)
closeback to summary
public void close()

Close this ServiceTracker.

This method should be called when this ServiceTracker should end the tracking of services.

This implementation calls getServiceReferences() to get the list of tracked services to remove.

getInitialReferencesback to summary
private ServiceReference<S>[] getInitialReferences(boolean trackAllServices, String className, String filterString) throws InvalidSyntaxException

Returns the list of initial ServiceReferences that will be tracked by this ServiceTracker.

Parameters
trackAllServices:boolean

If true, use getAllServiceReferences.

className:String

The class name with which the service was registered, or null for all services.

filterString:String

The filter criteria or null for all services.

Returns:ServiceReference<S>[]

The list of initial ServiceReferences.

Exceptions
InvalidSyntaxException:
If the specified filterString has an invalid syntax.
getServiceback to summary
public T getService(ServiceReference<S> reference)

Returns the service object for the specified ServiceReference if the specified referenced service is being tracked by this ServiceTracker.

Parameters
reference:ServiceReference<S>

The reference to the desired service.

Returns:T

A service object or null if the service referenced by the specified ServiceReference is not being tracked.

getServiceback to summary
public T getService()

Returns a service object for one of the services being tracked by this ServiceTracker.

If any services are being tracked, this implementation returns the result of calling getService(getServiceReference()).

Returns:T

A service object or null if no services are being tracked.

getServiceReferenceback to summary
public ServiceReference<S> getServiceReference()

Returns a ServiceReference for one of the services being tracked by this ServiceTracker.

If multiple services are being tracked, the service with the highest ranking (as specified in its service.ranking property) is returned. If there is a tie in ranking, the service with the lowest service id (as specified in its service.id property); that is, the service that was registered first is returned. This is the same algorithm used by BundleContext.getServiceReference.

This implementation calls getServiceReferences() to get the list of references for the tracked services.

Returns:ServiceReference<S>

A ServiceReference or null if no services are being tracked.

Since
1.1
getServiceReferencesback to summary
public ServiceReference<S>[] getServiceReferences()

Return an array of ServiceReferences for all services being tracked by this ServiceTracker.

Returns:ServiceReference<S>[]

Array of ServiceReferences or null if no services are being tracked.

getServicesback to summary
public Object[] getServices()

Return an array of service objects for all services being tracked by this ServiceTracker.

This implementation calls getServiceReferences() to get the list of references for the tracked services and then calls getService(ServiceReference) for each reference to get the tracked service object.

Returns:Object[]

An array of service objects or null if no services are being tracked.

getServicesback to summary
public T[] getServices(T[] array)

Return an array of service objects for all services being tracked by this ServiceTracker. The runtime type of the returned array is that of the specified array.

This implementation calls getServiceReferences() to get the list of references for the tracked services and then calls getService(ServiceReference) for each reference to get the tracked service object.

Parameters
array:T[]

An array into which the tracked service objects will be stored, if the array is large enough.

Returns:T[]

An array of service objects being tracked. If the specified array is large enough to hold the result, then the specified array is returned. If the specified array is longer then necessary to hold the result, the array element after the last service object is set to null. If the specified array is not large enough to hold the result, a new array is created and returned.

Since
1.5
getTrackedback to summary
public SortedMap<ServiceReference<S>, T> getTracked()

Return a SortedMap of the ServiceReferences and service objects for all services being tracked by this ServiceTracker. The map is sorted in reverse natural order of ServiceReference. That is, the first entry is the service with the highest ranking and the lowest service id.

Returns:SortedMap<ServiceReference<S>, T>

A SortedMap with the ServiceReferences and service objects for all services being tracked by this ServiceTracker. If no services are being tracked, then the returned map is empty.

Since
1.5
getTrackingCountback to summary
public int getTrackingCount()

Returns the tracking count for this ServiceTracker. The tracking count is initialized to 0 when this ServiceTracker is opened. Every time a service is added, modified or removed from this ServiceTracker, the tracking count is incremented.

The tracking count can be used to determine if this ServiceTracker has added, modified or removed a service by comparing a tracking count value previously collected with the current tracking count value. If the value has not changed, then no service has been added, modified or removed from this ServiceTracker since the previous tracking count was collected.

Returns:int

The tracking count for this ServiceTracker or -1 if this ServiceTracker is not open.

Since
1.2
isEmptyback to summary
public boolean isEmpty()

Return if this ServiceTracker is empty.

Returns:boolean

true if this ServiceTracker is not tracking any services.

Since
1.5
modifiedback to summary
pack-priv void modified()

Called by the Tracked object whenever the set of tracked services is modified. Clears the cache.

modifiedServiceback to summary
public void modifiedService(ServiceReference<S> reference, T service)

Implements org.osgi.util.tracker.ServiceTrackerCustomizer.modifiedService.

Default implementation of the ServiceTrackerCustomizer.modifiedService method.

This method is only called when this ServiceTracker has been constructed with a null ServiceTrackerCustomizer argument.

This implementation does nothing.

Parameters
reference:ServiceReference<S>

The reference to modified service.

service:T

The service object for the modified service.

See Also
ServiceTrackerCustomizer#modifiedService(ServiceReference, Object)
openback to summary
public void open()

Open this ServiceTracker and begin tracking services.

This implementation calls open(false).

Exceptions
IllegalStateException:
If the BundleContext with which this ServiceTracker was created is no longer valid.
See Also
open(boolean)
openback to summary
public void open(boolean trackAllServices)

Open this ServiceTracker and begin tracking services.

Services which match the search criteria specified when this ServiceTracker was created are now tracked by this ServiceTracker.

Parameters
trackAllServices:boolean

If true, then this ServiceTracker will track all matching services regardless of class loader accessibility. If false, then this ServiceTracker will only track matching services which are class loader accessible to the bundle whose BundleContext is used by this ServiceTracker.

Exceptions
IllegalStateException:
If the BundleContext with which this ServiceTracker was created is no longer valid.
Since
1.3
removeback to summary
public void remove(ServiceReference<S> reference)

Remove a service from this ServiceTracker. The specified service will be removed from this ServiceTracker. If the specified service was being tracked then the ServiceTrackerCustomizer.removedService method will be called for that service.

Parameters
reference:ServiceReference<S>

The reference to the service to be removed.

removedServiceback to summary
public void removedService(ServiceReference<S> reference, T service)

Implements org.osgi.util.tracker.ServiceTrackerCustomizer.removedService.

Default implementation of the ServiceTrackerCustomizer.removedService method.

This method is only called when this ServiceTracker has been constructed with a null ServiceTrackerCustomizer argument.

This implementation calls ungetService, on the BundleContext with which this ServiceTracker was created, passing the specified ServiceReference.

This method can be overridden in a subclass. If the default implementation of addingService method was used, this method must unget the service.

Parameters
reference:ServiceReference<S>

The reference to removed service.

service:T

The service object for the removed service.

See Also
ServiceTrackerCustomizer#removedService(ServiceReference, Object)
sizeback to summary
public int size()

Return the number of services being tracked by this ServiceTracker.

Returns:int

The number of services being tracked.

trackedback to summary
private ServiceTracker<S, T>.Tracked tracked()

Accessor method for the current Tracked object. This method is only intended to be used by the unsynchronized methods which do not modify the tracked field.

Returns:ServiceTracker<S, T>.Tracked

The current Tracked object.

waitForServiceback to summary
public T waitForService(long timeout) throws InterruptedException

Wait for at least one service to be tracked by this ServiceTracker. This method will also return when this ServiceTracker is closed.

It is strongly recommended that waitForService is not used during the calling of the BundleActivator methods. BundleActivator methods are expected to complete in a short period of time.

This implementation calls getService() to determine if a service is being tracked.

Parameters
timeout:long

The time interval in milliseconds to wait. If zero, the method will wait indefinitely.

Returns:T

Returns the result of getService().

Exceptions
InterruptedException:
If another thread has interrupted the current thread.
IllegalArgumentException:
If the value of timeout is negative.
org.osgi.util.tracker back to summary

private Class ServiceTracker.AllTracked

extends ServiceTracker<S, T>.Tracked
implements AllServiceListener
Class Inheritance
All Implemented Interfaces
org.osgi.framework.AllServiceListener, org.osgi.framework.ServiceListener, java.util.EventListener

Subclass of Tracked which implements the AllServiceListener interface. This class is used by the ServiceTracker if open is called with true.
Since
1.3

Constructor Summary

AccessConstructor and Description
pack-priv
AllTracked()

AllTracked constructor.

Method Summary

Inherited from org.osgi.util.tracker.ServiceTracker.Tracked:
customizerAddingcustomizerModifiedcustomizerRemovedmodifiedserviceChanged

Constructor Detail

AllTrackedback to summary
pack-priv AllTracked()

AllTracked constructor.

org.osgi.util.tracker back to summary

private Class ServiceTracker.Tracked

extends AbstractTracked<ServiceReference<S>, T, ServiceEvent>
implements ServiceListener
Class Inheritance
All Implemented Interfaces
org.osgi.framework.ServiceListener, java.util.EventListener
Known Direct Subclasses
org.osgi.util.tracker.ServiceTracker.AllTracked

Inner class which subclasses AbstractTracked. This class is the ServiceListener object for the tracker.

Field Summary

Inherited from org.osgi.util.tracker.AbstractTracked:
closedDEBUG

Constructor Summary

AccessConstructor and Description
pack-priv
Tracked()

Tracked constructor.

Method Summary

Modifier and TypeMethod and Description
pack-priv final T

Returns:

Customized object for the tracked item or null if the item is not to be tracked.
customizerAdding
(final ServiceReference<S>
Item to be tracked.
item
,
final ServiceEvent
Action related object.
related
)

Implements abstract org.osgi.util.tracker.AbstractTracked.customizerAdding.

Call the specific customizer adding method.

pack-priv final void
customizerModified(final ServiceReference<S>
Tracked item.
item
,
final ServiceEvent
Action related object.
related
,
final T
Customized object for the tracked item.
object
)

Implements abstract org.osgi.util.tracker.AbstractTracked.customizerModified.

Call the specific customizer modified method.

pack-priv final void
customizerRemoved(final ServiceReference<S>
Tracked item.
item
,
final ServiceEvent
Action related object.
related
,
final T
Customized object for the tracked item.
object
)

Implements abstract org.osgi.util.tracker.AbstractTracked.customizerRemoved.

Call the specific customizer removed method.

pack-priv final void
modified()

Overrides org.osgi.util.tracker.AbstractTracked.modified.

Increment the tracking count and tell the tracker there was a modification.

public final void
serviceChanged(final ServiceEvent
ServiceEvent object from the framework.
event
)

Implements org.osgi.framework.ServiceListener.serviceChanged.

ServiceListener method for the ServiceTracker class.

Inherited from org.osgi.util.tracker.AbstractTracked:
closecopyEntriescopyKeysgetCustomizedObjectgetTrackingCountisEmptysetInitialsizetracktrackInitialuntrack

Constructor Detail

Trackedback to summary
pack-priv Tracked()

Tracked constructor.

Method Detail

customizerAddingback to summary
pack-priv final T customizerAdding(final ServiceReference<S> item, final ServiceEvent related)

Implements abstract org.osgi.util.tracker.AbstractTracked.customizerAdding.

Call the specific customizer adding method. This method must not be called while synchronized on this object.

Parameters
item:ServiceReference<S>

Item to be tracked.

related:ServiceEvent

Action related object.

Returns:T

Customized object for the tracked item or null if the item is not to be tracked.

Annotations
@Override
customizerModifiedback to summary
pack-priv final void customizerModified(final ServiceReference<S> item, final ServiceEvent related, final T object)

Implements abstract org.osgi.util.tracker.AbstractTracked.customizerModified.

Call the specific customizer modified method. This method must not be called while synchronized on this object.

Parameters
item:ServiceReference<S>

Tracked item.

related:ServiceEvent

Action related object.

object:T

Customized object for the tracked item.

Annotations
@Override
customizerRemovedback to summary
pack-priv final void customizerRemoved(final ServiceReference<S> item, final ServiceEvent related, final T object)

Implements abstract org.osgi.util.tracker.AbstractTracked.customizerRemoved.

Call the specific customizer removed method. This method must not be called while synchronized on this object.

Parameters
item:ServiceReference<S>

Tracked item.

related:ServiceEvent

Action related object.

object:T

Customized object for the tracked item.

Annotations
@Override
modifiedback to summary
pack-priv final void modified()

Overrides org.osgi.util.tracker.AbstractTracked.modified.

Increment the tracking count and tell the tracker there was a modification.

Annotations
@Override
serviceChangedback to summary
public final void serviceChanged(final ServiceEvent event)

Implements org.osgi.framework.ServiceListener.serviceChanged.

ServiceListener method for the ServiceTracker class. This method must NOT be synchronized to avoid deadlock potential.

Parameters
event:ServiceEvent

ServiceEvent object from the framework.