APIdia Launch Partner
Top Description Fields Methods
java.rmi.registry

public Interface Registry

extends Remote
Known Direct Implementers
sun.rmi.registry.RegistryImpl, sun.rmi.registry.RegistryImpl_Stub
Imports
java.rmi.AccessException, .AlreadyBoundException, .NotBoundException, .Remote, .RemoteException

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 and TCP port number (default is 1099).

The 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 java.rmi.AccessException, which (because it extends java.rmi.RemoteException) will be wrapped in a 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.

Authors
Ann Wollrath, Peter Jones
Since
1.1
See Also
LocateRegistry

Field Summary

Modifier and TypeField and Description
public static final int
REGISTRY_PORT

Well known port for registry.

Method Summary

Modifier and TypeMethod and Description
public void
bind(String
the name to associate with the remote reference
name
,
Remote
a reference to a remote object (usually a stub)
obj
)

Binds a remote reference to the specified name in this registry.

public String[]

Returns:

an array of the names bound in this registry
list
()

Returns an array of the names bound in this registry.

public Remote

Returns:

a reference to a remote object
lookup
(String
the name for the remote reference to look up
name
)

Returns the remote reference bound to the specified name in this registry.

public void
rebind(String
the name to associate with the remote reference
name
,
Remote
a reference to a remote object (usually a stub)
obj
)

Replaces the binding for the specified name in this registry with the supplied remote reference.

public void
unbind(String
the name of the binding to remove
name
)

Removes the binding for the specified name in this registry.

Field Detail

REGISTRY_PORTback to summary
public static final int REGISTRY_PORT

Well known port for registry.

Method Detail

bindback to summary
public void bind(String name, Remote obj) throws RemoteException, AlreadyBoundException, AccessException

Binds a remote reference to the specified name in this registry.

Parameters
name:String

the name to associate with the remote reference

obj:Remote

a reference to a remote object (usually a stub)

Exceptions
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)
AlreadyBoundException:
if name is already bound
AccessException:
if this registry is local and it denies the caller access to perform this operation
NullPointerException:
if name is null, or if obj is null
listback to summary
public String[] list() throws RemoteException, 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:String[]

an array of the names bound in this registry

Exceptions
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:
if this registry is local and it denies the caller access to perform this operation
lookupback to summary
public Remote lookup(String name) throws RemoteException, NotBoundException, AccessException

Returns the remote reference bound to the specified name in this registry.

Parameters
name:String

the name for the remote reference to look up

Returns:Remote

a reference to a remote object

Exceptions
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
NotBoundException:
if name is not currently bound
AccessException:
if this registry is local and it denies the caller access to perform this operation
NullPointerException:
if name is null
rebindback to summary
public void rebind(String name, Remote obj) throws RemoteException, 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:String

the name to associate with the remote reference

obj:Remote

a reference to a remote object (usually a stub)

Exceptions
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:
if this registry is local and it denies the caller access to perform this operation
NullPointerException:
if name is null, or if obj is null
unbindback to summary
public void unbind(String name) throws RemoteException, NotBoundException, AccessException

Removes the binding for the specified name in this registry.

Parameters
name:String

the name of the binding to remove

Exceptions
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)
NotBoundException:
if name is not currently bound
AccessException:
if this registry is local and it denies the caller access to perform this operation
NullPointerException:
if name is null