jist.runtime
Class EntityRef

java.lang.Object
  extended by jist.runtime.EntityRef
All Implemented Interfaces:
java.lang.reflect.InvocationHandler
Direct Known Subclasses:
EntityRefDist

public class EntityRef
extends java.lang.Object
implements java.lang.reflect.InvocationHandler

Stores a reference to a (possibly remote) Entity object. A reference consists of a serialized reference to a Controller and an index within that Controller.

Since:
JIST1.0
Version:
$Id: EntityRef.java,v 1.25 2005/03/13 16:11:54 barr Exp $
Author:
Rimon Barr <barr+jist@cs.cornell.edu>

Field Summary
private  int index
          Entity index within Controller.
static EntityRef NULL
          NULL reference constant.
private static java.lang.Boolean RET_BOOLEAN
          boolean type for null return.
private static java.lang.Byte RET_BYTE
          byte type for null return.
private static java.lang.Character RET_CHARACTER
          char type for null return.
private static java.lang.Double RET_DOUBLE
          double type for null return.
private static java.lang.Float RET_FLOAT
          float type for null return.
private static java.lang.Integer RET_INTEGER
          int type for null return.
private static java.lang.Long RET_LONG
          long type for null return.
private static java.lang.Short RET_SHORT
          short type for null return.
 
Constructor Summary
EntityRef(int index)
          Initialise a new entity reference with given Controller and Entity IDs.
 
Method Summary
private  java.lang.Object blockingInvoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          Helper method: called whenever a BLOCKING method on proxy entity reference is invoked.
 boolean equals(java.lang.Object o)
          Test object equality.
 java.lang.Class getClassRef()
          Return class of referenced entity.
 ControllerRemote getController()
          Return controller of referenced entity.
 int getIndex()
          Return index of referenced entity.
 int hashCode()
          Return entity reference hashcode.
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          Called whenever a proxy entity reference is invoked.
 java.lang.String toString()
          Return toString of referenced entity.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL

public static final EntityRef NULL
NULL reference constant.


index

private final int index
Entity index within Controller.


RET_BOOLEAN

private static final java.lang.Boolean RET_BOOLEAN
boolean type for null return.


RET_BYTE

private static final java.lang.Byte RET_BYTE
byte type for null return.


RET_CHARACTER

private static final java.lang.Character RET_CHARACTER
char type for null return.


RET_DOUBLE

private static final java.lang.Double RET_DOUBLE
double type for null return.


RET_FLOAT

private static final java.lang.Float RET_FLOAT
float type for null return.


RET_INTEGER

private static final java.lang.Integer RET_INTEGER
int type for null return.


RET_LONG

private static final java.lang.Long RET_LONG
long type for null return.


RET_SHORT

private static final java.lang.Short RET_SHORT
short type for null return.

Constructor Detail

EntityRef

public EntityRef(int index)
Initialise a new entity reference with given Controller and Entity IDs.

Parameters:
index - entity ID
Method Detail

hashCode

public int hashCode()
Return entity reference hashcode.

Overrides:
hashCode in class java.lang.Object
Returns:
entity reference hashcode

equals

public boolean equals(java.lang.Object o)
Test object equality.

Overrides:
equals in class java.lang.Object
Parameters:
o - object to test equality
Returns:
object equality

getController

public ControllerRemote getController()
Return controller of referenced entity.

Returns:
controller of referenced entity

getIndex

public int getIndex()
Return index of referenced entity.

Returns:
index of referenced entity

toString

public java.lang.String toString()
Return toString of referenced entity.

Overrides:
toString in class java.lang.Object
Returns:
toString of referenced entity

getClassRef

public java.lang.Class getClassRef()
Return class of referenced entity.

Returns:
class of referenced entity

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Called whenever a proxy entity reference is invoked. Schedules the call at the appropriate Controller.

Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Parameters:
proxy - proxy entity reference object whose method was invoked
method - method invoked on entity reference object
args - arguments of the method invocation
Returns:
result of blocking event; null return for non-blocking events
Throws:
java.lang.Throwable - whatever was thrown by blocking events; never for non-blocking events

blockingInvoke

private java.lang.Object blockingInvoke(java.lang.Object proxy,
                                        java.lang.reflect.Method method,
                                        java.lang.Object[] args)
                                 throws java.lang.Throwable
Helper method: called whenever a BLOCKING method on proxy entity reference is invoked. Schedules the call at the appropriate Controller.

Parameters:
proxy - proxy entity reference object whose method was invoked
method - method invoked on entity reference object
args - arguments of the method invocation
Returns:
result of blocking event
Throws:
java.lang.Throwable - whatever was thrown by blocking events