diff --git a/core/src/main/java/org/springframework/ldap/config/ContextSourceParser.java b/core/src/main/java/org/springframework/ldap/config/ContextSourceParser.java
index df939400..94909655 100644
--- a/core/src/main/java/org/springframework/ldap/config/ContextSourceParser.java
+++ b/core/src/main/java/org/springframework/ldap/config/ContextSourceParser.java
@@ -45,6 +45,7 @@ import static org.springframework.ldap.config.ParserUtils.getString;
/**
* @author Mattias Hellborg Arthursson
+ * @author Eddu Melendez
*/
public class ContextSourceParser implements BeanDefinitionParser {
private static final String ATT_ANONYMOUS_READ_ONLY = "anonymous-read-only";
@@ -212,15 +213,16 @@ public class ContextSourceParser implements BeanDefinitionParser {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(PoolingContextSource.class);
builder.addPropertyValue("contextSource", targetContextSourceDefinition);
- builder.addPropertyValue("maxActive", getInt(poolingElement, ATT_MAX_ACTIVE, DEFAULT_MAX_ACTIVE));
- builder.addPropertyValue("maxTotal", getInt(poolingElement, ATT_MAX_TOTAL, DEFAULT_MAX_TOTAL));
- builder.addPropertyValue("maxIdle", getInt(poolingElement, ATT_MAX_IDLE, DEFAULT_MAX_IDLE));
- builder.addPropertyValue("minIdle", getInt(poolingElement, ATT_MIN_IDLE, DEFAULT_MIN_IDLE));
- builder.addPropertyValue("maxWait", getInt(poolingElement, ATT_MAX_WAIT, DEFAULT_MAX_WAIT));
+ builder.addPropertyValue("maxActive", getString(poolingElement, ATT_MAX_ACTIVE, String.valueOf(DEFAULT_MAX_ACTIVE)));
+ builder.addPropertyValue("maxTotal", getString(poolingElement, ATT_MAX_TOTAL, String.valueOf(DEFAULT_MAX_TOTAL)));
+ builder.addPropertyValue("maxIdle", getString(poolingElement, ATT_MAX_IDLE, String.valueOf(DEFAULT_MAX_IDLE)));
+ builder.addPropertyValue("minIdle", getString(poolingElement, ATT_MIN_IDLE, String.valueOf(DEFAULT_MIN_IDLE)));
+ builder.addPropertyValue("maxWait", getString(poolingElement, ATT_MAX_WAIT, String.valueOf(DEFAULT_MAX_WAIT)));
String whenExhausted = getString(poolingElement, ATT_WHEN_EXHAUSTED, PoolExhaustedAction.BLOCK.name());
builder.addPropertyValue("whenExhaustedAction", PoolExhaustedAction.valueOf(whenExhausted).getValue());
builder.addPropertyValue("timeBetweenEvictionRunsMillis", getString(poolingElement, ATT_EVICTION_RUN_MILLIS, String.valueOf(DEFAULT_EVICTION_RUN_MILLIS)));
builder.addPropertyValue("minEvictableIdleTimeMillis", getString(poolingElement, ATT_EVICTABLE_TIME_MILLIS, String.valueOf(DEFAULT_EVICTABLE_MILLIS)));
+ builder.addPropertyValue("numTestsPerEvictionRun", getString(poolingElement, ATT_TESTS_PER_EVICTION_RUN, String.valueOf(DEFAULT_TESTS_PER_EVICTION_RUN)));
boolean testOnBorrow = getBoolean(poolingElement, ATT_TEST_ON_BORROW, false);
boolean testOnReturn = getBoolean(poolingElement, ATT_TEST_ON_RETURN, false);
@@ -302,26 +304,26 @@ public class ContextSourceParser implements BeanDefinitionParser {
BeanDefinitionBuilder configBuilder = BeanDefinitionBuilder
.rootBeanDefinition(PoolConfig.class);
- configBuilder.addPropertyValue("maxTotal", getInt(element, ATT_MAX_TOTAL, DEFAULT_MAX_TOTAL));
- configBuilder.addPropertyValue("maxTotalPerKey", getInt(element, ATT_MAX_TOTAL_PER_KEY, DEFAULT_MAX_TOTAL_PER_KEY));
- configBuilder.addPropertyValue("maxIdlePerKey", getInt(element, ATT_MAX_IDLE_PER_KEY, DEFAULT_MAX_IDLE_PER_KEY));
- configBuilder.addPropertyValue("minIdlePerKey", getInt(element, ATT_MIN_IDLE_PER_KEY, DEFAULT_MIN_IDLE_PER_KEY));
+ configBuilder.addPropertyValue("maxTotal", getString(element, ATT_MAX_TOTAL, String.valueOf(DEFAULT_MAX_TOTAL)));
+ configBuilder.addPropertyValue("maxTotalPerKey", getString(element, ATT_MAX_TOTAL_PER_KEY, String.valueOf(DEFAULT_MAX_TOTAL_PER_KEY)));
+ configBuilder.addPropertyValue("maxIdlePerKey", getString(element, ATT_MAX_IDLE_PER_KEY, String.valueOf(DEFAULT_MAX_IDLE_PER_KEY)));
+ configBuilder.addPropertyValue("minIdlePerKey", getString(element, ATT_MIN_IDLE_PER_KEY, String.valueOf(DEFAULT_MIN_IDLE_PER_KEY)));
configBuilder.addPropertyValue("evictionPolicyClassName", getString(element, ATT_EVICTION_POLICY_CLASS, DEFAULT_EVICTION_POLICY_CLASS_NAME));
configBuilder.addPropertyValue("fairness", getBoolean(element, ATT_FAIRNESS, DEFAULT_FAIRNESS));
configBuilder.addPropertyValue("jmxEnabled", getBoolean(element, ATT_JMX_ENABLE, DEFAULT_JMX_ENABLE));
configBuilder.addPropertyValue("jmxNameBase", getString(element, ATT_JMX_NAME_BASE, DEFAULT_JMX_NAME_BASE));
configBuilder.addPropertyValue("jmxNamePrefix", getString(element, ATT_JMX_NAME_PREFIX, DEFAULT_JMX_NAME_PREFIX));
configBuilder.addPropertyValue("lifo", getBoolean(element, ATT_LIFO, DEFAULT_LIFO));
- configBuilder.addPropertyValue("maxWaitMillis", getInt(element, ATT_MAX_WAIT, DEFAULT_MAX_WAIT_MILLIS));
- configBuilder.addPropertyValue("blockWhenExhausted", getBoolean(element, ATT_BLOCK_WHEN_EXHAUSTED, DEFAULT_BLOCK_WHEN_EXHAUSTED));
+ configBuilder.addPropertyValue("maxWaitMillis", getString(element, ATT_MAX_WAIT, String.valueOf(DEFAULT_MAX_WAIT_MILLIS)));
+ configBuilder.addPropertyValue("blockWhenExhausted", Boolean.valueOf(getString(element, ATT_BLOCK_WHEN_EXHAUSTED, String.valueOf(DEFAULT_BLOCK_WHEN_EXHAUSTED))));
configBuilder.addPropertyValue("testOnBorrow", getBoolean(element, ATT_TEST_ON_BORROW, false));
configBuilder.addPropertyValue("testOnCreate", getBoolean(element, ATT_TEST_ON_CREATE, false));
configBuilder.addPropertyValue("testOnReturn", getBoolean(element, ATT_TEST_ON_RETURN, false));
configBuilder.addPropertyValue("testWhileIdle", getBoolean(element, ATT_TEST_WHILE_IDLE, false));
configBuilder.addPropertyValue("timeBetweenEvictionRunsMillis", getString(element, ATT_EVICTION_RUN_MILLIS, String.valueOf(DEFAULT_EVICTION_RUN_MILLIS)));
- configBuilder.addPropertyValue("numTestsPerEvictionRun", getInt(element, ATT_TESTS_PER_EVICTION_RUN, DEFAULT_TESTS_PER_EVICTION_RUN));
+ configBuilder.addPropertyValue("numTestsPerEvictionRun", getString(element, ATT_TESTS_PER_EVICTION_RUN, String.valueOf(DEFAULT_TESTS_PER_EVICTION_RUN)));
configBuilder.addPropertyValue("minEvictableIdleTimeMillis", getString(element, ATT_EVICTABLE_TIME_MILLIS, String.valueOf(DEFAULT_EVICTABLE_MILLIS)));
- configBuilder.addPropertyValue("softMinEvictableIdleTimeMillis", getInt(element, ATT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS, DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS));
+ configBuilder.addPropertyValue("softMinEvictableIdleTimeMillis", getString(element, ATT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS, String.valueOf(DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS)));
builder.addConstructorArgValue(configBuilder.getBeanDefinition());
}
diff --git a/core/src/main/resources/org/springframework/ldap/config/spring-ldap-2.0.xsd b/core/src/main/resources/org/springframework/ldap/config/spring-ldap-2.0.xsd
index 7d264720..80e038c7 100644
--- a/core/src/main/resources/org/springframework/ldap/config/spring-ldap-2.0.xsd
+++ b/core/src/main/resources/org/springframework/ldap/config/spring-ldap-2.0.xsd
@@ -105,7 +105,7 @@
-
+
The maximum number of active connections of each type (read-only|read-write)
@@ -114,7 +114,7 @@
-
+
The overall maximum number of active connections (for all types) that can be allocated from
@@ -122,7 +122,7 @@
-
+
The maximum number of active connections of each type (read-only|read-write) that can remain idle in the pool,
@@ -130,7 +130,7 @@
-
+
The minimum number of active connections of each type (read-only|read-write) that can remain
@@ -138,7 +138,7 @@
-
+
The maximum number of milliseconds that the pool will wait (when there are no available connections)
@@ -214,7 +214,7 @@
-
+
The number of objects to examine during each run of the idle object evictor thread (if any).
@@ -263,7 +263,7 @@
-
+
The overall maximum number of active connections (for all types) that can be allocated from
@@ -271,7 +271,7 @@
-
+
The limit on the number of object instances allocated by the pool (checked out or idle),
@@ -280,7 +280,7 @@
-
+
The maximum number of active connections per type (read-only|read-write) that can remain idle in the pool,
@@ -288,7 +288,7 @@
-
+
The minimum number of active connections per type (read-only|read-write) that can remain
@@ -296,7 +296,7 @@
-
+
The maximum number of milliseconds that the pool will wait (when there are no available connections)
@@ -355,7 +355,7 @@
-
+
The number of objects to examine during each run of the idle object evictor thread (if any).
@@ -371,7 +371,7 @@
-
+
The minimum amount of time an object may sit idle in the pool before it is eligible for
diff --git a/core/src/test/java/org/springframework/ldap/config/LdapTemplateNamespaceHandlerTest.java b/core/src/test/java/org/springframework/ldap/config/LdapTemplateNamespaceHandlerTest.java
index a831a31f..9b79541f 100644
--- a/core/src/test/java/org/springframework/ldap/config/LdapTemplateNamespaceHandlerTest.java
+++ b/core/src/test/java/org/springframework/ldap/config/LdapTemplateNamespaceHandlerTest.java
@@ -507,6 +507,12 @@ public class LdapTemplateNamespaceHandlerTest {
GenericKeyedObjectPool objectPool = (GenericKeyedObjectPool) getInternalState(pooledContextSource, "keyedObjectPool");
assertEquals(10, objectPool.getTimeBetweenEvictionRunsMillis());
assertEquals(20, objectPool.getMinEvictableIdleTimeMillis());
+ assertEquals(10, objectPool.getMaxWait());
+ assertEquals(11, objectPool.getMaxTotal());
+ assertEquals(15, objectPool.getMaxActive());
+ assertEquals(16, objectPool.getMinIdle());
+ assertEquals(17, objectPool.getMaxIdle());
+ assertEquals(18, objectPool.getNumTestsPerEvictionRun());
}
@Test
@@ -522,5 +528,11 @@ public class LdapTemplateNamespaceHandlerTest {
(org.apache.commons.pool2.impl.GenericKeyedObjectPool) getInternalState(pooledContextSource, "keyedObjectPool");
assertEquals(10, objectPool.getTimeBetweenEvictionRunsMillis());
assertEquals(20, objectPool.getMinEvictableIdleTimeMillis());
+ assertEquals(10, objectPool.getMaxWaitMillis());
+ assertEquals(11, objectPool.getMaxTotal());
+ assertEquals(12, objectPool.getMinIdlePerKey());
+ assertEquals(13, objectPool.getMaxIdlePerKey());
+ assertEquals(14, objectPool.getMaxTotalPerKey());
+ assertEquals(18, objectPool.getNumTestsPerEvictionRun());
}
}
diff --git a/core/src/test/resources/ldap-namespace-config-pooling-config-with-placeholders.xml b/core/src/test/resources/ldap-namespace-config-pooling-config-with-placeholders.xml
index 125329a2..1be275e8 100644
--- a/core/src/test/resources/ldap-namespace-config-pooling-config-with-placeholders.xml
+++ b/core/src/test/resources/ldap-namespace-config-pooling-config-with-placeholders.xml
@@ -8,8 +8,10 @@
-
+
-
\ No newline at end of file
+
diff --git a/core/src/test/resources/ldap-namespace-config-pooling2-config-with-placeholders.xml b/core/src/test/resources/ldap-namespace-config-pooling2-config-with-placeholders.xml
index 0e6523ac..2e0810a4 100644
--- a/core/src/test/resources/ldap-namespace-config-pooling2-config-with-placeholders.xml
+++ b/core/src/test/resources/ldap-namespace-config-pooling2-config-with-placeholders.xml
@@ -8,7 +8,9 @@
-
+
diff --git a/core/src/test/resources/ldap.properties b/core/src/test/resources/ldap.properties
index 0cc6cd15..1f6816a0 100644
--- a/core/src/test/resources/ldap.properties
+++ b/core/src/test/resources/ldap.properties
@@ -1,2 +1,14 @@
ldap.eviction.run.internal.milis=10
-ldap.min.evictable.time.milis=20
\ No newline at end of file
+ldap.min.evictable.time.milis=20
+ldap.maxWait=10
+ldap.maxTotal=11
+ldap.minIdlePerKey=12
+ldap.maxIdlePerKey=13
+ldap.maxTotalPerKey=14
+ldap.maxActive=15
+ldap.minIdle=16
+ldap.maxIdle=17
+ldap.testsPerEvictionRun=18
+ldap.testOnBorrow=true
+ldap.testOnReturn=true
+ldap.testWhileIdle=true