Registry (Java SE 15 & JDK 15) (original) (raw)
All Superinterfaces:
[Remote](../Remote.html "interface in java.rmi")
public interface Registry extends 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. Thebind
, 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 staticcreateRegistry
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, which (because it extends RemoteException) will be wrapped in a 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:
1.1
See Also:
Field Summary
Fields
Modifier and Type | Field | Description |
---|---|---|
static int | REGISTRY_PORT | Well known port for registry. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
void | bind(String name,Remote obj) | Binds a remote reference to the specified name in this registry. |
String[] | list() | Returns an array of the names bound in this registry. |
Remote | lookup(String name) | Returns the remote reference bound to the specifiedname in this registry. |
void | rebind(String name,Remote obj) | Replaces the binding for the specified name in this registry with the supplied remote reference. |
void | unbind(String name) | Removes the binding for the specified name in this registry. |
Field Details
REGISTRY_PORT
static final int REGISTRY_PORT
Well known port for registry.
See Also:
Constant Field ValuesMethod Details
lookup
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](../NotBoundException.html "class in java.rmi")
- ifname
is not currently bound
[RemoteException](../RemoteException.html "class in java.rmi")
- if remote communication with the registry failed; if exception is aServerException
containing anAccessException
, then the registry denies the caller access to perform this operation
[AccessException](../AccessException.html "class in java.rmi")
- if this registry is local and it denies the caller access to perform this operation
[NullPointerException](../../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- ifname
isnull
bind
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](../AlreadyBoundException.html "class in java.rmi")
- ifname
is already bound
[RemoteException](../RemoteException.html "class in java.rmi")
- if remote communication with the registry failed; if exception is aServerException
containing anAccessException
, then the registry denies the caller access to perform this operation (if originating from a non-local host, for example)
[AccessException](../AccessException.html "class in java.rmi")
- if this registry is local and it denies the caller access to perform this operation
[NullPointerException](../../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- ifname
isnull
, or ifobj
isnull
unbind
Removes the binding for the specified
name
in this registry.
Parameters:
name
- the name of the binding to remove
Throws:
[NotBoundException](../NotBoundException.html "class in java.rmi")
- ifname
is not currently bound
[RemoteException](../RemoteException.html "class in java.rmi")
- if remote communication with the registry failed; if exception is aServerException
containing anAccessException
, then the registry denies the caller access to perform this operation (if originating from a non-local host, for example)
[AccessException](../AccessException.html "class in java.rmi")
- if this registry is local and it denies the caller access to perform this operation
[NullPointerException](../../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- ifname
isnull
rebind
Replaces the binding for the specified
name
in this registry with the supplied remote reference. If there is an existing binding for the specifiedname
, 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](../RemoteException.html "class in java.rmi")
- if remote communication with the registry failed; if exception is aServerException
containing anAccessException
, then the registry denies the caller access to perform this operation (if originating from a non-local host, for example)
[AccessException](../AccessException.html "class in java.rmi")
- if this registry is local and it denies the caller access to perform this operation
[NullPointerException](../../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- ifname
isnull
, or ifobj
isnull
list
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](../RemoteException.html "class in java.rmi")
- if remote communication with the registry failed; if exception is aServerException
containing anAccessException
, then the registry denies the caller access to perform this operation
[AccessException](../AccessException.html "class in java.rmi")
- if this registry is local and it denies the caller access to perform this operation