Name

Naming

Synopsis

This is the primary application interface to the naming service within the RMI registry. References to remote objects are obtained with the lookup() method. Local object implementations can be bound to names within the local registry using the bind() and rebind() methods. Locally bound objects can be removed from the name registry using unbind(). All of the names for objects currently stored in the registry can be obtained using the list() method.

Each name argument to the methods on the Naming interface takes the form of a URL, e.g., rmi://remoteHost:port/objName. If a local object is being referenced, and the object is exported to the default registry port, then the URL can simply take the form of the object’s name in the local registry, e.g., objName. This is possible because the rmi: protocol is assumed if it isn’t present in the URL, and the default host is the local host.

Note that, while the lookup() method can reference any remote RMI registry, the bind(), rebind() and unbind() methods can only be called on the local registry. Attempting to call these methods against a remote registry will result in an AccessException being thrown.

public final class Naming {
// No Constructor
                  // Public Class Methods
   public static void bind(String name, 
        Remote obj) throws AlreadyBoundExceptionjava.net.MalformedURLExceptionRemoteException;  
   public static String[] list(
        String name) throws RemoteExceptionjava.net.MalformedURLException;  
   public static Remote lookup( String ...

Get Java Enterprise in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.