public class LookupDiscovery extends Object implements DiscoveryManagement, DiscoveryGroupManagement
ServiceRegistrar
,
DiscoveryChangeListener
,
DiscoveryManagement
,
DiscoveryGroupManagement
,
DiscoveryListener
,
DiscoveryEvent
,
DiscoveryPermission
Modifier and Type | Field and Description |
---|---|
static String[] |
ALL_GROUPS
Convenience constant used to request that attempts be made to discover all lookup services
that are within range, and which belong to any group.
|
static String[] |
NO_GROUPS
Convenience constant used to request that discovery by group membership be halted (or not
started, if the group discovery mechanism is simply being instantiated).
|
Constructor and Description |
---|
LookupDiscovery(String[] groups)
Construct a new lookup discovery object, set to discover the given set of groups.
|
LookupDiscovery(String[] groups,
Configuration config)
Constructs a new lookup discovery object, set to discover the given set of groups, and having
the given
Configuration . |
Modifier and Type | Method and Description |
---|---|
void |
addDiscoveryListener(DiscoveryListener l)
Register a listener as interested in receiving DiscoveryEvent notifications.
|
void |
addGroups(String[] newGroups)
Add a set of groups to the set to be discovered.
|
void |
discard(ServiceRegistrar reg)
Discard a registrar from the set of registrars already discovered.
|
String[] |
getGroups()
Return the set of group names this LookupDiscovery instance is trying to discover.
|
ServiceRegistrar[] |
getRegistrars()
Returns an array of instances of
ServiceRegistrar , each corresponding to a proxy
to one of the currently discovered lookup services. |
void |
removeDiscoveryListener(DiscoveryListener l)
Indicate that a listener is no longer interested in receiving DiscoveryEvent notifications.
|
void |
removeGroups(String[] oldGroups)
Remove a set of groups from the set to be discovered.
|
void |
setGroups(String[] newGroups)
Change the set of groups to be discovered to correspond to the given set.
|
void |
terminate()
Terminate the discovery process.
|
public static final String[] ALL_GROUPS
DiscoveryGroupManagement
for compatibility with earlier releases.public static final String[] NO_GROUPS
DiscoveryGroupManagement
for compatibility with
earlier releases.public LookupDiscovery(String[] groups) throws IOException
groups
- the set of group names to discover (null for no set, empty for no discovery)NullPointerException
- input array contains at least one null elementIOException
- an exception occurred in starting discoveryNO_GROUPS
,
ALL_GROUPS
,
setGroups(java.lang.String[])
,
DiscoveryPermission
public LookupDiscovery(String[] groups, Configuration config) throws IOException, ConfigurationException
Configuration
. The set of groups to discover is represented as an
array of strings. This array may be empty, which is taken as the empty set, and discovery is
not performed. The reference passed in may be null
, which is taken as no set,
and in which case discovery of all reachable lookup services is performed. Otherwise, the
array contains the names of groups to discover. The caller must have
DiscoveryPermission
for each group (or for all groups, if the array is
null
).
groups
- the set of group names to discover (null for no set, empty for no discovery)config
- an instance of Configuration
, used to obtain the objects needed to
configure the current instance of this classNullPointerException
- input array contains at least one
null
element or null
is input for the configurationIOException
- an exception occurred in starting discoveryConfigurationException
- indicates an exception occurred while
retrieving an item from the given
Configuration
NO_GROUPS
,
ALL_GROUPS
,
setGroups(java.lang.String[])
,
DiscoveryPermission
,
Configuration
,
ConfigurationException
public void addDiscoveryListener(DiscoveryListener l)
addDiscoveryListener
in interface DiscoveryManagement
l
- the listener to registerNullPointerException
- this exception occurs when null
is input
to the listener parameter l
.IllegalStateException
- this exception occurs when this method is called
after the terminate
method has been
called.DiscoveryEvent
,
removeDiscoveryListener(net.jini.discovery.DiscoveryListener)
public void removeDiscoveryListener(DiscoveryListener l)
removeDiscoveryListener
in interface DiscoveryManagement
l
- the listener to unregisterIllegalStateException
- this exception occurs when this method is called
after the terminate
method has been
called.addDiscoveryListener(net.jini.discovery.DiscoveryListener)
public ServiceRegistrar[] getRegistrars()
ServiceRegistrar
, each corresponding to a proxy
to one of the currently discovered lookup services. For each invocation of this method, a new
array is returned.getRegistrars
in interface DiscoveryManagement
ServiceRegistrar
, each corresponding to a proxy to
one of the currently discovered lookup servicesIllegalStateException
- this exception occurs when this method is called
after the terminate
method has been
called.ServiceRegistrar
,
DiscoveryManagement.removeDiscoveryListener(net.jini.discovery.DiscoveryListener)
public void discard(ServiceRegistrar reg)
If the registrar has been discovered using this LookupDiscovery object, each listener registered with this object will have its discarded method called with the given registrar as parameter.
discard
in interface DiscoveryManagement
reg
- the registrar to discardIllegalStateException
- this exception occurs when this method is called
after the terminate
method has been
called.DiscoveryListener.discarded(net.jini.discovery.DiscoveryEvent)
public void terminate()
terminate
in interface DiscoveryManagement
public String[] getGroups()
getGroups
in interface DiscoveryGroupManagement
IllegalStateException
- this exception occurs when this method is called
after the terminate
method has been
called.NO_GROUPS
,
ALL_GROUPS
,
setGroups(java.lang.String[])
public void addGroups(String[] newGroups) throws IOException
addGroups
in interface DiscoveryGroupManagement
newGroups
- the groups to addIOException
- the multicast request protocol failed to
startIllegalStateException
- this exception occurs when this method is
called after the terminate
method has been called.UnsupportedOperationException
- there is no set of groups to add toDiscoveryPermission
public void setGroups(String[] newGroups) throws IOException
setGroups
in interface DiscoveryGroupManagement
newGroups
- the new set of groups to discover (null for all, empty array for no
discovery)IOException
- an exception occurred when starting multicast
discoveryIllegalStateException
- this exception occurs when this method is called
after the terminate
method has been
called.LookupDiscovery(java.lang.String[], net.jini.config.Configuration)
,
ALL_GROUPS
,
NO_GROUPS
,
DiscoveryPermission
,
getGroups()
public void removeGroups(String[] oldGroups)
removeGroups
in interface DiscoveryGroupManagement
oldGroups
- groups to removeIllegalStateException
- this exception occurs when this method is
called after the terminate
method has been called.UnsupportedOperationException
- there is no set of groups from which to
removeDiscoveryGroupManagement.addGroups(java.lang.String[])
Copyright © GigaSpaces.