| CONTENTS | PREV | NEXT | Java Remote Method Invocation |
Registry Interface
Thejava.rmi.registry.Registryremote interface provides methods for lookup, binding, rebinding, unbinding, and listing the contents of a registry. Thejava.rmi.Namingclass uses theregistryremote interface to provide URL-based naming.
package java.rmi.registry;
public interface Registry extends java.rmi.Remote {
public static final int REGISTRY_PORT = 1099;
public java.rmi.Remote lookup(String name)
throws java.rmi.RemoteException,
java.rmi.NotBoundException, java.rmi.AccessException;
public void bind(String name, java.rmi.Remote obj)
throws java.rmi.RemoteException,
java.rmi.AlreadyBoundException, java.rmi.AccessException;
public void rebind(String name, java.rmi.Remote obj)
throws java.rmi.RemoteException, java.rmi.AccessException;
public void unbind(String name)
throws java.rmi.RemoteException,
java.rmi.NotBoundException, java.rmi.AccessException;
public String[] list()
throws java.rmi.RemoteException, java.rmi.AccessException;
}
TheREGISTRY_PORTis the default port of the registry.The
lookupmethod returns the remote object bound to the specified name. The remote object implements a set of remote interfaces. Clients can cast the remote object to the expected remote interface. (This cast can fail in the usual ways that casts can fail with aClassCastException.)The
bindmethod associates the name with the remote object, obj. If the name is already bound to an object,AlreadyBoundExceptionis thrown.The
rebindmethod associates the name with the remote object, obj. Any previous binding of the name is discarded.The
unbindmethod removes the binding between the name and the remote object, obj. If the name is not already bound to an object,NotBoundExceptionis thrown.The
listmethod returns an array ofStringscontaining a snapshot of the names bound in the registry. The return value contains a snapshot of the contents of the registry.Clients can access the registry either by using the
LocateRegistryandRegistryinterfaces, or by using the methods of the URL-basedjava.rmi.Namingclass. The registry supportsbind,unbind, andrebindonly from clients on the same host as the server; a lookup can be done from any host.