Author: arminw
Date: Thu Oct 5 13:35:35 2006
New Revision: 453369
URL: http://svn.apache.org/viewvc?view=rev&rev=453369
Log:
add missing pool properties, support for 'initialSize' property
Modified:
db/ojb/trunk/src/java/org/apache/ojb/broker/util/pooling/PoolConfiguration.java
Modified:
db/ojb/trunk/src/java/org/apache/ojb/broker/util/pooling/PoolConfiguration.java
URL:
http://svn.apache.org/viewvc/db/ojb/trunk/src/java/org/apache/ojb/broker/util/pooling/PoolConfiguration.java?view=diff&rev=453369&r1=453368&r2=453369
==============================================================================
---
db/ojb/trunk/src/java/org/apache/ojb/broker/util/pooling/PoolConfiguration.java
(original)
+++
db/ojb/trunk/src/java/org/apache/ojb/broker/util/pooling/PoolConfiguration.java
Thu Oct 5 13:35:35 2006
@@ -19,26 +19,28 @@
import java.util.Properties;
import org.apache.commons.dbcp.AbandonedConfig;
+import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.pool.impl.GenericKeyedObjectPool;
import org.apache.commons.pool.impl.GenericObjectPool;
-
/**
* Encapsulates configuration properties for
* implementations using [EMAIL PROTECTED] org.apache.commons.pool.ObjectPool}.
*
- * @author <a href="mailto:[EMAIL PROTECTED]">Armin Waibel</a>
* @version $Id$
*/
public class PoolConfiguration extends Properties implements Serializable
{
- private static final long serialVersionUID = -3850488378321541047L;
- public static final String EMPTY = "";
+ private static final long serialVersionUID = -3850488378321541047L;
+
+ private int initialSize = 0;
+
//*****************************************************
// constants
//*****************************************************
public static final String MAX_ACTIVE = "maxActive";
public static final String MAX_IDLE = "maxIdle";
+ public static final String MIN_IDLE = "minIdle";
public static final String MAX_WAIT = "maxWait";
public static final String WHEN_EXHAUSTED_ACTION = "whenExhaustedAction";
public static final String TEST_ON_BORROW = "testOnBorrow";
@@ -47,17 +49,19 @@
public static final String TIME_BETWEEN_EVICTION_RUNS_MILLIS =
"timeBetweenEvictionRunsMillis";
public static final String NUM_TESTS_PER_EVICTION_RUN =
"numTestsPerEvictionRun";
public static final String MIN_EVICTABLE_IDLE_TIME_MILLIS =
"minEvictableIdleTimeMillis";
+ //public static final String SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS =
"softMinEvictableIdleTimeMillis";
public static final String LOG_ABANDONED = "logAbandoned";
public static final String REMOVE_ABANDONED = "removeAbandoned";
public static final String REMOVE_ABANDONED_TIMEOUT =
"removeAbandonedTimeout";
public static final String VALIDATION_QUERY = "validationQuery";
-
+ public static final String INITIAL_SIZE = "initialSize";
//*****************************************************
// used default values
//*****************************************************
- public static final int DEFAULT_MAX_ACTIVE = 21;
+ public static final int DEFAULT_MAX_ACTIVE = 30;
public static final int DEFAULT_MAX_IDLE = -1;
+ public static final int DEFAULT_MIN_IDLE = 0;
public static final long DEFAULT_MAX_WAIT = 5000;
public static final byte DEFAULT_WHEN_EXHAUSTED_ACTION =
GenericObjectPool.WHEN_EXHAUSTED_FAIL;
public static final boolean DEFAULT_TEST_ON_BORROW = true;
@@ -74,12 +78,14 @@
{
this.setMaxActive(DEFAULT_MAX_ACTIVE);
this.setMaxIdle(DEFAULT_MAX_IDLE);
+ this.setMinIdle(DEFAULT_MIN_IDLE);
this.setMaxWait(DEFAULT_MAX_WAIT);
this.setWhenExhaustedAction(DEFAULT_WHEN_EXHAUSTED_ACTION);
this.setTestOnBorrow(DEFAULT_TEST_ON_BORROW);
this.setTestOnReturn(DEFAULT_TEST_ON_RETURN);
this.setTestWhileIdle(DEFAULT_TEST_WHILE_IDLE);
this.setMinEvictableIdleTimeMillis(DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
+
//this.setSoftMinEvictableIdleTimeMillis(GenericObjectPool.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
this.setTimeBetweenEvictionRunsMillis(DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
this.setNumTestsPerEvictionRun(DEFAULT_NUM_TESTS_PER_EVICTION_RUN);
this.setLogAbandoned(DEFAULT_LOG_ABANDONED);
@@ -104,8 +110,10 @@
GenericObjectPool.Config conf = new GenericObjectPool.Config();
conf.maxActive = getMaxActive();
conf.maxIdle = getMaxIdle();
+ conf.minIdle = getMinIdle();
conf.maxWait = getMaxWait();
conf.minEvictableIdleTimeMillis = getMinEvictableIdleTimeMillis();
+ //conf.softMinEvictableIdleTimeMillis =
getSoftMinEvictableIdleTimeMillis();
conf.numTestsPerEvictionRun = getNumTestsPerEvictionRun();
conf.testOnBorrow = isTestOnBorrow();
conf.testOnReturn = isTestOnReturn();
@@ -140,20 +148,20 @@
public AbandonedConfig getAbandonedConfig()
{
AbandonedConfig conf = new AbandonedConfig();
- conf.setLogAbandoned(isLogAbandoned());
conf.setRemoveAbandoned(isRemoveAbandoned());
conf.setRemoveAbandonedTimeout(getRemoveAbandonedTimeout());
+ conf.setLogAbandoned(isLogAbandoned());
return conf;
}
public boolean isLogAbandoned()
{
- return Boolean.valueOf(getProperty(LOG_ABANDONED)).booleanValue();
+ return Boolean.valueOf(getProperty(LOG_ABANDONED)).booleanValue();
}
public void setLogAbandoned(boolean logAbandoned)
{
- this.setProperty(LOG_ABANDONED, EMPTY + logAbandoned);
+ this.setProperty(LOG_ABANDONED,
BooleanUtils.toStringTrueFalse(logAbandoned));
}
public boolean isRemoveAbandoned()
@@ -163,7 +171,7 @@
public void setRemoveAbandoned(boolean removeAbandoned)
{
- this.setProperty(REMOVE_ABANDONED, EMPTY + removeAbandoned);
+ this.setProperty(REMOVE_ABANDONED,
BooleanUtils.toStringTrueFalse(removeAbandoned));
}
public int getRemoveAbandonedTimeout()
@@ -173,17 +181,18 @@
public void setRemoveAbandonedTimeout(int removeAbandonedTimeout)
{
- this.setProperty(REMOVE_ABANDONED_TIMEOUT, EMPTY +
removeAbandonedTimeout);
+ this.setProperty(REMOVE_ABANDONED_TIMEOUT,
Integer.toString(removeAbandonedTimeout));
}
public String getValidationQuery()
{
- return getProperty(VALIDATION_QUERY);
+ String result = getProperty(VALIDATION_QUERY);
+ return (result == null) || (result.length() == 0) ? null : result;
}
public void setValidationQuery(String validationQuery)
{
- if(validationQuery != null) setProperty(VALIDATION_QUERY,
validationQuery);
+ setProperty(VALIDATION_QUERY, validationQuery);
}
public int getMaxActive()
@@ -193,7 +202,7 @@
public void setMaxActive(int maxActive)
{
- this.setProperty(MAX_ACTIVE, EMPTY + maxActive);
+ this.setProperty(MAX_ACTIVE, Integer.toString(maxActive));
}
public int getMaxIdle()
@@ -203,9 +212,18 @@
public void setMaxIdle(int maxIdle)
{
- this.setProperty(MAX_IDLE, EMPTY + maxIdle);
+ this.setProperty(MAX_IDLE, Integer.toString(maxIdle));
}
+ public int getMinIdle()
+ {
+ return Integer.parseInt(getProperty(MIN_IDLE));
+ }
+
+ public void setMinIdle(int minIdle)
+ {
+ this.setProperty(MIN_IDLE, Integer.toString(minIdle));
+ }
public long getMaxWait()
{
@@ -214,18 +232,18 @@
public void setMaxWait(long maxWait)
{
- this.setProperty(MAX_WAIT, EMPTY + maxWait);
+ this.setProperty(MAX_WAIT, Long.toString(maxWait));
}
public byte getWhenExhaustedAction()
{
- return new Byte(getProperty(WHEN_EXHAUSTED_ACTION)).byteValue();
+ return Byte.parseByte(getProperty(WHEN_EXHAUSTED_ACTION));
}
public void setWhenExhaustedAction(byte whenExhaustedAction)
{
- this.setProperty(WHEN_EXHAUSTED_ACTION, EMPTY + whenExhaustedAction);
+ this.setProperty(WHEN_EXHAUSTED_ACTION,
Byte.toString(whenExhaustedAction));
}
@@ -236,7 +254,7 @@
public void setTestOnBorrow(boolean testOnBorrow)
{
- this.setProperty(TEST_ON_BORROW, EMPTY + testOnBorrow);
+ this.setProperty(TEST_ON_BORROW,
BooleanUtils.toStringTrueFalse(testOnBorrow));
}
@@ -247,7 +265,7 @@
public void setTestOnReturn(boolean testOnReturn)
{
- this.setProperty(TEST_ON_RETURN, EMPTY + testOnReturn);
+ this.setProperty(TEST_ON_RETURN,
BooleanUtils.toStringTrueFalse(testOnReturn));
}
@@ -258,7 +276,7 @@
public void setTestWhileIdle(boolean testWhileIdle)
{
- this.setProperty(TEST_WHILE_IDLE, EMPTY + testWhileIdle);
+ this.setProperty(TEST_WHILE_IDLE,
BooleanUtils.toStringTrueFalse(testWhileIdle));
}
@@ -269,7 +287,7 @@
public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)
{
- this.setProperty(MIN_EVICTABLE_IDLE_TIME_MILLIS, EMPTY +
minEvictableIdleTimeMillis);
+ this.setProperty(MIN_EVICTABLE_IDLE_TIME_MILLIS,
Long.toString(minEvictableIdleTimeMillis));
}
@@ -280,10 +298,21 @@
public void setTimeBetweenEvictionRunsMillis(long
timeBetweenEvictionRunsMillis)
{
- this.setProperty(TIME_BETWEEN_EVICTION_RUNS_MILLIS, EMPTY +
timeBetweenEvictionRunsMillis);
+ this.setProperty(TIME_BETWEEN_EVICTION_RUNS_MILLIS,
Long.toString(timeBetweenEvictionRunsMillis));
}
+// public long getSoftMinEvictableIdleTimeMillis()
+// {
+// return
Integer.parseInt(getProperty(SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS));
+// }
+//
+// public void setSoftMinEvictableIdleTimeMillis(long
softMinEvictableIdleTimeMillis)
+// {
+// this.setProperty(SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
Long.toString(softMinEvictableIdleTimeMillis));
+// }
+
+
public int getNumTestsPerEvictionRun()
{
return Integer.parseInt(getProperty(NUM_TESTS_PER_EVICTION_RUN));
@@ -291,7 +320,17 @@
public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun)
{
- this.setProperty(NUM_TESTS_PER_EVICTION_RUN, EMPTY +
numTestsPerEvictionRun);
+ this.setProperty(NUM_TESTS_PER_EVICTION_RUN,
Integer.toString(numTestsPerEvictionRun));
+ }
+
+ public int getInitialSize()
+ {
+ return initialSize;
+ }
+
+ public void setInitialSize(int initialSize)
+ {
+ this.initialSize = initialSize;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]