org.nakedobjects.object
Interface NakedObjectStore

All Superinterfaces:
DebugInfo
All Known Implementing Classes:
AbstractNakedObjectStore, ProxyObjectStore

public interface NakedObjectStore
extends DebugInfo


Method Summary
 void abortTransaction()
           
 void addElement(NakedCollection collection, NakedObject element)
           
 boolean areObjectsDistributed()
           
 boolean areObjectsProxied()
           
 java.util.Enumeration classes()
          Returns a list of all the classes (as NakedClasses) that this object store can handle.
 boolean containsElement(NakedCollection collection, NakedObject element)
           
 NakedObject createInstance(NakedClass type)
          Deprecated.  
 void destroyObject(NakedObject object)
          Removes the specified object from the object store.
 void endTransaction()
           
 java.util.Vector getNextElements(NakedCollection collection, NakedObject fromObject, int count)
          Retrieve the next set (the number specified by count) of objects for the specified collection starting from, but not including, the specified object.
 java.util.Vector getNextInstances(NakedObject pattern, NakedObject fromObject, int count)
          Gets the next page of instances.
 NakedObject getObject(java.lang.Object oid)
          Retrieves the object identified by the specified OID from the object store.
 java.util.Vector getPreviousElements(NakedCollection collection, NakedObject toObject, int count)
          Retrieve the previous set (the number specified by count) of objects for the specified collection starting from the specified object.
 java.util.Vector getPreviousInstances(NakedObject pattern, NakedObject toObject, int count)
          Gets the previous page of instances.
 boolean hasInstances(NakedClass type)
          Checks whether there are any instances of the specified type.
 void init()
           
 boolean isFirstElement(NakedCollection collection, NakedObject element)
           
 boolean isFirstInstance(NakedObject pattern, NakedObject instance)
          Checks whether the specified instance is the first one instance in the set of all instances.
 boolean isLastElement(NakedCollection collection, NakedObject element)
           
 boolean isLastInstance(NakedObject pattern, NakedObject instance)
          Checks whether the specified instance is the last instance in the set of all instances.
 boolean isLoaded(java.lang.Object oid)
          Returns true if the system already holds an object with the specific OID
 void loaded(NakedObject object)
          Called by a client to indicate it has loaded a NakedObject into the system.
 void makePersistent(NakedObject object)
          Makes a naked object persistent.
 java.lang.String name()
           
 int numberOfElements(NakedCollection collection)
           
 int numberOfInstances(NakedObject pattern)
           
 PersistenceType persistenceType()
           
 void removeElement(NakedCollection collection, NakedObject element)
           
 void resolve(NakedObject object)
          Re-initialises the fields of an object.
 void restart()
           
 void save(NakedObject object)
          Persists the specified object's state.
 long serialNumber(java.lang.String sequence)
          Generates a unique serial number for the specified squence set.
 void setLog(Log newLog)
          Specifies the Log that all future logging calls should be made to.
 void setUpdateNotifier(UpdateNotifier notifier)
           
 void shutdown()
           
 void startTransaction()
           
 void unloaded(NakedObject object)
          Called by a client to indicate it has unloaded a NakedObject from memory.
 
Methods inherited from interface org.nakedobjects.utility.DebugInfo
getDebugData, getDebugTitle
 

Method Detail

isFirstElement

public boolean isFirstElement(NakedCollection collection,
                              NakedObject element)
                       throws ObjectStoreException
Throws:
ObjectStoreException

isFirstInstance

public boolean isFirstInstance(NakedObject pattern,
                               NakedObject instance)
                        throws ObjectStoreException
Checks whether the specified instance is the first one instance in the set of all instances. The object store should find the instances as specified in the getNextInstances method. It should then check the first instance to see if it is the same as the one specified in instance and return true if it is, or false if it isn't.

Throws:
ObjectStoreException

isLastElement

public boolean isLastElement(NakedCollection collection,
                             NakedObject element)
                      throws ObjectStoreException
Throws:
ObjectStoreException

isLastInstance

public boolean isLastInstance(NakedObject pattern,
                              NakedObject instance)
                       throws ObjectStoreException
Checks whether the specified instance is the last instance in the set of all instances. The object store should find the instances as specified in the getPreviousInstances method. It should then check the last instance to see if it is the same as the one specified in instance and return true if it is, or false if it isn't.

Throws:
ObjectStoreException

getNextElements

public java.util.Vector getNextElements(NakedCollection collection,
                                        NakedObject fromObject,
                                        int count)
                                 throws ObjectStoreException
Retrieve the next set (the number specified by count) of objects for the specified collection starting from, but not including, the specified object. If fromObject is null then start from the first element. If the number of returned is less than the requested number then this set is the last set.

Throws:
ObjectStoreException

getNextInstances

public java.util.Vector getNextInstances(NakedObject pattern,
                                         NakedObject fromObject,
                                         int count)
                                  throws ObjectStoreException
Gets the next page of instances. The object store should create a vector and add to it those instances held by the persistence mechanism that:- 1) are of the type that the pattern object is; 2) have the same content as the pattern object where the pattern object has values or references specified, i.e. empty value objects and null references are to be ignored; 3) matches the fromObject object, or those that are found after it, unless fromObject is null in which case this last condition does not apply. The number of instances added to the vector should be limited to the number specified in count.

