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
Provides methods for using transactions in the booking application.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
TransactionHandler
(T handler) Constructs a handler for using transactions. -
Method Summary
Modifier and TypeMethodDescriptionabstract 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.
-
Field Details
-
handler
The handler for starting, committing and aborting transactions.
-
-
Constructor Details
-
TransactionHandler
Constructs a handler for using transactions.- Parameters:
handler
- the handler used for transactions.
-
-
Method Details
-
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.
-