com.sas.framework.expojo
Class PersistenceProvider

java.lang.Object
  extended by com.sas.framework.expojo.PersistenceProvider
Direct Known Subclasses:
HibernatePersistenceProvider, JdoPersistenceProvider, MockPersistenceProvider

public abstract class PersistenceProvider
extends java.lang.Object

Superclass for all persistence providers. This class is extended to provide persistence engine specific implementations. eg., HibernatePersistenceProvider and JdoPersistenceProvider. These objects are typically kept 'open' throughout multiple HTTP requests, for each request a transaction is begun at the start and commited (or rolled back) at the end. This implements the 'OpenSessionInView' (hibernate) or 'OpenPersistenceManagerInView' pattern. A future possible enhancement is to add an optional "free persistence provider' mechanism at the end of each HTTP request.


Field Summary
protected  int depth
          Depth of the deepest transaction.
 ModelExposer modelExposer
           
 
Constructor Summary
PersistenceProvider()
           
 
Method Summary
abstract  void beginTx()
          Begins a transaction.
abstract  void close()
          Closes the persistence provider.
abstract  void commitTx()
          Commits a transaction.
abstract  void delete(java.lang.Object object)
          Deletes the persistent object from the datastore.
abstract  boolean hasActiveTx()
          Returns true if the PersistenceProvider has an active transaction.
abstract  void open()
          Opens a persistence provider.
abstract  void persist(java.lang.Object object)
          Makes the given object persistent.
abstract  java.lang.RuntimeException processException(java.lang.RuntimeException e)
          Processes an exception thrown while in a transaction.
abstract  void rollbackTx()
          Rolls back a transaction.
 void setModelExposer(ModelExposer iModelExposer)
          Sets the owning ModelExposer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

depth

protected transient int depth
Depth of the deepest transaction. 0 = no active transaction. beginTx increments and commitTx and rollbackTx decrement depth. See rollbackTx for more information.


modelExposer

public ModelExposer modelExposer
Constructor Detail

PersistenceProvider

public PersistenceProvider()
Method Detail

hasActiveTx

public abstract boolean hasActiveTx()
Returns true if the PersistenceProvider has an active transaction.


setModelExposer

public void setModelExposer(ModelExposer iModelExposer)
Sets the owning ModelExposer.


open

public abstract void open()
Opens a persistence provider.


processException

public abstract java.lang.RuntimeException processException(java.lang.RuntimeException e)
Processes an exception thrown while in a transaction. The exception could be relevent to the persistence technology or a generic RuntimeException. If it's an optimistic verification exception (optimistic locking check failed) then no exception is thrown and the persistence technology may or may not need clean. In the case of JDO a rollback as already been performed.


close

public abstract void close()
Closes the persistence provider. It can no longer be used after being closed.


delete

public abstract void delete(java.lang.Object object)
Deletes the persistent object from the datastore.


persist

public abstract void persist(java.lang.Object object)
Makes the given object persistent.


rollbackTx

public abstract void rollbackTx()
Rolls back a transaction.


commitTx

public abstract void commitTx()
Commits a transaction.


beginTx

public abstract void beginTx()
Begins a transaction.