java.rmi.registry
Interface Registry

All Superinterfaces:
Remote sample code for java.rmi.Remote definition code for java.rmi.Remote

public interface Registry
extends Remote sample code for java.rmi.Remote definition code for java.rmi.Remote

Registry is a remote interface to a simple remote object registry that provides methods for storing and retrieving remote object references bound with arbitrary string names. The bind, unbind, and rebind methods are used to alter the name bindings in the registry, and the lookup and list methods are used to query the current name bindings.

In its typical usage, a Registry enables RMI client bootstrapping: it provides a simple means for a client to obtain an initial reference to a remote object. Therefore, a registry's remote object implementation is typically exported with a well-known address, such as with a well-known ObjID sample code for java.rmi.server.ObjID.REGISTRY_ID definition code for java.rmi.server.ObjID.REGISTRY_ID and TCP port number (default is 1099 sample code for java.rmi.registry.Registry.REGISTRY_PORT definition code for java.rmi.registry.Registry.REGISTRY_PORT ).

The LocateRegistry sample code for java.rmi.registry.LocateRegistry definition code for java.rmi.registry.LocateRegistry class provides a programmatic API for constructing a bootstrap reference to a Registry at a remote address (see the static getRegistry methods) and for creating and exporting a Registry in the current VM on a particular local address (see the static createRegistry methods).

