CONTENTS | PREV | NEXT Java Remote Method Invocation


5.1 The RemoteObject Class

The java.rmi.server.RemoteObject class implements the 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 can vary.

All of the other methods of java.lang.Object retain their original implementations.

package java.rmi.server;
public abstract class RemoteObject
	implements java.rmi.Remote, java.io.Serializable
{
	protected RemoteObject();
	protected RemoteObject(RemoteRef ref);
	public RemoteRef getRef();


	public static Remote toStub(java.rmi.Remote obj)
		throws java.rmi.NoSuchObjectException;

	public int hashCode();
	public boolean equals(Object obj);
	public String toString();
}


Since the RemoteObject class is abstract, it cannot be instantiated. Therefore, one of RemoteObject's constructors must be called from a subclass implementation. The first RemoteObject constructor creates a RemoteObject with a null remote reference. The second RemoteObject constructor creates a RemoteObject with the given remote reference, ref.

The getRef method returns the remote reference for the remote object.

The toStub method returns a stub for the remote object, obj, passes as a parameter. This operation is only valid after the remote object implementation has been exported. If the stub for the remote object could not be found, then the method throws NoSuchObjectException.



CONTENTS | PREV | NEXT
Copyright © 1997-1998 Sun Microsystems, Inc. All Rights Reserved.