Holger's
Java API

com.antelmann.db
Class DBTransactionStoreAdapter

java.lang.Object
  extended by com.antelmann.db.DBTransactionStoreAdapter
All Implemented Interfaces:
DBStoreListener, TransactionListener

public abstract class DBTransactionStoreAdapter
extends Object
implements TransactionListener, DBStoreListener

convenience class to extend from when implementing something like a DatabaseChangeMonitor

Since:
16.03.2017, 23:20:02
Author:
holger

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.antelmann.db.TransactionListener
TransactionListener.Adapter
 
Nested classes/interfaces inherited from interface com.antelmann.db.DBStoreListener
DBStoreListener.Adapter, DBStoreListener.StoreUpdateAdapter
 
Constructor Summary
DBTransactionStoreAdapter()
           
 
Method Summary
 void databaseAccessed(DBClassStore<?> dbstore, DBClassStore.DBMethod method, Object parameter, long timeTaken)
          called upon successfully reading from the database (guaranteed to be called from within the transaction).
 void databaseError(DBClassStore<?> dbstore, Throwable t, DBClassStore.DBMethod method, Object parameter)
          called when an error occurred while accessing the database (not guaranteed to be called from within the transaction)
 void databaseUpdated(DBUpdateEvent event, long timeTaken)
          called upon successful insert, delete or update; note that the update becomes permanent ONLY if the current transaction successfully commits.
 void fetchCall(DBClassStore<?> dbstore, DBEnumeration<?> e, String method, long timeTaken)
          called when a method is called on a DBEnumeration that is returned by the store
 void finishTransaction(DBTransaction transaction)
          called before the transaction commits (and before TransactionListener.prepareToCommit(DBTransaction)), so that the commit at the database level can be prevented by throwing a DatabaseException here.
 void prepareDatabaseCall(DBClassStore<?> dbstore, DBClassStore.DBMethod method, Object parameter)
          called before the given method is delegated to the embedded store
 void prepareToCommit(DBTransaction transaction)
          called right before the transaction actually commits and after TransactionListener.finishTransaction(DBTransaction).
 void transactionAborted(DBTransaction transaction)
          called after a database transaction was aborted; the transaction is already inactive.
 void transactionBegin(DBTransaction transaction)
          called upon beginning a transaction (the transaction is already active)
 void transactionCommitted(DBTransaction transaction)
          called after a successful database commit; the transaction is already inactive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBTransactionStoreAdapter

public DBTransactionStoreAdapter()
Method Detail

prepareDatabaseCall

public void prepareDatabaseCall(DBClassStore<?> dbstore,
                                DBClassStore.DBMethod method,
                                Object parameter)
                         throws DBVetoException
Description copied from interface: DBStoreListener
called before the given method is delegated to the embedded store

Specified by:
prepareDatabaseCall in interface DBStoreListener
Throws:
DBVetoException - if a listener seeks to prevent the call to the embedded store

databaseUpdated

public void databaseUpdated(DBUpdateEvent event,
                            long timeTaken)
                     throws DBVetoException
Description copied from interface: DBStoreListener
called upon successful insert, delete or update; note that the update becomes permanent ONLY if the current transaction successfully commits.

Specified by:
databaseUpdated in interface DBStoreListener
Throws:
DBVetoException - if the listener explicitly wants to prevent the update from occurring; this exception is then propagated
See Also:
TransactionListener, DatabaseChangeMonitor, DBVersionedUpdateEvent, Database.setVersioningEnabled(Class, boolean)

databaseAccessed

public void databaseAccessed(DBClassStore<?> dbstore,
                             DBClassStore.DBMethod method,
                             Object parameter,
                             long timeTaken)
Description copied from interface: DBStoreListener
called upon successfully reading from the database (guaranteed to be called from within the transaction). This method is not called when an update occurred - in which case only DBStoreListener.databaseUpdated(DBUpdateEvent, long) is called.

Specified by:
databaseAccessed in interface DBStoreListener

databaseError

public void databaseError(DBClassStore<?> dbstore,
                          Throwable t,
                          DBClassStore.DBMethod method,
                          Object parameter)
Description copied from interface: DBStoreListener
called when an error occurred while accessing the database (not guaranteed to be called from within the transaction)

Specified by:
databaseError in interface DBStoreListener

fetchCall

public void fetchCall(DBClassStore<?> dbstore,
                      DBEnumeration<?> e,
                      String method,
                      long timeTaken)
Description copied from interface: DBStoreListener
called when a method is called on a DBEnumeration that is returned by the store

Specified by:
fetchCall in interface DBStoreListener
See Also:
DBClassStore.fetch(com.antelmann.util.Filter), DBClassStore.fetchStubs(com.antelmann.util.Filter), DBEnumeration

transactionBegin

public void transactionBegin(DBTransaction transaction)
Description copied from interface: TransactionListener
called upon beginning a transaction (the transaction is already active)

Specified by:
transactionBegin in interface TransactionListener

finishTransaction

public void finishTransaction(DBTransaction transaction)
                       throws DatabaseException
Description copied from interface: TransactionListener
called before the transaction commits (and before TransactionListener.prepareToCommit(DBTransaction)), so that the commit at the database level can be prevented by throwing a DatabaseException here. This method can also be used to make some updates on another database or checking on certain data before the transaction is allowed to commit. In other words, this method may effectively veto the commit of a transaction After this call, the transaction is soon either going to be committed or aborted (right after all listeners have been called). As this method runs within the transaction, it is possible to access/update any resources from the database.

Specified by:
finishTransaction in interface TransactionListener
Throws:
DatabaseException

prepareToCommit

public void prepareToCommit(DBTransaction transaction)
Description copied from interface: TransactionListener
called right before the transaction actually commits and after TransactionListener.finishTransaction(DBTransaction). Any exception thrown is ignored; listeners must not do any lengthy operations here. This may be used for supporting the implementation of a 2-phase-commit.

Specified by:
prepareToCommit in interface TransactionListener
Parameters:
transaction - the transaction (being still active) that is about to be committed

transactionCommitted

public void transactionCommitted(DBTransaction transaction)
Description copied from interface: TransactionListener
called after a successful database commit; the transaction is already inactive. Note that you cannot start a new transaction within the call of this method, since subsequent listeners would not have a chance to react on this transaction end. If the implementation of this method tries to begin a new transaction, a TransactionException will be thrown. If you need to access/update resources of this database from this method, start a new thread that opens a new transaction.

Specified by:
transactionCommitted in interface TransactionListener

transactionAborted

public void transactionAborted(DBTransaction transaction)
Description copied from interface: TransactionListener
called after a database transaction was aborted; the transaction is already inactive. Note that you cannot to start a new transaction within the call of this method, since subsequent listeners would not have a chance to react on this transaction end. If the implementation of this method tries to begin a new transaction, a TransactionException will be thrown. If you need to access/update resources of this database from this method, start a new thread that opens a new transaction.

Specified by:
transactionAborted in interface TransactionListener


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads