Class DatabaseMySQLModule

java.lang.Object
com.google.inject.AbstractModule
io.github.devlibx.easy.lock.module.LockModule
io.github.devlibx.easy.database.mysql.module.DatabaseMySQLModule
All Implemented Interfaces:
com.google.inject.Module

public class DatabaseMySQLModule extends LockModule
This module provides all the dependencies to support MySQL related functions.
 Yoy can customize the following:

 TransactionInterceptor - this class handles how methods annotated with @Transactional
 handle transactions

 ITransactionManagerResolver - this class resolves the transaction manager to be used by methods annotated by
 Transactional

  NOTE - by default transaction aware data source is enabled. You must mark it false if you don't want to use it:

  If you want to disable it then you must set "enable-transaction-aware-datasource=false" using following code
  
  OptionalBinder.newOptionalBinder(binder(), Key.get(Boolean.class, Names.named("enable-transaction-aware-datasource")))
      .setBinding()
      .toInstance(Boolean.FALSE);
 

 Also use DatabaseMySQLModule(false) to disable transaction manager.
  • Constructor Details

    • DatabaseMySQLModule

      public DatabaseMySQLModule()
    • DatabaseMySQLModule

      public DatabaseMySQLModule(boolean enableTransactionInterceptor, int defaultTimeout)
  • Method Details

    • configure

      protected void configure()
      Overrides:
      configure in class LockModule
    • healthCheckRegistrationName

      protected String healthCheckRegistrationName()
    • transactionManagerResolver

      protected ITransactionManagerResolver transactionManagerResolver()
      Returns:
      DefaultTransactionManagerResolver - application can override this method to provide custom resolver.
    • transactionInterceptor

      protected TransactionInterceptor transactionInterceptor()
      Returns:
      TransactionInterceptor which will handle method annotated with @Transactional
    • jdbi

      @Provides @Inject public org.jdbi.v3.core.Jdbi jdbi(DataSource dataSource)