|
SPT Object Database API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sptci.prevayler.StorageSystem
com.sptci.prevayler.IndexSystem
com.sptci.prevayler.ConstraintSystem
com.sptci.prevayler.SearchSystem
com.sptci.prevayler.ObjectGraphSystem
com.sptci.prevayler.PrevalentSystem
public class PrevalentSystem
A base class for prevalent systems that will be managed by Prevayler and
wrapped in a Prevayler instance. This class may
be sub-classed to extend features or customise the implementation of the
various methods used to implement the rules of the database engine. We
hope that you will not need to sub-class this instance.
Note that all the methods provided by this class ensure encapsulation of the data stored in the prevalent system. All objects stored are clones of the prevalent objects passed in, and all prevalent object instances returned by transactional or query methods are clones of the instances stored in the system. This does increase the memory footprint of the system, however it is more critical to preserve encapsulation of data. To improve performance client code may utilise various caching products to cache the results of query execution to reduce the number of copies of the prevalent objects in the JVM heap space.
.© Copyright 2008 Sans Pareil Technologies, Inc.
PrevalentSystemFactory,
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class com.sptci.prevayler.StorageSystem |
|---|
StorageSystem.TaskQueue |
| Field Summary | |
|---|---|
private static String |
META_DATA
The name of the meta data field in PrevalentObject. |
private static String |
OBJECT_ID
The name of the object id field in PrevalentObject. |
private static long |
serialVersionUID
|
| Fields inherited from class com.sptci.prevayler.SearchSystem |
|---|
CLASS_FIELD, DOCUMENT_ID_FIELD, OBJECT_ID_FIELD, reader, SAVE_COUNT, searcher, SEPARATOR_CHAR, writer |
| Fields inherited from class com.sptci.prevayler.StorageSystem |
|---|
logger |
| Constructor Summary | |
|---|---|
protected |
PrevalentSystem()
Default constructor. |
| Method Summary | |
|---|---|
protected PrevalentObject |
add(PrevalentObject object,
Date executionTime)
Add a new prevalent object to the prevalent system. |
int |
count(Class cls)
Return the total number of instances of the specified type in the prevalent system. |
PrevalentObject |
delete(PrevalentObject object,
Date executionTime)
Delete the specified prevalent object from the prevalent system. |
Collection<PrevalentObject> |
fetch(Class cls,
long start,
long end)
Fetch the prevalent objects in the specified range of data. |
PrevalentObject |
fetch(Class cls,
Object oid)
Fetch the prevalent object of the specified type with the specified object id from the prevalent system. |
Collection<PrevalentObject> |
fetch(Class cls,
String field,
Object object)
Fetch the prevalent object(s) of the specified cls type
which has the specified object as the value of the specified
field. |
Collection<PrevalentObject> |
fetchIntersection(Class cls,
Map<String,?> parameters)
Fetch the prevalent object(s) of the specified cls type
which has the specified indexed field values. |
Collection<PrevalentObject> |
fetchUnion(Class cls,
Map<String,?> parameters)
Fetch the prevalent object(s) of the specified cls type
which has the specified indexed field values. |
PrevalentObject |
save(PrevalentObject object,
Date executionTime)
Save the specified prevalent object to the prevalent system. |
Collection<PrevalentObject> |
search(org.apache.lucene.search.Query query,
org.apache.lucene.search.Filter filter,
int count,
org.apache.lucene.search.Sort sort)
Execute the specified lucene query and return the collection of matching prevalent objects. |
protected void |
setOid(PrevalentObject object)
Set the PrevalentObject.objectId field to a new value if
not already set. |
protected PrevalentObject |
update(PrevalentObject object,
Date executionTime)
Update the specified prevalent object in the prevalent system. |
protected void |
updateOrdinaryField(PrevalentObject prevalentObject,
Field field,
Object source,
Object destination)
Update an ordinary field (non prevalent object or collection). |
| Methods inherited from class com.sptci.prevayler.ObjectGraphSystem |
|---|
compose, decompose, update |
| Methods inherited from class com.sptci.prevayler.SearchSystem |
|---|
index, remove, search |
| Methods inherited from class com.sptci.prevayler.ConstraintSystem |
|---|
checkFields, checkUnique, checkUnique, indexClass, indexFields, preAdd, preDelete, preDelete |
| Methods inherited from class com.sptci.prevayler.StorageSystem |
|---|
generateOid, getIndexStorage, getIndexStorage, getPrimaryStorage, getPrimaryStorage, getReferenceStorage, getReferenceStorage, getRelationStorage, getRelationStorage, getTaskQueue |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final long serialVersionUID
private static final String OBJECT_ID
PrevalentObject.
private static final String META_DATA
PrevalentObject.
| Constructor Detail |
|---|
protected PrevalentSystem()
| Method Detail |
|---|
public PrevalentObject save(PrevalentObject object,
Date executionTime)
throws PrevalentException
object - The prevalent object to be saved in the system.executionTime - The time at which the transaction was executed.
PrevalentException - If errors are encountered while
adding/updating the object. Errors thrown could indicate constraint
violations.
public PrevalentObject delete(PrevalentObject object,
Date executionTime)
throws PrevalentException
object - The prevalent object to delete.executionTime - The datetime at which the transaction was executed.
PrevalentException - If errors are encountered while deleting the
prevalent object.public int count(Class cls)
cls - The type of the prevalent object whose count is desired.
public PrevalentObject fetch(Class cls,
Object oid)
throws PrevalentException
cls - The type of the prevalent object.oid - The object id for the prevalent object to retrieve.
null if no
such object is stored in the prevalent system.
PrevalentException - If errors are encountered while reconstituting
the prevalent object.ObjectGraphSystem.compose(com.sptci.prevayler.PrevalentObject)
public Collection<PrevalentObject> fetch(Class cls,
String field,
Object object)
throws PrevalentException
cls type
which has the specified object as the value of the specified
field.
Note: Only indexed fields are searched. If the specified field is not indexed, this method returns an empty collection.
cls - The type of prevalent object to query for.field - The name of the field in the prevalent object using which
the results are to be queried.object - The value of the field.
PrevalentException - If errors are encountered while reconstituting
the prevalent objects being returned.
public Collection<PrevalentObject> fetchUnion(Class cls,
Map<String,?> parameters)
throws PrevalentException
cls type
which has the specified indexed field values. The results
contain a union of the matching objects.
Note: Only indexed fields are searched. If the specified field(s) are not indexed, this method ignores those field(s).
cls - The type of prevalent object to query for.parameters - The map of parameters to use to filter the
prevalent instances.
PrevalentException - If errors are encountered while reconstituting
the prevalent objects being returned.AbstractDatabase.fetch( Class, String, Object )
public Collection<PrevalentObject> fetchIntersection(Class cls,
Map<String,?> parameters)
throws PrevalentException
cls type
which has the specified indexed field values. The results
contain an intersection of the matching objects.
Note: Only indexed fields are searched. If the specified field(s) are not indexed, this method ignores those field(s).
cls - The type of prevalent object to query for.parameters - The map of parameters to use to filter the
prevalent instances.
PrevalentException - If errors are encountered while reconstituting
the prevalent objects being returned.AbstractDatabase.fetch( Class, String, Object )
public Collection<PrevalentObject> fetch(Class cls,
long start,
long end)
throws PrevalentException
cls - The type of prevalent object to retrive.start - The starting index (inclusive) from which to fetch the
prevalent objects.end - The ending index (exclusive) to which to fetch the
prevalent objects.
PrevalentException - If errors are encountered while fetching the
objects.PrimaryStorage.get( long, long )
public Collection<PrevalentObject> search(org.apache.lucene.search.Query query,
org.apache.lucene.search.Filter filter,
int count,
org.apache.lucene.search.Sort sort)
throws PrevalentException
Notes:
class
Field
which contains the fully qualified class name of the prevalent object.
query - The lucene query that is to be executed to find matching
prevalent object instances.filter - The filter to apply to restrict the query results.count - The maximum number to top hits for the search to return.sort - The sort criteria to use for the results.
PrevalentException - If errors are encountered while reconstituting
the prevalent objects being returned.
protected PrevalentObject add(PrevalentObject object,
Date executionTime)
throws PrevalentException
object - The object to be added to the system.executionTime - The time at which the transaction was executed.
object passed in.
PrevalentException - If errors are encountered while adding the
object.ConstraintSystem.preAdd(com.sptci.prevayler.PrevalentObject),
StorageSystem.getPrimaryStorage(java.lang.Class),
ObjectGraphSystem.decompose(com.sptci.prevayler.PrevalentObject, java.util.Date),
setOid(com.sptci.prevayler.PrevalentObject),
SearchSystem.index(com.sptci.prevayler.PrevalentObject)
protected PrevalentObject update(PrevalentObject object,
Date executionTime)
throws PrevalentException
add(com.sptci.prevayler.PrevalentObject, java.util.Date).
Note that this method invokes itself recursively to update any objects in the object graph that represent prevalent objects that also need updating.
object - The prevalent object to update in the system.executionTime - The datetime at which the transaction was executed.
PrevalentException - If errors are encountered while updating
(or adding) the prevalent object.fetch( Class, Object ),
add(com.sptci.prevayler.PrevalentObject, java.util.Date),
ObjectGraphSystem.update( Field, PrevalentObject, Date )
protected void setOid(PrevalentObject object)
throws PrevalentException
PrevalentObject.objectId field to a new value if
not already set.
object - The prevalent object whose primary key is to be set.
PrevalentException - If errors are encountered while setting the
privary key field.StorageSystem.generateOid(com.sptci.prevayler.PrevalentObject)
protected void updateOrdinaryField(PrevalentObject prevalentObject,
Field field,
Object source,
Object destination)
throws IllegalAccessException,
InvocationTargetException
prevalentObject - The prevalent object that is being updated.field - The field in the prevalent object that is being updated.source - The new value that is being set.destination - The old value in the field.
IllegalAccessException - Reflection error while setting field.
InvocationTargetException - Reflection error while setting field.
|
SPT Object Database API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||