Search in sources :

Example 1 with PoolConfig

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

the class RedisConnectionFactoryConfigWithServiceConfig method pool30Wait300_timeout20.

@Bean
public RedisConnectionFactory pool30Wait300_timeout20() {
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("timeout", 20);
    PoolConfig poolConfig = new PoolConfig(30, 300);
    RedisConnectionFactoryConfig serviceConfig = new RedisConnectionFactoryConfig(poolConfig, properties);
    return connectionFactory().redisConnectionFactory("my-service", serviceConfig);
}
Also used : HashMap(java.util.HashMap) RedisConnectionFactoryConfig(org.springframework.cloud.service.keyval.RedisConnectionFactoryConfig) PoolConfig(org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig) Bean(org.springframework.context.annotation.Bean)

Example 2 with PoolConfig

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

the class GenericServiceWithConnectorType method myServiceWithTypeWithServiceNameAndConfig.

@Bean
public DataSource myServiceWithTypeWithServiceNameAndConfig() {
    PoolConfig poolConfig = new PoolConfig(20, 200);
    ConnectionConfig connectionConfig = new ConnectionConfig("sessionVariables=sql_mode='ANSI';characterEncoding=UTF-8");
    DataSourceConfig serviceConfig = new DataSourceConfig(poolConfig, connectionConfig);
    return connectionFactory().service("my-service", DataSource.class, serviceConfig);
}
Also used : DataSourceConfig(org.springframework.cloud.service.relational.DataSourceConfig) PoolConfig(org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig) ConnectionConfig(org.springframework.cloud.service.relational.DataSourceConfig.ConnectionConfig) Bean(org.springframework.context.annotation.Bean)

Example 3 with PoolConfig

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

the class RedisConnectionFactoryConfigWithServiceConfig method pool20Wait200.

@Bean
public RedisConnectionFactory pool20Wait200() {
    PoolConfig poolConfig = new PoolConfig(20, 200);
    PooledServiceConnectorConfig serviceConfig = new PooledServiceConnectorConfig(poolConfig);
    return connectionFactory().redisConnectionFactory("my-service", serviceConfig);
}
Also used : PooledServiceConnectorConfig(org.springframework.cloud.service.PooledServiceConnectorConfig) PoolConfig(org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig) Bean(org.springframework.context.annotation.Bean)

Example 4 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 5 with PoolConfig

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

the class AbstractDataSourceCreatorTest method cloudDataSourceCreationWithConfig.

@Test
public void cloudDataSourceCreationWithConfig() throws Exception {
    SI relationalServiceInfo = createServiceInfo();
    PoolConfig poolConfig = new PoolConfig("5", 100);
    ConnectionConfig connectionConfig = new ConnectionConfig("foo=bar");
    List<String> pooledDataSource = Collections.singletonList(BasicDbcpPooledDataSourceCreator.class.getSimpleName());
    DataSourceConfig config = new DataSourceConfig(poolConfig, connectionConfig, pooledDataSource);
    DataSource dataSource = getCreator().create(relationalServiceInfo, config);
    assertDataSourceProperties(relationalServiceInfo, dataSource);
    DataSourceCloudConfigTestHelper.assertPoolProperties(dataSource, 5, 0, 100);
    Properties connectionProp = new Properties();
    connectionProp.put("foo", "bar");
    assertConnectionProperties(dataSource, connectionProp);
}
Also used : PoolConfig(org.springframework.cloud.service.PooledServiceConnectorConfig.PoolConfig) Properties(java.util.Properties) ConnectionConfig(org.springframework.cloud.service.relational.DataSourceConfig.ConnectionConfig) DelegatingDataSource(org.springframework.jdbc.datasource.DelegatingDataSource) DataSource(javax.sql.DataSource) Test(org.junit.Test)

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