net.jini.core.discovery
Class LookupLocator

java.lang.Object
  |
  +--net.jini.core.discovery.LookupLocator

public class LookupLocator
extends java.lang.Object
implements java.io.Serializable

A utility class that performs unicast discovery.

See Also:
Serialized Form

Field Summary
protected  java.lang.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 Summary
LookupLocator(java.lang.String url)
          Construct a new LookupLocator object, set up to perform discovery to the given URL.
LookupLocator(java.lang.String host, int port)
          Construct a new LookupLocator object, set to perform unicast discovery to the given host and port.
 
Method Summary
 boolean equals(java.lang.Object o)
          Two locators are equal if they have the same host and port.
 java.lang.String getHost()
          Return the name of the host this LookupLocator object should contact.
 int getPort()
          Return the number of the port to which this LookupLocator object 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.
 int hashCode()
           
 java.lang.String toString()
          Return the string form of this LookupLocator, as a jini-scheme URL.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

host

protected java.lang.String host
The name of the host at which to perform discovery.

port

protected int port
The port number on the host at which to perform discovery.
Constructor Detail

LookupLocator

public LookupLocator(java.lang.String url)
              throws java.net.MalformedURLException
Construct a new LookupLocator object, set up to perform discovery to the given URL.

The URL in question must be of the form jini://host/ or jini://host:port/.

Parameters:
url - the URL to use
Throws:
java.net.MalformedURLException - the URL passed in could not be parsed

LookupLocator

public LookupLocator(java.lang.String host,
                     int port)
Construct a new LookupLocator object, set to perform unicast discovery to the given host and port.
Parameters:
host - the name of the host to contact
port - the number of the port to connect to
Method Detail

getHost

public java.lang.String getHost()
Return the name of the host this LookupLocator object should contact.

getPort

public int getPort()
Return the number of the port to which this LookupLocator object should connect.

getRegistrar

public ServiceRegistrar getRegistrar()
                              throws java.io.IOException,
                                     java.lang.ClassNotFoundException
Perform unicast discovery and return the ServiceRegistrar object for the given lookup service. Unicast discovery is performed anew each time this method is called.
Returns:
the ServiceRegistrar for the lookup service denoted by this LookupLocator object
Throws:
java.io.IOException - an error occurred during discovery
java.lang.ClassNotFoundException - some discovery-related classes could not be found

getRegistrar

public ServiceRegistrar getRegistrar(int timeout)
                              throws java.io.IOException,
                                     java.lang.ClassNotFoundException
Perform unicast discovery and return the ServiceRegistrar object for the given lookup service. Unicast discovery is performed anew each time this method is called.

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
Returns:
the ServiceRegistrar for the lookup service denoted by this LookupLocator object
Throws:
java.io.IOException - an error occurred during discovery
java.lang.ClassNotFoundException - some discovery-related classes could not be found

toString

public java.lang.String toString()
Return the string form of this LookupLocator, as a jini-scheme URL.
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Two locators are equal if they have the same host and port.
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 1999 Sun Microsystems, Inc. All rights reserved