diff --git a/src/main/java/org/springframework/data/redis/connection/PoolConfig.java b/src/main/java/org/springframework/data/redis/connection/PoolConfig.java new file mode 100644 index 000000000..d5f7550bb --- /dev/null +++ b/src/main/java/org/springframework/data/redis/connection/PoolConfig.java @@ -0,0 +1,78 @@ +/* + * Copyright 2013 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.data.redis.connection; + +import org.apache.commons.pool.impl.GenericObjectPool.Config; + +/** + * Subclass of {@link Config} that includes setters for instantiation in Spring + * + * @author Jennifer Hickey + */ +public class PoolConfig extends Config { + + public PoolConfig() { + super(); + } + + public void setMaxIdle(int maxIdle) { + this.maxIdle = maxIdle; + } + + public void setMinIdle(int minIdle) { + this.minIdle = minIdle; + } + + public void setMaxActive(int maxActive) { + this.maxActive = maxActive; + } + + public void setMaxWait(long maxWait) { + this.maxWait = maxWait; + } + + public void setWhenExhaustedAction(byte whenExhaustedAction) { + this.whenExhaustedAction = whenExhaustedAction; + } + + public void setTestOnBorrow(boolean testOnBorrow) { + this.testOnBorrow = testOnBorrow; + } + + public void setTestOnReturn(boolean testOnReturn) { + this.testOnReturn = testOnReturn; + } + + public void setTestWhileIdle(boolean testWhileIdle) { + this.testWhileIdle = testWhileIdle; + } + + public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) { + this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis; + } + + public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) { + this.numTestsPerEvictionRun = numTestsPerEvictionRun; + } + + public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis) { + this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis; + } + + public void setSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis) { + this.softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis; + } +} diff --git a/src/test/java/org/springframework/data/redis/connection/lettuce/LettucePoolTests.java b/src/test/java/org/springframework/data/redis/connection/lettuce/LettucePoolTests.java index b9abb64b6..b7d94b5c9 100644 --- a/src/test/java/org/springframework/data/redis/connection/lettuce/LettucePoolTests.java +++ b/src/test/java/org/springframework/data/redis/connection/lettuce/LettucePoolTests.java @@ -24,6 +24,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.springframework.data.redis.SettingsUtils; +import org.springframework.data.redis.connection.PoolConfig; import org.springframework.data.redis.connection.PoolException; import com.lambdaworks.redis.RedisAsyncConnection; @@ -79,8 +80,8 @@ public class LettucePoolTests { @Test public void testGetResourceValidate() { - Config poolConfig = new Config(); - poolConfig.testOnBorrow = true; + PoolConfig poolConfig = new PoolConfig(); + poolConfig.setTestOnBorrow(true); this.pool = new LettucePool(client, poolConfig, 0); RedisAsyncConnection client = pool.getResource(); assertNotNull(client);