Package net.jini.discovery
Class LookupDiscovery
java.lang.Object
net.jini.discovery.LookupDiscovery
- All Implemented Interfaces:
DiscoveryGroupManagement,DiscoveryManagement
public class LookupDiscovery
extends Object
implements DiscoveryManagement, DiscoveryGroupManagement
This class is a helper utility class that encapsulates the functionality required of an entity
that wishes to employ multicast discovery to find lookup services located within the entity's
"multicast radius" (roughly, the number of hops beyond which neither the multicast requests from
the entity, nor the multicast announcements from the lookup service, will propagate). This class
helps make the process of acquiring references to lookup services - based on no information other
than lookup service group membership - much simpler for both services and clients.
- Author:
- Sun Microsystems, Inc.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLookupDiscovery(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 givenConfiguration. -
Method Summary
Modifier and TypeMethodDescriptionvoidRegister a listener as interested in receiving DiscoveryEvent notifications.voidAdd a set of groups to the set to be discovered.voiddiscard(ServiceRegistrar reg) Discard a registrar from the set of registrars already discovered.String[]Return the set of group names this LookupDiscovery instance is trying to discover.Returns an array of instances ofServiceRegistrar, each corresponding to a proxy to one of the currently discovered lookup services.voidIndicate that a listener is no longer interested in receiving DiscoveryEvent notifications.voidremoveGroups(String[] oldGroups) Remove a set of groups from the set to be discovered.voidChange the set of groups to be discovered to correspond to the given set.voidTerminate the discovery process.
-
Constructor Details
-
LookupDiscovery
Construct a new lookup discovery object, set to discover the given set of groups. The set 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).- Parameters:
groups- the set of group names to discover (null for no set, empty for no discovery)- Throws:
NullPointerException- input array contains at least one null elementIOException- an exception occurred in starting discovery- See Also:
-
LookupDiscovery
public LookupDiscovery(String[] groups, Configuration config) throws IOException, ConfigurationException Constructs a new lookup discovery object, set to discover the given set of groups, and having the givenConfiguration.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 haveDiscoveryPermissionfor each group (or for all groups, if the array isnull).- Parameters:
groups- the set of group names to discover (null for no set, empty for no discovery)config- an instance ofConfiguration, used to obtain the objects needed to configure the current instance of this class- Throws:
NullPointerException- input array contains at least onenullelement ornullis input for the configurationIOException- an exception occurred in starting discoveryConfigurationException- indicates an exception occurred while retrieving an item from the givenConfiguration- See Also:
-
-
Method Details
-
addDiscoveryListener
Register a listener as interested in receiving DiscoveryEvent notifications.- Specified by:
addDiscoveryListenerin interfaceDiscoveryManagement- Parameters:
l- the listener to register- Throws:
NullPointerException- this exception occurs whennullis input to the listener parameterl.IllegalStateException- this exception occurs when this method is called after theterminatemethod has been called.- See Also:
-
removeDiscoveryListener
Indicate that a listener is no longer interested in receiving DiscoveryEvent notifications.- Specified by:
removeDiscoveryListenerin interfaceDiscoveryManagement- Parameters:
l- the listener to unregister- Throws:
IllegalStateException- this exception occurs when this method is called after theterminatemethod has been called.- See Also:
-
getRegistrars
Returns an array of instances ofServiceRegistrar, each corresponding to a proxy to one of the currently discovered lookup services. For each invocation of this method, a new array is returned.- Specified by:
getRegistrarsin interfaceDiscoveryManagement- Returns:
- array of instances of
ServiceRegistrar, each corresponding to a proxy to one of the currently discovered lookup services - Throws:
IllegalStateException- this exception occurs when this method is called after theterminatemethod has been called.- See Also:
-
discard
Discard a registrar from the set of registrars already discovered. This does not prevent that registrar from being rediscovered; it is intended to be used to clear unreachable entries from the set.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.
- Specified by:
discardin interfaceDiscoveryManagement- Parameters:
reg- the registrar to discard- Throws:
IllegalStateException- this exception occurs when this method is called after theterminatemethod has been called.- See Also:
-
terminate
public void terminate()Terminate the discovery process.- Specified by:
terminatein interfaceDiscoveryManagement
-
getGroups
Return the set of group names this LookupDiscovery instance is trying to discover. If this method returns the empty array, that value is guaranteed to be referentially equal to LookupDiscovery.NO_GROUPS.- Specified by:
getGroupsin interfaceDiscoveryGroupManagement- Returns:
- the set of groups to be discovered (null for all, empty for no discovery)
- Throws:
IllegalStateException- this exception occurs when this method is called after theterminatemethod has been called.- See Also:
-
addGroups
Add a set of groups to the set to be discovered. The caller must have DiscoveryPermission for each group.- Specified by:
addGroupsin interfaceDiscoveryGroupManagement- Parameters:
newGroups- the groups to add- Throws:
IOException- the multicast request protocol failed to startIllegalStateException- this exception occurs when this method is called after theterminatemethod has been called.UnsupportedOperationException- there is no set of groups to add to- See Also:
-
setGroups
Change the set of groups to be discovered to correspond to the given set. The set 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).- Specified by:
setGroupsin interfaceDiscoveryGroupManagement- Parameters:
newGroups- the new set of groups to discover (null for all, empty array for no discovery)- Throws:
IOException- an exception occurred when starting multicast discoveryIllegalStateException- this exception occurs when this method is called after theterminatemethod has been called.- See Also:
-
removeGroups
Remove a set of groups from the set to be discovered.- Specified by:
removeGroupsin interfaceDiscoveryGroupManagement- Parameters:
oldGroups- groups to remove- Throws:
IllegalStateException- this exception occurs when this method is called after theterminatemethod has been called.UnsupportedOperationException- there is no set of groups from which to remove- See Also:
-