- All Implemented Interfaces:
- TaskManager.Task, Runnable
- Enclosing class:
- ServiceDiscoveryManager.LookupCacheImpl
private final class ServiceDiscoveryManager.LookupCacheImpl.RegisterListenerTask
extends ServiceDiscoveryManager.CacheTask
This task class, when executed, first registers to receive
ServiceEvents from the given ServiceRegistrar. If the registration
process succeeds (no RemoteExceptions), it then executes the
LookupTask to query the given ServiceRegistrar for a "snapshot"
of its current state with respect to services that match the
given template.
Note that the order of execution of the two tasks is important.
That is, the LookupTask must be executed only after registration
for events has completed. This is because when an entity registers
with the event mechanism of a ServiceRegistrar, the entity will
only receive notification of events that occur "in the future",
after the registration is made. The entity will not receive events
about changes to the state of the ServiceRegistrar that may have
occurred before or during the registration process.
Thus, if the order of these tasks were reversed and the LookupTask
were to be executed prior to the RegisterListenerTask, then the
possibility exists for the occurrence of a change in the
ServiceRegistrar's state between the time the LookupTask retrieves
a snapshot of that state, and the time the event registration
process has completed, resulting in an incorrect view of the
current state of the ServiceRegistrar.