Class LookupDiscoveryManager
- All Implemented Interfaces:
DiscoveryGroupManagement,DiscoveryLocatorManagement,DiscoveryManagement
- Direct Known Subclasses:
SharedDiscoveryManagement.SharedDiscoveryManager
LookupLocator
objects, and DiscoveryListener objects, clients and services can employ this class to
provide those facilities on their behalf. - Author:
- Sun Microsystems, Inc.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant that indicates the discovery mechanism is group discoverystatic final intConstant that indicates the discovery mechanism is locator discovery -
Constructor Summary
ConstructorsConstructorDescriptionLookupDiscoveryManager(String[] groups, LookupLocator[] locators, DiscoveryListener listener) Constructs an instance of this class that will organize and manage all discovery-related activities on behalf of the client or service that instantiates this class.LookupDiscoveryManager(String[] groups, LookupLocator[] locators, DiscoveryListener listener, Configuration config) Constructs an instance of this class, using the givenConfiguration, that will organize and manage all discovery-related activities on behalf of the client or service that instantiates this class.LookupDiscoveryManager(String[] groups, LookupLocator[] locators, DiscoveryListener listener, Configuration config, boolean runningWithinRegistrar) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDiscoveryListener(DiscoveryListener listener) Adds an instance ofDiscoveryListenerto the set of objects listening for discovery events.voidAdds a set of group names to the managed set of groups.voidaddLocators(LookupLocator[] locators) Adds a set of locators to the managed set of locators.voiddiscard(ServiceRegistrar proxy) Removes an instance ofServiceRegistrarfrom the managed set of lookup services, making the corresponding lookup service eligible for re-discovery.intgetFrom(ServiceRegistrar proxy) Return where the proxy come from.String[]Returns an array consisting of the elements of the managed set of groups; that is, the names of the groups whose members are the lookup services to discover.Returns an array consisting of the elements of the managed set of locators; that is, instances ofLookupLocatorin which each instance corresponds to a specific lookup service to discover.Returns an array of instances ofServiceRegistrar, each corresponding to a proxy to one of the currently discovered lookup services.voidremoveDiscoveryListener(DiscoveryListener listener) Removes a listener from the set of objects listening for discovery events.voidremoveGroups(String[] groups) Deletes a set of group names from the managed set of groups.voidremoveLocators(LookupLocator[] locators) Deletes a set of locators from the managed set of locators, and discards any already-discovered lookup service that corresponds to a deleted locator.voidReplaces all of the group names in the managed set with names from a new set.voidsetLocators(LookupLocator[] locators) Replaces all of the locators in the managed set with locators from a new set, and discards any already-discovered lookup service that corresponds to a locator that is removed from the managed set as a result of an invocation of this method.voidTerminates all threads, ending all discovery processing being performed by the current instance of this class.
-
Field Details
-
FROM_GROUP
public static final int FROM_GROUPConstant that indicates the discovery mechanism is group discovery- See Also:
-
FROM_LOCATOR
public static final int FROM_LOCATORConstant that indicates the discovery mechanism is locator discovery- See Also:
-
-
Constructor Details
-
LookupDiscoveryManager
public LookupDiscoveryManager(String[] groups, LookupLocator[] locators, DiscoveryListener listener) throws IOException Constructs an instance of this class that will organize and manage all discovery-related activities on behalf of the client or service that instantiates this class.If
null(DiscoveryGroupManagement.ALL_GROUPS) is input to thegroupsparameter, then attempts will be made via group discovery to discover all lookup services located within range of the entity that constructs this class. If the empty array (DiscoveryGroupManagement.NO_GROUPS) is input to that parameter, no group discovery will be performed until the set of groups to discover is populated.If an empty array or a
nullreference is input to thelocatorsparameter, no locator discovery will be performed until the set of locators to discover is populated.- Parameters:
groups-Stringarray, none of whose elements may benull, consisting of the names of the groups whose members are lookup services the client or service wishes to discover.locators- array of instances ofLookupLocator, none of whose elements may benull, and in which each element corresponds to a specific lookup service the client or service wishes to discover via locator discovery.listener- a reference toDiscoveryListenerobject that will be notified when a targeted lookup service is discovered or discarded.- Throws:
IOException- because construction of this class may initiate the discovery process, which can throw anIOExceptionwhen socket allocation occurs.NullPointerException- this exception occurs when either one or more of the elements of thegroupsparameter isnull, or one or more elements of thelocatorsparameter is null.- See Also:
-
LookupDiscoveryManager
public LookupDiscoveryManager(String[] groups, LookupLocator[] locators, DiscoveryListener listener, Configuration config) throws IOException, ConfigurationException Constructs an instance of this class, using the givenConfiguration, that will organize and manage all discovery-related activities on behalf of the client or service that instantiates this class.If
null(DiscoveryGroupManagement.ALL_GROUPS) is input to thegroupsparameter, then attempts will be made via group discovery to discover all lookup services located within range of the entity that constructs this class. If the empty array (DiscoveryGroupManagement.NO_GROUPS) is input to that parameter, no group discovery will be performed until the set of groups to discover is populated.If an empty array or a
nullreference is input to thelocatorsparameter, no locator discovery will be performed until the set of locators to discover is populated.- Parameters:
groups-Stringarray, none of whose elements may benull, consisting of the names of the groups whose members are lookup services the client or service wishes to discover.locators- array of instances ofLookupLocator, none of whose elements may benull, and in which each element corresponds to a specific lookup service the client or service wishes to discover via locator discovery.listener- a reference toDiscoveryListenerobject that will be notified when a targeted lookup service is discovered or discarded.config- an instance ofConfiguration, used to obtain the objects needed to configure the current instance of this class- Throws:
IOException- because construction of this class may initiate the discovery process, which can throw anIOExceptionwhen socket allocation occurs.ConfigurationException- indicates an exception occurred while retrieving an item from the givenConfigurationNullPointerException- this exception occurs when either one or more of the elements of thegroupsparameter isnull, or one or more elements of thelocatorsparameter isnull, or whennullis input for the configuration.- See Also:
-
LookupDiscoveryManager
public LookupDiscoveryManager(String[] groups, LookupLocator[] locators, DiscoveryListener listener, Configuration config, boolean runningWithinRegistrar) throws IOException, ConfigurationException - Throws:
IOExceptionConfigurationException
-
-
Method Details
-
getLocators
Returns an array consisting of the elements of the managed set of locators; that is, instances ofLookupLocatorin which each instance corresponds to a specific lookup service to discover. The returned set will include both the set ofLookupLocators corresponding to lookup services that have already been discovered as well as the set of those that have not yet been discovered. If the managed set of locators is empty, this method will return the empty array. This method returns a new array upon each invocation.- Specified by:
getLocatorsin interfaceDiscoveryLocatorManagement- Returns:
LookupLocatorarray consisting of the elements of the managed set of locators- See Also:
-
addLocators
Adds a set of locators to the managed set of locators. Elements in the input set that duplicate (using theLookupLocator.equalsmethod) elements already in the managed set will be ignored. If the empty array is input, the managed set of locators will not change.- Specified by:
addLocatorsin interfaceDiscoveryLocatorManagement- Parameters:
locators-LookupLocatorarray consisting of the locators to add to the managed set.- Throws:
UnsupportedOperationException- this exception occurs when there is no managed set of locators to augment. That is, the current managed set of locators isnull.NullPointerException- this exception occurs when eithernullis input to thelocatorsparameter, or one or more of the elements of thelocatorsparameter isnull.- See Also:
-
removeLocators
Deletes a set of locators from the managed set of locators, and discards any already-discovered lookup service that corresponds to a deleted locator. For any lookup service that is discarded as a result of an invocation of this method, a discard notification is sent; and that lookup service will not be eligible for re-discovery (assuming it is not currently eligible for discovery through other means, such as group discovery).If the empty array is input, this method takes no action.
- Specified by:
removeLocatorsin interfaceDiscoveryLocatorManagement- Parameters:
locators-LookupLocatorarray consisting of the locators that will be removed from the managed set.- Throws:
UnsupportedOperationException- this exception occurs when there is no managed set of locators from which remove elements.NullPointerException- this exception occurs whennullis input to thelocatorsparameter.- See Also:
-
setLocators
Replaces all of the locators in the managed set with locators from a new set, and discards any already-discovered lookup service that corresponds to a locator that is removed from the managed set as a result of an invocation of this method. For any such lookup service that is discarded, a discard notification is sent; and that lookup service will not be eligible for re-discovery (assuming it is not currently eligible for discovery through other means, such as group discovery).If the empty array is input, locator discovery will cease until this method is invoked with an input parameter that is non-
nulland non-empty.- Specified by:
setLocatorsin interfaceDiscoveryLocatorManagement- Parameters:
locators-LookupLocatorarray consisting of the locators that will replace the current locators in the managed set.- Throws:
NullPointerException- this exception occurs whennullis input to thelocatorsparameter.- See Also:
-
getGroups
Returns an array consisting of the elements of the managed set of groups; that is, the names of the groups whose members are the lookup services to discover. If the managed set of groups is empty, this method will return the empty array. If there is no managed set of groups, then null is returned; indicating that all groups are to be discovered. This method returns a new array upon each invocation.- Specified by:
getGroupsin interfaceDiscoveryGroupManagement- Returns:
Stringarray consisting of the elements of the managed set of groups- See Also:
-
addGroups
Adds a set of group names to the managed set of groups. Elements in the input set that duplicate elements already in the managed set will be ignored. Once a new name is added to the managed set, attempts will be made to discover all (as yet) undiscovered lookup services that are members of the group having that name. If the empty array (DiscoveryGroupManagement.NO_GROUPS) is input, the managed set of groups will not change. Note that any entity that invokes this method must haveDiscoveryPermissionon each of the groups in the new set, otherwise aSecurityExceptionwill be propagated through this method.- Specified by:
addGroupsin interfaceDiscoveryGroupManagement- Parameters:
groups-Stringarray consisting of the group names to add to the managed set.- Throws:
IOException- because an invocation of this method may result in the re-initiation of the discovery process, which can throw anIOExceptionwhen socket allocation occurs.UnsupportedOperationException- this exception occurs when there is no managed set of groups to augment. That is, the current managed set of groups isnull. If the managed set of groups isnull, all groups are being discovered; thus, requesting that a set of groups be added to the set of all groups makes no sense.NullPointerException- this exception occurs when eithernullis input to thegroupsparameter, or one or more of the elements of thegroupsparameter isnull. If anullis input, then the entity is effectively requesting that "all groups" be added to the current managed set of groups; which is not allowed. (Note that if the entity wishes to change the managed set of groups from a finite set of names to "all groups", thesetGroupsmethod should be invoked withnullinput.)- See Also:
-
removeGroups
Deletes a set of group names from the managed set of groups. If the empty array (DiscoveryGroupManagement.NO_GROUPS) is input, this method takes no action.- Specified by:
removeGroupsin interfaceDiscoveryGroupManagement- Parameters:
groups-Stringarray consisting of the group names that will be removed from the managed set.- Throws:
UnsupportedOperationException- this exception occurs when there is no managed set of groups from which to remove elements.NullPointerException- this exception occurs whennullis input to thegroupsparameter.- See Also:
-
setGroups
Replaces all of the group names in the managed set with names from a new set. Once a new group name has been placed in the managed set, if there are lookup services belonging to that group that have already been discovered, no event will be sent to the entity's listener for those particular lookup services. Attempts to discover all (as yet) undiscovered lookup services belonging to that group will continue to be made.If null (
DiscoveryGroupManagement.ALL_GROUPS) is input to this method, then attempts will be made to discover all (as yet) undiscovered lookup services that are within range, and which are members of any group. If the empty array (DiscoveryGroupManagement.NO_GROUPS) is input, then group discovery will cease until this method is invoked with an input parameter that is non-nulland non-empty. Note that any entity that invokes this method must haveDiscoveryPermissionon each of the groups in the new set, otherwise aSecurityExceptionwill be propagated through this method.- Specified by:
setGroupsin interfaceDiscoveryGroupManagement- Parameters:
groups-Stringarray consisting of the group names that will replace the current names in the managed set.- Throws:
IOException- because an invocation of this method may result in the re-initiation of the discovery process, which can throw anIOExceptionwhen socket allocation occurs.- See Also:
-
addDiscoveryListener
Adds an instance ofDiscoveryListenerto the set of objects listening for discovery events. Once the listener is registered, it will be notified of all lookup services discovered to date, and will then be notified as new lookup services are discovered or existing lookup services are discarded.If
nullis input, this method takes no action. If the listener input to this method duplicates (using theequalsmethod) another element in the current set of listeners, no action is taken.- Specified by:
addDiscoveryListenerin interfaceDiscoveryManagement- Parameters:
listener- an instance ofDiscoveryListenercorresponding to the listener to add to the set of listeners.- Throws:
NullPointerException- this exception occurs whennullis input to thelistenerparameter.- See Also:
-
removeDiscoveryListener
Removes a listener from the set of objects listening for discovery events. If the listener object input to this method does not exist in the set of listeners, then this method will take no action.- Specified by:
removeDiscoveryListenerin interfaceDiscoveryManagement- Parameters:
listener- an instance ofDiscoveryListenercorresponding to the listener to remove from the set of listeners.- 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 - See Also:
-
discard
Removes an instance ofServiceRegistrarfrom the managed set of lookup services, making the corresponding lookup service eligible for re-discovery. This method takes no action if the parameter input to this method isnull, or if it does not match (usingequals) any of the elements in the managed set.- Specified by:
discardin interfaceDiscoveryManagement- Parameters:
proxy- the instance ofServiceRegistrarto discard from the managed set of lookup services- See Also:
-
terminate
public void terminate()Terminates all threads, ending all discovery processing being performed by the current instance of this class.After this method has been invoked, no new lookup services will be discovered, and the effect of any new operations performed on the current instance of this class are undefined.
- Specified by:
terminatein interfaceDiscoveryManagement- See Also:
-
getFrom
Return where the proxy come from.- Parameters:
proxy- a ServiceRegistrar object- Returns:
- an
intindicating whether the proxy was obtained through group or locator discovery.
-
getDynamicLocatorDiscovery
-