org.nakedobjects.runtime.persistence.objectstore
Class NakedObjectStoreDelegating

java.lang.Object
  extended by org.nakedobjects.runtime.persistence.objectstore.NakedObjectStoreDelegating
All Implemented Interfaces:
Component, NamedComponent, SessionScopedComponent, DebugInfo, ObjectStore, ObjectStorePersistence, ObjectStoreTransactionManagement

public abstract class NakedObjectStoreDelegating
extends java.lang.Object
implements ObjectStore

Implementation that simply delegates to underlying ObjectStore.

Useful for quickly writing decorating implementations.


Constructor Summary
NakedObjectStoreDelegating(ObjectStore underlying, java.lang.String name)
           
 
Method Summary
 void abortTransaction()
          Used by the ObjectStoreTransactionManager to tell the underlying ObjectStore to abort a transaction.
 void close()
           
 CreateObjectCommand createCreateObjectCommand(NakedObject object)
          Makes a naked object persistent.
 DestroyObjectCommand createDestroyObjectCommand(NakedObject object)
          Removes the specified object from the object store.
 SaveObjectCommand createSaveObjectCommand(NakedObject object)
          Persists the specified object's state.
 void debugData(DebugString debug)
           
 java.lang.String debugTitle()
           
 void endTransaction()
          Used by the ObjectStoreTransactionManager to tell the underlying ObjectStore to commit a transaction.
 void execute(java.util.List<PersistenceCommand> commands)
          Used by the current ObjectStoreTransaction to flush changes to the ObjectStore (either via a NakedObjectTransactionManager.flushTransaction() or a NakedObjectTransactionManager.endTransaction()).
 NakedObject[] getInstances(PersistenceQuery persistenceQuery)
           
 NakedObject getObject(Oid oid, NakedObjectSpecification hint)
          Retrieves the object identified by the specified OID from the object store.
 Oid getOidForService(java.lang.String name)
          Returns the OID for the adapted service.
 boolean hasInstances(NakedObjectSpecification specification)
           
 boolean isFixturesInstalled()
          Determine if the object store has been initialized with its set of start up objects.
 java.lang.String name()
           
 void open()
           
 void registerService(java.lang.String name, Oid oid)
           
 void reset()
          TODO: move to PersistenceSessionFactory ??
 void resolveField(NakedObject object, NakedObjectAssociation field)
          Called by the resolveEagerly method in NakedObjectManager.
 void resolveImmediately(NakedObject object)
          Called by the resolveImmediately method in NakedObjectManager.
 void startTransaction()
          Used by the ObjectStoreTransactionManager to tell the underlying ObjectStore to start a transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NakedObjectStoreDelegating

public NakedObjectStoreDelegating(ObjectStore underlying,
                                  java.lang.String name)
Method Detail

name

public java.lang.String name()
Specified by:
name in interface NamedComponent

open

public void open()
Specified by:
open in interface SessionScopedComponent

close

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

reset

public void reset()
Description copied from interface: ObjectStorePersistence
TODO: move to PersistenceSessionFactory ??

Specified by:
reset in interface ObjectStorePersistence

isFixturesInstalled

public boolean isFixturesInstalled()
Description copied from interface: ObjectStorePersistence
Determine if the object store has been initialized with its set of start up objects.

This method is called only once after the #init() has been called. If it returns false then the framework will run the fixtures to initialise the object store.

Specified by:
isFixturesInstalled in interface ObjectStorePersistence

createCreateObjectCommand

public CreateObjectCommand createCreateObjectCommand(NakedObject object)
Description copied from interface: ObjectStorePersistence
Makes a naked object persistent. The specified object should be stored away via this object store's persistence mechanism, and have an new and unique OID assigned to it (by calling the object's setOid method). The object, should also be added to the cache as the object is implicitly 'in use'.

If the object has any associations then each of these, where they aren't already persistent, should also be made persistent by recursively calling this method.

If the object to be persisted is a collection, then each element of that collection, that is not already persistent, should be made persistent by recursively calling this method.

Specified by:
createCreateObjectCommand in interface ObjectStorePersistence

createDestroyObjectCommand

public DestroyObjectCommand createDestroyObjectCommand(NakedObject object)
Description copied from interface: ObjectStorePersistence
Removes the specified object from the object store. The specified object's data should be removed from the persistence mechanism and, if it is cached (which it probably is), removed from the cache also.

Specified by:
createDestroyObjectCommand in interface ObjectStorePersistence

