Module bus.pager
Package org.miaixz.bus.pager.dialect
Class AbstractAutoDialect<Ds extends DataSource>
java.lang.Object
org.miaixz.bus.pager.dialect.AbstractAutoDialect<Ds>
- Type Parameters:
Ds- The specificDataSourceimplementation type this dialect handler supports.
- All Implemented Interfaces:
AutoDialect<String>
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 Summary
FieldsModifier and TypeFieldDescriptionprotected ClassThe class of the specific DataSource implementation. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an AbstractAutoDialect instance and determines the specific DataSource class from the generic type parameter. -
Method Summary
Modifier and TypeMethodDescriptionextractDialect(String dialectKey, org.apache.ibatis.mapping.MappedStatement ms, DataSource dataSource, Properties properties) Extracts and returns the appropriateAbstractPagingdialect based on the dialect key (JDBC URL).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.abstract StringgetJdbcUrl(Ds ds) Retrieves the JDBC URL from the specific DataSource instance.
-
Field Details
-
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
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:
extractDialectKeyin interfaceAutoDialect<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 appropriateAbstractPagingdialect based on the dialect key (JDBC URL).- Specified by:
extractDialectin interfaceAutoDialect<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
AbstractPagingrepresenting the determined dialect.
-