Search in sources :

Example 6 with PoolConfig

use of org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig in project spring-cloud-connectors by spring-cloud.

the class RedisConnectionFactoryConfigWithServiceConfig method pool5_30Wait3000.

@Bean
public RedisConnectionFactory pool5_30Wait3000() {
    PoolConfig poolConfig = new PoolConfig(5, 30, 3000);
    PooledServiceConnectorConfig serviceConfig = new RedisConnectionFactoryConfig(poolConfig);
    return connectionFactory().redisConnectionFactory("my-service", serviceConfig);
}
Also used : RedisConnectionFactoryConfig(org.springframework.cloud.service.keyval.RedisConnectionFactoryConfig) PooledServiceConnectorConfig(org.springframework.cloud.service.PooledServiceConnectorConfig) PoolConfig(org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig) Bean(org.springframework.context.annotation.Bean)

Example 7 with PoolConfig

use of org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig in project spring-cloud-connectors by spring-cloud.

the class PooledDataSourceCreatorsTest method pooledDataSourceCreationDefault.

@Test
public void pooledDataSourceCreationDefault() throws Exception {
    PoolConfig poolConfig = new PoolConfig(MIN_POOL_SIZE, MAX_POOL_SIZE, MAX_WAIT_TIME);
    ConnectionConfig connectionConfig = new ConnectionConfig(CONNECTION_PROPERTIES_STRING);
    DataSourceConfig config = new DataSourceConfig(poolConfig, connectionConfig);
    DataSource ds = createMysqlDataSource(config);
    assertTomcatJdbcDataSource(ds, true);
}
Also used : PoolConfig(org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig) ConnectionConfig(org.springframework.cloud.service.relational.DataSourceConfig.ConnectionConfig) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 8 with PoolConfig

use of org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig in project spring-cloud-connectors by spring-cloud.

the class PooledServiceConnectorConfigurer method configure.

@Override
public SC configure(SC serviceConnector, SCC config) {
    if (config != null) {
        BeanWrapper target = new BeanWrapperImpl(serviceConnector);
        PoolConfig poolConfig = config.getPoolConfig();
        if (poolConfig != null) {
            BeanWrapper poolSource = new BeanWrapperImpl(poolConfig);
            setCorrespondingProperties(target, poolSource);
        }
    }
    return serviceConnector;
}
Also used : BeanWrapper(org.springframework.beans.BeanWrapper) BeanWrapperImpl(org.springframework.beans.BeanWrapperImpl) PoolConfig(org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig)

Example 9 with PoolConfig

use of org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig in project spring-cloud-connectors by spring-cloud.

the class PooledDataSourceCreatorsTest method createMysqlDataSourceWithPooledName.

private DataSource createMysqlDataSourceWithPooledName(String pooledDataSourceName) {
    List<String> dataSourceNames = Collections.singletonList(pooledDataSourceName);
    PoolConfig poolConfig = new PoolConfig(MIN_POOL_SIZE, MAX_POOL_SIZE, MAX_WAIT_TIME);
    ConnectionConfig connectionConfig = new ConnectionConfig(CONNECTION_PROPERTIES_STRING);
    DataSourceConfig config = new DataSourceConfig(poolConfig, connectionConfig, dataSourceNames);
    return createMysqlDataSource(config);
}
Also used : PoolConfig(org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig) ConnectionConfig(org.springframework.cloud.service.relational.DataSourceConfig.ConnectionConfig)

Example 10 with PoolConfig

use of org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig in project spring-cloud-connectors by spring-cloud.

the class DatasourceConfigWithServiceConfig method dataSourceWithPoolConfig.

@Bean
public DataSource dataSourceWithPoolConfig() {
    PoolConfig poolConfig = new PoolConfig(5, 30, 3000);
    DataSourceConfig serviceConfig = new DataSourceConfig(poolConfig, null, basicDbcpConnectionPool());
    return connectionFactory().dataSource("my-service", serviceConfig);
}
Also used : DataSourceConfig(org.springframework.cloud.service.relational.DataSourceConfig) PoolConfig(org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig) Bean(org.springframework.context.annotation.Bean)

Aggregations

PoolConfig (org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig)10 Bean (org.springframework.context.annotation.Bean)6 ConnectionConfig (org.springframework.cloud.service.relational.DataSourceConfig.ConnectionConfig)5 DataSourceConfig (org.springframework.cloud.service.relational.DataSourceConfig)3 DataSource (javax.sql.DataSource)2 Test (org.junit.Test)2 PooledServiceConnectorConfig (org.springframework.cloud.service.PooledServiceConnectorConfig)2 RedisConnectionFactoryConfig (org.springframework.cloud.service.keyval.RedisConnectionFactoryConfig)2 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 BeanWrapper (org.springframework.beans.BeanWrapper)1 BeanWrapperImpl (org.springframework.beans.BeanWrapperImpl)1 DelegatingDataSource (org.springframework.jdbc.datasource.DelegatingDataSource)1