CONTENTS | PREV | NEXT | Java Remote Method Invocation |
Registry
Interface
Thejava.rmi.registry.Registry
remote interface provides methods for lookup, binding, rebinding, unbinding, and listing the contents of a registry. Thejava.rmi.Naming
class uses theregistry
remote 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_PORT
is the default port of the registry.The
lookup
method 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
bind
method associates the name with the remote object, obj. If the name is already bound to an object,AlreadyBoundException
is thrown.The
rebind
method associates the name with the remote object, obj. Any previous binding of the name is discarded.The
unbind
method removes the binding between the name and the remote object, obj. If the name is not already bound to an object,NotBoundException
is thrown.The
list
method returns an array ofStrings
containing 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
LocateRegistry
andRegistry
interfaces, or by using the methods of the URL-basedjava.rmi.Naming
class. The registry supportsbind
,unbind
, andrebind
only from clients on the same host as the server; a lookup can be done from any host.