Book Home Java Enterprise in a Nutshell Search this book

Chapter 16. The java.rmi.registry Package

The java.rmi.registry package contains classes that provide an interface and an implementation for the various elements of the RMI object naming registry. Figure 16-1 shows the class hierarchy for this package.

figure

Figure 16-1. The java.rmi.registry package

LocateRegistryJava 1.1
java.rmi.registryPJ1.1(opt)

This class provides a low-level interface to an RMI registry service, residing either on the local host or on a remote server. On an object lookup, the Naming service parses the host and port from the remote object URL and uses methods of 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() methods create a registry running on the local host on the given port number. The second form of the createRegistry() method allows you to specify custom socket factories the registry uses when it communicates with clients and server objects.

public final class LocateRegistry {
// No Constructor
// Public Class Methods
public static Registry createRegistry (int port) throws RemoteException;
1.2public static Registry createRegistry (int port, java.rmi.server.RMIClientSocketFactory csf, java.rmi.server.RMIServerSocketFactory ssf) throws RemoteException;
public static Registry getRegistry () throws RemoteException;
public static Registry getRegistry (String host) throws RemoteException;
public static Registry getRegistry (int port) throws RemoteException;
public static Registry getRegistry (String host, int port) throws RemoteException;
1.2public static Registry getRegistry (String host, int port, java.rmi.server.RMIClientSocketFactory csf) throws RemoteException;
}
RegistryJava 1.1
java.rmi.registryremote PJ1.1(opt)

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 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 class, 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 finds objects by name in the Registry, while the list() method gets a list of the names of all objects currently in the Registry.

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

Hierarchy: (Registry(Remote))

Returned By: LocateRegistry.{createRegistry(), getRegistry()}, RegistryHandler.{registryImpl(), registryStub()}

RegistryHandlerJava 1.1; Deprecated in Java 1.2
java.rmi.registryPJ1.1(opt)

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

public abstract interface RegistryHandler {
// Deprecated Public Methods
#public abstract Registry registryImpl (int port) throws RemoteException;
#public abstract Registry registryStub (String host, int port) throws RemoteException, java.rmi.UnknownHostException;
}


Library Navigation Links

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

This HTML Help has been published using the chm2web software.