|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.db.AbstractDBTransaction
public abstract class AbstractDBTransaction
a simple base implementation for a DBTransaction. By implementing the abstract methods (instead of those that implement the interface and are marked final), the listeners are handled transparently.
| Field Summary | |
|---|---|
protected Database<?> |
database
|
| Constructor Summary | |
|---|---|
AbstractDBTransaction(Database<?> database)
|
|
| Method Summary | |
|---|---|
void |
abort()
aborts this transaction; requires ownership of this instance. |
boolean |
addTransactionListener(TransactionListener listener)
|
void |
begin()
sets the transaction to active and allows access to the Resources provided that the calling thread holds the lock on this instance. |
void |
commit()
commits all data within the transaction scope to the underlying database; requires ownership of this instance. |
protected abstract void |
doAbort()
|
protected abstract void |
doBegin()
|
protected abstract void |
doCommit()
|
Database<?> |
getDatabase()
gives access to the associated Database |
TransactionListener[] |
getTransactionListeners()
|
boolean |
isActive()
if true, a transaction is currently in progress and has not been committed or aborted, yet. |
boolean |
isReadOnly()
informs whether the currently running transaction is configured to be read-only. |
boolean |
removeTransactionListener(TransactionListener listener)
|
void |
setNextToReadOnly(boolean flag)
allows to configure the next transaction to be read-only. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Database<?> database
| Constructor Detail |
|---|
public AbstractDBTransaction(Database<?> database)
| Method Detail |
|---|
public boolean addTransactionListener(TransactionListener listener)
addTransactionListener in interface DBTransactionpublic boolean removeTransactionListener(TransactionListener listener)
removeTransactionListener in interface DBTransactionpublic TransactionListener[] getTransactionListeners()
getTransactionListeners in interface DBTransactionpublic Database<?> getDatabase()
DBTransaction
getDatabase in interface DBTransaction
protected abstract void doBegin()
throws TransactionException
TransactionException
protected abstract void doCommit()
throws DatabaseException
DatabaseException
protected abstract void doAbort()
throws DatabaseException
DatabaseException
public final void begin()
throws TransactionException
DBTransaction
begin in interface DBTransactionTransactionException - if the transaction is already active
or if the transaction is in transitionTransactionListener.transactionAborted(DBTransaction),
TransactionListener.transactionCommitted(DBTransaction)
public final void commit()
throws TransactionException,
DatabaseException
DBTransaction
commit in interface DBTransactionTransactionException - if the transaction is already active
DatabaseException - if the transaction could not be committed to the underlying service
public final void abort()
throws TransactionException,
DatabaseException
DBTransaction
abort in interface DBTransactionTransactionException - if the transaction is already active
DatabaseException - if the transaction could not be aborted from the underlying servicepublic boolean isActive()
DBTransaction
isActive in interface DBTransactionpublic boolean isReadOnly()
DBTransactionDBTransaction.setNextToReadOnly(boolean)
isReadOnly in interface DBTransaction
public void setNextToReadOnly(boolean flag)
throws TransactionException,
UnsupportedOperationException
DBTransaction
setNextToReadOnly in interface DBTransactionflag - if true, the next transaction will run read-only;
if false, the next transaction will be read-write
TransactionException - if a transaction is currently active
UnsupportedOperationExceptionDBTransaction.isReadOnly()
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||