org.nakedobjects.runtime.persistence.objectstore
Interface ObjectStorePersistence

All Superinterfaces:
Component, DebugInfo, NamedComponent, SessionScopedComponent
All Known Subinterfaces:
ObjectStore
All Known Implementing Classes:
InMemoryObjectStore, NakedObjectStoreDelegating, NakedObjectStoreLogger

public interface ObjectStorePersistence
extends DebugInfo, SessionScopedComponent, NamedComponent


Method Summary
 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 execute(java.util.List<PersistenceCommand> commands)
           
 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.
 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.
 
Methods inherited from interface org.nakedobjects.metamodel.commons.debug.DebugInfo
debugData, debugTitle
 
Methods inherited from interface org.nakedobjects.metamodel.commons.component.SessionScopedComponent
close, open
 
Methods inherited from interface org.nakedobjects.metamodel.commons.component.NamedComponent
name
 

Method Detail

isFixturesInstalled

boolean isFixturesInstalled()
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.


reset

void reset()
TODO: move to PersistenceSessionFactory ??


createCreateObjectCommand

CreateObjectCommand createCreateObjectCommand(NakedObject object)
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.


createSaveObjectCommand

SaveObjectCommand createSaveObjectCommand(NakedObject object)
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.


createDestroyObjectCommand

DestroyObjectCommand createDestroyObjectCommand(NakedObject object)
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.


execute

void execute(java.util.List<PersistenceCommand> commands)

getObject

NakedObject getObject(Oid oid,
                      NakedObjectSpecification hint)
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 .

Returns:
the requested NakedObject that has the specified Oid.
Throws:
ObjectNotFoundException - when no object corresponding to the oid can be found

getInstances

NakedObject[] getInstances(PersistenceQuery persistenceQuery)

hasInstances

boolean hasInstances(NakedObjectSpecification specification)

resolveField

void resolveField(NakedObject object,
                  NakedObjectAssociation field)
Called by the resolveEagerly method in NakedObjectManager.

See Also:
PersistenceSessionContainer.resolveField(NakedObject, NakedObjectAssociation)

resolveImmediately

void resolveImmediately(NakedObject object)
Called by the resolveImmediately method in NakedObjectManager.

See Also:
PersistenceSessionContainer.resolveImmediately(NakedObject)

registerService

void registerService(java.lang.String name,
                     Oid oid)

getOidForService

Oid getOidForService(java.lang.String name)
Returns the OID for the adapted service.



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