Throws:
ObjectStoreException

getPreviousElements

public java.util.Vector getPreviousElements(NakedCollection collection,
                                            NakedObject toObject,
                                            int count)
                                     throws ObjectStoreException
Retrieve the previous set (the number specified by count) of objects for the specified collection starting from the specified object. If fromObject is null then start from the first element. If the number of elements before toObject is less than the number of elements requested then return the required number of elements from the start of the collection.

Throws:
ObjectStoreException

getPreviousInstances

public java.util.Vector getPreviousInstances(NakedObject pattern,
                                             NakedObject toObject,
                                             int count)
                                      throws ObjectStoreException
Gets the previous page of instances. This should be implemented as the getNextInstances method was, except the last instance in the vector should be the one specified in toObject. If, however, the toObject is null then the vector should contain the last count instances.

Throws:
ObjectStoreException

addElement

public void addElement(NakedCollection collection,
                       NakedObject element)
                throws ObjectStoreException
Throws:
ObjectStoreException

init

public void init()
          throws ObjectStoreException
Throws:
ObjectStoreException

abortTransaction

public void abortTransaction()

areObjectsDistributed

public boolean areObjectsDistributed()

areObjectsProxied

public boolean areObjectsProxied()

classes

public java.util.Enumeration classes()
                              throws ObjectStoreException
Returns a list of all the classes (as NakedClasses) that this object store can handle.

Throws:
ObjectStoreException

containsElement

public boolean containsElement(NakedCollection collection,
                               NakedObject element)
                        throws ObjectStoreException
Throws:
ObjectStoreException

destroyObject

public void destroyObject(NakedObject object)
                   throws ObjectStoreException
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.

Throws:
ObjectStoreException

endTransaction

public void endTransaction()

hasInstances

public boolean hasInstances(NakedClass type)
                     throws ObjectStoreException
Checks whether there are any instances of the specified type. The object store should look for instances of the type represented by type and return true if there are, or false if there are not.

Throws:
ObjectStoreException

createInstance

public NakedObject createInstance(NakedClass type)
                           throws ObjectStoreException
Deprecated.  

Creates an new, persistent, naked object of the specified type - creates a logical instance. This creates a physical instance, makes it persistent, calls the new instance's created method, and ensures the object's initial logical state is stored away.

Throws:
ObjectStoreException

makePersistent

public void makePersistent(NakedObject object)
                    throws ObjectStoreException
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.

Throws:
ObjectStoreException

name

public java.lang.String name()

numberOfElements

public int numberOfElements(NakedCollection collection)
                     throws ObjectStoreException
Throws:
ObjectStoreException

numberOfInstances

public int numberOfInstances(NakedObject pattern)
                      throws ObjectStoreException
Throws:
ObjectStoreException

persistenceType

public PersistenceType persistenceType()

removeElement

public void removeElement(NakedCollection collection,
                          NakedObject element)
                   throws ObjectStoreException
Throws:
ObjectStoreException

resolve

public void resolve(NakedObject object)
             throws ObjectStoreException
Re-initialises the fields of an object. This method should return immediately if the object's resolved flag (determined by calling isResolved on the object) is already set. If the object is unresolved then the object's missing data should be retreieved from the persistence mechanism and be used to set up the value objects and associations. The object should be set up in the same manner as in getObject above.

Throws:
ObjectStoreException

save

public void save(NakedObject object)
          throws ObjectStoreException
Persists the specified object's state. Essentially the data held by the persistence mechanism should be updated 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.

Throws:
ObjectStoreException

serialNumber

public long serialNumber(java.lang.String sequence)
Generates a unique serial number for the specified squence set. Each set of serial numbers are a simple numerical sequence. Calling this method with a unused sequence name creates a new set.


setLog

public void setLog(Log newLog)
Specifies the Log that all future logging calls should be made to.

Parameters:
newLog - org.nakedobjects.utility.Log

setUpdateNotifier

public void setUpdateNotifier(UpdateNotifier notifier)

shutdown

public void shutdown()
              throws ObjectStoreException
Throws:
ObjectStoreException

startTransaction

public void startTransaction()

isLoaded

public boolean isLoaded(java.lang.Object oid)
Returns true if the system already holds an object with the specific OID

Parameters:
oid -

getObject

public NakedObject getObject(java.lang.Object oid)
                      throws ObjectNotFoundException,
                             ObjectStoreException
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 that has the specified OID.

Parameters:
oid - of the object to be retrieved
Returns:
the requested naked object
Throws:
ObjectNotFoundException - when no object corresponding to the oid can be found
ObjectStoreException

restart

public void restart()

loaded

public void loaded(NakedObject object)
Called by a client to indicate it has loaded a NakedObject into the system. Should throw ResolveException if the object has already been loaded.

Parameters:
object -

unloaded

public void unloaded(NakedObject object)
Called by a client to indicate it has unloaded a NakedObject from memory. Should throw ResolveException if the object has already been unloaded.

Parameters:
object -