Package net.jini.discovery
Class LookupLocatorDiscovery
java.lang.Object
net.jini.discovery.LookupLocatorDiscovery
- All Implemented Interfaces:
DiscoveryLocatorManagement,DiscoveryManagement
public class LookupLocatorDiscovery
extends Object
implements DiscoveryManagement, DiscoveryLocatorManagement
This class encapsulates the functionality required of an entity that wishes to employ the unicast
discovery protocol to discover a lookup service. This utility provides an implementation that
makes the process of finding specific lookup services much simpler for both services and clients.
Because this class participates in only the unicast discovery protocol, and because the
unicast discovery protocol imposes no restriction on the physical location of the entity relative
to a lookup service, this utility can be used to discover lookup services running on hosts that
are located far from, or near to, the host on which the entity is running. This lack of a
restriction on location brings with it a requirement that the discovering entity supply this
class with specific information about the desired lookup services; namely, the location of the
device(s) hosting each lookup service. This information is supplied through an instance of the
LookupLocator class.-
Constructor Summary
ConstructorsConstructorDescriptionLookupLocatorDiscovery(LookupLocator[] locators) Creates an instance of this class (LookupLocatorDiscovery), with an initial array ofLookupLocators to be managed.LookupLocatorDiscovery(LookupLocator[] locators, Configuration config) Constructs a new lookup locator discovery object, set to discover the given set of locators, and having the givenConfiguration. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a DiscoveryListener to the listener set.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.Returns the set ofLookupLocatorobjects representing the desired lookup services that are currently discovered.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.Returns the set ofLookupLocatorobjects representing the desired lookup services that have not yet been discovered.voidRemove a DiscoveryListener from the listener set.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.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 locator discovery processing being performed by the current instance of this class.
-
Constructor Details
-
LookupLocatorDiscovery
Creates an instance of this class (LookupLocatorDiscovery), with an initial array ofLookupLocators to be managed. For each managedLookupLocator, unicast discovery is performed to obtain aServiceRegistrarproxy for that lookup service.- Parameters:
locators- the locators to discover- Throws:
NullPointerException- input array contains at least onenullelement
-
LookupLocatorDiscovery
public LookupLocatorDiscovery(LookupLocator[] locators, Configuration config) throws ConfigurationException Constructs a new lookup locator discovery object, set to discover the given set of locators, and having the givenConfiguration. For each managedLookupLocator, unicast discovery is performed to obtain aServiceRegistrarproxy for that lookup service.- Parameters:
locators- the locators to discoverconfig- an instance ofConfiguration, used to obtain the objects needed to configure the current instance of this class- Throws:
ConfigurationException- indicates an exception occurred while retrieving an item from the givenConfigurationNullPointerException- input array contains at least onenullelement ornullis input for the configuration
-
-
Method Details
-
addDiscoveryListener
Add a DiscoveryListener to the listener set. The listener's discovered method gets called right way with an array of ServiceRegistrars that have already been discovered, and will be called in the future whenever additional lookup services are discovered.- Specified by:
addDiscoveryListenerin interfaceDiscoveryManagement- Parameters:
l- the new DiscoveryListener to add- 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
Remove a DiscoveryListener from the listener set. It does nothing if the DiscoveryListener does not exist in the the listener set.- Specified by:
removeDiscoveryListenerin interfaceDiscoveryManagement- Parameters:
l- the existing DiscoveryListener to remove- 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
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- Throws:
IllegalStateException- this exception occurs when this method is called after theterminatemethod has been called.- See Also:
-
terminate
public void terminate()Terminates all threads, ending all locator 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:
-
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- Throws:
IllegalStateException- this exception occurs when this method is called after theterminatemethod has been called.- 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:
NullPointerException- this exception occurs when eithernullis input to thelocatorsparameter, or one or more of the elements of thelocatorsparameter isnull.IllegalStateException- this exception occurs when this method is called after theterminatemethod has been called.- 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 when eithernullis input to thelocatorsparameter, or one or more of the elements of thelocatorsparameter isnull.IllegalStateException- this exception occurs when this method is called after theterminatemethod has been called.- 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:
NullPointerException- this exception occurs when eithernullis input to thelocatorsparameter, or one or more of the elements of thelocatorsparameter isnull.IllegalStateException- this exception occurs when this method is called after theterminatemethod has been called.- See Also:
-
getDiscoveredLocators
Returns the set ofLookupLocatorobjects representing the desired lookup services that are currently discovered. If no lookup services are currently discovered, this method returns the empty array. This method returns a new array upon each invocation.- Returns:
LookupLocatorarray consisting of the elements from the managed set of locators that correspond to lookup services that have already been discovered.- Throws:
IllegalStateException- this exception occurs when this method is called after theterminatemethod has been called.
-
getUndiscoveredLocators
Returns the set ofLookupLocatorobjects representing the desired lookup services that have not yet been discovered. If all of the desired lookup services are currently discovered, this method returns the empty array. This method returns a new array upon each invocation.- Returns:
LookupLocatorarray consisting of the elements from the managed set of locators that correspond to lookup services that have not yet been discovered.- Throws:
IllegalStateException- this exception occurs when this method is called after theterminatemethod has been called.
-