net.sf.jso
Interface StorageManager

All Superinterfaces:
java.util.EventListener, QueryProcessor, SchemaListener, java.io.Serializable, StatusListener, StorageListener
All Known Implementing Classes:
JSOStorageManager, StorageManagerProxy

public interface StorageManager
extends java.io.Serializable, QueryProcessor, StatusListener, StorageListener, SchemaListener

Manager responsible for storage operations with storable objects.

See Also:
Storable

Method Summary
 void addStatusListener(StatusListener listener)
          Starts sending status events to a listener.
 void addStorageListener(StorageListener listener)
          Starts sending storage events to a listener.
 void batchStore(java.util.Collection objs, boolean deep)
          Stores a collection of objects in one only "batch" operation.
 OID createOID(java.lang.Object obj)
          Creates an OID from an object.
 void delete(java.lang.Object obj)
          Deletes an object.
 void delete(OID oid)
          Deletes an object.
 int delete(Parameters params)
          Deletes objects according to parameters.
 ManagerInfo getManagerInfo()
          Gets storage management information.
 OID getOID(java.lang.Object obj)
          Returns OID of a transient storable object.
 Status getStatus()
          Gets manager's status.
 Transaction getTransaction()
          Gets the transaction associated to the current thread.
 void invalidateCache()
          Invalidates manager's cache.
 boolean isRemote()
          Indicates if manager is running on another JVM.
 void removeStatusListener(StatusListener listener)
          Stops sending status events to a listener.
 void removeStorageListener(StorageListener listener)
          Stops sending storage events to a listener.
 java.lang.Object retrieve(OID oid)
          Retrieves an object.
 java.lang.Object retrieve(OID oid, boolean summary)
          Retrieves an object.
 java.lang.Object retrieve(OID oid, boolean summary, boolean lazy)
          Retrieves an object.
 void start(StorageController aController)
          Starts the manager.
 void stop()
          Stops the manager.
 OID store(java.lang.Object obj)
          Stores an object and referenced objects.
 OID store(java.lang.Object obj, boolean deep)
          Stores an object.
 void unlinkTransientObjects()
          Unlinks transient storable objects from stored ones.
 
Methods inherited from interface net.sf.jso.query.QueryProcessor
count, countPages, retrieve
 
Methods inherited from interface net.sf.jso.StatusListener
statusChanged
 
Methods inherited from interface net.sf.jso.storage.StorageListener
objectDeleted, objectStored
 
Methods inherited from interface net.sf.jso.schema.SchemaListener
classAltered, classDropped, subclassCreated, subclassDropped
 

Method Detail

start

public void start(StorageController aController)
           throws StorageException
Starts the manager.

Parameters:
aController - Application's controller.
Throws:
StorageException

stop

public void stop()
          throws StorageException
Stops the manager.

Throws:
StorageException

getStatus

public Status getStatus()
Gets manager's status.

Returns:
manager's current status.

isRemote

public boolean isRemote()
Indicates if manager is running on another JVM.

Returns:
true if manager is running on another JVM; false otherwise.

invalidateCache

public void invalidateCache()
Invalidates manager's cache.


getManagerInfo

public ManagerInfo getManagerInfo()
Gets storage management information.

Returns:
Information about storage management.

getTransaction

public Transaction getTransaction()
                           throws StorageException
Gets the transaction associated to the current thread.

Returns:
If no transaction is currently associated to the current thread a new one is created and returned. Otherwise the associated transaction is returned.
Throws:
StorageException

createOID

public OID createOID(java.lang.Object obj)
Creates an OID from an object.

Parameters:
obj - An OID representation. Usually a String or Number object.

getOID

public OID getOID(java.lang.Object obj)
           throws StorageException
Returns OID of a transient storable object.

Parameters:
obj - The object to be identified.
Returns:
Storable object's OID.
Throws:
StorageException

unlinkTransientObjects

public void unlinkTransientObjects()
Unlinks transient storable objects from stored ones.


store

public OID store(java.lang.Object obj)
          throws StorageException,
                 ObjectNotFoundException,
                 DuplicateObjectException
Stores an object and referenced objects. Current thread's transaction is used. If current thread has no transaction associated a new one is begun and committed.

Parameters:
obj - The object to be stored.
Returns:
The stored object identification.
Throws:
StorageException - If any storage operation fails.
ObjectNotFoundException - When trying to update an unexistent object.
DuplicateObjectException - When trying to store an object that violates unique key constraints.

store

public OID store(java.lang.Object obj,
                 boolean deep)
          throws StorageException,
                 ObjectNotFoundException,
                 DuplicateObjectException
Stores an object. Current thread's transaction is used. If current thread has no transaction associated a new one is begun and committed.

Parameters:
obj - The object to be stored.
deep - Indicates if referenced objects should also be stored.
Returns:
The stored object identification.
Throws:
StorageException - If any storage operation fails.
ObjectNotFoundException - When trying to update an unexistent object.
DuplicateObjectException - When trying to store an object that violates unique key constraints.

batchStore

public void batchStore(java.util.Collection objs,
                       boolean deep)
                throws StorageException,
                       ObjectNotFoundException,
                       DuplicateObjectException
Stores a collection of objects in one only "batch" operation. Current thread's transaction is used. If current thread has no transaction associated a new one is begun and committed.

Parameters:
objs - The collection of object to be stored.
deep - Indicates if referenced objects should also be stored.
Throws:
StorageException - If any storage operation fails.
ObjectNotFoundException - When trying to update an unexistent object.
DuplicateObjectException - When trying to store an object that violates unique key constraints.

retrieve

public java.lang.Object retrieve(OID oid)
                          throws StorageException,
                                 ObjectNotFoundException
Retrieves an object. Current thread's transaction is used. If current thread has no transaction associated a new one is begun and committed.

Parameters:
oid - The identification of object to be stored.
Returns:
The stored object.
Throws:
StorageException - If any storage operation fails.
ObjectNotFoundException - If no object can be found by the supplied OID.

retrieve

public java.lang.Object retrieve(OID oid,
                                 boolean summary)
                          throws StorageException,
                                 ObjectNotFoundException
Retrieves an object. Current thread's transaction is used. If current thread has no transaction associated a new one is begun and committed.

Parameters:
oid - The identification of object to be stored.
summary - Indicates if only summary fields should be retrieved.
Returns:
The stored object.
Throws:
StorageException - If any storage operation fails.
ObjectNotFoundException - If no object can be found by the supplied OID.

retrieve

public java.lang.Object retrieve(OID oid,
                                 boolean summary,
                                 boolean lazy)
                          throws StorageException,
                                 ObjectNotFoundException
Retrieves an object. Current thread's transaction is used. If current thread has no transaction associated a new one is begun and committed.

Parameters:
oid - The identification of object to be stored.
summary - Indicates if only summary fields should be retrieved.
lazy - Indicates if referenced objects should be lazy loaded.
Returns:
The stored object.
Throws:
StorageException - If any storage operation fails.
ObjectNotFoundException - If no object can be found by the supplied OID.

delete

public void delete(java.lang.Object obj)
            throws StorageException,
                   ObjectNotFoundException,
                   IntegrityException
Deletes an object. Current thread's transaction is used. If current thread has no transaction associated a new one is begun and committed.

Parameters:
obj - The object to be deleted.
Throws:
StorageException - If any storage operation fails.
ObjectNotFoundException - When trying to delete an unexistent object.
IntegrityException - When deleting an object violates referential integrity constraints.

delete

public void delete(OID oid)
            throws StorageException,
                   ObjectNotFoundException,
                   IntegrityException
Deletes an object. Current thread's transaction is used. If current thread has no transaction associated a new one is begun and committed.

Parameters:
oid - The identification of object to be deleted.
Throws:
StorageException - If any storage operation fails.
ObjectNotFoundException - When trying to delete an unexistent object.
IntegrityException - When deleting an object violates referential integrity constraints.

delete

public int delete(Parameters params)
           throws StorageException
Deletes objects according to parameters. Current thread's transaction is used. If current thread has no transaction associated a new one is begun and committed.

Parameters:
params - Parameters to be used.
Returns:
The number of objects deleted.
Throws:
StorageException - If any storage operation fails.

addStatusListener

public void addStatusListener(StatusListener listener)
Starts sending status events to a listener.

Parameters:
listener - Listener to receive status events.

removeStatusListener

public void removeStatusListener(StatusListener listener)
Stops sending status events to a listener.

Parameters:
listener - Listener to stop receiving status events.

addStorageListener

public void addStorageListener(StorageListener listener)
Starts sending storage events to a listener.

Parameters:
listener - Listener to receive storage events.

removeStorageListener

public void removeStorageListener(StorageListener listener)
Stops sending storage events to a listener.

Parameters:
listener - Listener to stop receiving storage events.