org.nakedobjects.runtime.persistence
Interface PersistenceSessionContainer

All Known Subinterfaces:
PersistenceSession
All Known Implementing Classes:
PersistenceSessionAbstract, PersistenceSessionLogger, PersistenceSessionObjectStore

public interface PersistenceSessionContainer

PersistenceSession as it appears to most typical client-side code.


Method Summary
 NakedObject createInstance(NakedObjectSpecification specification)
          Creates a new instance of the specified type and returns it in an adapter whose resolved state set to ResolveState.TRANSIENT (except if the type is marked as aggregated in which case it will be set to ResolveState.VALUE).
 void destroyObject(NakedObject object)
           
 NakedObject findInstances(PersistenceQuery criteria)
          Finds and returns instances that match the specified PersistenceQuery.
<T> NakedObject
findInstances(Query<T> query, QueryCardinality cardinality)
          Finds and returns instances that match the specified query.
 boolean hasInstances(NakedObjectSpecification specification)
          Whether there are any instances of the specified type.
 NakedObject loadObject(Oid oid, NakedObjectSpecification spec)
          Loads the object identified by the specified Oid from the persisted set of objects.
 void makePersistent(NakedObject object)
          Makes a naked object persistent.
 void objectChanged(NakedObject object)
          Mark the NakedObject as changed, and therefore requiring flushing to the persistence mechanism.
 void resolveField(NakedObject object, NakedObjectAssociation association)
          Hint that specified field within the specified object is likely to be needed soon.
 void resolveImmediately(NakedObject object)
          Re-initialises the fields of an object.
 

Method Detail

createInstance

NakedObject createInstance(NakedObjectSpecification specification)
Creates a new instance of the specified type and returns it in an adapter whose resolved state set to ResolveState.TRANSIENT (except if the type is marked as aggregated in which case it will be set to ResolveState.VALUE).

REVIEW: not sure about ResolveState.VALUE - see comments in #adapterFor(Object, Oid, Version).

While creating the object the it will be initialised with default values and its created lifecycle method (its logical constructor) will be invoked. Contrast this with #recreateTransientInstance(Oid, NakedObjectSpecification).

This method is ultimately delegated to by the DomainObjectContainer.


loadObject

NakedObject loadObject(Oid oid,
                       NakedObjectSpecification spec)
Loads the object identified by the specified Oid from the persisted set of objects.

As used primarily by ServerDistribution.


findInstances

<T> NakedObject findInstances(Query<T> query,
                              QueryCardinality cardinality)
Finds and returns instances that match the specified query.

The QueryCardinality determines whether all instances or just the first matching instance is returned.

Throws:
UnsupportedFindException - if the criteria is not support by this persistor

findInstances

NakedObject findInstances(PersistenceQuery criteria)
Finds and returns instances that match the specified PersistenceQuery.

Compared to findInstances(Query, QueryCardinality), not that there is no QueryCardinality parameter. That's because PersistenceQuery intrinsically carry the knowledge as to how many rows they return.

Throws:
UnsupportedFindException - if the criteria is not support by this persistor

hasInstances

boolean hasInstances(NakedObjectSpecification specification)
Whether there are any instances of the specified type.

Used (ostensibly) by client-side code.


resolveImmediately

void resolveImmediately(NakedObject object)
Re-initialises the fields of an object. If the object is unresolved then the object's missing data should be retrieved from the persistence mechanism and be used to set up the value objects and associations.


resolveField

void resolveField(NakedObject object,
                  NakedObjectAssociation association)
Hint that specified field within the specified object is likely to be needed soon. This allows the object's data to be loaded, ready for use.

This method need not do anything, but offers the object store the opportunity to load in objects before their use. Contrast this with resolveImmediately, which requires an object to be loaded before continuing.

See Also:
resolveImmediately(NakedObject)

makePersistent

void makePersistent(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.


objectChanged

void objectChanged(NakedObject object)
Mark the NakedObject as changed, and therefore requiring flushing to the persistence mechanism.


destroyObject

void destroyObject(NakedObject object)


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