CONTENTS | PREV | NEXT Java Remote Method Invocation


9.3 The ObjID Class

The class ObjID is used to identify remote objects uniquely in a virtual machine over time. Each identifier contains an object number and an address space identifier that is unique with respect to a specific host. An object identifier is assigned to a remote object when it is exported.

An ObjID consists of an object number (a long) and a unique identifier for the address space (a UID).

package java.rmi.server;

public final class ObjID implements java.io.Serializable {
	public ObjID ();
	public ObjID (int num);
	public void write(ObjectOutput out) 
                throws java.io.IOException;
	public static ObjID read(ObjectInput in)
		throws java.io.IOException;
	public int hashCode() 
	public boolean equals(Object obj) 
	public String toString()
}
The first form of the ObjID constructor generates a unique object identifier. The second constructor generates well-known object identifiers (such as those used by the registry and the distributed garbage collector) and takes as an argument a well-known object number. A well-known object ID generated via this second constructor will not clash with any object IDs generated via the default constructor; to enforce this, the object number of the ObjID is set to the "well-known" number supplied in the constructor and all UID fields are set to zero.

The method write marshals the object ID's representation to an output stream.

The method read constructs an object ID whose contents is read from the specified input stream.

The method hashCode returns the object number as the hashcode

The equals method returns true if obj is an ObjID with the same contents.

The toString method returns a string containing the object ID representation. The address space identifier is included in the string representation only if the object ID is from a non-local address space.



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