- All Implemented Interfaces:
- Runnable
- Enclosing class:
- ServiceDiscoveryManager.LookupCacheImpl
private static 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 performs a lookup
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 is important. That
is, the lookup 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 lookup
were to be performed prior to the RegisterListenerTask, then the
possibility exists for the occurrence of a change in the
ServiceRegistrar's state between the time lookup 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.