Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.rmi
Class Naming  view Naming download Naming.java

java.lang.Object
  extended byjava.rmi.Naming

public final class Naming
extends java.lang.Object

The Naming class handles interactions with RMI registries. Each method takes a URL in String form, which points to the RMI registry. The scheme of the URL is irrelevant. The relevant part is:

//host:port/name

which tells the method how to locate and access the registry. The host and port are both optional, and default to `localhost' and the standard RMI registry port (1099) respectively. The name is simply a string used to refer to a particular service hosted by the registry. The registry does not attempt to interpret this further.

RMI services are registered using one of these names, and the same name is later used by the client to lookup the service and access its methods. Registries can be shared by multiple services, or a service can create its own registry using createRegistry().

Since:
1.1

Constructor Summary
private Naming()
          This class isn't intended to be instantiated.
 
Method Summary
static void bind(java.lang.String name, Remote obj)
          Try to bind the given object to the given service name.
private static java.lang.String getName(java.net.URL url)
          Checks that the URL contains a name, and removes any leading slashes.
private static java.rmi.registry.Registry getRegistry(java.net.URL u)
           
static java.lang.String[] list(java.lang.String name)
          Lists all services at the named registry.
static Remote lookup(java.lang.String name)
          Looks for the remote object that is associated with the named service.
private static java.net.URL parseURL(java.lang.String name)
          Parses the supplied URL and converts it to use the HTTP protocol.
static void rebind(java.lang.String name, Remote obj)
          Forces the binding between the given Remote-object and the given service name, even if there was already an object bound to this name.
static void unbind(java.lang.String name)
          Remove a binding for a given service name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Naming

private Naming()
This class isn't intended to be instantiated.

Method Detail

lookup

public static Remote lookup(java.lang.String name)
                     throws NotBoundException,
                            java.net.MalformedURLException,
                            RemoteException
Looks for the remote object that is associated with the named service. Name and location is given in form of a URL without a scheme:
 //host:port/service-name
 
The port is optional.


bind

public static void bind(java.lang.String name,
                        Remote obj)
                 throws AlreadyBoundException,
                        java.net.MalformedURLException,
                        RemoteException
Try to bind the given object to the given service name.


unbind

public static void unbind(java.lang.String name)
                   throws RemoteException,
                          NotBoundException,
                          java.net.MalformedURLException
Remove a binding for a given service name.


rebind

public static void rebind(java.lang.String name,
                          Remote obj)
                   throws RemoteException,
                          java.net.MalformedURLException
Forces the binding between the given Remote-object and the given service name, even if there was already an object bound to this name.


list

public static java.lang.String[] list(java.lang.String name)
                               throws RemoteException,
                                      java.net.MalformedURLException
Lists all services at the named registry.


getRegistry

private static java.rmi.registry.Registry getRegistry(java.net.URL u)
                                               throws RemoteException

parseURL

private static java.net.URL parseURL(java.lang.String name)
                              throws java.net.MalformedURLException
Parses the supplied URL and converts it to use the HTTP protocol. From an RMI perspective, the scheme is irrelevant and we want to be able to create a URL for which a handler is available.


getName

private static java.lang.String getName(java.net.URL url)
                                 throws java.net.MalformedURLException
Checks that the URL contains a name, and removes any leading slashes.