java.rmi.registry

Interface Registry

All Superinterfaces:
Remote

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. 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 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:
JDK1.1
See Also:
LocateRegistry

Field Summary

static int
REGISTRY_PORT
Well known port for registry.

Method Summary

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 specified name 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

public static final int REGISTRY_PORT
Well known port for registry.
Field Value:
1099
Usages and Demos :

View More Examples of Registry.REGISTRY_PORT
   1:         SRPRemoteServer server = new SRPRemoteServer(store);
   2:         Registry reg = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
   3:         reg.bind("SimpleSRPServer", server);
   4:     }

View Full Code Here
   1:     try { return Integer.parseInt(getInitParameter("registryPort")); }
   2:     catch (NumberFormatException e) { return Registry.REGISTRY_PORT; }
   3:   }
   4: 
   5:   public void doGet(HttpServletRequest req, HttpServletResponse res)

View Full Code Here
   1:     try {                    
   2:         rmiRegistry = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
   3:         Enumeration serviceNames = handlers.keys();
   4:         while (serviceNames.hasMoreElements()){
   5:         String serviceName = (String)serviceNames.nextElement();

View Full Code Here
   1:     private static final Log log = LogFactory.getLog(RMIRegistryService.class);
   2:     private int port = Registry.REGISTRY_PORT;
   3:     private Registry registry;
   4: 
   5:     public int getPort() {

View Full Code Here
   1:   private Map objectMap = Collections.synchronizedMap(new HashMap());
   2:   private int port = Registry.REGISTRY_PORT;
   3:   private Registry registry;
   4: 
   5:   public RemoteObjImpl(String name) throws RemoteException {

View Full Code Here

Method Details

bind

public void bind(String name,
                 Remote obj)
            throws RemoteException,
                   AlreadyBoundException,
                   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 - if name is already bound
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
Usages and Demos :

View More Examples of bind(String name,Remote obj)
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3:         ...
   4: import java.rmi.registry.Registry;
   5: 
   6:         ...
   7:         SRPRemoteServer server = new SRPRemoteServer(store);
   8:         Registry reg = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
   9:         ...
  10:         reg.bind("SimpleSRPServer", server);

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.Registry;
   3: 
   4:         ...
   5: 
   6:     Registry remoteRegistry = null;
   7:     try {
   8:         ...
   9:         Remote r = unrestrictedRegistry.lookup("/restricted/Registry");
  10:         remoteRegistry = (Registry) r;
  11:         ...
  12:     try {
  13:         remoteRegistry.bind("NotAllowed", remoteRegistry);

View Full Code Here
   1: import java.rmi.NotBoundException;
   2: import java.rmi.registry.Registry;
   3:         ...
   4: import java.rmi.registry.LocateRegistry;
   5: import java.rmi.server.UnicastRemoteObject;
   6:         ...
   7:                 Naming.rebind(proxyAddress, eventProxy);
   8:                 if(debug) System.out.println(rmiName + " bound to existing registry at port " + portnum );
   9: 
  10:         ...
  11:                     Registry r = LocateRegistry.createRegistry(portnum);
  12:                     r.bind(rmiName, eventProxy);

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3:         ...
   4: import java.rmi.registry.Registry;
   5: 
   6:         ...
   7:   public static void bind() {
   8:     bind(new Integer(java.rmi.registry.Registry.REGISTRY_PORT));
   9:   }
  10:         ...
  11:       try {
  12:         reg.bind("FactoryInterface", fi);

View Full Code Here
   1: import java.rmi.Remote;
   2: import java.rmi.registry.LocateRegistry;
   3:         ...
   4: import java.rmi.registry.Registry;
   5: import java.rmi.server.ExportException;
   6:         ...
   7: 
   8:   public static Registry createRegistry(
   9:       RMISocketFactory rsf,
  10:         ...
  11:       RMIAccess t = new RMIAccessImpl(bp, rsf, rsf);
  12:       r.bind(path, t);

View Full Code Here

list

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:
an array of the names bound in this registry
Throws:
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
Usages and Demos :

View More Examples of list()
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3:         ...
   4: import java.rmi.registry.Registry;
   5: import java.rmi.server.UnicastRemoteObject;
   6:         ...
   7:    private int m_port;
   8:    private Registry m_registry;
   9:    private boolean m_running;
  10:         ...
  11:       if (!isRunning()) throw new IllegalStateException("NamingService is not running");
  12:       return m_registry.list();

View Full Code Here
   1: import java.rmi.*;
   2: import java.rmi.registry.*;
   3: import textbender.g.util.logging.LoggerX;
   4:         ...
   5: 
   6:     public static Registry ensureRegistry() throws RemoteException
   7:     {
   8:         ...
   9:         Registry registry = getRegistryOrNull();
  10:         if( registry == null )

View Full Code Here
   1: import java.rmi.server.*;
   2: import java.rmi.registry.*;
   3: import java.util.*;
   4:         ...
   5:                                               implements Remote {
   6:   protected Registry registry;
   7: 
   8:   public void init(ServletConfig config) throws ServletException {
   9:     super.init(config);

View Full Code Here
   1: import java.rmi.server.*;
   2: import java.rmi.registry.*;
   3: import java.util.*;
   4:         ...
   5:                                         implements Remote {
   6:   protected Registry registry;
   7: 
   8:   public void init(ServletConfig config) throws ServletException {
   9:     super.init(config);

View Full Code Here
   1: 
   2: import java.rmi.registry.*;
   3: import java.net.MalformedURLException;
   4:         ...
   5: 
   6:     Registry registry = null;
   7: 
   8:         ...
   9:         try {
  10:         s = registry.list();
  11:         }

View Full Code Here

lookup

public Remote lookup(String name)
            throws RemoteException,
                   NotBoundException,
                   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 - if name is not currently bound
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
NullPointerException - if name is null
Usages and Demos :

View More Examples of lookup(String name)
   1: 
   2: import java.rmi.registry.Registry;
   3:         ...
   4: import java.rmi.registry.LocateRegistry;
   5: 
   6:         ...
   7:       String name = argv[1];
   8:       Registry rmtReg = LocateRegistry.getRegistry(host);
   9:         ...
  10:       AccountManager mgr = (AccountManager)rmtReg.lookup(name);

View Full Code Here
   1: import java.rmi.*;
   2: import java.rmi.registry.*;
   3: import javax.servlet.*;
   4:         ...
   5:     try {
   6:       Registry registry =
   7:         LocateRegistry.getRegistry(getRegistryHost(), getRegistryPort());
   8:         ...
   9:       return (DaytimeServer)registry.lookup(getRegistryName());
  10:     }

View Full Code Here
   1: 
   2: import java.rmi.registry.LocateRegistry;
   3:         ...
   4: import java.rmi.registry.Registry;
   5: 
   6:         ...
   7: 
   8:     Registry reg;
   9:     try {
  10:         ...
  11:     try {
  12:       rhd = (RemoteHostDecl) reg.lookup(REG_NAME);

View Full Code Here
   1: import java.net.URL;
   2: import java.rmi.registry.*;
   3: 
   4:         ...
   5:       Resources rsrc = (org.demo.webwader.Resources)Resources.instance();
   6:       int port = rsrc.get(Browser.REGISTRY_PORT, Registry.REGISTRY_PORT);
   7:         ...
   8:       Registry registry = LocateRegistry.getRegistry(port);
   9: 
  10:         ...
  11:       displayer = (RemoteDisplayer)registry.lookup(Browser.SERVANT);

View Full Code Here
   1: 
   2: import java.rmi.registry.*;
   3: import java.net.MalformedURLException;
   4:         ...
   5: 
   6:     Registry registry = null;
   7: 
   8:         ...
   9: 
  10:         process = (ProcessOp)registry.lookup(Processor.PROCESS);
  11:     }

View Full Code Here

rebind

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 - the name to associate with the remote reference
obj - a reference to a remote object (usually a stub)
Throws:
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
Usages and Demos :

View More Examples of rebind(String name,Remote obj)
   1: 
   2: import java.rmi.registry.LocateRegistry;
   3:         ...
   4: import java.rmi.registry.Registry;
   5: import java.rmi.server.RemoteServer;
   6:         ...
   7: 
   8:     Registry registry = LocateRegistry.getRegistry();
   9:         ...
  10:     registry.rebind( "Adder", stub );

View Full Code Here
   1: 
   2: import java.rmi.registry.Registry;
   3:         ...
   4: import java.rmi.registry.LocateRegistry;
   5: import java.rmi.Remote;
   6:         ...
   7:     private static final String         NAME = "RMI";
   8:     private Registry                    nameService;
   9: 
  10:         ...
  11:         Remote  servant = createServant();
  12:         nameService.rebind(servantName, servant);

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3:         ...
   4: import java.rmi.registry.Registry;
   5: import java.util.HashMap;
   6:         ...
   7:         Integer key = new Integer(port);
   8:         Registry reg = (Registry) registries.get(key);
   9:         if (reg == null)
  10:         ...
  11: 
  12:         reg.rebind(service, provider);

View Full Code Here
   1: import java.rmi.*;
   2: import java.rmi.registry.*;
   3: import java.rmi.server.*;
   4:         ...
   5:   private Map objectMap = Collections.synchronizedMap(new HashMap());
   6:   private int port = Registry.REGISTRY_PORT;
   7:         ...
   8:   private Registry registry;
   9: 
  10:         ...
  11:     logger.debug("RemoteObjImpl: rebind: "+name+":"+this);
  12:     registry.rebind(name, this);

View Full Code Here
   1: import java.rmi.*;
   2: import java.rmi.registry.*;
   3: import java.net.MalformedURLException;
   4:         ...
   5:   {
   6:       int port = resources.get("Registry.port", Registry.REGISTRY_PORT);
   7:         ...
   8:       Registry registry = LocateRegistry.createRegistry(port);
   9: 
  10:         ...
  11:       ToolBox.warn("Process bound to " + url);
  12:       registry.rebind(PROCESS, process);

View Full Code Here

unbind

public void unbind(String name)
            throws RemoteException,
                   NotBoundException,
                   AccessException
Removes the binding for the specified name in this registry.
Parameters:
name - the name of the binding to remove
Throws:
NotBoundException - if name is not currently bound
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
Usages and Demos :

View More Examples of unbind(String name)
   1: 
   2: import java.rmi.registry.Registry;
   3:         ...
   4: import java.rmi.registry.LocateRegistry;
   5: import java.rmi.Remote;
   6:         ...
   7:     private static final String         NAME = "RMI";
   8:     private Registry                    nameService;
   9: 
  10:         ...
  11:     public void shutdown() throws Exception {
  12:         nameService.unbind(servantName);

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3:         ...
   4: import java.rmi.registry.Registry;
   5: import java.rmi.server.UnicastRemoteObject;
   6:         ...
   7:    private int m_port;
   8:    private Registry m_registry;
   9:    private boolean m_running;
  10:         ...
  11:       if (!isRunning()) throw new IllegalStateException("NamingService is not running");
  12:       m_registry.unbind(name);

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3:         ...
   4: import java.rmi.registry.Registry;
   5: import java.util.HashMap;
   6:         ...
   7:         Integer key = new Integer(port);
   8:         Registry reg = (Registry) registries.get(key);
   9:         if (reg == null)
  10:         ...
  11:             {
  12:                 reg.unbind(service);

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3:         ...
   4: import java.rmi.registry.Registry;
   5: import java.rmi.server.RMISocketFactory;
   6:         ...
   7:     private static RMIServer RMIServer = null;
   8:     private static Registry rmiRegistry = null;
   9:     private static final Logger logger = Logger.getLogger(RMIServer.class);
  10:         ...
  11:               RMIServer = null;
  12:               rmiRegistry.unbind(Constants.RMI_SERVICE_SEARCH);

View Full Code Here
   1: import java.rmi.RemoteException;
   2: import java.rmi.registry.LocateRegistry;
   3:         ...
   4: import java.rmi.registry.Registry;
   5: 
   6:         ...
   7:   public static void bind() {
   8:     bind(new Integer(java.rmi.registry.Registry.REGISTRY_PORT));
   9:   }
  10:         ...
  11:       if (reg != null) {
  12:         reg.unbind("FactoryInterface");

View Full Code Here