public final class ConstrainableLookupLocator extends LookupLocator implements RemoteMethodControl
LookupLocatorsubclass which supports constraint operations through the
RemoteMethodControlinterface. The constraints of a
ConstrainableLookupLocatorinstance control how it performs unicast discovery, and apply only to its
getRegistrar(int)methods. The constraints may also be used by other utilities, such as
LookupLocatorDiscovery, to determine how unicast discovery should be performed on behalf of a given
ConstrainableLookupLocatorinstances can be verified using the
DiscoveryProtocolVersion: this constraint can be used to control which version of the unicast discovery protocol is used.
UnicastSocketTimeout: this constraint can be used to control the read timeout set on sockets over which unicast discovery is performed.
ConnectionRelativeTime: this constraint can be used to control the relative connection timeout set on sockets over which unicast discovery is performed.
ConnectionAbsoluteTime: this constraint can be used to control the absolute connection timeout set on sockets over which unicast discovery is performed.
In addition, the
MulticastTimeToLive constraint types are
trivially supported, but do not have any effect on unicast discovery
operations. Constraints other than those mentioned above are passed on to
the underlying implementations of versions 1 and 2 of the discovery
An example of using constraints with
The resultingnew ConstrainableLookupLocator("target_host", 4160, new
InvocationConstraints( DiscoveryProtocolVersion.TWO, new UnicastSocketTimeout(120000))));
ConstrainableLookupLocatorinstance would (when used) perform unicast discovery to the host
target_hoston port 4160 using discovery protocol version 2, with a socket read timeout of 120000 milliseconds unless one was explicitly specified using the
|Constructor and Description|
Constructs a new
Constructs a new
|Modifier and Type||Method and Description|
Two locators are equal if they have the same
Returns the client constraints placed on this proxy.
Performs unicast discovery as specified by
Performs unicast discovery as specified by
Returns a hash code value calculated from the
Returns a new copy of this proxy with the client constraints set to the specified constraints.
Returns a string representation of this object.
public ConstrainableLookupLocator(String url, MethodConstraints constraints) throws MalformedURLException
ConstrainableLookupLocatorinstance which can be used to perform unicast discovery to the host and port named by the given URL with the provided constraints applied. This constructor invokes its superclass
LookupLocator.LookupLocator(String)constructor. Any exceptions thrown by the superclass constructor are rethrown.
url must be a valid URL of scheme
constraints value is interpreted as mapping both
getRegistrar methods to empty constraints.
public ConstrainableLookupLocator(String host, int port, MethodConstraints constraints)
ConstrainableLookupLocatorinstance which can be used to perform unicast discovery to the given host and port with the provided constraints applied. This constructor invokes its superclass
LookupLocator.LookupLocator(String, int)constructor. Any exceptions thrown by the superclass constructor are rethrown.
null constraints value is interpreted as mapping both
getRegistrar methods to empty constraints. The
port must satisfy the requirements of
LookupLocator(String, int) constructor.
host- the name of the host to contact
port- the number of the port to connect to
constraints- the constraints to apply to unicast discovery, or
IllegalArgumentException- if the port and host do not meet the requirements of
public int hashCode()
public boolean equals(Object o)
portfields. The case of the
hostis ignored. Alternative forms of the same IPv6 addresses for the
hostvalue are treated as being unequal.
public ServiceRegistrar getRegistrar() throws IOException, ClassNotFoundException
LookupLocator.getRegistrar()with the following differences.
net.jini.discovery.timeoutsystem property is ignored.
ConstrainableLookupLocatorimplements this method to use the values of the
portfield in determining the host and port to connect to.
public ServiceRegistrar getRegistrar(int timeout) throws IOException, ClassNotFoundException
LookupLocator.getRegistrar(int), additionally applying the supplied discovery constraints. The
timeoutis considered a requirement with respect to other constraints specified for this instance.
timeout- the maximum time to wait for a response, in milliseconds. A value of
0specifies an infinite timeout.
UnsupportedConstraintException- if the discovery-related constraints contain conflicts, or otherwise cannot be processed
IOException- an error occurred during discovery
public String toString()
public RemoteMethodControl setConstraints(MethodConstraints constraints)
getConstraintsmethod of the copy returns the identical constraints instance. The original proxy is not modified. A
nullvalue is interpreted as mapping all methods to empty constraints (one that has no requirements and no preferences). For any given remote call, the specific client requirements and preferences to be satisfied are given by the return value of invoking the
getConstraintsmethod of the specified
MethodConstraintsinstance with a
Methodobject representing the remote method.
Client constraints placed on a proxy are included in the serialized
state of the proxy. This allows third-party services to be transparent
to the client's needs. For example, if remote object
obtains a proxy for remote object
s2, and passes that
proxy to remote object
invoke a remote method on
control that call by placing its constraints directly on the proxy
before passing it to
s3 does not
wish to be transparent in this way, then it should explicitly replace
the client constraints on received proxies with whatever constraints
are appropriate to implement its own policy.
public MethodConstraints getConstraints()
null, which is interpreted as mapping all methods to empty constraints (one that has no requirements and no preferences).
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.