edu.rit.m2mi
Class Handle

java.lang.Object
  extended by edu.rit.m2mi.Handle
All Implemented Interfaces:
Externalizable, Serializable
Direct Known Subclasses:
Multihandle, Omnihandle, Unihandle

public abstract class Handle
extends Object
implements Externalizable

Class Handle is the abstract base class for all M2MI handle objects. There are three subclasses corresponding to the three kinds of handles: class Omnihandle, class Unihandle, and class Multihandle. An actual handle class is a synthesized subclass of one of those three subclasses which implements the handle's target interface. Calling a target interface method on a handle object causes M2MI invocations to be performed on the target object or objects to which the handle refers.

See Also:
Serialized Form

Field Summary
protected  Eoid myEoid
          Exported object identifier (EOID).
protected  InvocationFactory myInvocationFactory
          Invocation factory.
protected  Class myTargetInterface
          Target interface.
 
Constructor Summary
Handle()
          Construct a new handle.
 
Method Summary
 Eoid getEoid()
          Returns this handle's exported object identifier (EOID).
 Class getInterface()
          Returns this handle's target interface.
 String getInterfaceName()
          Returns this handle's target interface name.
abstract  boolean invokes(Object theObject)
          Determine if a method invocation on this handle will be executed by the given object.
protected  boolean isExportedEoid(Object theObject)
          Determine if the given object is exported with this handle's EOID in the M2MI Layer.
protected  boolean isExportedInterface(Object theObject)
          Determine if the given object is exported with this handle's target interface in the M2MI layer.
abstract  Iterator iterator()
          Obtain an iterator for visiting the objects associated with this handle.
protected  Iterator iteratorEoid()
          Obtain an iterator for visiting the objects associated with this handle's EOID.
protected  Iterator iteratorInterface()
          Obtain an iterator for visiting the objects associated with this handle's target interface.
 void readExternal(ObjectInput theObjectInput)
          Read this handle from the given object input stream.
protected  void setEoid(Eoid theEoid)
          Set this handle's EOID.
protected  void setInvocationFactory(InvocationFactory theInvocationFactory)
          Set this handle's invocation factory.
protected  void setTargetInterface(Class theTargetInterface)
          Set this handle's target interface.
 void writeExternal(ObjectOutput theObjectOutput)
          Write this handle to the given object output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myEoid

protected Eoid myEoid
Exported object identifier (EOID).


myTargetInterface

protected Class myTargetInterface
Target interface.


myInvocationFactory

protected InvocationFactory myInvocationFactory
Invocation factory.

Constructor Detail

Handle

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

Method Detail

getEoid

public Eoid getEoid()
Returns this handle's exported object identifier (EOID).

Returns:
EOID.

getInterface

public Class getInterface()
Returns this handle's target interface. This handle implements the target interface and (implicitly) all superinterfaces thereof.

Returns:
Target interface.

getInterfaceName

public String getInterfaceName()
Returns this handle's target interface name.

Returns:
Fully-qualified name of the target interface.

invokes

public abstract boolean invokes(Object theObject)
Determine if a method invocation on this handle will be executed by the given object. The exact criterion depends on what kind of handle this is. See Omnihandle.invokes(), Unihandle.invokes(), or Multihandle.invokes() for further information.

Parameters:
theObject - Object to test.
Returns:
True if a method invocation on this handle will be executed by theObject, false otherwise.
Throws:
IllegalStateException - (unchecked exception) Thrown if the M2MI Layer is not initialized.

iterator

public abstract Iterator iterator()
Obtain an iterator for visiting the objects associated with this handle. The returned iterator visits the objects, if any, in the local process that would be invoked by calling a method on this handle. 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.

Returns:
Iterator.

writeExternal

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

Specified by:
writeExternal in interface Externalizable
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 handle from the given object input stream. It assumes the stream was written by writeExternal().

Specified by:
readExternal in interface Externalizable
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.

setEoid

protected void setEoid(Eoid theEoid)
Set this handle's EOID.

Parameters:
theEoid - EOID.

setTargetInterface

protected void setTargetInterface(Class theTargetInterface)
Set this handle's target interface.

Parameters:
theTargetInterface - Target interface.

setInvocationFactory

protected void setInvocationFactory(InvocationFactory theInvocationFactory)
Set this handle's invocation factory.

Parameters:
theInvocationFactory - Invocation factory.

isExportedEoid

protected boolean isExportedEoid(Object theObject)
Determine if the given object is exported with this handle's EOID in the M2MI Layer.

Parameters:
theObject - Object to test.
Returns:
True if theObject is exported with this handle's EOID, false otherwise.
Throws:
IllegalStateException - (unchecked exception) Thrown if the M2MI Layer is not initialized.

isExportedInterface

protected boolean isExportedInterface(Object theObject)
Determine if the given object is exported with this handle's target interface in the M2MI layer.

Parameters:
theObject - Object to test.
Returns:
True if theObject is exported with this handle's target interface, false otherwise.
Throws:
IllegalStateException - (unchecked exception) Thrown if the M2MI Layer is not initialized.

iteratorEoid

protected Iterator iteratorEoid()
Obtain an iterator for visiting the objects associated with this handle's EOID. The returned iterator visits the objects, if any, in the local process associated with this handle's EOID. 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.

Returns:
Iterator.

iteratorInterface

protected Iterator iteratorInterface()
Obtain an iterator for visiting the objects associated with this handle's target interface. The returned iterator visits the objects, if any, in the local process associated with this handle's target interface. 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.

Returns:
Iterator.


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