A Registry implementation may choose to restrict access to some or all of its methods (for example, methods that mutate the registry's bindings may be restricted to calls originating from the local host). If a Registry method chooses to deny access for a given invocation, its implementation may throw AccessException sample code for java.rmi.AccessException definition code for java.rmi.AccessException , which (because it extends RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException ) will be wrapped in a ServerException sample code for java.rmi.ServerException definition code for java.rmi.ServerException when caught by a remote client.

The names used for bindings in a Registry are pure strings, not parsed. A service which stores its remote reference in a Registry may wish to use a package name as a prefix in the name binding to reduce the likelihood of name collisions in the registry.

Since:
JDK1.1
See Also:
LocateRegistry sample code for java.rmi.registry.LocateRegistry definition code for java.rmi.registry.LocateRegistry

Field Summary
static int REGISTRY_PORT sample code for java.rmi.registry.Registry.REGISTRY_PORT definition code for java.rmi.registry.Registry.REGISTRY_PORT
          Well known port for registry.
 
Method Summary
 void bind sample code for java.rmi.registry.Registry.bind(java.lang.String, java.rmi.Remote) definition code for java.rmi.registry.Registry.bind(java.lang.String, java.rmi.Remote) (String sample code for java.lang.String definition code for java.lang.String  name, Remote sample code for java.rmi.Remote definition code for java.rmi.Remote  obj)
          Binds a remote reference to the specified name in this registry.
 String sample code for java.lang.String definition code for java.lang.String [] list sample code for java.rmi.registry.Registry.list() definition code for java.rmi.registry.Registry.list() ()
          Returns an array of the names bound in this registry.
 Remote sample code for java.rmi.Remote definition code for java.rmi.Remote lookup sample code for java.rmi.registry.Registry.lookup(java.lang.String) definition code for java.rmi.registry.Registry.lookup(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  name)
          Returns the remote reference bound to the specified name in this registry.
 void rebind sample code for java.rmi.registry.Registry.rebind(java.lang.String, java.rmi.Remote) definition code for java.rmi.registry.Registry.rebind(java.lang.String, java.rmi.Remote) (String sample code for java.lang.String definition code for java.lang.String  name, Remote sample code for java.rmi.Remote definition code for java.rmi.Remote  obj)
          Replaces the binding for the specified name in this registry with the supplied remote reference.
 void unbind sample code for java.rmi.registry.Registry.unbind(java.lang.String) definition code for java.rmi.registry.Registry.unbind(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  name)
          Removes the binding for the specified name in this registry.
 

Field Detail

REGISTRY_PORT sample code for java.rmi.registry.Registry.REGISTRY_PORT

static final int REGISTRY_PORT
Well known port for registry.

See Also:
Constant Field Values
Method Detail

lookup sample code for java.rmi.registry.Registry.lookup(java.lang.String) definition code for java.rmi.registry.Registry.lookup(java.lang.String)

Remote sample code for java.rmi.Remote definition code for java.rmi.Remote  lookup(String sample code for java.lang.String definition code for java.lang.String  name)
              throws RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException ,
                     NotBoundException sample code for java.rmi.NotBoundException definition code for java.rmi.NotBoundException ,
                     AccessException sample code for java.rmi.AccessException definition code for java.rmi.AccessException 
Returns the remote reference bound to the specified name in this registry.

Parameters:
name - the name for the remote reference to look up
Returns:
a reference to a remote object
Throws:
NotBoundException sample code for java.rmi.NotBoundException definition code for java.rmi.NotBoundException - if name is not currently bound
RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException - if remote communication with the registry failed; if exception is a ServerException containing an AccessException, then the registry denies the caller access to perform this operation
AccessException sample code for java.rmi.AccessException definition code for java.rmi.AccessException - if this registry is local and it denies the caller access to perform this operation
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if name is null

bind sample code for java.rmi.registry.Registry.bind(java.lang.String, java.rmi.Remote) definition code for java.rmi.registry.Registry.bind(java.lang.String, java.rmi.Remote)

void bind(String sample code for java.lang.String definition code for java.lang.String  name,
          Remote sample code for java.rmi.Remote definition code for java.rmi.Remote  obj)
          throws RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException ,
                 AlreadyBoundException sample code for java.rmi.AlreadyBoundException definition code for java.rmi.AlreadyBoundException ,
                 AccessException sample code for java.rmi.AccessException definition code for java.rmi.AccessException 
Binds a remote reference to the specified name in this registry.

Parameters:
name - the name to associate with the remote reference
obj - a reference to a remote object (usually a stub)
Throws:
AlreadyBoundException sample code for java.rmi.AlreadyBoundException definition code for java.rmi.AlreadyBoundException - if name is already bound
RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException - if remote communication with the registry failed; if exception is a ServerException containing an AccessException, then the registry denies the caller access to perform this operation (if originating from a non-local host, for example)
AccessException sample code for java.rmi.AccessException definition code for java.rmi.AccessException - if this registry is local and it denies the caller access to perform this operation
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if name is null, or if obj is null

unbind sample code for java.rmi.registry.Registry.unbind(java.lang.String) definition code for java.rmi.registry.Registry.unbind(java.lang.String)

void unbind(String sample code for java.lang.String definition code for java.lang.String  name)
            throws RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException ,
                   NotBoundException sample code for java.rmi.NotBoundException definition code for java.rmi.NotBoundException ,
                   AccessException sample code for java.rmi.AccessException definition code for java.rmi.AccessException 
Removes the binding for the specified name in this registry.

Parameters:
name - the name of the binding to remove
Throws:
NotBoundException sample code for java.rmi.NotBoundException definition code for java.rmi.NotBoundException - if name is not currently bound
RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException - if remote communication with the registry failed; if exception is a ServerException containing an AccessException, then the registry denies the caller access to perform this operation (if originating from a non-local host, for example)
AccessException sample code for java.rmi.AccessException definition code for java.rmi.AccessException - if this registry is local and it denies the caller access to perform this operation
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if name is null

rebind sample code for java.rmi.registry.Registry.rebind(java.lang.String, java.rmi.Remote) definition code for java.rmi.registry.Registry.rebind(java.lang.String, java.rmi.Remote)

void rebind(String sample code for java.lang.String definition code for java.lang.String  name,
            Remote sample code for java.rmi.Remote definition code for java.rmi.Remote  obj)
            throws RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException ,
                   AccessException sample code for java.rmi.AccessException definition code for java.rmi.AccessException 
Replaces the binding for the specified name in this registry with the supplied remote reference. If there is an existing binding for the specified name, it is discarded.

Parameters:
name - the name to associate with the remote reference
obj - a reference to a remote object (usually a stub)
Throws:
RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException - if remote communication with the registry failed; if exception is a ServerException containing an AccessException, then the registry denies the caller access to perform this operation (if originating from a non-local host, for example)
AccessException sample code for java.rmi.AccessException definition code for java.rmi.AccessException - if this registry is local and it denies the caller access to perform this operation
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if name is null, or if obj is null

list sample code for java.rmi.registry.Registry.list() definition code for java.rmi.registry.Registry.list()

String sample code for java.lang.String definition code for java.lang.String [] list()
              throws RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException ,
                     AccessException sample code for java.rmi.AccessException definition code for java.rmi.AccessException 
Returns an array of the names bound in this registry. The array will contain a snapshot of the names bound in this registry at the time of the given invocation of this method.

Returns:
an array of the names bound in this registry
Throws:
RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException - if remote communication with the registry failed; if exception is a ServerException containing an AccessException, then the registry denies the caller access to perform this operation
AccessException sample code for java.rmi.AccessException definition code for java.rmi.AccessException - if this registry is local and it denies the caller access to perform this operation