Class TransactionHandlerFactory
java.lang.Object
io.github.marcopaglio.booking.transaction.handler.factory.TransactionHandlerFactory
A factory of transaction handlers.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateTransactionHandler
(com.mongodb.client.MongoClient mongoClient, com.mongodb.TransactionOptions txnOptions) Creates a new session for handling MongoDB transactions using a client.createTransactionHandler
(jakarta.persistence.EntityManagerFactory emf) Creates a new entity manager for handling PostgreSQL transactions using an EntityManagerFactory.
-
Constructor Details
-
TransactionHandlerFactory
public TransactionHandlerFactory()Empty constructor.
-
-
Method Details
-
createTransactionHandler
public TransactionMongoHandler createTransactionHandler(com.mongodb.client.MongoClient mongoClient, com.mongodb.TransactionOptions txnOptions) throws IllegalArgumentException Creates a new session for handling MongoDB transactions using a client.- Parameters:
mongoClient
- the client using the MongoDB database.txnOptions
- the options used in the transaction.- Returns:
- a new
ClientSession
for creating transactions. - Throws:
IllegalArgumentException
- ifmongoClient
is null.
-
createTransactionHandler
public TransactionPostgresHandler createTransactionHandler(jakarta.persistence.EntityManagerFactory emf) Creates a new entity manager for handling PostgreSQL transactions using an EntityManagerFactory.- Parameters:
emf
- the entity manager factory for interacting with the PostgreSQL database.- Returns:
- a new
TransactionPostgresHandler
for creating transactions. - Throws:
IllegalArgumentException
- ifemf
is null.
-