Class TransactionHandlerFactory

java.lang.Object
io.github.marcopaglio.booking.transaction.handler.factory.TransactionHandlerFactory

public class TransactionHandlerFactory extends Object
A factory of transaction handlers.
  • 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 - if mongoClient 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 - if emf is null.