public class LookupLocator extends Object implements Serializable
It's main purpose now is to contain a url used for unicast discovery of
a ServiceRegistrar
, it is now
immutable, since River 2.2.1, this may break overriding classes.
"jini"
Unicast Discovery may be performed using any Discovery
V1 or V2 provider and depending on routing and firewall rules,
may be used to contact a ServiceRegistrar
.
The "https"
scheme based Unicast Discovery is neither
Discovery V1 or V2 compliant, as firewall rules and proxy servers
that allow https communications are likely to prevent the handshake
required to select a "jini"
Discovery provider.
LookupLocator is used as a parameter in LookupLocatorDiscovery constructors. LookupLocatorDiscovery has methods to perform Discovery using either version 1 or 2 with constraints. ConstrainableLookupLocator is a subclass which uses discovery V1 or V2 and enables the use of constraints.
see net.jini.discovery.LookupLocatorDiscovery
ConstrainableLookupLocator
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected String |
host
The name of the host at which to perform discovery.
|
protected int |
port
The port number on the host at which to perform discovery.
|
Constructor and Description |
---|
LookupLocator(AtomicSerial.GetArg arg) |
LookupLocator(String url)
Construct a new
LookupLocator object, set up to perform
discovery to the given URL. |
LookupLocator(String host,
int port)
Construct a new
LookupLocator object, set to perform unicast
discovery to the input host and port with the
default "jini" scheme. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
Two locators are equal if they have the same
host and
port fields. |
String |
getHost()
Returns the name of the host that this instance should contact.
|
int |
getPort()
Returns the number of the port to which this instance should connect.
|
ServiceRegistrar |
getRegistrar()
Perform unicast discovery and return the ServiceRegistrar
object for the given lookup service.
|
ServiceRegistrar |
getRegistrar(int timeout)
Perform unicast discovery and return the ServiceRegistrar
object for the given lookup service, with the given discovery timeout.
|
protected ServiceRegistrar |
getRegistrar(InvocationConstraints constraints)
Perform unicast discovery and return the ServiceRegistrar
object for the given lookup service, with the given constraints.
|
protected ServiceRegistrar |
getRegistrar(InvocationConstraints constraints,
Collection context)
Perform unicast discovery and return the ServiceRegistrar
object for the given lookup service, with the given constraints
and context.
|
int |
hashCode()
Returns a hash code value calculated from the
host and
port field values. |
String |
scheme()
Returns the scheme used by this LookupLocator, either traditional
"jini" or "https".
|
String |
toString()
Return the string form of this LookupLocator, as a URL of scheme
"jini" or "https" . |
protected final String host
protected final int port
public LookupLocator(String url) throws MalformedURLException
LookupLocator
object, set up to perform
discovery to the given URL. The host
and port
fields 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
URI
with a server-based naming authority.
Requirements for the components are as follows:
"jini"
or "https"
must be present.
4160
is used for "jini"
and a default value of 443
is used for "https"
.
"/"
; path segments must not be present.
The four allowed forms of the URL are thus:
scheme://
host
scheme://
host/
scheme://
host:
port
scheme://
host:
port/
url
- the URL to useMalformedURLException
- url
could not be parsedNullPointerException
- if url
is null
public LookupLocator(AtomicSerial.GetArg arg) throws IOException
IOException
public LookupLocator(String host, int port)
LookupLocator
object, set to perform unicast
discovery to the input host
and port
with the
default "jini"
scheme. The
host
and port
fields will be populated with the
host
and port
arguments. No host name
resolution is attempted.
The host
argument must meet any one of the following syntactical requirements:
host
- the name of the host to contactport
- the number of the port to connect toIllegalArgumentException
- if port
is not between
1 and 65535 (both included) or if host
cannot be parsed.NullPointerException
- if host
is null
public String scheme()
public String getHost()
LookupLocator
implements this method to return
the host
field.public int getPort()
LookupLocator
implements this method to return the
port
field.public ServiceRegistrar getRegistrar() throws IOException, ClassNotFoundException
LookupLocator
implements this method to simply invoke
getRegistrar(int)
with a timeout value, which is determined
by the value of the net.jini.discovery.timeout
system
property. If the property is set, is not negative, and can be parsed as
an Integer
, the value of the property is used as the timeout
value. Otherwise, a default value of 60
seconds is assumed.IOException
- an error occurred during discoveryClassNotFoundException
- if a class required to unmarshal the
ServiceRegistrar
proxy cannot be foundpublic ServiceRegistrar getRegistrar(int timeout) throws IOException, ClassNotFoundException
LookupLocator
implements this method to use the values
of the host
and port
field 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.
timeout
- the maximum time to wait for a response, in
milliseconds. A value of 0
specifies an infinite timeout.IOException
- an error occurred during discoveryClassNotFoundException
- if a class required to unmarshal the
ServiceRegistrar
proxy cannot be foundIllegalArgumentException
- if timeout
is negativeprotected final ServiceRegistrar getRegistrar(InvocationConstraints constraints) throws IOException, ClassNotFoundException
LookupLocator
implements this method to use the values
of the host
and port
field in determining
the host and port to connect to.constraints
- discovery constraintsIOException
- an error occurred during discoveryUnsupportedConstraintException
- if the
discovery-related constraints contain conflicts, or otherwise cannot be
processedClassNotFoundException
- if a class required to unmarshal the
ServiceRegistrar
proxy cannot be foundprotected final ServiceRegistrar getRegistrar(InvocationConstraints constraints, Collection context) throws IOException, ClassNotFoundException
MethodConstraints
for ProxyCodebaseSpi
.
Unicast discovery is performed anew each time this method is called.
LookupLocator
implements this method to use the values
of the host
and port
field in determining
the host and port to connect to.constraints
- discovery constraintscontext
- the stream context ObjectStreamContext.getObjectStreamContext()
IOException
- an error occurred during discoveryUnsupportedConstraintException
- if the
discovery-related constraints contain conflicts, or otherwise cannot be
processedClassNotFoundException
- if a class required to unmarshal the
ServiceRegistrar
proxy cannot be foundpublic String toString()
"jini"
or "https"
.public boolean equals(Object o)
host
and
port
fields. The case of the host
is ignored.
Alternative forms of the same IPv6 addresses for the host
value are treated as being unequal.Copyright © 2016–2018 The Apache Software Foundation. All rights reserved.