io.github.sinri.keel.mysql.KeelMySQLDataSourceProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Keel Show documentation
Show all versions of Keel Show documentation
A website framework with VERT.X for ex-PHP-ers, exactly Ark Framework Users.
The newest version!
package io.github.sinri.keel.mysql;
import io.vertx.sqlclient.SqlConnection;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import static io.github.sinri.keel.facade.KeelInstance.Keel;
public class KeelMySQLDataSourceProvider {
@Nonnull
public static String defaultMySQLDataSourceName() {
return Objects.requireNonNull(Keel.getConfiguration().readString(List.of("mysql", "default_data_source_name"), "default"));
}
/**
* @since 3.0.11 Technical Preview.
* @since 3.0.18 Finished Technical Preview.
*/
public static NamedMySQLDataSource initializeNamedMySQLDataSource(
@Nonnull String dataSourceName,
Function sqlConnectionWrapper
) {
var configuration = Keel.getConfiguration().extract("mysql", dataSourceName);
Objects.requireNonNull(configuration);
KeelMySQLConfiguration mySQLConfigure = new KeelMySQLConfiguration(configuration);
return new NamedMySQLDataSource<>(mySQLConfigure, sqlConnectionWrapper);
}
/**
* @since 3.0.11 Technical Preview.
* @since 3.0.18 Finished Technical Preview.
*/
public static NamedMySQLDataSource initializeDynamicNamedMySQLDataSource(@Nonnull String dataSourceName) {
return initializeNamedMySQLDataSource(dataSourceName, sqlConnection -> new DynamicNamedMySQLConnection(sqlConnection, dataSourceName));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy