Package net.jini.core.discovery
Class LookupLocator
java.lang.Object
net.jini.core.discovery.LookupLocator
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ConstrainableLookupLocator
A utility class that performs unicast discovery, using version 1 of the unicast discovery
protocol.
- Since:
- 1.0
- Author:
- Sun Microsystems, Inc.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLookupLocator(String url) Construct a newLookupLocatorobject, set up to perform discovery to the given URL.LookupLocator(String host, int port) Construct a newLookupLocatorobject, set to perform unicast discovery to the inputhostandport. -
Method Summary
Modifier and TypeMethodDescriptionbooleanTwo locators are equal if they have the samehostandportfields.getHost()Returns the name of the host that this instance should contact.intgetPort()Returns the number of the port to which this instance should connect.Perform unicast discovery and return the ServiceRegistrar object for the given lookup service.getRegistrar(int timeout) Perform unicast discovery and return the ServiceRegistrar object for the given lookup service, with the given discovery timeout.inthashCode()Returns a hash code value calculated from thehostandportfield values.toString()Return the string form of this LookupLocator, as a URL of scheme"jini".
-
Field Details
-
host
The name of the host at which to perform discovery. -
port
protected int portThe port number on the host at which to perform discovery.
-
-
Constructor Details
-
LookupLocator
Construct a newLookupLocatorobject, set up to perform discovery to the given URL. Thehostandportfields will be populated with the host and port components of the input URL. No host name resolution is attempted.The syntax of the URL must be that of a hierarchical
URIwith a server-based naming authority. Requirements for the components are as follows:- A scheme of
"jini"must be present. - A
server-based naming authority must be present; user-info must not be present.
The port, if present, must be between 1 and 65535 (both included). If no port is
specified, a default value of
4162is used. - A path if present, must
be
"/"; path segments must not be present. - There must not be any other components present.
The four allowed forms of the URL are thus:
-
jini://host -
jini://host/ -
jini://host:port -
jini://host:port/
- Parameters:
url- the URL to use- Throws:
MalformedURLException-urlcould not be parsedNullPointerException- ifurlisnull
- A scheme of
-
LookupLocator
Construct a newLookupLocatorobject, set to perform unicast discovery to the inputhostandport. Thehostandportfields will be populated with thehostandportarguments. No host name resolution is attempted.The
hostargument must meet any one of the following syntactical requirements:- A host as required by a server-based naming authority in section 3.2.2 of RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax
- A literal IPv6 address as defined by RFC 2732: Format for Literal IPv6 Addresses in URL's
- A literal IPv6 address as defined by RFC 3513: Internet Protocol Version 6 (IPv6) Addressing Architecture
- Parameters:
host- the name of the host to contactport- the number of the port to connect to- Throws:
IllegalArgumentException- ifportis not between 1 and 65535 (both included) or ifhostcannot be parsed.NullPointerException- ifhostisnull
-
-
Method Details
-
getHost
Returns the name of the host that this instance should contact.LookupLocatorimplements this method to return thehostfield.- Returns:
- a String representing the host value
-
getPort
public int getPort()Returns the number of the port to which this instance should connect.LookupLocatorimplements this method to return theportfield.- Returns:
- an int representing the port value
-
getRegistrar
Perform unicast discovery and return the ServiceRegistrar object for the given lookup service. Unicast discovery is performed anew each time this method is called.LookupLocatorimplements this method to simply invokegetRegistrar(int)with a timeout value, which is determined by the value of thenet.jini.discovery.timeoutsystem property. If the property is set, is not negative, and can be parsed as anInteger, the value of the property is used as the timeout value. Otherwise, a default value of60seconds is assumed.- Returns:
- the ServiceRegistrar for the lookup service denoted by this LookupLocator object
- Throws:
IOException- an error occurred during discoveryClassNotFoundException- if a class required to unmarshal theServiceRegistrarproxy cannot be found
-
getRegistrar
Perform unicast discovery and return the ServiceRegistrar object for the given lookup service, with the given discovery timeout. Unicast discovery is performed anew each time this method is called.LookupLocatorimplements this method to use the values of thehostandportfield in determining the host and port to connect to.If a connection can be established to start unicast discovery but the remote end fails to respond within the given time limit, an exception is thrown.
- Parameters:
timeout- the maximum time to wait for a response, in milliseconds. A value of0specifies an infinite timeout.- Returns:
- the ServiceRegistrar for the lookup service denoted by this LookupLocator object
- Throws:
IOException- an error occurred during discoveryClassNotFoundException- if a class required to unmarshal theServiceRegistrarproxy cannot be foundIllegalArgumentException- iftimeoutis negative
-
toString
Return the string form of this LookupLocator, as a URL of scheme"jini". -
equals
Two locators are equal if they have the samehostandportfields. The case of thehostis ignored. Alternative forms of the same IPv6 addresses for thehostvalue are treated as being unequal. -
hashCode
public int hashCode()Returns a hash code value calculated from thehostandportfield values.
-