Module bus.pager

Class AbstractAutoDialect<Ds extends DataSource>

java.lang.Object
org.miaixz.bus.pager.dialect.AbstractAutoDialect<Ds>
Type Parameters:
Ds - The specific DataSource implementation type this dialect handler supports.
All Implemented Interfaces:
AutoDialect<String>
Direct Known Subclasses:
Druid, Hikari

public abstract class AbstractAutoDialect<Ds extends DataSource> extends Object implements AutoDialect<String>
Abstract base class for auto-detecting database dialects from a DataSource. This class provides a default implementation that can extract the JDBC URL from specific DataSource types, such as HikariCP, to determine the dialect.
Since:
Java 17+
Author:
Kimi Liu
  • Field Details

    • dataSourceClass

      protected Class dataSourceClass
      The class of the specific DataSource implementation.
  • Constructor Details

    • AbstractAutoDialect

      public AbstractAutoDialect()
      Constructs an AbstractAutoDialect instance and determines the specific DataSource class from the generic type parameter.
  • Method Details

    • getJdbcUrl

      public abstract String getJdbcUrl(Ds ds)
      Retrieves the JDBC URL from the specific DataSource instance.
      Parameters:
      ds - the DataSource instance.
      Returns:
      the JDBC URL string.
    • extractDialectKey

      public String extractDialectKey(org.apache.ibatis.mapping.MappedStatement ms, DataSource dataSource, Properties properties)
      Extracts the dialect key (JDBC URL) if the provided DataSource matches the supported type.
      Specified by:
      extractDialectKey in interface AutoDialect<Ds extends DataSource>
      Parameters:
      ms - the MappedStatement being executed.
      dataSource - the DataSource associated with the MappedStatement.
      properties - the configuration properties.
      Returns:
      the JDBC URL as the dialect key if the DataSource is of the supported type, otherwise null.
    • extractDialect

      public AbstractPaging extractDialect(String dialectKey, org.apache.ibatis.mapping.MappedStatement ms, DataSource dataSource, Properties properties)
      Extracts and returns the appropriate AbstractPaging dialect based on the dialect key (JDBC URL).
      Specified by:
      extractDialect in interface AutoDialect<Ds extends DataSource>
      Parameters:
      dialectKey - the dialect key (JDBC URL).
      ms - the MappedStatement being executed.
      dataSource - the DataSource associated with the MappedStatement.
      properties - the configuration properties.
      Returns:
      an instance of AbstractPaging representing the determined dialect.