com.ashridgetech.prevdb.client
Class PrevDb

java.lang.Object
  |
  +--com.ashridgetech.prevdb.client.PrevDb

public class PrevDb
extends Object

The overall controller for all the Persistent objects in a PrevDb system. Manages loading and saving data and transactions. Needs to be configured at startup with the Persistent classes to be managed, and the SystemStore implementations.

Version:
1.0
Author:
paulb

Constructor Summary
PrevDb()
           
 
Method Summary
protected  void applyTransaction(Transaction tran)
          Apply the effects of a Transaction to the objects in this PrevDb.
 Transaction commitTransaction()
          Commit the current unit of work.
 void defineNonUniqueIndex(PersistentField field)
          Define a non-unique index required for a class managed by this PrevDb.
 void definePersistentClass(Class persistentClass, PersistentField oidField)
          Define a new persistent class.
 Transaction getCurrentTransaction()
          Get the Transaction currently in progress
 Collection getPersistentClasses()
          Get the collection of persistent object classes.
 SystemStore getSystemStore()
          Get the default SystemStore for this PrevDb.
protected  boolean isLoading()
          Indicate whether this prevDb is loading objects.
 PersistentManager manager(Class persistentClass)
          Find the PersistentManager for a Class.
protected  void notifyFieldUpdate(Persistent obj, PersistentField field, Object oldValue, Object newValue)
          Notify this PrevDb that a field in one of its persistent objects has been updated.
protected  void notifyNewObject(Persistent obj)
          Notify this PrevDb that a new persistent object has been created.
 void rollbackTransaction()
          Abandon the current unit of work.
protected  void rollbackTransaction(Transaction tran)
          Undo the effects of a Transaction on the objects in this PrevDb.
 void setSystemStore(SystemStore systemStore)
          Set the default SystemStore for this PrevDb.
 void shutdown()
          End the operation of this PrevDb.
 void snapshot()
          Take a snapshot of the system data during running.
 void startTransaction()
          Start a new unit of work that will be managed by this PrevDb.
 void startup()
          Start the operation of this PrevDb.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrevDb

public PrevDb()
Method Detail

startup

public void startup()
             throws DataException
Start the operation of this PrevDb. Loads the data from the SystemStore, which must have previously been set by setSystemStore(com.ashridgetech.prevdb.store.SystemStore).

DataException

shutdown

public void shutdown()
End the operation of this PrevDb. Save the system data to the SystemStore.


snapshot

public void snapshot()
Take a snapshot of the system data during running. This may reduce the time needed at the next startup.


manager

public PersistentManager manager(Class persistentClass)
Find the PersistentManager for a Class.

Parameters:
persistentClass - the class for which the PersistentManager is needed.
Throws:
ObjectNotFoundException - if there is no object with the given oid

getSystemStore

public SystemStore getSystemStore()
Get the default SystemStore for this PrevDb.

Returns:
the store
Throws:
IllegalStateException - if no store has been set with setSystemStore(com.ashridgetech.prevdb.store.SystemStore)

setSystemStore

public void setSystemStore(SystemStore systemStore)
Set the default SystemStore for this PrevDb.

Parameters:
systemStore - the store

definePersistentClass

public void definePersistentClass(Class persistentClass,
                                  PersistentField oidField)
Define a new persistent class. The class must implement Persistent. NOTE: if the class is a subclass of another Persistent class, that class must have been defined already.

Parameters:
persistentClass - the class to define.
oidField - the oid field of persistentClass.

defineNonUniqueIndex

public void defineNonUniqueIndex(PersistentField field)
Define a non-unique index required for a class managed by this PrevDb.

Parameters:
field - the field to be indexed - the PersistentField knows which class it belongs to

getPersistentClasses

public Collection getPersistentClasses()
Get the collection of persistent object classes.

Returns:
the collection of classes

startTransaction

public void startTransaction()
Start a new unit of work that will be managed by this PrevDb. All changes made to objects managed by this PrevDb during the transaction will be recorded. They may be made permanent in the system store, or reversed if necessary.

Throws:
IllegalStateException - if a transaction is currently in progress
See Also:
#rollbackTransaction

getCurrentTransaction

public Transaction getCurrentTransaction()
Get the Transaction currently in progress

Returns:
the Transaction, or null if there is no Transaction in progress

commitTransaction

public Transaction commitTransaction()
Commit the current unit of work. All changes made to objects managed by this PrevDb during the transaction are made permanent in the system store. The getCurrentTransaction() will return nullafter this call.

Returns:
the Transaction that has been committed, so that its contents can be used by the application if required
Throws:
IllegalStateException - if no transaction is currently in progress
See Also:
rollbackTransaction()

rollbackTransaction

public void rollbackTransaction()
Abandon the current unit of work. All changes made to objects managed by this PrevDb during the transaction are reversed, and they are not made permanent in the system store. The getCurrentTransaction() will return nullafter this call.

Throws:
IllegalStateException - if no transaction is currently in progress
See Also:
commitTransaction()

applyTransaction

protected void applyTransaction(Transaction tran)
                         throws DataException
Apply the effects of a Transaction to the objects in this PrevDb.

Parameters:
tran - the Transaction to apply
DataException

rollbackTransaction

protected void rollbackTransaction(Transaction tran)
Undo the effects of a Transaction on the objects in this PrevDb.

Parameters:
tran - the Transaction to undo

notifyNewObject

protected void notifyNewObject(Persistent obj)
Notify this PrevDb that a new persistent object has been created. Do nothing if during the operation of startup()

Parameters:
obj - the new object

notifyFieldUpdate

protected void notifyFieldUpdate(Persistent obj,
                                 PersistentField field,
                                 Object oldValue,
                                 Object newValue)
Notify this PrevDb that a field in one of its persistent objects has been updated.

Parameters:
obj - the new object

isLoading

protected boolean isLoading()
Indicate whether this prevDb is loading objects.

Returns:
true if it is in the loading state


Copyright © 2003 Ashridge Technologies Ltd. All Rights Reserved.