org.xorm
Class InterfaceInvocationHandler

java.lang.Object
  |
  +--org.xorm.ObjectState
        |
        +--org.xorm.InterfaceInvocationHandler
All Implemented Interfaces:
net.sf.cglib.MethodInterceptor

public class InterfaceInvocationHandler
extends org.xorm.ObjectState
implements net.sf.cglib.MethodInterceptor

Handles calls to an interface of the object model. The interface may be defined as a Java interface or a Java abstract class. This class ties the notion of an object with state (ObjectState) with the concept of the XORM Datastore Row.


Field Summary
protected  Object proxy
           
protected  byte status
           
static byte STATUS_DELETED
           
static byte STATUS_DIRTY
           
static byte STATUS_HOLLOW
           
static byte STATUS_NEW
           
static byte STATUS_PERSISTENT
           
static byte STATUS_PERSISTENT_CLEAN
           
static byte STATUS_PERSISTENT_DELETED
           
static byte STATUS_PERSISTENT_DIRTY
           
static byte STATUS_PERSISTENT_NEW
           
static byte STATUS_PERSISTENT_NEW_DELETED
           
static byte STATUS_PERSISTENT_NONTRANSACTIONAL
           
static byte STATUS_TRANSACTIONAL
           
static byte STATUS_TRANSIENT
           
static byte STATUS_TRANSIENT_CLEAN
           
static byte STATUS_TRANSIENT_DIRTY
           
 
Constructor Summary
InterfaceInvocationHandler(InterfaceManagerFactory factory, ClassMapping mapping, Row row)
           
 
Method Summary
 int compareTo(InterfaceInvocationHandler other)
           
 boolean dependsOn(InterfaceInvocationHandler other)
          Returns true if any of the references from this object resolve to the object supplied as a parameter.
 void enterTransaction(TransactionImpl txn)
          This is the only method where the txn field gets set.
 boolean exitTransaction(boolean commit)
           
 ClassMapping getClassMapping()
          The ClassMapping that describes how the proxy data translates into the datastore Row.
static InterfaceInvocationHandler getHandler(Object object)
          Gets the InterfaceInvocationHandler associated with the object.
 org.xorm.InterfaceManager getInterfaceManager()
          The InterfaceManager that is managing this proxy.
 Object getObjectId()
           
 Object getProxy()
           
 Row getRow()
          Initializes or retrieves the working Row.
 byte getStatus()
           
 String getStatusName()
           
 Object intercept(Object proxy, Method method, Object[] args, net.sf.cglib.MethodProxy methodProxy)
          This method is invoked after execution, or in the case of abstract or interface methods, instead of.
 Object invokeGet(String field, ClassMapping returnTypeMapping, Class returnType)
          Returns the object associated with the given field that is of the given return type.
 boolean isDeleted()
           
 boolean isDirty()
           
 boolean isHollow()
           
 boolean isNew()
           
 boolean isPersistent()
           
 boolean isTransactional()
           
 void makeDirty()
           
 void makePersistent(org.xorm.InterfaceManager mgr)
          Marks this object and all the objects it contains as persistent (persistence by reachability).
 void notifyIDChanged(Object oldID, Object newID)
           
 void refresh(org.xorm.InterfaceManager mgr)
           
 void refreshObjectId()
           
 void setDeleted(boolean value)
           
 void setDirty(boolean value)
           
 void setHollow(boolean value)
           
 void setNew(boolean value)
           
 void setPersistent(boolean value)
           
 void setProxy(Object proxy)
           
 void setRow(Row newRow)
          Sets the working Row.
 void setStatus(byte status)
           
 void setTransactional(boolean value)
           
 void snapshot()
          Clones the current backing row for use in case of rollback.
 String toString()
          Returns a debug representation of this handler, in the format [org.xorm.InterfaceInvocationHandler@xxxxxx; interface com.xyz.model.MyClass, primaryKey: {id}, status: PERSISTENT_CLEAN]
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STATUS_TRANSACTIONAL

public static final byte STATUS_TRANSACTIONAL
See Also:
Constant Field Values

STATUS_DIRTY

public static final byte STATUS_DIRTY
See Also:
Constant Field Values

STATUS_PERSISTENT

public static final byte STATUS_PERSISTENT
See Also:
Constant Field Values

STATUS_NEW

public static final byte STATUS_NEW
See Also:
Constant Field Values

STATUS_DELETED

public static final byte STATUS_DELETED
See Also:
Constant Field Values

STATUS_HOLLOW

public static final byte STATUS_HOLLOW
See Also:
Constant Field Values

STATUS_TRANSIENT

public static final byte STATUS_TRANSIENT
See Also:
Constant Field Values

STATUS_TRANSIENT_CLEAN

public static final byte STATUS_TRANSIENT_CLEAN
See Also:
Constant Field Values

STATUS_TRANSIENT_DIRTY

public static final byte STATUS_TRANSIENT_DIRTY
See Also:
Constant Field Values

STATUS_PERSISTENT_NONTRANSACTIONAL

public static final byte STATUS_PERSISTENT_NONTRANSACTIONAL
See Also:
Constant Field Values

STATUS_PERSISTENT_CLEAN

public static final byte STATUS_PERSISTENT_CLEAN
See Also:
Constant Field Values

STATUS_PERSISTENT_DIRTY

public static final byte STATUS_PERSISTENT_DIRTY
See Also:
Constant Field Values

STATUS_PERSISTENT_NEW

public static final byte STATUS_PERSISTENT_NEW
See Also:
Constant Field Values

STATUS_PERSISTENT_DELETED

public static final byte STATUS_PERSISTENT_DELETED
See Also:
Constant Field Values

STATUS_PERSISTENT_NEW_DELETED

public static final byte STATUS_PERSISTENT_NEW_DELETED
See Also:
Constant Field Values

status

protected byte status

proxy

protected Object proxy
Constructor Detail

InterfaceInvocationHandler

public InterfaceInvocationHandler(InterfaceManagerFactory factory,
                                  ClassMapping mapping,
                                  Row row)
Method Detail

getHandler

public static InterfaceInvocationHandler getHandler(Object object)
Gets the InterfaceInvocationHandler associated with the object.


getInterfaceManager

public org.xorm.InterfaceManager getInterfaceManager()
The InterfaceManager that is managing this proxy.


getClassMapping

public ClassMapping getClassMapping()
The ClassMapping that describes how the proxy data translates into the datastore Row.


enterTransaction

public void enterTransaction(TransactionImpl txn)
This is the only method where the txn field gets set. All reachable collection references become transactional under the same transaction. Additionally, persistent-non-transactional objects become persistent-clean.


exitTransaction

public boolean exitTransaction(boolean commit)
Returns:
true if the handler should be detached from the transaction.

makeDirty

public void makeDirty()

makePersistent

public void makePersistent(org.xorm.InterfaceManager mgr)
Marks this object and all the objects it contains as persistent (persistence by reachability). Any newly persistent objects will be inserted into the database when the transaction is committed.


notifyIDChanged

public void notifyIDChanged(Object oldID,
                            Object newID)

compareTo

public int compareTo(InterfaceInvocationHandler other)

dependsOn

public boolean dependsOn(InterfaceInvocationHandler other)
Returns true if any of the references from this object resolve to the object supplied as a parameter.


getObjectId

public Object getObjectId()

refreshObjectId

public void refreshObjectId()

refresh

public void refresh(org.xorm.InterfaceManager mgr)

snapshot

public void snapshot()
Clones the current backing row for use in case of rollback.


getRow

public Row getRow()
Initializes or retrieves the working Row.


setRow

public void setRow(Row newRow)
Sets the working Row.


toString

public String toString()
Returns a debug representation of this handler, in the format [org.xorm.InterfaceInvocationHandler@xxxxxx; interface com.xyz.model.MyClass, primaryKey: {id}, status: PERSISTENT_CLEAN]

Overrides:
toString in class Object

intercept

public Object intercept(Object proxy,
                        Method method,
                        Object[] args,
                        net.sf.cglib.MethodProxy methodProxy)
                 throws Throwable
This method is invoked after execution, or in the case of abstract or interface methods, instead of.

Specified by:
intercept in interface net.sf.cglib.MethodInterceptor
Parameters:
proxy - this
method - Method
args - Arg array
methodProxy - the MethodProxy
Returns:
value to return from generated method
Throws:
Throwable - any exception

invokeGet

public Object invokeGet(String field,
                        ClassMapping returnTypeMapping,
                        Class returnType)
Returns the object associated with the given field that is of the given return type.


getStatusName

public final String getStatusName()

isDirty

public boolean isDirty()

setDirty

public void setDirty(boolean value)

isTransactional

public boolean isTransactional()

setTransactional

public void setTransactional(boolean value)

isPersistent

public boolean isPersistent()

setPersistent

public void setPersistent(boolean value)

isNew

public boolean isNew()

setNew

public void setNew(boolean value)

isDeleted

public boolean isDeleted()

setDeleted

public void setDeleted(boolean value)

isHollow

public boolean isHollow()

setHollow

public void setHollow(boolean value)

setStatus

public void setStatus(byte status)

getStatus

public byte getStatus()

setProxy

public void setProxy(Object proxy)

getProxy

public Object getProxy()


$Header: /cvsroot/xorm/xorm/docs/api/org/xorm/InterfaceInvocationHandler.html,v 1.9 2004/05/30 08:55:03 wbiggs Exp $