public class ServiceDiscoveryEvent extends EventObject
ServiceDiscoveryEvent
class encapsulates the
service discovery information made available by the event mechanism
of the LookupCache
. All listeners
that an entity has registered with the cache's event mechanism will
receive an event of type ServiceDiscoveryEvent
upon
the discovery, removal, or modification of one of the cache's services.
This class is used by
ServiceDiscoveryManager
.ServiceDiscoveryManager
,
Serialized Formsource
Constructor and Description |
---|
ServiceDiscoveryEvent(AtomicSerial.GetArg arg)
AtomicSerial constructor
|
ServiceDiscoveryEvent(Object source,
ServiceItem preEventItem,
ServiceItem postEventItem)
The constructor of
ServiceDiscoveryEvent takes
three arguments:
An instance of Object corresponding to the
instance of LookupCache from which the given event
originated
A ServiceItem reference representing the state
of the service (associated with the given event) prior to the
occurrence of the event
A ServiceItem reference representing the state
of the service after the occurrence of the event
If null is passed as the source parameter for the
constructor, a NullPointerException will be thrown. |
Modifier and Type | Method and Description |
---|---|
ServiceItem |
getPostEventServiceItem()
Returns an instance of a
ServiceItem containing the
service reference corresponding to the given event. |
ServiceItem |
getPreEventServiceItem()
Returns an instance of a
ServiceItem containing the
service reference corresponding to the given event. |
getSource, toString
public ServiceDiscoveryEvent(Object source, ServiceItem preEventItem, ServiceItem postEventItem)
The constructor of ServiceDiscoveryEvent
takes
three arguments:
Object
corresponding to the
instance of LookupCache
from which the given event
originatedServiceItem
reference representing the state
of the service (associated with the given event) prior to the
occurrence of the eventServiceItem
reference representing the state
of the service after the occurrence of the event
If null
is passed as the source parameter for the
constructor, a NullPointerException
will be thrown.
Depending on the nature of the discovery event, a null reference
may be passed as one or the other of the remaining parameters, but
never both. If null
is passed as both the
preEventItem
and the postEventItem
parameters, a NullPointerException
will be thrown.
Note that the constructor will not modify the contents of either
ServiceItem
argument. Doing so can result in
unpredictable and undesirable effects on future processing by the
ServiceDiscoveryManager
. That is why the effects of any
such modification to the contents of either input parameter are
undefined.
source
- an instance of Object
corresponding
to the instance of LookupCache
from
which the given event originated.preEventItem
- a ServiceItem
reference
representing the state of the service (associated
with the given event) prior to the occurrence of
the event.postEventItem
- a ServiceItem
reference
representing the state of the service after the
occurrence of the event.NullPointerException
- if null
is
passed as the source parameter for the constructor,
or if null
is passed as both the
preEventItem
and the
postEventItem
parameters.public ServiceDiscoveryEvent(AtomicSerial.GetArg arg) throws IOException
arg
- IOException
public ServiceItem getPreEventServiceItem()
ServiceItem
containing the
service reference corresponding to the given event. The service
state reflected in the returned service item is the state of the
service prior to the occurrence of the event.
If the event is a discovery event (as opposed to a removal or
modification event), then this method will return null
because the discovered service had no state in the cache prior to
its discovery.
Because making a copy can be a very expensive process, this
method does not return a copy of the service reference associated
with the given event. Rather, it returns the appropriate service
reference from the cache itself. Due to this cost, listeners that
receive a ServiceDiscoveryEvent
must not modify the
contents of the object returned by this method; doing so could
cause the state of the cache to become corrupted or inconsistent
because the objects returned by this method are also members of
the cache. This potential for corruption or inconsistency is why
the effects of modifying the object returned by this accessor
method are undefined.
public ServiceItem getPostEventServiceItem()
ServiceItem
containing the
service reference corresponding to the given event. The service
state reflected in the returned service item is the state of the
service after the occurrence of the event.
If the event is a removal event, then this method will return
null
because the discovered service has no state in
the cache after it is removed from the cache.
Because making a copy can be a very expensive process, this
method does not return a copy of the service reference associated
with the given event. Rather, it returns the appropriate service
reference from the cache itself. Due to this cost, listeners that
receive a ServiceDiscoveryEvent
must not modify the
contents of the object returned by this method; doing so could
cause the state of the cache to become corrupted or inconsistent
because the objects returned by this method are also members of
the cache. This potential for corruption or inconsistency is why
the effects of modifying the object returned by this accessor
method are undefined.
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.