SPT Object Database API

com.sptci.prevayler
Class StorageSystem

java.lang.Object
  extended by com.sptci.prevayler.StorageSystem
All Implemented Interfaces:
AbstractDatabase<PrevalentObject>, DatabaseSystem, Serializable
Direct Known Subclasses:
IndexSystem

abstract class StorageSystem
extends Object
implements DatabaseSystem

The base class for the prevalent system that provides the storage engine for storing the various prevalent object maintained by the system.

© Copyright 2008 Sans Pareil Technologies, Inc.

Version:
$Id: StorageSystem.java 22 2008-11-24 19:04:25Z sptrakesh $
Author:
Rakesh 2008-05-22

Nested Class Summary
protected static class StorageSystem.TaskQueue
          The task queue used to ensure that recursive loops when persisting inter-related object graphs do not result in infinite loops.
 
Field Summary
private  Map<String,PrimaryStorage> classMap
          A map used to manage the various prevalent objects that may be managed by this prevalent system.
private  Map<String,IndexStorage> indexMap
          A map used to maintain indices for the various prevalent object types that are managed by this prevalent system.
protected static Logger logger
          The logger to use to log messages/errors.
private  Map<String,ReferenceStorage> referenceMap
          A map used to maintain the references in a prevalent object to other prevalent objects.
private  Map<String,RelationStorage> relationMap
          A map used to maintain the reverse relationships from prevalent objects to their parents.
private  long sequence
          The sequence used to generate object ids.
private static long serialVersionUID
           
private static StorageSystem.TaskQueue taskQueue
          A task queue used when persisting object graphs to avoid infinite loops due to the recursive nature of following object graphs.
 
Constructor Summary
StorageSystem()
           
 
Method Summary
protected  Object generateOid(PrevalentObject object)
          Generate the oid to assign to the specified prevalent object.
protected  IndexStorage getIndexStorage(Class cls)
          Return the map in which the indices for the prevalent class are stored with the indexed field name.
protected  IndexStorage getIndexStorage(String name)
          Return the map in which the indices for the prevalent class are stored with the indexed field name.
protected  PrimaryStorage getPrimaryStorage(Class cls)
          Return the map used to maintain instances of the specified type of prevalent objects by its object id.
protected  PrimaryStorage getPrimaryStorage(String name)
          Return the map used to maintain instances of the specified type of prevalent objects by its object id.
protected  ReferenceStorage getReferenceStorage(Class cls)
          Return the map used to manage the references to other prevalent objects for the specified prevalent class.
protected  ReferenceStorage getReferenceStorage(String name)
          Return the map used to manage the references to other prevalent objects for the specified prevalent class.
protected  RelationStorage getRelationStorage(Class cls)
          Return the map used to manage the relations to other prevalent objects for the specified prevalent class.
protected  RelationStorage getRelationStorage(String name)
          Return the map used to manage the relations to other prevalent objects for the specified prevalent class.
protected  Collection<PrevalentObject> getTaskQueue()
          Return the task queue used when persisting objects by reachability.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sptci.prevayler.DatabaseSystem
delete, save
 
Methods inherited from interface com.sptci.prevayler.AbstractDatabase
count, fetch, fetch, fetch, fetchIntersection, fetchUnion, search
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

logger

protected static final transient Logger logger
The logger to use to log messages/errors.


classMap

private final Map<String,PrimaryStorage> classMap
A map used to manage the various prevalent objects that may be managed by this prevalent system. This map provides the primary storage for the prevalent objects maintained in the system. The key for the map are the various classes that are stored in the prevalent system while the values are the PrimaryStorage instances that store the prevalent objects of each type.


indexMap

private final Map<String,IndexStorage> indexMap
A map used to maintain indices for the various prevalent object types that are managed by this prevalent system. The key for the map are the various classes that are stored in the prevalent system while the values are the IndexStorage instances that store the indices for the indexed fields in the prevalent objects of each type.


referenceMap

private final Map<String,ReferenceStorage> referenceMap
A map used to maintain the references in a prevalent object to other prevalent objects. This is used to ensure that references are properly reconstituted when de-serialised. The key for the map are the various classes that are stored in the prevalent system while the values are the ReferenceStorage instances that store the references for the prevalent objects referenced by the prevalent object being managed.


relationMap

private final Map<String,RelationStorage> relationMap
A map used to maintain the reverse relationships from prevalent objects to their parents. This is used to implement configured actions when deleting a prevalent object.


taskQueue

private static transient StorageSystem.TaskQueue taskQueue
A task queue used when persisting object graphs to avoid infinite loops due to the recursive nature of following object graphs.


sequence

private long sequence
The sequence used to generate object ids.

Constructor Detail

StorageSystem

StorageSystem()
Method Detail

generateOid

protected Object generateOid(PrevalentObject object)
Generate the oid to assign to the specified prevalent object. Default implementation returns an incremented sequence value if the prevalent object does not already have an object id.

Parameters:
object - The prevalent object for which an oid is to be generated.
Returns:
The oid to assign to the prevalent object.

getPrimaryStorage

protected PrimaryStorage getPrimaryStorage(Class cls)
Return the map used to maintain instances of the specified type of prevalent objects by its object id.

Parameters:
cls - The class whose primary storage is to be retrieved.
Returns:
The primary storage used for the specified prevalent type.
See Also:
getPrimaryStorage( String )

getPrimaryStorage

protected PrimaryStorage getPrimaryStorage(String name)
Return the map used to maintain instances of the specified type of prevalent objects by its object id.

Parameters:
name - The fully qualified name of the class whose primary storage is to be retrieved.
Returns:
The primary storage used for the specified prevalent type.

getIndexStorage

protected IndexStorage getIndexStorage(Class cls)
Return the map in which the indices for the prevalent class are stored with the indexed field name.

Parameters:
cls - The class whose index storage is to be retrieved.
Returns:
The index storage for the specified prevalent type.
See Also:
getIndexStorage( String )

getIndexStorage

protected IndexStorage getIndexStorage(String name)
Return the map in which the indices for the prevalent class are stored with the indexed field name.

Parameters:
name - The fully qualified name of the class whose index storage is to be retrieved.
Returns:
The index storage for the specified prevalent type.

getReferenceStorage

protected ReferenceStorage getReferenceStorage(Class cls)
Return the map used to manage the references to other prevalent objects for the specified prevalent class.

Parameters:
cls - The class whose reference storage is to be retrieved.
Returns:
The reference storage for the prevalent class.
See Also:
getReferenceStorage( String )

getReferenceStorage

protected ReferenceStorage getReferenceStorage(String name)
Return the map used to manage the references to other prevalent objects for the specified prevalent class.

Parameters:
name - The fully qualified name of the class whose reference storage is to be retrieved.
Returns:
The reference storage for the prevalent class.

getRelationStorage

protected RelationStorage getRelationStorage(Class cls)
Return the map used to manage the relations to other prevalent objects for the specified prevalent class.

Parameters:
cls - The class whose relations storage is to be retrieved.
Returns:
The relations storage for the prevalent class.
See Also:
getRelationStorage( String )

getRelationStorage

protected RelationStorage getRelationStorage(String name)
Return the map used to manage the relations to other prevalent objects for the specified prevalent class.

Parameters:
name - The fully qualified name of the class whose relation storage is to be retrieved.
Returns:
The relations storage for the prevalent class.

getTaskQueue

protected Collection<PrevalentObject> getTaskQueue()
Return the task queue used when persisting objects by reachability.

Returns:
The queue of prevalent objects in the object graph.

SPT Object Database API