org.sourceforge.jemm
Class AbstractStore

java.lang.Object
  extended by org.sourceforge.jemm.AbstractStore
All Implemented Interfaces:
Store
Direct Known Subclasses:
MemoryStore, PersistentStore, RemoteStore

public abstract class AbstractStore
extends java.lang.Object
implements Store

Internal base class for implementing stores.

N.b. extending classes must call setup() once their constructor initialisation is finished.

Author:
Rory Graves

Field Summary
protected  ObjectDatabase db
           
protected  LifecycleListenerImpl listener
           
 
Constructor Summary
AbstractStore()
           
AbstractStore(boolean debug)
           
 
Method Summary
protected abstract  Database createUnderlyingDatabase()
           
 java.lang.Object getRoot(java.lang.String rootName)
          Return the model object set for the root named 'rootName'
 void initialise()
          Called by the Session.setStore method to inform the Store that is should start.
 void setRoot(java.lang.String rootName, java.lang.Object value)
          Set the store root object with the given rootName to hold a reference to the specified model object.
 java.lang.Object setRootIfNull(java.lang.String rootName, java.lang.Object value)
          Set the root 'rootName' to the given value if it is not already set.
protected  void setup()
           
 void shutdown()
          Shutdown should be called before the JVM is exited.
protected abstract  void shutdownUnderlyingDatabase()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

db

protected ObjectDatabase db

listener

protected LifecycleListenerImpl listener
Constructor Detail

AbstractStore

public AbstractStore()

AbstractStore

public AbstractStore(boolean debug)
Method Detail

setup

protected void setup()

createUnderlyingDatabase

protected abstract Database createUnderlyingDatabase()

shutdownUnderlyingDatabase

protected abstract void shutdownUnderlyingDatabase()

initialise

public void initialise()
Description copied from interface: Store
Called by the Session.setStore method to inform the Store that is should start. In particular implementations should register a ConstructorListener with ConstructorLifecycle via its static methods so that object construction events are received.

Specified by:
initialise in interface Store

shutdown

public void shutdown()
Description copied from interface: Store
Shutdown should be called before the JVM is exited. The shutdown could be called multiple times and repeated runs should always succeed. Once the store is shutdown it should be able to be reinitialised with a call to initialise.

Specified by:
shutdown in interface Store

getRoot

public java.lang.Object getRoot(java.lang.String rootName)
Description copied from interface: Store
Return the model object set for the root named 'rootName'

Specified by:
getRoot in interface Store
Parameters:
rootName - The name of the root to fetch.
Returns:
Object reference if set, null otherwise.

setRoot

public void setRoot(java.lang.String rootName,
                    java.lang.Object value)
Description copied from interface: Store
Set the store root object with the given rootName to hold a reference to the specified model object.

Specified by:
setRoot in interface Store
Parameters:
rootName - The name of the root.
value - The model object to store.

setRootIfNull

public java.lang.Object setRootIfNull(java.lang.String rootName,
                                      java.lang.Object value)
Set the root 'rootName' to the given value if it is not already set.

Specified by:
setRootIfNull in interface Store
Parameters:
rootName - The name of the root.
value - The value to store (must be an entity)
Returns:
If the stored value was null, the value passed (the new stored value), otherwise the current value stored.


Copyright © 2009. All Rights Reserved.