|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.ecf.remoteservice.util.tracker.RemoteServiceTracker
public class RemoteServiceTracker
Remote service tracker. Implementation of ServiceTracker
for the ECF remoteservices API. The getRemoteService() method
returns instances of IRemoteService
.
Field Summary | |
---|---|
protected IRemoteServiceContainerAdapter |
containerAdapter
IRemoteServiceContainerAdapter containerAdapter against which this RemoteServiceTracker is tracking. |
protected ID[] |
containerIDs
Container IDs that provide the context for tracking. |
protected IRemoteFilter |
filter
Filter specifying search criteria for the services to track. |
Constructor Summary | |
---|---|
RemoteServiceTracker(IRemoteServiceContainerAdapter containerAdapter,
ID[] containerIDs,
IRemoteServiceReference reference,
IRemoteServiceTrackerCustomizer customizer)
Create a RemoteServiceTracker on the specified
IRemoteServiceReference . |
|
RemoteServiceTracker(IRemoteServiceContainerAdapter containerAdapter,
ID[] containerIDs,
java.lang.String clazz,
IRemoteServiceTrackerCustomizer customizer)
Create a RemoteServiceTracker object on the specified class
name. |
Method Summary | |
---|---|
IRemoteService |
addingService(IRemoteServiceReference reference)
Default implementation of the IRemoteServiceTrackerCustomizer.addingService method. |
void |
close()
Close this RemoteServiceTracker . |
IRemoteService |
getRemoteService()
Returns a service object for one of the services being tracked by this RemoteServiceTracker object. |
IRemoteService |
getRemoteService(IRemoteServiceReference reference)
Returns the service object for the specified ServiceReference object if the referenced service is being
tracked by this RemoteServiceTracker object. |
IRemoteServiceReference |
getRemoteServiceReference()
Returns a ServiceReference object for one of the services
being tracked by this RemoteServiceTracker object. |
IRemoteServiceReference[] |
getRemoteServiceReferences()
Return an array of ServiceReference objects for all
services being tracked by this RemoteServiceTracker object. |
IRemoteService[] |
getRemoteServices()
Return an array of service objects for all services being tracked by this RemoteServiceTracker object. |
int |
getTrackingCount()
Returns the tracking count for this RemoteServiceTracker object. |
void |
modifiedService(IRemoteServiceReference reference,
IRemoteService remoteService)
Default implementation of the ServiceTrackerCustomizer.modifiedService method. |
void |
open()
Open this RemoteServiceTracker object and begin tracking
services. |
void |
remove(IRemoteServiceReference reference)
Remove a service from this RemoteServiceTracker object. |
void |
removedService(IRemoteServiceReference reference,
IRemoteService remoteService)
Default implementation of the ServiceTrackerCustomizer.removedService method. |
int |
size()
Return the number of services being tracked by this RemoteServiceTracker object. |
IRemoteService |
waitForRemoteService(long timeout)
Wait for at least one service to be tracked by this RemoteServiceTracker object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final IRemoteServiceContainerAdapter containerAdapter
RemoteServiceTracker
is tracking.
protected final ID[] containerIDs
protected final IRemoteFilter filter
Constructor Detail |
---|
public RemoteServiceTracker(IRemoteServiceContainerAdapter containerAdapter, ID[] containerIDs, IRemoteServiceReference reference, IRemoteServiceTrackerCustomizer customizer)
RemoteServiceTracker
on the specified
IRemoteServiceReference
.
The remote service referenced by the specified IRemoteServiceReference
object will be tracked by this RemoteServiceTracker
object.
containerAdapter
- IRemoteServiceContainerAdapter
against which the
tracking is done.reference
- IRemoteServiceReference
for the remote service
to be tracked.customizer
- The customizer object to call when services are added,
modified, or removed in this RemoteServiceTracker
object.
If customizer is null
, then this
RemoteServiceTracker
object will be used as the
ServiceTrackerCustomizer
object and the
RemoteServiceTracker
object will call the
ServiceTrackerCustomizer
methods on itself.public RemoteServiceTracker(IRemoteServiceContainerAdapter containerAdapter, ID[] containerIDs, java.lang.String clazz, IRemoteServiceTrackerCustomizer customizer)
RemoteServiceTracker
object on the specified class
name.
Services registered under the specified class name will be tracked by
this RemoteServiceTracker
object.
containerAdapter
- BundleContext
object against which the
tracking is done.clazz
- Class name of the services to be tracked.customizer
- The customizer object to call when services are added,
modified, or removed in this RemoteServiceTracker
object.
If customizer is null
, then this
RemoteServiceTracker
object will be used as the
ServiceTrackerCustomizer
object and the
RemoteServiceTracker
object will call the
ServiceTrackerCustomizer
methods on itself.Method Detail |
---|
public void open()
RemoteServiceTracker
object and begin tracking
services.
Services which match the search criteria specified when this
RemoteServiceTracker
object was created are now tracked by this
RemoteServiceTracker
object.
java.lang.IllegalStateException
- if the BundleContext
object with which this RemoteServiceTracker
object was
created is no longer valid.public void close()
RemoteServiceTracker
.
This method should be called when this RemoteServiceTracker
object should end the tracking of services.
public IRemoteService addingService(IRemoteServiceReference reference)
IRemoteServiceTrackerCustomizer.addingService
method.
This method is only called when this RemoteServiceTracker
object
has been constructed with a null IRemoteServiceTrackerCustomizer
argument.
The default implementation returns the result of calling
getService
, on the BundleContext
object
with which this RemoteServiceTracker
object was created, passing
the specified ServiceReference
object.
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 that will unget the service.
addingService
in interface IRemoteServiceTrackerCustomizer
reference
- Reference to service being added to this
RemoteServiceTracker
object.
RemoteServiceTracker
object.IRemoteServiceTrackerCustomizer
public void modifiedService(IRemoteServiceReference reference, IRemoteService remoteService)
ServiceTrackerCustomizer.modifiedService
method.
This method is only called when this RemoteServiceTracker
object
has been constructed with a null ServiceTrackerCustomizer
argument.
The default implementation does nothing.
modifiedService
in interface IRemoteServiceTrackerCustomizer
reference
- Reference to modified service.remoteService
- The service object for the modified service.IRemoteServiceTrackerCustomizer
public void removedService(IRemoteServiceReference reference, IRemoteService remoteService)
ServiceTrackerCustomizer.removedService
method.
This method is only called when this RemoteServiceTracker
object
has been constructed with a null ServiceTrackerCustomizer
argument.
The default implementation calls ungetService
, on the
BundleContext
object with which this
RemoteServiceTracker
object was created, passing the specified
ServiceReference
object.
This method can be overridden in a subclass. If the default
implementation of addingService
method was used, this
method must unget the service.
removedService
in interface IRemoteServiceTrackerCustomizer
reference
- Reference to removed service.remoteService
- The service object for the removed service.IRemoteServiceTrackerCustomizer
public IRemoteService waitForRemoteService(long timeout) throws java.lang.InterruptedException
RemoteServiceTracker
object.
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.
timeout
- time interval in milliseconds to wait. If zero, the method
will wait indefinitely.
getService()
.
java.lang.InterruptedException
- If another thread has interrupted the
current thread.
java.lang.IllegalArgumentException
- If the value of timeout is negative.public IRemoteServiceReference[] getRemoteServiceReferences()
ServiceReference
objects for all
services being tracked by this RemoteServiceTracker
object.
ServiceReference
objects or
null
if no service are being tracked.public IRemoteServiceReference getRemoteServiceReference()
ServiceReference
object for one of the services
being tracked by this RemoteServiceTracker
object.
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
.
ServiceReference
object or null
if
no service is being tracked.public IRemoteService getRemoteService(IRemoteServiceReference reference)
ServiceReference
object if the referenced service is being
tracked by this RemoteServiceTracker
object.
reference
- Reference to the desired service.
null
if the service referenced
by the specified ServiceReference
object is not
being tracked.public IRemoteService[] getRemoteServices()
RemoteServiceTracker
object.
null
if no service are
being tracked.public IRemoteService getRemoteService()
RemoteServiceTracker
object.
If any services are being tracked, this method returns the result of
calling getService(getServiceReference())
.
null
if no service is being
tracked.public void remove(IRemoteServiceReference reference)
RemoteServiceTracker
object.
The specified service will be removed from this
RemoteServiceTracker
object. If the specified service was being
tracked then the ServiceTrackerCustomizer.removedService
method will be called for that service.
reference
- Reference to the service to be removed.public int size()
RemoteServiceTracker
object.
public int getTrackingCount()
RemoteServiceTracker
object.
The tracking count is initialized to 0 when this
RemoteServiceTracker
object is opened. Every time a service is
added, modified or removed from this RemoteServiceTracker
object
the tracking count is incremented.
The tracking count can be used to determine if this
RemoteServiceTracker
object 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
RemoteServiceTracker
object since the previous tracking count
was collected.
RemoteServiceTracker
object
or -1 if this RemoteServiceTracker
object is not open.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |