com.sptci.prevayler
Class ObjectGraphSystem
java.lang.Object
com.sptci.prevayler.StorageSystem
com.sptci.prevayler.IndexSystem
com.sptci.prevayler.ConstraintSystem
com.sptci.prevayler.SearchSystem
com.sptci.prevayler.ObjectGraphSystem
- All Implemented Interfaces:
- AbstractDatabase<PrevalentObject>, DatabaseSystem, Serializable
- Direct Known Subclasses:
- PrevalentSystem
abstract class ObjectGraphSystem
- extends SearchSystem
Abstracts all the code for decomposing and reconstituting object graphs
for the prevalent system. Due to the inherent limitations in object
serialisation, this step is necessary to ensure that de-serialised objects
contain proper references to other prevalent objects and not local copies.
© Copyright 2008 Sans
Pareil Technologies, Inc.
- Version:
- $Id: ObjectGraphSystem.java 22 2008-11-24 19:04:25Z sptrakesh $
- Author:
- Rakesh Vidyadharan 2008-05-23
|
Method Summary |
protected PrevalentObject |
compose(PrevalentObject object)
Create a clone of the specified prevalent object and reconstitute object
references to other prevalent objects. |
protected PrevalentObject |
decompose(PrevalentObject object,
Date executionTime)
Clone the specified object and decouple references to other prevalent
object to make suitable for storage in the prevalent system. |
private void |
decomposeCollection(PrevalentObject object,
Field field,
Date executionTime)
Decompose a collection or references to other prevalent objects in the
prevalent object being managed. |
private void |
decomposeObject(PrevalentObject object,
Field field,
Date executionTime)
Decompose a direct reference represented by the specified field in the
prevalent object. |
private void |
populateReference(PrevalentObject object)
Populate the references to other prevalent objects in the specified
prevalent object. |
protected void |
update(Field field,
PrevalentObject object,
Date executionTime)
Replace the prevalent object in the field specified from the specified
object prevalent object to the po object
that exists in the system. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
ObjectGraphSystem
ObjectGraphSystem()
compose
protected PrevalentObject compose(PrevalentObject object)
throws PrevalentException
- Create a clone of the specified prevalent object and reconstitute object
references to other prevalent objects. Reads in the references from
StorageSystem.referenceMap and reconstitutes the references. Recursively
invokes this method on prevalent objects to ensure that the entire
object graph is replicated.
- Parameters:
object - The object that is to be cloned and reconstituted.
- Returns:
- The reconstituted prevalent object that represents a persisted
prevalent object.
- Throws:
PrevalentException - If errors are encountered while reconsituting
the prevalent object.- See Also:
populateReference(com.sptci.prevayler.PrevalentObject)
populateReference
private void populateReference(PrevalentObject object)
throws PrevalentException,
IllegalAccessException
- Populate the references to other prevalent objects in the specified
prevalent object.
- Parameters:
object - The prevalent object that is being reconstituted.
- Throws:
PrevalentException - If errors are encountered while fetching
the references to the other prevalent objects.
IllegalAccessException - If errors are encountered while setting
the field values.
decompose
protected PrevalentObject decompose(PrevalentObject object,
Date executionTime)
throws PrevalentException
- Clone the specified object and decouple references to other prevalent
object to make suitable for storage in the prevalent system. Updates
StorageSystem.referenceMap with references that are decomposed.
If a referenced persistent object is not yet persistent, then it is
made persistent following persistence by reachability principle. This
addition is affected by invoked SearchSystem.save(com.sptci.prevayler.PrevalentObject, org.apache.lucene.document.Document) on the referenced object
resulting in persisting the entire object graph through reachability.
- Parameters:
object - The object that is to be cloned and decoupled.executionTime - The datetime at which the transaction was executed.
- Returns:
- The decomposed prevalent object.
- Throws:
PrevalentException - If errors are encountered while processing
the class fields.- See Also:
AbstractDatabase.fetch( Class, Object )
decomposeObject
private void decomposeObject(PrevalentObject object,
Field field,
Date executionTime)
throws PrevalentException
- Decompose a direct reference represented by the specified field in the
prevalent object.
- Parameters:
object - The prevalent object to decompose.field - The field that contains a direct reference to another
prevalent object.executionTime - The datetime at which the transaction was executed.
- Throws:
PrevalentException - If errors are encountered while accessing
the field.
decomposeCollection
private void decomposeCollection(PrevalentObject object,
Field field,
Date executionTime)
throws PrevalentException
- Decompose a collection or references to other prevalent objects in the
prevalent object being managed.
- Parameters:
object - The prevalent object that is to be decomposed prior to
storage in the system.field - The field that contains a collection of references to other
prevalent objects.executionTime - The datetime at which the transaction was executed.
- Throws:
PrevalentException - If errors are encountered while fetching the
fields of the prevalent object.
update
protected void update(Field field,
PrevalentObject object,
Date executionTime)
throws PrevalentException
- Replace the prevalent object in the field specified from the specified
object prevalent object to the po object
that exists in the system.
- Parameters:
field - The field whose value is being updated.object - The prevalent object that is being updated.executionTime - The datetime at which the transaction was executed.
- Throws:
ConstraintException - If the field is marked as unique and the
newObject specified is already associated with another prevalent
object of the same type.
PrevalentException - If errors are encountered while setting
the value of the field.- See Also:
ConstraintSystem.checkUnique(com.sptci.prevayler.PrevalentObject)