|
|
|
Advertisement
|
In addition to the lookup and browsing methods, the
ServiceRegistrar interface also includes a
notify() method that
notifies clients when new services register or unregister with a lookup
service:
public EventRegistration notify(ServiceTemplate tmpl,
int transitions, RemoteEventListener listener,
MarshalledObject handback, long leaseDuration)
throws RemoteException;
You invoke notify() to register yourself (or another
listener) to receive a distributed event whenever the services
that match the passed ServiceTemplate undergo a state
change described by the transitions parameter.
The transitions parameter is a bitwise OR of any non-empty set of
these three values, which are defined as constants in
ServiceRegistrar:
TRANSITION_MATCH_MATCH TRANSITION_MATCH_NOMATCH TRANSITION_NOMATCH_MATCH
You build the ServiceTemplate for notify() in
the same way you build it for lookup(). You can indicate
explicit types, a service ID, attributes (which must exactly match), or
wildcards (which match anything) in any of those fields. The transitions are
based on a change
(or non-change) in the status of whatever matches your
ServiceTemplate before and after any operation is performed on
the lookup service.
For example, TRANSITION_MATCH_MATCH indicates that at
least one service item matched your template before and after an operation.
TRANSITION_MATCH_NOMATCH indicates that, although at least one
particular service item matched your template before an operation,
it no longer matched your template after the operation.
To receive notification when any new services are added to a lookup
service, you simply specify a template that matches any
service, and pass TRANSITION_NOMATCH_MATCH as the
transition to the notify() method.
|
Sponsored Links
|