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 and Description
    --- | ---
    `protected ExceptionListenerDispatcher` | `exceptionListenerDispatcher`
    `protected TransactionListenerDispatcher` | `transactionListenerDispatcher`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractFbTransaction(TransactionState initialState, FbDatabase database)` Initializes AbstractFbTransaction.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addExceptionListener(ExceptionListener listener)` Adds an exception listener to this object.
    `void` | `addTransactionListener(TransactionListener listener)` Adds a `TransactionListener` to the list of strongly referenced listeners.
    `void` | `addWeakTransactionListener(TransactionListener listener)` Adds a `TransactionListener` to the list of weakly referenced listeners.
    `protected void` | `finalize()`
    `protected FbDatabase` | `getDatabase()`
    `TransactionState` | `getState()`
    `protected java.lang.Object` | `getSynchronizationObject()` Get synchronization object.
    `long` | `getTransactionId()` Retrieves the transaction id.
    `<T> T` | `getTransactionInfo(byte[] requestItems, int bufferLength, InfoProcessor<T> infoProcessor)` Request transaction info.
    `void` | `removeExceptionListener(ExceptionListener listener)` Removes an exception listener to this object.
    `void` | `removeTransactionListener(TransactionListener listener)` Removes the `TransactionListener` from the list of listeners.
    `protected void` | `switchState(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 are `TransactionState.ACTIVE` and `TransactionState.PREPARED`.
        `database` - FbDatabase that created this handle.

  - ### Method Detail

    - #### getState

          public final TransactionState getState()

      Specified by:
        `getState` in interface `FbTransaction`
      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: `FbTransaction`
      Adds a `TransactionListener` to the list of strongly referenced listeners.
      Specified by:
        `addTransactionListener` in interface `FbTransaction`
      Parameters:
        `listener` - TransactionListener to register

    - #### addWeakTransactionListener

          public final void addWeakTransactionListener(TransactionListener listener)

      Description copied from interface: `FbTransaction`
      Adds a `TransactionListener` to the list of weakly referenced listeners.

      If the listener is already strongly referenced, this call will be ignored

      Specified by:
        `addWeakTransactionListener` in interface `FbTransaction`
      Parameters:
        `listener` - TransactionListener to register

    - #### removeTransactionListener

          public final void removeTransactionListener(TransactionListener listener)

      Description copied from interface: `FbTransaction`
      Removes the `TransactionListener` from the list of listeners.
      Specified by:
        `removeTransactionListener` in interface `FbTransaction`
      Parameters:
        `listener` - TransactionListener to remove

    - #### addExceptionListener

          public final void addExceptionListener(ExceptionListener listener)

      Description copied from interface: `ExceptionListenable`
      Adds an exception listener to this object.

      Implementations use `WeakReference`.

      Specified by:
        `addExceptionListener` in interface `ExceptionListenable`
      Parameters:
        `listener` - Listener to register

    - #### removeExceptionListener

          public final void removeExceptionListener(ExceptionListener listener)

      Description copied from interface: `ExceptionListenable`
      Removes an exception listener to this object.
      Specified by:
        `removeExceptionListener` in interface `ExceptionListenable`
      Parameters:
        `listener` - Listener to remove

    - #### getTransactionInfo

          public <T> T getTransactionInfo(byte[] requestItems,
                                          int bufferLength,
                                          InfoProcessor<T> infoProcessor)
                                   throws java.sql.SQLException

      Description copied from interface: `FbTransaction`
      Request transaction info.
      Specified by:
        `getTransactionInfo` in interface `FbTransaction`
      Parameters:
        `requestItems` - Array of info items to request
        `bufferLength` - Response buffer length to use
        `infoProcessor` - Implementation of `InfoProcessor` to 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.SQLException

      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 interface `FbTransaction`
      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:
        `finalize` in class `java.lang.Object`
      Throws:
        `java.lang.Throwable`

    - #### getDatabase

          protected FbDatabase getDatabase()

Copyright © 2001-2021 Jaybird (Firebird JDBC/JCA) team. All rights reserved.