org.jooq.ConnectionProvider Java Examples

The following examples show how to use org.jooq.ConnectionProvider. 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: JooqBinder.java    From droptools with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure() {
    // bind default Configuration to DSLContext
    bindFactory(new DSLContextFactory(configurationMap.values().stream().findFirst().orElse(null)))
            .to(DSLContext.class)
            .in(RequestScoped.class);

    // bind multiple instances of Configuration and ConnectionProvider for Named DSLContext(s)
    for (final Configuration configuration : configurationMap.values()) {

        bind(configuration).to(Configuration.class);

        bind(configuration.connectionProvider())
                .to(ConnectionProvider.class);
    }

    // bind a ValueParamProvider for Named DSLContext(s)
    bind(new DSLContextValueParamProvider(configurationMap))
            .to(ValueParamProvider.class);
}
 
Example #2
Source File: JooqFactory.java    From droptools with Apache License 2.0 5 votes vote down vote up
public Configuration build(Environment environment, PooledDataSourceFactory factory, String name) throws ClassNotFoundException {
    final Settings settings = buildSettings();
    final ManagedDataSource dataSource = factory.build(environment.metrics(), name);
    final SQLDialect dialect = determineDialect(factory, dataSource);
    final ConnectionProvider connectionProvider = new DataSourceConnectionProvider(dataSource);
    final Configuration config = new DefaultConfiguration()
            .set(settings)
            .set(dialect)
            .set(connectionProvider);

    environment.lifecycle().manage(dataSource);

    return config;
}