java.lang.Object
org.firebirdsql.gds.ng.AbstractFbTransaction
- All Implemented Interfaces:
FbTransaction
,ExceptionListenable
- Direct Known Subclasses:
V10Transaction
- Since:
- 3.0
- Author:
- Mark Rotteveel
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ExceptionListenerDispatcher
protected final TransactionListenerDispatcher
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractFbTransaction
(TransactionState initialState, FbDatabase database) Initializes AbstractFbTransaction. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addExceptionListener
(ExceptionListener listener) Adds an exception listener to this object.final void
addTransactionListener
(TransactionListener listener) Adds aTransactionListener
to the list of strongly referenced listeners.final void
Adds aTransactionListener
to the list of weakly referenced listeners.protected FbDatabase
final TransactionState
getState()
long
Retrieves the transaction id.<T> T
getTransactionInfo
(byte[] requestItems, int bufferLength, InfoProcessor<T> infoProcessor) Request transaction info.protected final void
logUnexpectedState
(TransactionState expectedState, System.Logger log) final void
removeExceptionListener
(ExceptionListener listener) Removes an exception listener to this object.final void
removeTransactionListener
(TransactionListener listener) Removes theTransactionListener
from the list of listeners.protected final void
switchState
(TransactionState newState) Switches current state to the supplied newState.protected final LockCloseable
withLock()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.firebirdsql.gds.ng.FbTransaction
commit, getHandle, getTransactionInfo, prepare, rollback
-
Field Details
-
exceptionListenerDispatcher
-
transactionListenerDispatcher
-
-
Constructor Details
-
AbstractFbTransaction
Initializes AbstractFbTransaction.- Parameters:
initialState
- Initial transaction state (allowed values areTransactionState.ACTIVE
andTransactionState.PREPARED
).database
- FbDatabase that created this handle.
-
-
Method Details
-
getState
- Specified by:
getState
in interfaceFbTransaction
- Returns:
- Current transaction state
-
switchState
Switches current state to the supplied newState.- Parameters:
newState
- New state to switch to- Throws:
SQLException
- If the requested state transition is not allowed or if the current state is also changed in a concurrent thread.
-
addTransactionListener
Description copied from interface:FbTransaction
Adds aTransactionListener
to the list of strongly referenced listeners.- Specified by:
addTransactionListener
in interfaceFbTransaction
- Parameters:
listener
- TransactionListener to register
-
addWeakTransactionListener
Description copied from interface:FbTransaction
Adds aTransactionListener
to the list of weakly referenced listeners.If the listener is already strongly referenced, this call will be ignored
- Specified by:
addWeakTransactionListener
in interfaceFbTransaction
- Parameters:
listener
- TransactionListener to register
-
removeTransactionListener
Description copied from interface:FbTransaction
Removes theTransactionListener
from the list of listeners.- Specified by:
removeTransactionListener
in interfaceFbTransaction
- Parameters:
listener
- TransactionListener to remove
-
addExceptionListener
Description copied from interface:ExceptionListenable
Adds an exception listener to this object.Implementations use
WeakReference
.- Specified by:
addExceptionListener
in interfaceExceptionListenable
- Parameters:
listener
- Listener to register
-
removeExceptionListener
Description copied from interface:ExceptionListenable
Removes an exception listener to this object.- Specified by:
removeExceptionListener
in interfaceExceptionListenable
- Parameters:
listener
- Listener to remove
-
getTransactionInfo
public <T> T getTransactionInfo(byte[] requestItems, int bufferLength, InfoProcessor<T> infoProcessor) throws SQLException Description copied from interface:FbTransaction
Request transaction info.- Specified by:
getTransactionInfo
in interfaceFbTransaction
- Parameters:
requestItems
- Array of info items to requestbufferLength
- Response buffer length to useinfoProcessor
- Implementation ofInfoProcessor
to transform the info response- Returns:
- Transformed info response of type T
- Throws:
SQLException
- For errors retrieving or transforming the response.
-
getTransactionId
Description copied from interface:FbTransaction
Retrieves 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:
getTransactionId
in interfaceFbTransaction
- Returns:
- Database transaction id.
- Throws:
SQLException
-
withLock
- See Also:
-
getDatabase
-
logUnexpectedState
-