org.neodatis.odb.core.layers.layer3.engine
Class AbstractStorageEngine

java.lang.Object
  extended by org.neodatis.odb.core.layers.layer3.engine.AbstractStorageEngineReader
      extended by org.neodatis.odb.core.layers.layer3.engine.AbstractStorageEngine
All Implemented Interfaces:
IStorageEngine
Direct Known Subclasses:
LocalStorageEngine, ServerStorageEngine

public abstract class AbstractStorageEngine
extends AbstractStorageEngineReader
implements IStorageEngine

The storage Engine

 
 
  The Local Storage Engine class in the most important class in ODB. It manages reading, writing and querying objects.
  
  All write operations are delegated to the ObjectWriter class.
  
  All read operations are delegated to the ObjectReader class.
  
  All Id operations are delegated to the IdManager class.
  
  All Introspecting operations are delegated to the ObjectIntrospector class.
  
  All Trigger operations are delegated to the TriggerManager class.
  
  All session related operations are executed by The Session class. Session Class using the Transaction
  class are responsible for ACID behavior. *
 
 


Field Summary
protected  IClassIntrospector classIntrospector
           
protected  IOdbList<ICommitListener> commitListeners
           
protected  TransactionId currentTransactionId
          To keep track of current transaction Id
protected  IIntrospectionCallback introspectionCallbackForInsert
          This is a visitor used to execute some specific action(like calling 'Before Insert Trigger') when introspecting an object
protected  IIntrospectionCallback introspectionCallbackForUpdate
          This is a visitor used to execute some specific action when introspecting an object
protected  boolean isLocal
          Used to know if the storage engine is executed in local mode (embedded mode) or client server mode
protected  IObjectIntrospector objectIntrospector
           
protected  ITriggerManager triggerManager
           
 
Fields inherited from class org.neodatis.odb.core.layers.layer3.engine.AbstractStorageEngineReader
baseIdentification, isClosed, objectReader, provider
 
Constructor Summary
AbstractStorageEngine(IBaseIdentification parameters)
          The database file name
 
