| java.lang.Object hu.netmind.persistence.ObjectTracker
ObjectTracker | public class ObjectTracker implements TransactionListener,WeakMapListener(Code) | | This class tracks objects' ids and values for different transactions.
Basically this tracker can answer questions about the state of a
previously registered object.
author: Brautigam Robert version: Revision: $Revision$ |
Inner Class :public class ObjectData implements Comparable | |
Inner Class :public class SharedData | |
Inner Class :public class ObjectWrapper | |
Method Summary | |
public boolean | equals(Object o1, Object o2) Determines, whether two objects are of the same database instance.
Two objects are the same, if their ids equal. | public boolean | exists(Object obj) Determine whether an object exists.
True, if object exists in store. | public Object | getAttributeValue(Object obj, String attributeName) Return the attribute's last known value. | public long | getIdentifier(Object obj) Get the identifier for a given object.
Parameters: obj - The object to identify. | public PersistenceMetaData | getMetaData(Object obj) Get the meta data associated with the object. | public ObjectData | getObjectData(Object obj) Get the data structure for an object. | public static Object | getTypeValue(Object value, Class attrClass) Convert a value of a type to a given target type. | public ObjectWrapper | getWrapper(Object obj) Get an object wrapper for an object which disregards object's
own equals() and hashCode() methods. | public boolean | hasChanged(ClassInfo info, Object obj, String attributeName, Map dbAttributes) Return whether a given attribute of a given object changed. | public void | makeExist(Object obj) Mark object as existent. | public void | makeUnexist(Object obj) Mark an object as non-existent. | public void | notifyValueLeave(Object id) Called when an object leaves the weak map. | public void | registerObject(Object obj, long id) Register an object into the tracker. | public void | transactionCommited(Transaction transaction) Called, when transaction tracker commits a transaction successfully. | public void | transactionRolledback(Transaction transaction) Called, when transaction tracker rolls back a transaction successfully. | public void | updateAttribute(Object obj, String identifier, Object value) Update a single attribute. | public void | updateObject(Object obj, Map changes) Update the attribute's known values with those given. |
equals | public boolean equals(Object o1, Object o2)(Code) | | Determines, whether two objects are of the same database instance.
Two objects are the same, if their ids equal. Note however, that
they do not need to contain the same values, or be of same version!
|
exists | public boolean exists(Object obj)(Code) | | Determine whether an object exists.
True, if object exists in store. This means that searcheswill return the object. If this is false, the object cannot befound yet. |
getAttributeValue | public Object getAttributeValue(Object obj, String attributeName)(Code) | | Return the attribute's last known value. The last known value is
determined as follows: If the value changed during current transaction,
the new value is returned, or else the last known saved value is
returned. That means, if a transaction currently changes this
attribute, another transaction will see the old value until the
first transaction commits.
|
getIdentifier | public long getIdentifier(Object obj)(Code) | | Get the identifier for a given object.
Parameters: obj - The object to identify. The identifier, or 0 if the object is not registered. |
getObjectData | public ObjectData getObjectData(Object obj)(Code) | | Get the data structure for an object.
|
getTypeValue | public static Object getTypeValue(Object value, Class attrClass)(Code) | | Convert a value of a type to a given target type.
|
getWrapper | public ObjectWrapper getWrapper(Object obj)(Code) | | Get an object wrapper for an object which disregards object's
own equals() and hashCode() methods.
|
hasChanged | public boolean hasChanged(ClassInfo info, Object obj, String attributeName, Map dbAttributes)(Code) | | Return whether a given attribute of a given object changed.
|
makeExist | public void makeExist(Object obj)(Code) | | Mark object as existent. If this is inside a transaction,
the existence will only be permanent, if object is saved inside
the transaction.
|
makeUnexist | public void makeUnexist(Object obj)(Code) | | Mark an object as non-existent. This happens, if the object gets
deleted, but there are some object instances that are used.
|
notifyValueLeave | public void notifyValueLeave(Object id)(Code) | | Called when an object leaves the weak map. Note: This is thread-safe
because it is called from WeakMap, which is handled safely in this
class.
|
registerObject | public void registerObject(Object obj, long id)(Code) | | Register an object into the tracker. This means, the object will
get an id, and associated tracking data structure will be allocated.
Parameters: obj - The object to register. Parameters: id - The id of object. If this is given (not 0), the object is assumed to exist. |
transactionCommited | public void transactionCommited(Transaction transaction)(Code) | | Called, when transaction tracker commits a transaction successfully.
This tracker uses it to set object to exists and not exists state.
Parameters: transaction - The transaction which committed. |
transactionRolledback | public void transactionRolledback(Transaction transaction)(Code) | | Called, when transaction tracker rolls back a transaction successfully.
Parameters: transaction - The transaction which rolled back. |
updateAttribute | public void updateAttribute(Object obj, String identifier, Object value)(Code) | | Update a single attribute. This method simply calls updateObject() .
|
updateObject | public void updateObject(Object obj, Map changes)(Code) | | Update the attribute's known values with those given. Note, that
this method will first make the changes only in current transaction,
and only publish them when the current transaction commits.
|
|
|