Class TransactionHandler<T>

java.lang.Object
io.github.marcopaglio.booking.transaction.handler.TransactionHandler<T>
Type Parameters:
T - the type of transactions handler.
Direct Known Subclasses:
TransactionMongoHandler, TransactionPostgresHandler

public abstract class TransactionHandler<T> extends Object
Provides methods for using transactions in the booking application.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected T
    The handler for starting, committing and aborting transactions.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructs a handler for using transactions.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    Closes the handler connection, if still open.
    abstract void
    Commits changes of the active transaction.
    final T
    Retrieves the handler of type T used for using transactions.
    abstract void
    Rolls back changes of the active transaction.
    abstract void
    Starts a new transaction, if one isn't already active.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • handler

      protected T handler
      The handler for starting, committing and aborting transactions.
  • Constructor Details

    • TransactionHandler

      protected TransactionHandler(T handler)
      Constructs a handler for using transactions.
      Parameters:
      handler - the handler used for transactions.
  • Method Details

    • getHandler

      @Generated public final T getHandler()
      Retrieves the handler of type T used for using transactions.
      Returns:
      the transaction handler of type T.
    • startTransaction

      public abstract void startTransaction()
      Starts a new transaction, if one isn't already active.
    • commitTransaction

      public abstract void commitTransaction()
      Commits changes of the active transaction.
    • rollbackTransaction

      public abstract void rollbackTransaction()
      Rolls back changes of the active transaction. Note: an already committed transaction cannot be rolled back.
    • closeHandler

      public abstract void closeHandler()
      Closes the handler connection, if still open.