Method Summary
 void addCommitListener(ICommitListener commitListener)
           
 void addDeleteTriggerFor(java.lang.String className, DeleteTrigger trigger)
           
 void addInsertTriggerFor(java.lang.String className, InsertTrigger trigger)
           
 void addOidTriggerFor(java.lang.String className, OIDTrigger trigger)
           
 void addSelectTriggerFor(java.lang.String className, SelectTrigger trigger)
           
 void addSession(ISession session, boolean readMetamodel)
           
 void addUpdateTriggerFor(java.lang.String className, UpdateTrigger trigger)
           
 CheckMetaModelResult checkMetaModelCompatibility(java.util.Map<java.lang.String,ClassInfo> currentCIs)
          Receive the current class info (loaded from current java classes present on classpath and check against the persisted meta model
 void checkRuntimeCompatibility()
          This is a runtime compatibility check.
 void close()
           
 void commit()
           
 long count(CriteriaQuery query)
           
 CriteriaQuery criteriaQuery(java.lang.Class clazz)
           
 CriteriaQuery criteriaQuery(java.lang.Class clazz, ICriterion criterion)
           
 OID delete(java.lang.Object object, boolean cascade)
          Actually deletes an object database
 void deleteObjectWithOid(OID oid, boolean cascade)
          Warning,
 void disconnect(java.lang.Object object)
          Used to disconnect the object from the current session.
 java.util.List<FullIDInfo> getAllObjectIdInfos(java.lang.String objectType, boolean displayObjects)
           
 java.util.List<java.lang.Long> getAllObjectIds()
           
 IBaseIdentification getBaseIdentification()
           
 IOdbList<ICommitListener> getCommitListeners()
           
 OID getCurrentIdBlockMaxOid()
           
 int getCurrentIdBlockNumber()
           
 long getCurrentIdBlockPosition()
           
 TransactionId getCurrentTransactionId()
           
 DatabaseId getDatabaseId()
           
 OID getMaxOid()
           
 NonNativeObjectInfo getMetaObjectFromOid(OID oid)
           
 java.lang.Object getObjectFromOid(OID oid)
           
 OID getObjectId(java.lang.Object object, boolean throwExceptionIfDoesNotExist)
           
 ObjectInfoHeader getObjectInfoHeaderFromOid(OID oid, boolean useCache)
           
 IObjectIntrospector getObjectIntrospector()
           
 IObjectReader getObjectReader()
           
 IObjectWriter getObjectWriter()
           
 IRefactorManager getRefactorManager()
          Returns the object used to refactor the database
 ITriggerManager getTriggerManager()
           
 Values getValues(IValuesQuery query, int startIndex, int endIndex)
           
 int getVersion()
           
protected  void init()
           
protected  OID internalDelete(java.lang.Object object, boolean cascade, java.util.Map<OID,OID> alreadyDeletedObjects)
           
protected  OID internalStore(java.lang.Object object)
          Store an object in ODBFactory database.
protected  OID internalStore(OID oid, java.lang.Object object, boolean forceUpdate)
          Store an object with the specific id
 boolean isClosed()
           
 boolean isLocal()
          Used to know if the storage engine is executed in local mode (embedded mode) or client server mode
 void reconnect(java.lang.Object object)
          Reconnect an object to the current session.
 void resetCommitListeners()
           
 void rollback()
           
 void setCurrentIdBlockInfos(long currentBlockPosition, int currentBlockNumber, OID maxId)
           
 void setCurrentTransactionId(TransactionId transactionId)
           
 void setDatabaseId(DatabaseId databaseId)
           
 void setLastODBCloseStatus(boolean lastCloseStatus)
           
 void setMetaModel(MetaModel metaModel2)
           
 void setNbClasses(long nbClasses)
           
 void setVersion(int version)
           
 OID store(java.lang.Object object)
          Store an object in an database.
 OID store(OID oid, java.lang.Object object)
           
 java.lang.String toString()
          Returns a string of the meta-model
 OID update(OID oid, java.lang.Object object)
           
 void updateMetaModel()
           
 OID updateObject(NonNativeObjectInfo nnoi, boolean forceUpdate)
          Updates an object already transformed into meta representation!
 OID writeObjectInfo(OID oid, NonNativeObjectInfo aoi, long position, boolean updatePointers)
          Write an object already transformed into meta representation!
 
Methods inherited from class org.neodatis.odb.core.layers.layer3.engine.AbstractStorageEngineReader
addIndexOn, config, defragmentTo, deleteIndex, getMetaModel, getObjectInfos, getObjects, getObjects, getSession, rebuildIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.neodatis.odb.core.layers.layer3.IStorageEngine
addClasses, addIndexOn, buildDefaultSession, buildObjectIntrospector, buildObjectReader, buildObjectWriter, buildTriggerManager, defragmentTo, deleteIndex, getObjectInfos, getObjects, getObjects, getSession, rebuildIndex
 

Field Detail

objectIntrospector

protected IObjectIntrospector objectIntrospector

classIntrospector

protected IClassIntrospector classIntrospector

triggerManager

protected ITriggerManager triggerManager

commitListeners

protected IOdbList<ICommitListener> commitListeners

isLocal

protected boolean isLocal
Used to know if the storage engine is executed in local mode (embedded mode) or client server mode


currentTransactionId

protected TransactionId currentTransactionId
To keep track of current transaction Id


introspectionCallbackForInsert

protected IIntrospectionCallback introspectionCallbackForInsert
This is a visitor used to execute some specific action(like calling 'Before Insert Trigger') when introspecting an object


introspectionCallbackForUpdate

protected IIntrospectionCallback introspectionCallbackForUpdate
This is a visitor used to execute some specific action when introspecting an object

Constructor Detail

AbstractStorageEngine

public AbstractStorageEngine(IBaseIdentification parameters)
The database file name

Method Detail

init

protected void init()

addSession

public void addSession(ISession session,
                       boolean readMetamodel)
Specified by:
addSession in interface IStorageEngine

checkMetaModelCompatibility

public CheckMetaModelResult checkMetaModelCompatibility(java.util.Map<java.lang.String,ClassInfo> currentCIs)
Receive the current class info (loaded from current java classes present on classpath and check against the persisted meta model

Specified by:
checkMetaModelCompatibility in interface IStorageEngine
Parameters:
currentCIs -

checkRuntimeCompatibility

public void checkRuntimeCompatibility()
This is a runtime compatibility check. Java version must be greater than 1.5


updateMetaModel

public void updateMetaModel()

store

public OID store(java.lang.Object object)
Description copied from interface: IStorageEngine
Store an object in an database. To detect if object must be updated or insert, we use the cache. To update an object, it must be first selected from the database. When an object is to be stored, if it exist in the cache, then it will be updated, else it will be inserted as a new object. If the object is null, the cache will be used to check if the meta representation is in the cache

Specified by:
store in interface IStorageEngine

store

public OID store(OID oid,
                 java.lang.Object object)
Specified by:
store in interface IStorageEngine

update

public OID update(OID oid,
                  java.lang.Object object)

internalStore

protected OID internalStore(java.lang.Object object)
Store an object in ODBFactory database.
        Transforms the object into meta representation and calls the internalStoreObject
 

Parameters:
object -
Returns:
The object insertion position
Throws:
java.io.IOException

internalStore

protected OID internalStore(OID oid,
                            java.lang.Object object,
                            boolean forceUpdate)
Store an object with the specific id

Parameters:
oid -
object -
Returns:

deleteObjectWithOid

public void deleteObjectWithOid(OID oid,
                                boolean cascade)
Warning,

Specified by:
deleteObjectWithOid in interface IStorageEngine

delete

public OID delete(java.lang.Object object,
                  boolean cascade)
Actually deletes an object database

Specified by:
delete in interface IStorageEngine
Parameters:
object -
cascade -
alreadyDeletedObjects - Contain the oids of already deleted objects. This is to manage cyclic reference

internalDelete

protected OID internalDelete(java.lang.Object object,
                             boolean cascade,
                             java.util.Map<OID,OID> alreadyDeletedObjects)

toString

public java.lang.String toString()
Returns a string of the meta-model

Overrides:
toString in class java.lang.Object
Returns:
The engine description

close

public void close()
Specified by:
close in interface IStorageEngine

count

public long count(CriteriaQuery query)
Specified by:
count in interface IStorageEngine

getObjectReader

public IObjectReader getObjectReader()
Specified by:
getObjectReader in interface IStorageEngine

getObjectWriter

public IObjectWriter getObjectWriter()
Specified by:
getObjectWriter in interface IStorageEngine

commit

public void commit()
Specified by:
commit in interface IStorageEngine

rollback

public void rollback()
Specified by:
rollback in interface IStorageEngine

getObjectId

public OID getObjectId(java.lang.Object object,
                       boolean throwExceptionIfDoesNotExist)
Specified by:
getObjectId in interface IStorageEngine

getObjectFromOid

public java.lang.Object getObjectFromOid(OID oid)
Specified by:
getObjectFromOid in interface IStorageEngine

getMetaObjectFromOid

public NonNativeObjectInfo getMetaObjectFromOid(OID oid)
Specified by:
getMetaObjectFromOid in interface IStorageEngine

getObjectInfoHeaderFromOid

public ObjectInfoHeader getObjectInfoHeaderFromOid(OID oid,
                                                   boolean useCache)
Specified by:
getObjectInfoHeaderFromOid in interface IStorageEngine

getAllObjectIds

public java.util.List<java.lang.Long> getAllObjectIds()
Specified by:
getAllObjectIds in interface IStorageEngine

getAllObjectIdInfos

public java.util.List<FullIDInfo> getAllObjectIdInfos(java.lang.String objectType,
                                                      boolean displayObjects)
Specified by:
getAllObjectIdInfos in interface IStorageEngine

setVersion

public void setVersion(int version)
Specified by:
setVersion in interface IStorageEngine

setDatabaseId

public void setDatabaseId(DatabaseId databaseId)
Specified by:
setDatabaseId in interface IStorageEngine

setNbClasses

public void setNbClasses(long nbClasses)
Specified by:
setNbClasses in interface IStorageEngine

setLastODBCloseStatus

public void setLastODBCloseStatus(boolean lastCloseStatus)
Specified by:
setLastODBCloseStatus in interface IStorageEngine

setCurrentIdBlockInfos

public void setCurrentIdBlockInfos(long currentBlockPosition,
                                   int currentBlockNumber,
                                   OID maxId)
Specified by:
setCurrentIdBlockInfos in interface IStorageEngine

getCurrentIdBlockNumber

public int getCurrentIdBlockNumber()
Specified by:
getCurrentIdBlockNumber in interface IStorageEngine
Returns:
Returns the currentIdBlockNumber.

getCurrentIdBlockPosition

public long getCurrentIdBlockPosition()
Specified by:
getCurrentIdBlockPosition in interface IStorageEngine
Returns:
Returns the currentIdBlockPosition.

getDatabaseId

public DatabaseId getDatabaseId()
Specified by:
getDatabaseId in interface IStorageEngine

getCurrentIdBlockMaxOid

public OID getCurrentIdBlockMaxOid()
Specified by:
getCurrentIdBlockMaxOid in interface IStorageEngine
Returns:
Returns the currentIdBlockMaxId.

getMaxOid

public OID getMaxOid()
Specified by:
getMaxOid in interface IStorageEngine

setMetaModel

public void setMetaModel(MetaModel metaModel2)
Specified by:
setMetaModel in interface IStorageEngine

isClosed

public boolean isClosed()
Specified by:
isClosed in interface IStorageEngine

getVersion

public int getVersion()
Specified by:
getVersion in interface IStorageEngine

getBaseIdentification

public IBaseIdentification getBaseIdentification()
Specified by:
getBaseIdentification in interface IStorageEngine

writeObjectInfo

public OID writeObjectInfo(OID oid,
                           NonNativeObjectInfo aoi,
                           long position,
                           boolean updatePointers)
Description copied from interface: IStorageEngine
Write an object already transformed into meta representation!

Specified by:
writeObjectInfo in interface IStorageEngine
Returns:
te object position(or id (if <0, it is id)) @

updateObject

public OID updateObject(NonNativeObjectInfo nnoi,
                        boolean forceUpdate)
Description copied from interface: IStorageEngine
Updates an object already transformed into meta representation!

Specified by:
updateObject in interface IStorageEngine
Parameters:
nnoi - The Object Meta representation
Returns:
The OID of the update object @

getValues

public Values getValues(IValuesQuery query,
                        int startIndex,
                        int endIndex)
Specified by:
getValues in interface IStorageEngine

addCommitListener

public void addCommitListener(ICommitListener commitListener)
Specified by:
addCommitListener in interface IStorageEngine

getCommitListeners

public IOdbList<ICommitListener> getCommitListeners()
Specified by:
getCommitListeners in interface IStorageEngine

getRefactorManager

public IRefactorManager getRefactorManager()
Description copied from interface: IStorageEngine
Returns the object used to refactor the database

Specified by:
getRefactorManager in interface IStorageEngine

resetCommitListeners

public void resetCommitListeners()
Specified by:
resetCommitListeners in interface IStorageEngine

isLocal

public boolean isLocal()
Description copied from interface: IStorageEngine
Used to know if the storage engine is executed in local mode (embedded mode) or client server mode

Specified by:
isLocal in interface IStorageEngine

getCurrentTransactionId

public TransactionId getCurrentTransactionId()
Specified by:
getCurrentTransactionId in interface IStorageEngine

setCurrentTransactionId

public void setCurrentTransactionId(TransactionId transactionId)
Specified by:
setCurrentTransactionId in interface IStorageEngine

disconnect

public void disconnect(java.lang.Object object)
Description copied from interface: IStorageEngine
Used to disconnect the object from the current session. The object is removed from the cache

Specified by:
disconnect in interface IStorageEngine

reconnect

public void reconnect(java.lang.Object object)
Reconnect an object to the current session. It connects the object and all the dependent objects (Objects accessible from the object graph of the root object

Specified by:
reconnect in interface IStorageEngine

getTriggerManager

public ITriggerManager getTriggerManager()
Specified by:
getTriggerManager in interface IStorageEngine

addDeleteTriggerFor

public void addDeleteTriggerFor(java.lang.String className,
                                DeleteTrigger trigger)
Specified by:
addDeleteTriggerFor in interface IStorageEngine

addInsertTriggerFor

public void addInsertTriggerFor(java.lang.String className,
                                InsertTrigger trigger)
Specified by:
addInsertTriggerFor in interface IStorageEngine

addOidTriggerFor

public void addOidTriggerFor(java.lang.String className,
                             OIDTrigger trigger)
Specified by:
addOidTriggerFor in interface IStorageEngine

addSelectTriggerFor

public void addSelectTriggerFor(java.lang.String className,
                                SelectTrigger trigger)
Specified by:
addSelectTriggerFor in interface IStorageEngine

addUpdateTriggerFor

public void addUpdateTriggerFor(java.lang.String className,
                                UpdateTrigger trigger)
Specified by:
addUpdateTriggerFor in interface IStorageEngine

getObjectIntrospector

public IObjectIntrospector getObjectIntrospector()
Specified by:
getObjectIntrospector in interface IStorageEngine

criteriaQuery

public CriteriaQuery criteriaQuery(java.lang.Class clazz,
                                   ICriterion criterion)
Specified by:
criteriaQuery in interface IStorageEngine
Returns:

criteriaQuery

public CriteriaQuery criteriaQuery(java.lang.Class clazz)
Specified by:
criteriaQuery in interface IStorageEngine
Returns: