edu.rit.m2mi
Class Omnihandle

java.lang.Object
  extended by edu.rit.m2mi.Handle
      extended by edu.rit.m2mi.Omnihandle
All Implemented Interfaces:
Externalizable, Serializable

public class Omnihandle
extends Handle

Class Omnihandle is the base class for all M2MI omnihandle objects. An actual omnihandle class is a synthesized subclass of class Omnihandle which implements the handle's target interface. Calling a target interface method on an omnihandle object causes M2MI invocations to be performed on the target object or objects to which the omnihandle refers, namely all objects that have been exported as the omnihandle's target interface or a subinterface thereof.

While instances of class Omnihandle can be constructed, this is intended only for use during object serialization. When a synthesized omnihandle is serialized into an object output stream, the synthesized omnihandle replaces itself in the stream with an instance of class Omnihandle containing the same EOID and target interface. When an instance of class Omnihandle is deserialized from an object input stream, the omnihandle synthesizes the proper subclass, creates an instance of the synthesized subclass containing the same EOID and target interface, and replaces itself with the subclass instance. In this way omnihandle objects can be transported across the network without needing to transport the synthesized subclasses.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.rit.m2mi.Handle
myEoid, myInvocationFactory, myTargetInterface
 
Constructor Summary
Omnihandle()
          Construct a new omnihandle.
Omnihandle(Eoid theEoid, Class theTargetInterface)
          Construct a new omnihandle with the given EOID and target interface.
 
Method Summary
 boolean equals(Object theObject)
          Determine if this omnihandle is equal to the given object.
 int hashCode()
          Returns a hash code for this omnihandle.
 boolean invokes(Object theObject)
          Determine if a method invocation on this omnihandle will be executed by the given object.
 Iterator iterator()
          Obtain an iterator for visiting the objects associated with this omnihandle.
 void readExternal(ObjectInput theObjectInput)
          Read this omnihandle from the given object input stream.
 String toString()
          Returns a string version of this omnihandle.
 void writeExternal(ObjectOutput theObjectOutput)
          Write this omnihandle to the given object output stream.
 
Methods inherited from class edu.rit.m2mi.Handle
getEoid, getInterface, getInterfaceName, isExportedEoid, isExportedInterface, iteratorEoid, iteratorInterface, setEoid, setInvocationFactory, setTargetInterface
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Omnihandle

public Omnihandle()
Construct a new omnihandle. The EOID, target interface, and invocation factory are initially null.


Omnihandle

public Omnihandle(Eoid theEoid,
                  Class theTargetInterface)
Construct a new omnihandle with the given EOID and target interface. The invocation factory is initially null.

Parameters:
theEoid - EOID.
theTargetInterface - Target interface.
Method Detail

invokes

public boolean invokes(Object theObject)
Determine if a method invocation on this omnihandle will be executed by the given object. Specifically, the following must all be true:
  1. theObject is not null.
  2. theObject is exported.
  3. One of the target interfaces with which theObject is exported is this omnihandle's target interface or a subinterface thereof.

Specified by:
invokes in class Handle
Parameters:
theObject - Object to test.
Returns:
True if a method invocation on this omnihandle will be executed by theObject, false otherwise.

iterator

public Iterator iterator()
Obtain an iterator for visiting the objects associated with this omnihandle. The returned iterator visits the objects, if any, in the local process that would be invoked by calling a method on this omnihandle. The iterator() method takes a "snapshot" of the associated objects at the time it is called, and returns an iterator for the snapshot. Subsequently exporting or unexporting objects will have no effect on the returned iterator.

Specified by:
iterator in class Handle
Returns:
Iterator.

writeExternal

public void writeExternal(ObjectOutput theObjectOutput)
                   throws IOException
Write this omnihandle to the given object output stream.

Specified by:
writeExternal in interface Externalizable
Overrides:
writeExternal in class Handle
Parameters:
theObjectOutput - Object output stream.
Throws:
IOException - Thrown if an I/O error occurred.

readExternal

public void readExternal(ObjectInput theObjectInput)
                  throws ClassNotFoundException,
                         IOException
Read this omnihandle from the given object input stream. It assumes the stream was written by writeExternal().

Specified by:
readExternal in interface Externalizable
Overrides:
readExternal in class Handle
Parameters:
theObjectInput - Object input stream.
Throws:
ClassNotFoundException - Thrown if the class for an object being deserialized cannot be found.
IOException - Thrown if an I/O error occurred.

equals

public boolean equals(Object theObject)
Determine if this omnihandle is equal to the given object. To be equal, the given object must be an instance of interface Omnihandle with the same target interface as this omnihandle.

Overrides:
equals in class Object
Parameters:
theObject - Object to test.
Returns:
True if this omnihandle is equal to theObject, false otherwise.

hashCode

public int hashCode()
Returns a hash code for this omnihandle.

Overrides:
hashCode in class Object

toString

public String toString()
Returns a string version of this omnihandle.

Overrides:
toString in class Object


Copyright © 2001-2006 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.