All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkiverse.mybatis.runtime.QuarkusDatabaseIdProvider Maven / Gradle / Ivy

The newest version!
package io.quarkiverse.mybatis.runtime;

import java.sql.SQLException;

import javax.sql.DataSource;

import org.apache.ibatis.mapping.DatabaseIdProvider;
import org.eclipse.microprofile.config.ConfigProvider;

public class QuarkusDatabaseIdProvider implements DatabaseIdProvider {
    @Override
    public String getDatabaseId(final DataSource dataSource) throws SQLException {
        if (dataSource instanceof QuarkusDataSource ds) {
            String name = ds.getDataSourceName();
            return ConfigProvider.getConfig().getOptionalValue(
                    "quarkus.mybatis." + ("".equals(name) ? "" : name + ".") + "database-id", String.class)
                    .orElse(null);
        }
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy