java.rmi
Class Naming

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.rmi.Naming

public final class Naming
extends Object sample code for java.lang.Object definition code for java.lang.Object

The Naming class provides methods for storing and obtaining references to remote objects in a remote object registry. Each method of the Naming class takes as one of its arguments a name that is a java.lang.String in URL format (without the scheme component) of the form:

    //host:port/name
 

where host is the host (remote or local) where the registry is located, port is the port number on which the registry accepts calls, and where name is a simple string uninterpreted by the registry. Both host and port are optional. If host is omitted, the host defaults to the local host. If port is omitted, then the port defaults to 1099, the "well-known" port that RMI's registry, rmiregistry, uses.

Binding a name for a remote object is associating or registering a name for a remote object that can be used at a later time to look up that remote object. A remote object can be associated with a name using the Naming class's bind or rebind methods.

Once a remote object is registered (bound) with the RMI registry on the local host, callers on a remote (or local) host can lookup the remote object by name, obtain its reference, and then invoke remote methods on the object. A registry may be shared by all servers running on a host or an individual server process may create and use its own registry if desired (see java.rmi.registry.LocateRegistry.createRegistry method for details).

Since:
JDK1.1
See Also:
Registry sample code for java.rmi.registry.Registry definition code for java.rmi.registry.Registry , LocateRegistry sample code for java.rmi.registry.LocateRegistry definition code for java.rmi.registry.LocateRegistry , LocateRegistry.createRegistry(int) sample code for java.rmi.registry.LocateRegistry.createRegistry(int) definition code for java.rmi.registry.LocateRegistry.createRegistry(int)

Method Summary
static void bind sample code for java.rmi.Naming.bind(java.lang.String, java.rmi.Remote) definition code for java.rmi.Naming.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 the specified name to a remote object.
static String sample code for java.lang.String definition code for java.lang.String [] list sample code for java.rmi.Naming.list(java.lang.String) definition code for java.rmi.Naming.list(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  name)
          Returns an array of the names bound in the registry.
static Remote sample code for java.rmi.Remote definition code for java.rmi.Remote lookup sample code for java.rmi.Naming.lookup(java.lang.String) definition code for java.rmi.Naming.lookup(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  name)
          Returns a reference, a stub, for the remote object associated with the specified name.
static void rebind sample code for java.rmi.Naming.rebind(java.lang.String, java.rmi.Remote) definition code for java.rmi.Naming.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)
          Rebinds the specified name to a new remote object.
static void unbind sample code for java.rmi.Naming.unbind(java.lang.String) definition code for java.rmi.Naming.unbind(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  name)
          Destroys the binding for the specified name that is associated with a remote object.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Method Detail

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

public static 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 NotBoundException sample code for java.rmi.NotBoundException definition code for java.rmi.NotBoundException ,
                            MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException ,
                            RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException 
Returns a reference, a stub, for the remote object associated with the specified name.

Parameters:
name - a name in URL format (without the scheme component)
Returns:
a reference for 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 registry could not be contacted
AccessException sample code for java.rmi.AccessException definition code for java.rmi.AccessException - if this operation is not permitted
MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException - if the name is not an appropriately formatted URL
Since:
JDK1.1

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

public static 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 AlreadyBoundException sample code for java.rmi.AlreadyBoundException definition code for java.rmi.AlreadyBoundException ,
                        MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException ,
                        RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException 
Binds the specified name to a remote object.

Parameters:
name - a name in URL format (without the scheme component)
obj - a reference for the remote object (usually a stub)
Throws:
AlreadyBoundException sample code for java.rmi.AlreadyBoundException definition code for java.rmi.AlreadyBoundException - if name is already bound
MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException - if the name is not an appropriately formatted URL
RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException - if registry could not be contacted
AccessException sample code for java.rmi.AccessException definition code for java.rmi.AccessException - if this operation is not permitted (if originating from a non-local host, for example)
Since:
JDK1.1

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

public static 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 ,
                          MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException 
Destroys the binding for the specified name that is associated with a remote object.

Parameters:
name - a name in URL format (without the scheme component)
Throws:
NotBoundException sample code for java.rmi.NotBoundException definition code for java.rmi.NotBoundException - if name is not currently bound
MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException - if the name is not an appropriately formatted URL
RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException - if registry could not be contacted
AccessException sample code for java.rmi.AccessException definition code for java.rmi.AccessException - if this operation is not permitted (if originating from a non-local host, for example)
Since:
JDK1.1

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

public static 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 ,
                          MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException 
Rebinds the specified name to a new remote object. Any existing binding for the name is replaced.

Parameters:
name - a name in URL format (without the scheme component)
obj - new remote object to associate with the name
Throws:
MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException - if the name is not an appropriately formatted URL
RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException - if registry could not be contacted
AccessException sample code for java.rmi.AccessException definition code for java.rmi.AccessException - if this operation is not permitted (if originating from a non-local host, for example)
Since:
JDK1.1

list sample code for java.rmi.Naming.list(java.lang.String) definition code for java.rmi.Naming.list(java.lang.String)

public static String sample code for java.lang.String definition code for java.lang.String [] list(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 ,
                            MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException 
Returns an array of the names bound in the registry. The names are URL-formatted (without the scheme component) strings. The array contains a snapshot of the names present in the registry at the time of the call.

Parameters:
name - a registry name in URL format (without the scheme component)
Returns:
an array of names (in the appropriate format) bound in the registry
Throws:
MalformedURLException sample code for java.net.MalformedURLException definition code for java.net.MalformedURLException - if the name is not an appropriately formatted URL
RemoteException sample code for java.rmi.RemoteException definition code for java.rmi.RemoteException - if registry could not be contacted.
Since:
JDK1.1