DJ.5. LookupLocator Class

The LookupLocator class provides a simple interface for performing unicast discovery:

package net.jini.core.discovery; 

import java.io.IOException; 
import java.io.Serializable; 
import java.net.MalformedURLException; 
import net.jini.core.lookup.ServiceRegistrar; 

public class LookupLocator implements Serializable {
    public LookupLocator(String host, int port) {...} 
    public LookupLocator(String url) 
        throws MalformedURLException {...} 
    public String getHost() {...} 
    public int getPort() {...} 
    public ServiceRegistrar getRegistrar() 
        throws IOException, ClassNotFoundException {...} 
    public ServiceRegistrar getRegistrar(int timeout) 
        throws IOException, ClassNotFoundException {...} 
} 

Each constructor takes parameters that allow the object to determine what IP address and TCP port number it should connect to. The first form takes a host name and port number. The second form takes what should be a jini -scheme URL. If the URL is invalid, it throws a java.net.MalformedURLException. Neither constructor performs the unicast discovery protocol, nor does either resolve the host name passed as argument.

The getHost method returns the name of the host with which this object attempts to perform unicast discovery, and the getPort method returns the TCP port at that host to which this object connects. The equals method returns true if both instances have the same host and port.

There are two forms of getRegistrar method. Each performs unicast discovery and returns an instance of the proxy for the specified lookup service, or throws either a java.io.IOException or a java.lang.ClassNotFoundException if a problem occurs during the discovery protocol. Each method performs unicast discovery every time it is called.

The form of this method that takes a timeout parameter will throw a java.io.InterruptedIOException if it blocks for more than timeout milliseconds while waiting for a response. A similar timeout is implied for the no-arg form of this method, but the value of the timeout in milliseconds may be specified globally using the net.jini.discovery.timeout system property, with a default equal to 60 seconds.

DJ.5.1. Jini Technology URL Syntax

While the Uniform Resource Locator (URL) specification merely demands that a URL be of the form protocol:data, standard URL syntaxes tend to take one of two forms:

  • protocol://host/data

  • protocol://host:port/data

The protocol component of a Jini technology URL is, not surprisingly, jini. The host name component of the URL is an ordinary DNS name or IP address. If the DNS name resolves to multiple IP addresses, it is assumed that a lookup service for the same djinn lives at each address. If no port number is specified, the default is 4160. [2]

[2] If you speak hexadecimal, you will notice that 4160 is the decimal representation of (CAFEBABE) .

The URL has no data component, since the lookup service is generally not searchable by name. As a result, a Jini technology URL ends up looking like

jini://example.org 

with the port defaulting to 4160 since it is not provided explicitly, or, to indicate a non-default port,

jini://example.com:4162 

DJ.5.2. Serialized Form

Class serialVersionUID Serialized Fields
LookupLocator 1448769379829432795L String host int port

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.137.37