Topics:
package java.rmi;
public interface Remote {}
Remote interface serves to identify all remote objects, any object that is a remote object must directly or indirectly implement this interface.
java.rmi.RemoteException. This allows interfaces to handle all types of remote exceptions and to distinguish local exceptions and exceptions specific to the method from exceptions thrown by the underlying distributed object mechanisms.
package java.rmi;
public class RemoteException
extends java.lang.Exception
{
public RemoteException(String s);
public RemoteException(String s, Exception e);
}
java.lang.Object behavior for remote objects. The hashCode and equals methods are implemented to allow remote object references to be stored in hashtables and compared. The equals method returns true if two Remote objects refer to the same remote object. It compares the remote object references of the remote objects.The
toString method returns a string describing the remote object. The contents and syntax of this string is implementation specific and may vary.All of the other methods of
java.lang.Object retain their original implementations.
package java.rmi.server;
public abstract class RemoteObject
implements Remote
{
public int hashCode();
public boolean equals(Object obj);
public String toString();
}
RemoteStub class is the common superclass to all client stubs and provides the framework to support a wide range of remote reference semantics.
package java.rmi.server;
public abstract class RemoteStub extends RemoteObject {}
Naming interface allows remote objects to be retrieved and defined using the familiar Uniform Resource Locator (URL) syntax. The URL consists of protocol, host, port and name fields. The Registry service on the specified host and port is used to perform the specified operation. The protocol should be specified as rmi, as in rmi://java.sun.com:2001/root.
package java.rmi;
public class Naming {
public static Remote lookup(String url)
throws RemoteException, NotBoundException,
AccessException, UnknownHostException;
public static void bind(String url, Remote obj)
throws RemoteException, AlreadyBoundException,
AccessException, UnknownHostException;
public static void rebind(String url, Remote obj)
throws RemoteException, AccessException,
UnknownHostException;
public static void unbind(String url)
throws RemoteException, NotBoundException,
AccessException, UnknownHostException;
public static String[] list(String url)
throws RemoteException, AccessException,
UnknownHostException;
}
lookup method returns the Remote interface associated with the file portion of the name; so in the preceding example it would return the object named root. The NotBoundException is thrown if the name has not been bound to an object.The
bind method binds the specified name to the remote object. It throws the AlreadyBoundException if the name is already bound to an object.The
rebind method always binds the name to the object even if the name is already bound. The old binding is lost.The
unbind method removes the binding between the name and the remote object. It will throw the NotBoundException if there was no binding.The
list method returns an array of Strings containing a snapshot of the URLs bound in the Registry. The file part of the URL is ignored.
java.rmi.AlreadyBoundException - a name is already bound
java.rmi.NotBoundException - a name is not bound
java.rmi.RemoteException - superclass of all exceptions from the RMI runtime
java.rmi.StubNotFoundException - the stub for a class could not be found
java.rmi.StubSecurityException - a class violated that stub restrictions
java.rmi.NoSuchObjectException - an object reference is invalid or obsolete
java.rmi.UnknownHostException - a host cannot be found