Package com.syncleus.ferma.tx
Interface TxFactory
public interface TxFactory
Interface which can be used for custom transaction factories in
order to provide various ways of executing transaction handlers.
-
Method Summary
Modifier and Type Method Description Tx
createTx()
Create a new transaction.default Tx
tx()
Return a new autoclosable transaction handler.<T> T
tx(TxAction<T> txHandler)
Execute the txHandler within the scope of a transaction and call the result handler once the transaction handler code has finished.default void
tx(TxAction0 txHandler)
Execute the txHandler within the scope of a transaction.default <T> T
tx(TxAction1<T> txHandler)
Execute the txHandler within the scope of a transaction.default void
tx(TxAction2 txHandler)
Execute the txHandler within the scope of a transaction.
-
Method Details
-
tx
Return a new autoclosable transaction handler. This object should be used within a try-with-resource block. Return an active transaction or create a new transaction if no active could be found.{ @code try(Tx tx = db.tx()) { // interact with graph db here } }
- Returns:
- Created transaction
-
createTx
Tx createTx()Create a new transaction.- Returns:
- new transaction.
-
tx
Execute the txHandler within the scope of a transaction and call the result handler once the transaction handler code has finished.- Type Parameters:
T
- Type of the object returned by the handler- Parameters:
txHandler
- Handler that will be executed within the scope of the transaction.- Returns:
- Object which was returned by the handler
-
tx
Execute the txHandler within the scope of a transaction.- Parameters:
txHandler
- Handler that will be executed within the scope of the transaction.
-
tx
Execute the txHandler within the scope of a transaction.- Type Parameters:
T
- type of the object returned by the handler.- Parameters:
txHandler
- Handler that will be executed within the scope of the transaction.- Returns:
- Result of the handler
-
tx
Execute the txHandler within the scope of a transaction.- Parameters:
txHandler
- Handler that will be executed within the scope of the transaction.
-