createSaveObjectCommand

public SaveObjectCommand createSaveObjectCommand(NakedObject object)
Description copied from interface: ObjectStorePersistence
Persists the specified object's state. Essentially the data held by the persistence mechanism should be updated to reflect the state of the specified objects. Once updated, the object store should issue a notification to all of the object's users via the UpdateNotifier object. This can be achieved simply, if extending the AbstractObjectStore by calling its broadcastObjectUpdate method.

Specified by:
createSaveObjectCommand in interface ObjectStorePersistence

execute

public void execute(java.util.List<PersistenceCommand> commands)
Description copied from interface: ObjectStoreTransactionManagement
Used by the current ObjectStoreTransaction to flush changes to the ObjectStore (either via a NakedObjectTransactionManager.flushTransaction() or a NakedObjectTransactionManager.endTransaction()).

Specified by:
execute in interface ObjectStorePersistence
Specified by:
execute in interface ObjectStoreTransactionManagement

startTransaction

public void startTransaction()
Description copied from interface: ObjectStoreTransactionManagement
Used by the ObjectStoreTransactionManager to tell the underlying ObjectStore to start a transaction.

Specified by:
startTransaction in interface ObjectStoreTransactionManagement

endTransaction

public void endTransaction()
Description copied from interface: ObjectStoreTransactionManagement
Used by the ObjectStoreTransactionManager to tell the underlying ObjectStore to commit a transaction.

Specified by:
endTransaction in interface ObjectStoreTransactionManagement

abortTransaction

public void abortTransaction()
Description copied from interface: ObjectStoreTransactionManagement
Used by the ObjectStoreTransactionManager to tell the underlying ObjectStore to abort a transaction.

Specified by:
abortTransaction in interface ObjectStoreTransactionManagement

getObject

public NakedObject getObject(Oid oid,
                             NakedObjectSpecification hint)
Description copied from interface: ObjectStorePersistence
Retrieves the object identified by the specified OID from the object store. The cache should be checked first and, if the object is cached, the cached version should be returned. It is important that if this method is called again, while the originally returned object is in working memory, then this method must return that same Java object.

Assuming that the object is not cached then the data for the object should be retreived from the persistence mechanism and the object recreated (as describe previously). The specified OID should then be assigned to the recreated object by calling its setOID . Before returning the object its resolved flag should also be set by calling its setResolved method as well.

If the persistence mechanism does not known of an object with the specified Oid then a ObjectNotFoundException should be thrown. Note that the OID could be for an internal collection, and is therefore related to the parent object (using a CompositeOid ). The elements for an internal collection are commonly stored as part of the parent object, so to get element the parent object needs to be retrieved first, and the internal collection can be got from that.

Returns the stored NakedObject object .

Specified by:
getObject in interface ObjectStorePersistence
Returns:
the requested NakedObject that has the specified Oid.

resolveField

public void resolveField(NakedObject object,
                         NakedObjectAssociation field)
Description copied from interface: ObjectStorePersistence
Called by the resolveEagerly method in NakedObjectManager.

Specified by:
resolveField in interface ObjectStorePersistence
See Also:
PersistenceSessionContainer.resolveField(NakedObject, NakedObjectAssociation)

resolveImmediately

public void resolveImmediately(NakedObject object)
Description copied from interface: ObjectStorePersistence
Called by the resolveImmediately method in NakedObjectManager.

Specified by:
resolveImmediately in interface ObjectStorePersistence
See Also:
PersistenceSessionContainer.resolveImmediately(NakedObject)

getInstances

public NakedObject[] getInstances(PersistenceQuery persistenceQuery)
Specified by:
getInstances in interface ObjectStorePersistence

hasInstances

public boolean hasInstances(NakedObjectSpecification specification)
Specified by:
hasInstances in interface ObjectStorePersistence

getOidForService

public Oid getOidForService(java.lang.String name)
Description copied from interface: ObjectStorePersistence
Returns the OID for the adapted service.

Specified by:
getOidForService in interface ObjectStorePersistence

registerService

public void registerService(java.lang.String name,
                            Oid oid)
Specified by:
registerService in interface ObjectStorePersistence

debugData

public void debugData(DebugString debug)
Specified by:
debugData in interface DebugInfo

debugTitle

public java.lang.String debugTitle()
Specified by:
debugTitle in interface DebugInfo


Copyright © 2001-2009 Naked Objects Group Ltd.. All Rights Reserved.