Package org.firebirdsql.gds.ng
Class AbstractFbTransaction
- java.lang.Object
-
- org.firebirdsql.gds.ng.AbstractFbTransaction
-
- All Implemented Interfaces:
FbTransaction,ExceptionListenable
- Direct Known Subclasses:
JnaTransaction,V10Transaction
public abstract class AbstractFbTransaction extends java.lang.Object implements FbTransaction
- Since:
- 3.0
- Author:
- Mark Rotteveel
-
-
Field Summary
Fields Modifier and Type Field Description protected ExceptionListenerDispatcherexceptionListenerDispatcherprotected TransactionListenerDispatchertransactionListenerDispatcher
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractFbTransaction(TransactionState initialState, FbDatabase database)Initializes AbstractFbTransaction.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddExceptionListener(ExceptionListener listener)Adds an exception listener to this object.voidaddTransactionListener(TransactionListener listener)Adds aTransactionListenerto the list of strongly referenced listeners.voidaddWeakTransactionListener(TransactionListener listener)Adds aTransactionListenerto the list of weakly referenced listeners.protected voidfinalize()protected FbDatabasegetDatabase()TransactionStategetState()protected java.lang.ObjectgetSynchronizationObject()Get synchronization object.longgetTransactionId()Retrieves the transaction id.<T> TgetTransactionInfo(byte[] requestItems, int bufferLength, InfoProcessor<T> infoProcessor)Request transaction info.voidremoveExceptionListener(ExceptionListener listener)Removes an exception listener to this object.voidremoveTransactionListener(TransactionListener listener)Removes theTransactionListenerfrom the list of listeners.protected voidswitchState(TransactionState newState)Switches current state to the supplied newState.-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.firebirdsql.gds.ng.FbTransaction
commit, getHandle, getTransactionInfo, prepare, rollback
-
-
-
-
Field Detail
-
exceptionListenerDispatcher
protected final ExceptionListenerDispatcher exceptionListenerDispatcher
-
transactionListenerDispatcher
protected final TransactionListenerDispatcher transactionListenerDispatcher
-
-
Constructor Detail
-
AbstractFbTransaction
protected AbstractFbTransaction(TransactionState initialState, FbDatabase database)
Initializes AbstractFbTransaction.- Parameters:
initialState- Initial transaction state (allowed values areTransactionState.ACTIVEandTransactionState.PREPARED.database- FbDatabase that created this handle.
-
-
Method Detail
-
getState
public final TransactionState getState()
- Specified by:
getStatein interfaceFbTransaction- Returns:
- Current transaction state
-
switchState
protected final void switchState(TransactionState newState) throws java.sql.SQLException
Switches current state to the supplied newState.- Parameters:
newState- New state to switch to- Throws:
java.sql.SQLException- If the requested state transition is not allowed or if the current state is also changed in a concurrent thread.
-
addTransactionListener
public final void addTransactionListener(TransactionListener listener)
Description copied from interface:FbTransactionAdds aTransactionListenerto the list of strongly referenced listeners.- Specified by:
addTransactionListenerin interfaceFbTransaction- Parameters:
listener- TransactionListener to register
-
addWeakTransactionListener
public final void addWeakTransactionListener(TransactionListener listener)
Description copied from interface:FbTransactionAdds aTransactionListenerto the list of weakly referenced listeners.If the listener is already strongly referenced, this call will be ignored
- Specified by:
addWeakTransactionListenerin interfaceFbTransaction- Parameters:
listener- TransactionListener to register
-
removeTransactionListener
public final void removeTransactionListener(TransactionListener listener)
Description copied from interface:FbTransactionRemoves theTransactionListenerfrom the list of listeners.- Specified by:
removeTransactionListenerin interfaceFbTransaction- Parameters:
listener- TransactionListener to remove
-
addExceptionListener
public final void addExceptionListener(ExceptionListener listener)
Description copied from interface:ExceptionListenableAdds an exception listener to this object.Implementations use
WeakReference.- Specified by:
addExceptionListenerin interfaceExceptionListenable- Parameters:
listener- Listener to register
-
removeExceptionListener
public final void removeExceptionListener(ExceptionListener listener)
Description copied from interface:ExceptionListenableRemoves an exception listener to this object.- Specified by:
removeExceptionListenerin interfaceExceptionListenable- Parameters:
listener- Listener to remove
-
getTransactionInfo
public <T> T getTransactionInfo(byte[] requestItems, int bufferLength, InfoProcessor<T> infoProcessor) throws java.sql.SQLExceptionDescription copied from interface:FbTransactionRequest transaction info.- Specified by:
getTransactionInfoin interfaceFbTransaction- Parameters:
requestItems- Array of info items to requestbufferLength- Response buffer length to useinfoProcessor- Implementation ofInfoProcessorto transform the info response- Returns:
- Transformed info response of type T
- Throws:
java.sql.SQLException- For errors retrieving or transforming the response.
-
getTransactionId
public long getTransactionId() throws java.sql.SQLExceptionDescription copied from interface:FbTransactionRetrieves the transaction id.The transaction id is the database transaction id, not to be confused with the attachment level transaction handle provided by
FbTransaction.getHandle().- Specified by:
getTransactionIdin interfaceFbTransaction- Returns:
- Database transaction id.
- Throws:
java.sql.SQLException
-
getSynchronizationObject
protected final java.lang.Object getSynchronizationObject()
Get synchronization object.- Returns:
- object, cannot be
null.
-
finalize
protected void finalize() throws java.lang.Throwable- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable
-
getDatabase
protected FbDatabase getDatabase()
-
-