io.agroal.api.configuration.supplier.AgroalDataSourceConfigurationSupplier Java Examples

The following examples show how to use io.agroal.api.configuration.supplier.AgroalDataSourceConfigurationSupplier. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AgroalDataSourceFactory.java    From kumuluzee with MIT License 5 votes vote down vote up
public static AgroalDataSource createDataSource(DataSourceConfig dsc, boolean jtaPresent) {
    AgroalDataSourceConfigurationSupplier dataSourceConfig = new AgroalDataSourceConfigurationSupplier();

    AgroalConnectionPoolConfigurationSupplier poolConfig = dataSourceConfig.connectionPoolConfiguration();

    AgroalConnectionFactoryConfigurationSupplier connectionFactoryConfig = poolConfig.connectionFactoryConfiguration();

    if (!jtaPresent) {
        dataSourceConfig.dataSourceImplementation(DataSourceImplementation.HIKARI);
    } else {
        poolConfig.transactionIntegration( JtaProvider.getInstance().getTransactionIntegration() );
    }

    if (!StringUtils.isNullOrEmpty( dsc.getDriverClass() )) {
        connectionFactoryConfig.connectionProviderClassName(dsc.getDriverClass());
    } else if (!StringUtils.isNullOrEmpty( dsc.getDataSourceClass( ))) {
        connectionFactoryConfig.connectionProviderClassName(dsc.getDataSourceClass());
    }

    if (!StringUtils.isNullOrEmpty( dsc.getConnectionUrl() )) {
        connectionFactoryConfig.jdbcUrl(dsc.getConnectionUrl());
    }

    setDatabaseCredentials(connectionFactoryConfig, dsc.getUsername(), dsc.getPassword());

    setConnectionPoolConfiguration(poolConfig, connectionFactoryConfig, dsc.getPool(), !jtaPresent);

    dsc.getProps().forEach(connectionFactoryConfig::jdbcProperty);

    try {
        return AgroalDataSource.from( dataSourceConfig );
    } catch (SQLException e) {
        throw new KumuluzServerException("Failed to create DataSource", e);
    }
}
 
Example #2
Source File: AgroalDataSourceFactory.java    From kumuluzee with MIT License 5 votes vote down vote up
public static AgroalDataSource createXaDataSource(XaDataSourceConfig xdsc, boolean jtaPresent) {
    AgroalDataSourceConfigurationSupplier xaDataSourceConfig = new AgroalDataSourceConfigurationSupplier();

    AgroalConnectionPoolConfigurationSupplier poolConfig = xaDataSourceConfig.connectionPoolConfiguration();

    AgroalConnectionFactoryConfigurationSupplier connectionFactoryConfig = poolConfig.connectionFactoryConfiguration();

    if (jtaPresent) {
        poolConfig.transactionIntegration( JtaProvider.getInstance().getTransactionIntegration() );
    }

    if (!StringUtils.isNullOrEmpty( xdsc.getXaDatasourceClass() )) {
        connectionFactoryConfig.connectionProviderClassName( xdsc.getXaDatasourceClass() );
    }

    setDatabaseCredentials(connectionFactoryConfig, xdsc.getUsername(), xdsc.getPassword());

    setConnectionPoolConfiguration(poolConfig, connectionFactoryConfig, xdsc.getPool(), false);

    xdsc.getProps().forEach(connectionFactoryConfig::jdbcProperty);

    try {
        return AgroalDataSource.from( xaDataSourceConfig );
    } catch (SQLException e) {
        throw new KumuluzServerException("Failed to create XaDataSource", e);
    }
}
 
Example #3
Source File: AgroalConnectionConfigurer.java    From quarkus with Apache License 2.0 4 votes vote down vote up
default void disableSslSupport(String databaseKind, AgroalDataSourceConfigurationSupplier dataSourceConfiguration) {
    log.warnv("Agroal does not support disabling SSL for database kind: {0}", databaseKind);
}
 
Example #4
Source File: MariaDBAgroalConnectionConfigurer.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public void disableSslSupport(String databaseKind, AgroalDataSourceConfigurationSupplier dataSourceConfiguration) {
    dataSourceConfiguration.connectionPoolConfiguration().connectionFactoryConfiguration().jdbcProperty("useSSL", "false");
}
 
Example #5
Source File: PostgreSQLAgroalConnectionConfigurer.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public void disableSslSupport(String databaseKind, AgroalDataSourceConfigurationSupplier dataSourceConfiguration) {
    dataSourceConfiguration.connectionPoolConfiguration().connectionFactoryConfiguration().jdbcProperty("sslmode",
            "disable");
}
 
Example #6
Source File: H2AgroalConnectionConfigurer.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public void disableSslSupport(String databaseKind, AgroalDataSourceConfigurationSupplier dataSourceConfiguration) {
    // do not log anything for H2
}
 
Example #7
Source File: MsSQLAgroalConnectionConfigurer.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public void disableSslSupport(String databaseKind, AgroalDataSourceConfigurationSupplier dataSourceConfiguration) {
    dataSourceConfiguration.connectionPoolConfiguration().connectionFactoryConfiguration().jdbcProperty("encrypt", "false");
}
 
Example #8
Source File: MySQLAgroalConnectionConfigurer.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public void disableSslSupport(String databaseKind, AgroalDataSourceConfigurationSupplier dataSourceConfiguration) {
    dataSourceConfiguration.connectionPoolConfiguration().connectionFactoryConfiguration().jdbcProperty("useSSL", "false");
}