home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book Home Java Distributed Computing Search this book

D.2. The java.rmi.registry Package

This package contains classes that provide an interface and implementation for the various elements of the RMI object registry.

java.rmi.registry.LocateRegistry

This is a low-level interface to the RMI registry service, either on the local host or on remote servers. On lookups, the Naming service parses the host and port from the remote object URL and uses the LocateRegistry to connect to the remote registry. The various getRegistry() methods provide the means to get a reference to the local registry, or a stub to a remote registry running on a given host and port. The createRegistry() method creates a registry running on the local host on the given port number.

public final class LocateRegistry {
// Class Methods
    public static Registry createRegistry(int port) throws RemoteException;
    public static Registry getRegistry() throws RemoteException;
    public static Registry getRegistry(int port) throws RemoteException;
    public static Registry getRegistry(String host)
        throws RemoteException, UnknownHostException;
    public static Registry getRegistry(String host, int port)
        throws RemoteException, UnknownHostException;
}
java.rmi.registry.Registry

The Registry is an interface to the RMI object registry that runs on every node in a distributed RMI system. While the Naming interface can be used to look up objects stored in any registry on the network, a Registry operates on a single registry on a single host. URL object names are passed into methods on the Naming service, which finds the right Registry stub using the LocateRegistry interface, and then calls the lookup() method on the remote (or local) Registry to get a stub for the remote object. A similar sequence of calls takes place with the local Registry when bind(), rebind(), or unbind() are called on the Naming interface.

The Registry stores objects under unique names. An object is assigned to a name in the Registry using its bind() method. The object assigned to a particular name can be changed using the rebind() method. Objects are removed from the Registry using the unbind() method. The lookup() method is used to find objects by name in the Registry, and the list() method is used to get a list of the names of all of the objects currently in the Registry.

public interface Registry extends Remote {
// Class Constants
    public static final int REGISTRY_PORT = 1099;
// Public Instance Methods
    public void bind(String name, Remote obj) throws RemoteException,
        AlreadyBoundException, AccessException;
    public String[] list() throws RemoteException, AccessException;
    public Remote lookup(String name)
        throws RemoteException, NotBoundException, AccessException;
    public void rebind(String name, Remote obj)
        throws RemoteException, AccessException;
    public void unbind(String name) throws RemoteException, 
        NotBoundException, AccessException;
} 
java.rmi.registry.RegistryHandler

This interface is mainly of interest to implementors of RMI registry services. It defines the interface to the internal registry-handling implementation.

public interface RegistryHandler {
// Public Instance Methods
    public Registry registryImpl(int port) throws RemoteException;
    public Registry registryStub(String host, int port)
                    throws RemoteException, UnknownHostException;
} 


Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.