You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/10/22 23:29:57 UTC
svn commit: r1187811 [2/4] - in /tomcat/trunk/modules/jdbc-pool: ./ doc/
src/main/java/org/apache/tomcat/jdbc/naming/
src/main/java/org/apache/tomcat/jdbc/pool/
src/main/java/org/apache/tomcat/jdbc/pool/interceptor/
src/main/java/org/apache/tomcat/jdbc...
Modified: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java?rev=1187811&r1=1187810&r2=1187811&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java (original)
+++ tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java Sat Oct 22 21:29:55 2011
@@ -31,10 +31,10 @@ import org.apache.tomcat.jdbc.pool.PoolP
/**
*
- * The DataSource proxy lets us implements methods that don't exist in the current
+ * The DataSource proxy lets us implements methods that don't exist in the current
* compiler JDK but might be methods that are part of a future JDK DataSource interface.
* <br/>
- * It's a trick to work around compiler issues when implementing interfaces. For example,
+ * It's a trick to work around compiler issues when implementing interfaces. For example,
* I could put in Java 6 methods of javax.sql.DataSource here, and compile it with JDK 1.5
* and still be able to run under Java 6 without getting NoSuchMethodException.
*
@@ -44,15 +44,15 @@ import org.apache.tomcat.jdbc.pool.PoolP
public class DataSourceProxy implements PoolConfiguration {
private static final Log log = LogFactory.getLog(DataSourceProxy.class);
-
+
protected volatile ConnectionPool pool = null;
-
+
protected PoolConfiguration poolProperties = null;
public DataSourceProxy() {
this(new PoolProperties());
}
-
+
public DataSourceProxy(PoolConfiguration poolProperties) {
if (poolProperties == null) throw new NullPointerException("PoolConfiguration can not be null.");
this.poolProperties = poolProperties;
@@ -99,7 +99,7 @@ public class DataSourceProxy implements
return pCreatePool();
}
}
-
+
/**
* Sets up the connection pool, by creating a pooling driver.
* @return Driver
@@ -123,10 +123,10 @@ public class DataSourceProxy implements
return createPool().getConnection();
return pool.getConnection();
}
-
+
/**
* Invokes an sync operation to retrieve the connection.
- * @return a Future containing a reference to the connection when it becomes available
+ * @return a Future containing a reference to the connection when it becomes available
* @throws SQLException
*/
public Future<Connection> getConnectionAsync() throws SQLException {
@@ -134,9 +134,9 @@ public class DataSourceProxy implements
return createPool().getConnectionAsync();
return pool.getConnectionAsync();
}
-
+
/**
- * {@link javax.sql.XADataSource#getXAConnection()}
+ * {@link javax.sql.XADataSource#getXAConnection()}
*/
public XAConnection getXAConnection() throws SQLException {
Connection con = getConnection();
@@ -147,9 +147,9 @@ public class DataSourceProxy implements
throw new SQLException("Connection from pool does not implement javax.sql.XAConnection");
}
}
-
+
/**
- * {@link javax.sql.XADataSource#getXAConnection(String, String)}
+ * {@link javax.sql.XADataSource#getXAConnection(String, String)}
*/
public XAConnection getXAConnection(String username, String password) throws SQLException {
Connection con = getConnection(username, password);
@@ -176,12 +176,12 @@ public class DataSourceProxy implements
String password) throws SQLException {
return (javax.sql.PooledConnection) getConnection();
}
-
+
public ConnectionPool getPool() {
return pool;
}
-
+
public void close() {
close(false);
}
@@ -205,7 +205,7 @@ public class DataSourceProxy implements
else return p.getSize();
}
-
+
@Override
public String toString() {
return super.toString()+"{"+getPoolProperties()+"}";
@@ -215,216 +215,216 @@ public class DataSourceProxy implements
/*-----------------------------------------------------------------------*/
// PROPERTIES WHEN NOT USED WITH FACTORY
/*------------------------------------------------------------------------*/
-
- /**
+
+ /**
* {@inheritDoc}
*/
-
+
@Override
public String getPoolName() {
return pool.getName();
}
-
-
+
+
public void setPoolProperties(PoolConfiguration poolProperties) {
this.poolProperties = poolProperties;
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setDriverClassName(String driverClassName) {
this.poolProperties.setDriverClassName(driverClassName);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setInitialSize(int initialSize) {
this.poolProperties.setInitialSize(initialSize);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setInitSQL(String initSQL) {
this.poolProperties.setInitSQL(initSQL);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setLogAbandoned(boolean logAbandoned) {
this.poolProperties.setLogAbandoned(logAbandoned);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setMaxActive(int maxActive) {
this.poolProperties.setMaxActive(maxActive);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setMaxIdle(int maxIdle) {
this.poolProperties.setMaxIdle(maxIdle);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setMaxWait(int maxWait) {
this.poolProperties.setMaxWait(maxWait);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) {
this.poolProperties.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setMinIdle(int minIdle) {
this.poolProperties.setMinIdle(minIdle);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
this.poolProperties.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setPassword(String password) {
this.poolProperties.setPassword(password);
this.poolProperties.getDbProperties().setProperty("password",this.poolProperties.getPassword());
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setRemoveAbandoned(boolean removeAbandoned) {
this.poolProperties.setRemoveAbandoned(removeAbandoned);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
this.poolProperties.setRemoveAbandonedTimeout(removeAbandonedTimeout);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setTestOnBorrow(boolean testOnBorrow) {
this.poolProperties.setTestOnBorrow(testOnBorrow);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setTestOnConnect(boolean testOnConnect) {
this.poolProperties.setTestOnConnect(testOnConnect);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setTestOnReturn(boolean testOnReturn) {
this.poolProperties.setTestOnReturn(testOnReturn);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setTestWhileIdle(boolean testWhileIdle) {
this.poolProperties.setTestWhileIdle(testWhileIdle);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) {
this.poolProperties.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setUrl(String url) {
this.poolProperties.setUrl(url);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setUsername(String username) {
this.poolProperties.setUsername(username);
this.poolProperties.getDbProperties().setProperty("user",getPoolProperties().getUsername());
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setValidationInterval(long validationInterval) {
this.poolProperties.setValidationInterval(validationInterval);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setValidationQuery(String validationQuery) {
this.poolProperties.setValidationQuery(validationQuery);
@@ -433,79 +433,79 @@ public class DataSourceProxy implements
/**
* {@inheritDoc}
*/
-
+
@Override
public void setValidatorClassName(String className) {
this.poolProperties.setValidatorClassName(className);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setJdbcInterceptors(String interceptors) {
this.getPoolProperties().setJdbcInterceptors(interceptors);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setJmxEnabled(boolean enabled) {
this.getPoolProperties().setJmxEnabled(enabled);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setFairQueue(boolean fairQueue) {
this.getPoolProperties().setFairQueue(fairQueue);
}
-
- /**
+
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setUseLock(boolean useLock) {
this.getPoolProperties().setUseLock(useLock);
}
-
- /**
+
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setDefaultCatalog(String catalog) {
this.getPoolProperties().setDefaultCatalog(catalog);
}
-
- /**
+
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setDefaultAutoCommit(Boolean autocommit) {
this.getPoolProperties().setDefaultAutoCommit(autocommit);
}
-
- /**
+
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setDefaultTransactionIsolation(int defaultTransactionIsolation) {
this.getPoolProperties().setDefaultTransactionIsolation(defaultTransactionIsolation);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setConnectionProperties(String properties) {
try {
@@ -523,11 +523,11 @@ public class DataSourceProxy implements
throw new RuntimeException(x);
}
}
-
- /**
+
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setUseEquals(boolean useEquals) {
this.getPoolProperties().setUseEquals(useEquals);
@@ -572,27 +572,27 @@ public class DataSourceProxy implements
poolProperties.setMaxWait(1000 * i);
}
- }
-
-
+ }
+
+
/**
* {@inheritDoc}
*/
-
+
@Override
public int getSuspectTimeout() {
- return getPoolProperties().getSuspectTimeout();
+ return getPoolProperties().getSuspectTimeout();
}
/**
* {@inheritDoc}
*/
-
+
@Override
public void setSuspectTimeout(int seconds) {
getPoolProperties().setSuspectTimeout(seconds);
}
-
+
//===============================================================================
// Expose JMX attributes through Tomcat's dynamic reflection
//===============================================================================
@@ -648,7 +648,7 @@ public class DataSourceProxy implements
throw new RuntimeException(x);
}
}
-
+
/**
* @return number of connections in use by the application
* {@link DataSource#getActive()}
@@ -688,151 +688,151 @@ public class DataSourceProxy implements
}catch (SQLException x) {
throw new RuntimeException(x);
}
- }
+ }
//=========================================================
// PROPERTIES / CONFIGURATION
- //=========================================================
-
- /**
+ //=========================================================
+
+ /**
* {@inheritDoc}
*/
-
+
@Override
public String getConnectionProperties() {
return getPoolProperties().getConnectionProperties();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public Properties getDbProperties() {
return getPoolProperties().getDbProperties();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public String getDefaultCatalog() {
return getPoolProperties().getDefaultCatalog();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public int getDefaultTransactionIsolation() {
return getPoolProperties().getDefaultTransactionIsolation();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public String getDriverClassName() {
return getPoolProperties().getDriverClassName();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public int getInitialSize() {
return getPoolProperties().getInitialSize();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public String getInitSQL() {
return getPoolProperties().getInitSQL();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public String getJdbcInterceptors() {
return getPoolProperties().getJdbcInterceptors();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public int getMaxActive() {
return getPoolProperties().getMaxActive();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public int getMaxIdle() {
return getPoolProperties().getMaxIdle();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public int getMaxWait() {
return getPoolProperties().getMaxWait();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public int getMinEvictableIdleTimeMillis() {
return getPoolProperties().getMinEvictableIdleTimeMillis();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public int getMinIdle() {
return getPoolProperties().getMinIdle();
}
-
- /**
+
+ /**
* {@inheritDoc}
*/
-
+
@Override
public long getMaxAge() {
return getPoolProperties().getMaxAge();
- }
+ }
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public String getName() {
return getPoolProperties().getName();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public int getNumTestsPerEvictionRun() {
return getPoolProperties().getNumTestsPerEvictionRun();
@@ -846,56 +846,56 @@ public class DataSourceProxy implements
return "Password not available as DataSource/JMX operation.";
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public int getRemoveAbandonedTimeout() {
return getPoolProperties().getRemoveAbandonedTimeout();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public int getTimeBetweenEvictionRunsMillis() {
return getPoolProperties().getTimeBetweenEvictionRunsMillis();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public String getUrl() {
return getPoolProperties().getUrl();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public String getUsername() {
return getPoolProperties().getUsername();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public long getValidationInterval() {
return getPoolProperties().getValidationInterval();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public String getValidationQuery() {
return getPoolProperties().getValidationQuery();
@@ -904,7 +904,7 @@ public class DataSourceProxy implements
/**
* {@inheritDoc}
*/
-
+
@Override
public String getValidatorClassName() {
return getPoolProperties().getValidatorClassName();
@@ -913,13 +913,13 @@ public class DataSourceProxy implements
/**
* {@inheritDoc}
*/
-
+
@Override
public Validator getValidator() {
return getPoolProperties().getValidator();
}
-
- /**
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -928,249 +928,249 @@ public class DataSourceProxy implements
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public boolean isAccessToUnderlyingConnectionAllowed() {
return getPoolProperties().isAccessToUnderlyingConnectionAllowed();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public Boolean isDefaultAutoCommit() {
return getPoolProperties().isDefaultAutoCommit();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public Boolean isDefaultReadOnly() {
return getPoolProperties().isDefaultReadOnly();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public boolean isLogAbandoned() {
return getPoolProperties().isLogAbandoned();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public boolean isPoolSweeperEnabled() {
return getPoolProperties().isPoolSweeperEnabled();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public boolean isRemoveAbandoned() {
return getPoolProperties().isRemoveAbandoned();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public int getAbandonWhenPercentageFull() {
return getPoolProperties().getAbandonWhenPercentageFull();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public boolean isTestOnBorrow() {
return getPoolProperties().isTestOnBorrow();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public boolean isTestOnConnect() {
return getPoolProperties().isTestOnConnect();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public boolean isTestOnReturn() {
return getPoolProperties().isTestOnReturn();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public boolean isTestWhileIdle() {
return getPoolProperties().isTestWhileIdle();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public Boolean getDefaultAutoCommit() {
return getPoolProperties().getDefaultAutoCommit();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public Boolean getDefaultReadOnly() {
return getPoolProperties().getDefaultReadOnly();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public InterceptorDefinition[] getJdbcInterceptorsAsArray() {
return getPoolProperties().getJdbcInterceptorsAsArray();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public boolean getUseLock() {
return getPoolProperties().getUseLock();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public boolean isFairQueue() {
return getPoolProperties().isFairQueue();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public boolean isJmxEnabled() {
return getPoolProperties().isJmxEnabled();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public boolean isUseEquals() {
return getPoolProperties().isUseEquals();
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setAbandonWhenPercentageFull(int percentage) {
getPoolProperties().setAbandonWhenPercentageFull(percentage);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setAccessToUnderlyingConnectionAllowed(boolean accessToUnderlyingConnectionAllowed) {
getPoolProperties().setAccessToUnderlyingConnectionAllowed(accessToUnderlyingConnectionAllowed);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setDbProperties(Properties dbProperties) {
getPoolProperties().setDbProperties(dbProperties);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setDefaultReadOnly(Boolean defaultReadOnly) {
getPoolProperties().setDefaultReadOnly(defaultReadOnly);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setMaxAge(long maxAge) {
getPoolProperties().setMaxAge(maxAge);
}
- /**
+ /**
* {@inheritDoc}
*/
-
+
@Override
public void setName(String name) {
getPoolProperties().setName(name);
}
-
- /**
+
+ /**
* {@inheritDoc}
*/
@Override
public void setDataSource(Object ds) {
getPoolProperties().setDataSource(ds);
}
-
- /**
+
+ /**
* {@inheritDoc}
*/
@Override
public Object getDataSource() {
return getPoolProperties().getDataSource();
}
-
-
- /**
+
+
+ /**
* {@inheritDoc}
*/
@Override
public void setDataSourceJNDI(String jndiDS) {
getPoolProperties().setDataSourceJNDI(jndiDS);
}
-
- /**
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -1178,7 +1178,7 @@ public class DataSourceProxy implements
return getPoolProperties().getDataSourceJNDI();
}
- /**
+ /**
* {@inheritDoc}
*/
@Override
@@ -1186,12 +1186,12 @@ public class DataSourceProxy implements
return getPoolProperties().isAlternateUsernameAllowed();
}
- /**
+ /**
* {@inheritDoc}
*/
@Override
public void setAlternateUsernameAllowed(boolean alternateUsernameAllowed) {
getPoolProperties().setAlternateUsernameAllowed(alternateUsernameAllowed);
}
-
+
}
Modified: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java?rev=1187811&r1=1187810&r2=1187811&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java (original)
+++ tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/FairBlockingQueue.java Sat Oct 22 21:29:55 2011
@@ -32,7 +32,7 @@ import java.util.concurrent.locks.Reentr
*
* A simple implementation of a blocking queue with fairness waiting.
* invocations to method poll(...) will get handed out in the order they were received.
- * Locking is fine grained, a shared lock is only used during the first level of contention, waiting is done in a
+ * Locking is fine grained, a shared lock is only used during the first level of contention, waiting is done in a
* lock per thread basis so that order is guaranteed once the thread goes into a suspended monitor state.
* <br/>
* Not all of the methods of the {@link java.util.concurrent.BlockingQueue} are implemented.
@@ -41,12 +41,12 @@ import java.util.concurrent.locks.Reentr
*/
public class FairBlockingQueue<E> implements BlockingQueue<E> {
-
+
/**
- * This little sucker is used to reorder the way to do
+ * This little sucker is used to reorder the way to do
* {@link java.util.concurrent.locks.Lock#lock()},
* {@link java.util.concurrent.locks.Lock#unlock()}
- * and
+ * and
* {@link java.util.concurrent.CountDownLatch#countDown()}
* during the {@link #poll(long, TimeUnit)} operation.
* On Linux, it performs much better if we count down while we hold the global
@@ -55,10 +55,10 @@ public class FairBlockingQueue<E> implem
*/
final static boolean isLinux = "Linux".equals(System.getProperty("os.name")) &&
(!Boolean.getBoolean(FairBlockingQueue.class.getName()+".ignoreOS"));
-
+
/**
- * Phase one entry lock in order to give out
- * per-thread-locks for the waiting phase we have
+ * Phase one entry lock in order to give out
+ * per-thread-locks for the waiting phase we have
* a phase one lock during the contention period.
*/
final ReentrantLock lock = new ReentrantLock(false);
@@ -72,7 +72,7 @@ public class FairBlockingQueue<E> implem
* All threads waiting for an object are stored in a linked list
*/
final LinkedList<ExchangeCountDownLatch<E>> waiters;
-
+
/**
* Creates a new fair blocking queue.
*/
@@ -117,7 +117,7 @@ public class FairBlockingQueue<E> implem
/**
* Will never timeout, as it invokes the {@link #offer(Object)} method.
- * Once a lock has been acquired, the
+ * Once a lock has been acquired, the
* {@inheritDoc}
*/
@Override
@@ -168,7 +168,7 @@ public class FairBlockingQueue<E> implem
}
return result;
}
-
+
/**
* Request an item from the queue asynchronously
* @return - a future pending the result from the queue poll request
@@ -202,7 +202,7 @@ public class FairBlockingQueue<E> implem
}
return result;
}
-
+
/**
* {@inheritDoc}
*/
@@ -216,7 +216,7 @@ public class FairBlockingQueue<E> implem
lock.unlock();
}
}
-
+
/**
* {@inheritDoc}
*/
@@ -286,7 +286,7 @@ public class FairBlockingQueue<E> implem
* {@inheritDoc}
* @throws UnsupportedOperationException - this operation is not supported
*/
-
+
@Override
public int drainTo(Collection<? super E> c) {
return drainTo(c,Integer.MAX_VALUE);
@@ -428,15 +428,15 @@ public class FairBlockingQueue<E> implem
protected volatile T item = null;
protected volatile ExchangeCountDownLatch<T> latch = null;
protected volatile boolean canceled = false;
-
+
public ItemFuture(T item) {
this.item = item;
}
-
+
public ItemFuture(ExchangeCountDownLatch<T> latch) {
this.latch = latch;
}
-
+
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
return false; //don't allow cancel for now
@@ -476,7 +476,7 @@ public class FairBlockingQueue<E> implem
public boolean isDone() {
return (item!=null || latch.getItem()!=null);
}
-
+
}
//------------------------------------------------------------------
Modified: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java?rev=1187811&r1=1187810&r2=1187811&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java (original)
+++ tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/JdbcInterceptor.java Sat Oct 22 21:29:55 2011
@@ -24,14 +24,14 @@ import org.apache.tomcat.jdbc.pool.PoolP
/**
* Abstract class that is to be extended for implementations of interceptors.
- * Everytime an operation is called on the {@link java.sql.Connection} object the
+ * Everytime an operation is called on the {@link java.sql.Connection} object the
* {@link #invoke(Object, Method, Object[])} method on the interceptor will be called.
* Interceptors are useful to change or improve behavior of the connection pool.<br/>
- * Interceptors can receive a set of properties. Each sub class is responsible for parsing the properties during runtime when they
- * are needed or simply override the {@link #setProperties(Map)} method.
+ * Interceptors can receive a set of properties. Each sub class is responsible for parsing the properties during runtime when they
+ * are needed or simply override the {@link #setProperties(Map)} method.
* Properties arrive in a key-value pair of Strings as they were received through the configuration.
* This method is called once per cached connection object when the object is first configured.
- *
+ *
* @author Filip Hanik
* @version 1.0
*/
@@ -61,12 +61,12 @@ public abstract class JdbcInterceptor im
*/
public static final String ISWRAPPERFOR_VAL = "isWrapperFor";
-
+
/**
* Properties for this interceptor.
*/
- protected Map<String,InterceptorProperty> properties = null;
-
+ protected Map<String,InterceptorProperty> properties = null;
+
/**
* The next interceptor in the chain
*/
@@ -89,7 +89,7 @@ public abstract class JdbcInterceptor im
* Gets invoked each time an operation on {@link java.sql.Connection} is invoked.
* {@inheritDoc}
*/
-
+
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (getNext()!=null) return getNext().invoke(proxy,method,args);
@@ -111,7 +111,7 @@ public abstract class JdbcInterceptor im
public void setNext(JdbcInterceptor next) {
this.next = next;
}
-
+
/**
* Performs a string comparison, using references unless the useEquals property is set to true.
* @param name1
@@ -125,7 +125,7 @@ public abstract class JdbcInterceptor im
return name1==name2;
}
}
-
+
/**
* Compares a method name (String) to a method (Method)
* {@link #compare(String,String)}
@@ -137,7 +137,7 @@ public abstract class JdbcInterceptor im
public boolean compare(String methodName, Method method) {
return compare(methodName, method.getName());
}
-
+
/**
* Gets called each time the connection is borrowed from the pool
* This means that if an interceptor holds a reference to the connection
@@ -148,7 +148,7 @@ public abstract class JdbcInterceptor im
* @param con - the pooled connection
*/
public abstract void reset(ConnectionPool parent, PooledConnection con);
-
+
/**
* Called when {@link java.sql.Connection#close()} is called on the underlying connection.
* This is to notify the interceptors, that the physical connection has been released.
@@ -159,8 +159,8 @@ public abstract class JdbcInterceptor im
*/
public void disconnected(ConnectionPool parent, PooledConnection con, boolean finalizing) {
}
-
-
+
+
/**
* Returns the properties configured for this interceptor
* @return the configured properties for this interceptor
@@ -183,7 +183,7 @@ public abstract class JdbcInterceptor im
setUseEquals(Boolean.parseBoolean(p.getValue()));
}
}
-
+
/**
* @return true if the compare method uses the Object.equals(Object) method
* false if comparison is done on a reference level
@@ -191,7 +191,7 @@ public abstract class JdbcInterceptor im
public boolean isUseEquals() {
return useEquals;
}
-
+
/**
* Set to true if string comparisons (for the {@link #compare(String, Method)} and {@link #compare(String, String)} methods) should use the Object.equals(Object) method
* The default is false
@@ -200,7 +200,7 @@ public abstract class JdbcInterceptor im
public void setUseEquals(boolean useEquals) {
this.useEquals = useEquals;
}
-
+
/**
* This method is invoked by a connection pool when the pool is closed.
* Interceptor classes can override this method if they keep static
Modified: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/MultiLockFairBlockingQueue.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/MultiLockFairBlockingQueue.java?rev=1187811&r1=1187810&r2=1187811&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/MultiLockFairBlockingQueue.java (original)
+++ tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/MultiLockFairBlockingQueue.java Sat Oct 22 21:29:55 2011
@@ -36,7 +36,7 @@ import java.util.concurrent.locks.Reentr
*
* An implementation of a blocking queue with fairness waiting and lock dispersal to avoid contention.
* invocations to method poll(...) will get handed out in the order they were received.
- * Locking is fine grained, a shared lock is only used during the first level of contention, waiting is done in a
+ * Locking is fine grained, a shared lock is only used during the first level of contention, waiting is done in a
* lock per thread basis so that order is guaranteed once the thread goes into a suspended monitor state.
* <br/>
* Not all of the methods of the {@link java.util.concurrent.BlockingQueue} are implemented.
@@ -45,24 +45,24 @@ import java.util.concurrent.locks.Reentr
*/
public class MultiLockFairBlockingQueue<E> implements BlockingQueue<E> {
-
+
final int LOCK_COUNT = Runtime.getRuntime().availableProcessors();
-
+
final AtomicInteger putQueue = new AtomicInteger(0);
final AtomicInteger pollQueue = new AtomicInteger(0);
-
+
public int getNextPut() {
int idx = Math.abs(putQueue.incrementAndGet()) % LOCK_COUNT;
return idx;
}
-
+
public int getNextPoll() {
int idx = Math.abs(pollQueue.incrementAndGet()) % LOCK_COUNT;
return idx;
}
/**
- * Phase one entry lock in order to give out
- * per-thread-locks for the waiting phase we have
+ * Phase one entry lock in order to give out
+ * per-thread-locks for the waiting phase we have
* a phase one lock during the contention period.
*/
private final ReentrantLock[] locks = new ReentrantLock[LOCK_COUNT];
@@ -76,7 +76,7 @@ public class MultiLockFairBlockingQueue<
* All threads waiting for an object are stored in a linked list
*/
final LinkedList<ExchangeCountDownLatch<E>>[] waiters;
-
+
/**
* Creates a new fair blocking queue.
*/
@@ -126,7 +126,7 @@ public class MultiLockFairBlockingQueue<
/**
* Will never timeout, as it invokes the {@link #offer(Object)} method.
- * Once a lock has been acquired, the
+ * Once a lock has been acquired, the
* {@inheritDoc}
*/
@Override
@@ -178,7 +178,7 @@ public class MultiLockFairBlockingQueue<
}
return result;
}
-
+
/**
* Request an item from the queue asynchronously
* @return - a future pending the result from the queue poll request
@@ -213,7 +213,7 @@ public class MultiLockFairBlockingQueue<
}
return result;
}
-
+
/**
* {@inheritDoc}
*/
@@ -231,7 +231,7 @@ public class MultiLockFairBlockingQueue<
}
return false;
}
-
+
/**
* {@inheritDoc}
*/
@@ -445,15 +445,15 @@ public class MultiLockFairBlockingQueue<
protected volatile T item = null;
protected volatile ExchangeCountDownLatch<T> latch = null;
protected volatile boolean canceled = false;
-
+
public ItemFuture(T item) {
this.item = item;
}
-
+
public ItemFuture(ExchangeCountDownLatch<T> latch) {
this.latch = latch;
}
-
+
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
return false; //don't allow cancel for now
@@ -493,7 +493,7 @@ public class MultiLockFairBlockingQueue<
public boolean isDone() {
return (item!=null || latch.getItem()!=null);
}
-
+
}
//------------------------------------------------------------------
@@ -528,7 +528,7 @@ public class MultiLockFairBlockingQueue<
try {
elements = (E[]) new Object[MultiLockFairBlockingQueue.this.items[idx].size()];
MultiLockFairBlockingQueue.this.items[idx].toArray(elements);
-
+
} finally {
lock.unlock();
}
@@ -563,7 +563,7 @@ public class MultiLockFairBlockingQueue<
lock.unlock();
}
}
-
+
}
}
Modified: tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java?rev=1187811&r1=1187810&r2=1187811&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java (original)
+++ tomcat/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/PoolConfiguration.java Sat Oct 22 21:29:55 2011
@@ -36,20 +36,20 @@ public interface PoolConfiguration {
public static final String PKG_PREFIX = "org.apache.tomcat.jdbc.pool.interceptor.";
/**
- * Connections that have been abandoned (timed out) wont get closed and reported up unless the number of connections in use are
- * above the percentage defined by abandonWhenPercentageFull.
- * The value should be between 0-100.
- * The default value is 0, which implies that connections are eligible for
+ * Connections that have been abandoned (timed out) wont get closed and reported up unless the number of connections in use are
+ * above the percentage defined by abandonWhenPercentageFull.
+ * The value should be between 0-100.
+ * The default value is 0, which implies that connections are eligible for
* closure as soon as removeAbandonedTimeout has been reached.
* @param percentage a value between 0 and 100 to indicate when connections that have been abandoned/timed out are considered abandoned
*/
public void setAbandonWhenPercentageFull(int percentage);
/**
- * Connections that have been abandoned (timed out) wont get closed and reported up unless the number of connections in use are
- * above the percentage defined by abandonWhenPercentageFull.
- * The value should be between 0-100.
- * The default value is 0, which implies that connections are eligible for
+ * Connections that have been abandoned (timed out) wont get closed and reported up unless the number of connections in use are
+ * above the percentage defined by abandonWhenPercentageFull.
+ * The value should be between 0-100.
+ * The default value is 0, which implies that connections are eligible for
* closure as soon as removeAbandonedTimeout has been reached.
* @return percentage - a value between 0 and 100 to indicate when connections that have been abandoned/timed out are considered abandoned
*/
@@ -62,18 +62,18 @@ public interface PoolConfiguration {
public boolean isFairQueue();
/**
- * Set to true if you wish that calls to getConnection
- * should be treated fairly in a true FIFO fashion.
- * This uses the {@link FairBlockingQueue} implementation for the list of the idle connections.
- * The default value is true.
+ * Set to true if you wish that calls to getConnection
+ * should be treated fairly in a true FIFO fashion.
+ * This uses the {@link FairBlockingQueue} implementation for the list of the idle connections.
+ * The default value is true.
* This flag is required when you want to use asynchronous connection retrieval.
* @param fairQueue
*/
public void setFairQueue(boolean fairQueue);
-
+
/**
* Property not used. Access is always allowed.
- * Access can be achieved by calling unwrap on the pooled connection. see {@link javax.sql.DataSource} interface
+ * Access can be achieved by calling unwrap on the pooled connection. see {@link javax.sql.DataSource} interface
* or call getConnection through reflection or cast the object as {@link javax.sql.PooledConnection}
* @return true
*/
@@ -84,11 +84,11 @@ public interface PoolConfiguration {
* @param accessToUnderlyingConnectionAllowed parameter ignored
*/
public void setAccessToUnderlyingConnectionAllowed(boolean accessToUnderlyingConnectionAllowed);
-
+
/**
- * The connection properties that will be sent to the JDBC driver when establishing new connections.
+ * The connection properties that will be sent to the JDBC driver when establishing new connections.
* Format of the string is [propertyName=property;] <br/>
- * NOTE - The "user" and "password" properties will be passed explicitly, so they do not need to be included here.
+ * NOTE - The "user" and "password" properties will be passed explicitly, so they do not need to be included here.
* The default value is null.
*/
public String getConnectionProperties();
@@ -96,11 +96,11 @@ public interface PoolConfiguration {
/**
* The properties that will be passed into {@link java.sql.Driver#connect(String, Properties)} method.
* Username and password do not need to be stored here, they will be passed into the properties right before the connection is established.
- * @param connectionProperties properties - Format of the string is [propertyName=property;]*
+ * @param connectionProperties properties - Format of the string is [propertyName=property;]*
* Example: prop1=value1;prop2=value2
*/
public void setConnectionProperties(String connectionProperties);
-
+
/**
* Returns the database properties that are passed into the {@link java.sql.Driver#connect(String, Properties)} method.
* @return database properties that are passed into the {@link java.sql.Driver#connect(String, Properties)} method.
@@ -112,23 +112,23 @@ public interface PoolConfiguration {
* @param dbProperties
*/
public void setDbProperties(Properties dbProperties);
-
+
/**
- * The default auto-commit state of connections created by this pool.
+ * The default auto-commit state of connections created by this pool.
* If not set (null), default is JDBC driver default (If set to null then the {@link java.sql.Connection#setAutoCommit(boolean)} method will not be called.)
* @return the default auto commit setting, null is Driver default.
*/
public Boolean isDefaultAutoCommit();
-
+
/**
- * The default auto-commit state of connections created by this pool.
+ * The default auto-commit state of connections created by this pool.
* If not set (null), default is JDBC driver default (If set to null then the {@link java.sql.Connection#setAutoCommit(boolean)} method will not be called.)
* @return the default auto commit setting, null is Driver default.
*/
public Boolean getDefaultAutoCommit();
-
+
/**
- * The default auto-commit state of connections created by this pool.
+ * The default auto-commit state of connections created by this pool.
* If not set (null), default is JDBC driver default (If set to null then the {@link java.sql.Connection#setAutoCommit(boolean)} method will not be called.)
* @param defaultAutoCommit default auto commit setting, null is Driver default.
*/
@@ -139,13 +139,13 @@ public interface PoolConfiguration {
* @return the default catalog, null if not set and accepting the driver default.
*/
public String getDefaultCatalog();
-
+
/**
* If non null, during connection creation the method {@link java.sql.Connection#setCatalog(String)} will be called with the set value.
* @param defaultCatalog null if not set and accepting the driver default.
*/
public void setDefaultCatalog(String defaultCatalog);
-
+
/**
* If non null, during connection creation the method {@link java.sql.Connection#setReadOnly(boolean)} will be called with the set value.
* @return null if not set and accepting the driver default otherwise the read only value
@@ -164,20 +164,20 @@ public interface PoolConfiguration {
*/
public void setDefaultReadOnly(Boolean defaultReadOnly);
-
+
/**
* Returns the default transaction isolation level. If set to {@link DataSourceFactory#UNKNOWN_TRANSACTIONISOLATION} the method
* {@link java.sql.Connection#setTransactionIsolation(int)} will not be called during connection creation.
* @return driver transaction isolation level, or -1 {@link DataSourceFactory#UNKNOWN_TRANSACTIONISOLATION} if not set.
*/
public int getDefaultTransactionIsolation();
-
+
/**
* If set to {@link DataSourceFactory#UNKNOWN_TRANSACTIONISOLATION} the method
- * {@link java.sql.Connection#setTransactionIsolation(int)} will not be called during connection creation. Otherwise the method
+ * {@link java.sql.Connection#setTransactionIsolation(int)} will not be called during connection creation. Otherwise the method
* will be called with the isolation level set by this property.
* @param defaultTransactionIsolation a value of {@link java.sql.Connection#TRANSACTION_NONE}, {@link java.sql.Connection#TRANSACTION_READ_COMMITTED},
- * {@link java.sql.Connection#TRANSACTION_READ_UNCOMMITTED}, {@link java.sql.Connection#TRANSACTION_REPEATABLE_READ},
+ * {@link java.sql.Connection#TRANSACTION_READ_UNCOMMITTED}, {@link java.sql.Connection#TRANSACTION_REPEATABLE_READ},
* {@link java.sql.Connection#TRANSACTION_SERIALIZABLE} or {@link DataSourceFactory#UNKNOWN_TRANSACTIONISOLATION}
* The last value will not be set on the connection.
*/
@@ -185,43 +185,43 @@ public interface PoolConfiguration {
/**
* The fully qualified Java class name of the JDBC driver to be used. The driver has to be accessible from the same classloader as tomcat-jdbc.jar
- * @return fully qualified JDBC driver name.
+ * @return fully qualified JDBC driver name.
*/
public String getDriverClassName();
-
+
/**
* The fully qualified Java class name of the JDBC driver to be used. The driver has to be accessible from the same classloader as tomcat-jdbc.jar
* @param driverClassName a fully qualified Java class name of a {@link java.sql.Driver} implementation.
*/
public void setDriverClassName(String driverClassName);
-
+
/**
* Returns the number of connections that will be established when the connection pool is started.
- * Default value is 10
+ * Default value is 10
* @return number of connections to be started when pool is started
*/
public int getInitialSize();
-
+
/**
* Set the number of connections that will be established when the connection pool is started.
* Default value is 10.
- * If this value exceeds {@link #setMaxActive(int)} it will automatically be lowered.
+ * If this value exceeds {@link #setMaxActive(int)} it will automatically be lowered.
* @param initialSize the number of connections to be established.
- *
+ *
*/
public void setInitialSize(int initialSize);
/**
- * boolean flag to set if stack traces should be logged for application code which abandoned a Connection.
- * Logging of abandoned Connections adds overhead for every Connection borrow because a stack trace has to be generated.
+ * boolean flag to set if stack traces should be logged for application code which abandoned a Connection.
+ * Logging of abandoned Connections adds overhead for every Connection borrow because a stack trace has to be generated.
* The default value is false.
* @return true if the connection pool logs stack traces when connections are borrowed from the pool.
*/
public boolean isLogAbandoned();
-
+
/**
- * boolean flag to set if stack traces should be logged for application code which abandoned a Connection.
- * Logging of abandoned Connections adds overhead for every Connection borrow because a stack trace has to be generated.
+ * boolean flag to set if stack traces should be logged for application code which abandoned a Connection.
+ * Logging of abandoned Connections adds overhead for every Connection borrow because a stack trace has to be generated.
* The default value is false.
* @param logAbandoned set to true if stack traces should be recorded when {@link DataSource#getConnection()} is called.
*/
@@ -232,79 +232,79 @@ public interface PoolConfiguration {
* @return the maximum number of connections used by this pool
*/
public int getMaxActive();
-
+
/**
* The maximum number of active connections that can be allocated from this pool at the same time. The default value is 100
* @param maxActive hard limit for number of managed connections by this pool
*/
public void setMaxActive(int maxActive);
-
+
/**
* The maximum number of connections that should be kept in the idle pool if {@link #isPoolSweeperEnabled()} returns false.
* If the If {@link #isPoolSweeperEnabled()} returns true, then the idle pool can grow up to {@link #getMaxActive}
* and will be shrunk according to {@link #getMinEvictableIdleTimeMillis()} setting.
- * Default value is maxActive:100
+ * Default value is maxActive:100
* @return the maximum number of idle connections.
*/
public int getMaxIdle();
-
+
/**
* The maximum number of connections that should be kept in the idle pool if {@link #isPoolSweeperEnabled()} returns false.
* If the If {@link #isPoolSweeperEnabled()} returns true, then the idle pool can grow up to {@link #getMaxActive}
* and will be shrunk according to {@link #getMinEvictableIdleTimeMillis()} setting.
- * Default value is maxActive:100
+ * Default value is maxActive:100
* @param maxIdle the maximum size of the idle pool
*/
public void setMaxIdle(int maxIdle);
/**
- * The maximum number of milliseconds that the pool will wait (when there are no available connections and the
- * {@link #getMaxActive} has been reached) for a connection to be returned
+ * The maximum number of milliseconds that the pool will wait (when there are no available connections and the
+ * {@link #getMaxActive} has been reached) for a connection to be returned
* before throwing an exception. Default value is 30000 (30 seconds)
* @return the number of milliseconds to wait for a connection to become available if the pool is maxed out.
*/
public int getMaxWait();
/**
- * The maximum number of milliseconds that the pool will wait (when there are no available connections and the
- * {@link #getMaxActive} has been reached) for a connection to be returned
+ * The maximum number of milliseconds that the pool will wait (when there are no available connections and the
+ * {@link #getMaxActive} has been reached) for a connection to be returned
* before throwing an exception. Default value is 30000 (30 seconds)
* @param maxWait the maximum number of milliseconds to wait.
*/
public void setMaxWait(int maxWait);
/**
- * The minimum amount of time an object must sit idle in the pool before it is eligible for eviction.
+ * The minimum amount of time an object must sit idle in the pool before it is eligible for eviction.
* The default value is 60000 (60 seconds).
- * @return the minimum amount of idle time in milliseconds before a connection is considered idle and eligible for eviction.
+ * @return the minimum amount of idle time in milliseconds before a connection is considered idle and eligible for eviction.
*/
public int getMinEvictableIdleTimeMillis();
-
+
/**
- * The minimum amount of time an object must sit idle in the pool before it is eligible for eviction.
+ * The minimum amount of time an object must sit idle in the pool before it is eligible for eviction.
* The default value is 60000 (60 seconds).
* @param minEvictableIdleTimeMillis the number of milliseconds a connection must be idle to be eligible for eviction.
*/
public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis);
/**
- * The minimum number of established connections that should be kept in the pool at all times.
- * The connection pool can shrink below this number if validation queries fail and connections get closed.
+ * The minimum number of established connections that should be kept in the pool at all times.
+ * The connection pool can shrink below this number if validation queries fail and connections get closed.
* Default value is derived from {@link #getInitialSize()} (also see {@link #setTestWhileIdle(boolean)}
* The idle pool will not shrink below this value during an eviction run, hence the number of actual connections
* can be between {@link #getMinIdle()} and somewhere between {@link #getMaxIdle()} and {@link #getMaxActive()}
* @return the minimum number of idle or established connections
*/
public int getMinIdle();
-
+
/**
- * The minimum number of established connections that should be kept in the pool at all times.
- * The connection pool can shrink below this number if validation queries fail and connections get closed.
+ * The minimum number of established connections that should be kept in the pool at all times.
+ * The connection pool can shrink below this number if validation queries fail and connections get closed.
* Default value is derived from {@link #getInitialSize()} (also see {@link #setTestWhileIdle(boolean)}
* The idle pool will not shrink below this value during an eviction run, hence the number of actual connections
* can be between {@link #getMinIdle()} and somewhere between {@link #getMaxIdle()} and {@link #getMaxActive()}
- *
+ *
* @param minIdle the minimum number of idle or established connections
*/
public void setMinIdle(int minIdle);
@@ -314,9 +314,9 @@ public interface PoolConfiguration {
* @return the name of the pool, should be unique in a JVM
*/
public String getName();
-
+
/**
- * Sets the name of the connection pool
+ * Sets the name of the connection pool
* @param name the name of the pool, should be unique in a runtime JVM
*/
public void setName(String name);
@@ -326,7 +326,7 @@ public interface PoolConfiguration {
* @return unknown value
*/
public int getNumTestsPerEvictionRun();
-
+
/**
* Property not used
* @param numTestsPerEvictionRun parameter ignored.
@@ -338,11 +338,11 @@ public interface PoolConfiguration {
* @return the password in string format
*/
public String getPassword();
-
+
/**
* Sets the password to establish the connection with.
* The password will be included as a database property with the name 'password'.
- * @param password
+ * @param password
* @see #getDbProperties()
*/
public void setPassword(String password);
@@ -352,7 +352,7 @@ public interface PoolConfiguration {
* @return name
*/
public String getPoolName();
-
+
/**
* Returns the username used to establish the connection with
* @return the username used to establish the connection with
@@ -369,22 +369,22 @@ public interface PoolConfiguration {
/**
- * boolean flag to remove abandoned connections if they exceed the removeAbandonedTimout.
- * If set to true a connection is considered abandoned and eligible for removal if it has
- * been in use longer than the {@link #getRemoveAbandonedTimeout()} and the condition for
+ * boolean flag to remove abandoned connections if they exceed the removeAbandonedTimout.
+ * If set to true a connection is considered abandoned and eligible for removal if it has
+ * been in use longer than the {@link #getRemoveAbandonedTimeout()} and the condition for
* {@link #getAbandonWhenPercentageFull()} is met.
- * Setting this to true can recover db connections from applications that fail to close a connection.
+ * Setting this to true can recover db connections from applications that fail to close a connection.
* See also {@link #isLogAbandoned()} The default value is false.
* @return true if abandoned connections can be closed and expelled out of the pool
*/
public boolean isRemoveAbandoned();
-
+
/**
- * boolean flag to remove abandoned connections if they exceed the removeAbandonedTimout.
- * If set to true a connection is considered abandoned and eligible for removal if it has
- * been in use longer than the {@link #getRemoveAbandonedTimeout()} and the condition for
+ * boolean flag to remove abandoned connections if they exceed the removeAbandonedTimout.
+ * If set to true a connection is considered abandoned and eligible for removal if it has
+ * been in use longer than the {@link #getRemoveAbandonedTimeout()} and the condition for
* {@link #getAbandonWhenPercentageFull()} is met.
- * Setting this to true can recover db connections from applications that fail to close a connection.
+ * Setting this to true can recover db connections from applications that fail to close a connection.
* See also {@link #isLogAbandoned()} The default value is false.
* @param removeAbandoned set to true if abandoned connections can be closed and expelled out of the pool
*/
@@ -403,35 +403,35 @@ public interface PoolConfiguration {
* The timer can be reset upon queries using an interceptor.
* @see org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer
* @return the time in seconds before a used connection can be considered abandoned
- */
+ */
public int getRemoveAbandonedTimeout();
/**
- * The indication of whether objects will be validated before being borrowed from the pool.
- * If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.
- * NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string.
+ * The indication of whether objects will be validated before being borrowed from the pool.
+ * If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.
+ * NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string.
* Default value is false
* In order to have a more efficient validation, see {@link #setValidationInterval(long)}
* @return true if the connection is to be validated upon borrowing a connection from the pool
* @see #getValidationInterval()
*/
public boolean isTestOnBorrow();
-
+
/**
- * The indication of whether objects will be validated before being borrowed from the pool.
- * If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.
- * NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string.
+ * The indication of whether objects will be validated before being borrowed from the pool.
+ * If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.
+ * NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string.
* Default value is false
* In order to have a more efficient validation, see {@link #setValidationInterval(long)}
* @param testOnBorrow set to true if validation should take place before a connection is handed out to the application
* @see #getValidationInterval()
*/
public void setTestOnBorrow(boolean testOnBorrow);
-
+
/**
- * The indication of whether objects will be validated after being returned to the pool.
- * If the object fails to validate, it will be dropped from the pool.
- * NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string.
+ * The indication of whether objects will be validated after being returned to the pool.
+ * If the object fails to validate, it will be dropped from the pool.
+ * NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string.
* Default value is false
* In order to have a more efficient validation, see {@link #setValidationInterval(long)}
* @return true if validation should take place after a connection is returned to the pool
@@ -440,109 +440,109 @@ public interface PoolConfiguration {
public boolean isTestOnReturn();
/**
- * The indication of whether objects will be validated after being returned to the pool.
- * If the object fails to validate, it will be dropped from the pool.
- * NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string.
+ * The indication of whether objects will be validated after being returned to the pool.
+ * If the object fails to validate, it will be dropped from the pool.
+ * NOTE - for a true value to have any effect, the validationQuery parameter must be set to a non-null string.
* Default value is false
* In order to have a more efficient validation, see {@link #setValidationInterval(long)}
* @param testOnReturn true if validation should take place after a connection is returned to the pool
* @see #getValidationInterval()
*/
public void setTestOnReturn(boolean testOnReturn);
-
-
+
+
/**
* Set to true if query validation should take place while the connection is idle.
* @return true if validation should take place during idle checks
* @see #setTimeBetweenEvictionRunsMillis(int)
*/
public boolean isTestWhileIdle();
-
+
/**
* Set to true if query validation should take place while the connection is idle.
* @param testWhileIdle true if validation should take place during idle checks
* @see #setTimeBetweenEvictionRunsMillis(int)
*/
public void setTestWhileIdle(boolean testWhileIdle);
-
+
/**
- * The number of milliseconds to sleep between runs of the idle connection validation, abandoned cleaner
- * and idle pool resizing. This value should not be set under 1 second.
+ * The number of milliseconds to sleep between runs of the idle connection validation, abandoned cleaner
+ * and idle pool resizing. This value should not be set under 1 second.
* It dictates how often we check for idle, abandoned connections, and how often we validate idle connection and resize the idle pool.
* The default value is 5000 (5 seconds)
* @return the sleep time in between validations in milliseconds
*/
public int getTimeBetweenEvictionRunsMillis();
-
+
/**
- * The number of milliseconds to sleep between runs of the idle connection validation, abandoned cleaner
- * and idle pool resizing. This value should not be set under 1 second.
+ * The number of milliseconds to sleep between runs of the idle connection validation, abandoned cleaner
+ * and idle pool resizing. This value should not be set under 1 second.
* It dictates how often we check for idle, abandoned connections, and how often we validate idle connection and resize the idle pool.
* The default value is 5000 (5 seconds)
* @param timeBetweenEvictionRunsMillis the sleep time in between validations in milliseconds
*/
public void setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis);
-
+
/**
* The URL used to connect to the database
* @return the configured URL for this connection pool
* @see java.sql.Driver#connect(String, Properties)
*/
public String getUrl();
-
+
/**
* Sets the URL used to connect to the database
* @param url the configured URL for this connection pool
* @see java.sql.Driver#connect(String, Properties)
*/
public void setUrl(String url);
-
+
/**
- * The SQL query that will be used to validate connections from this
- * pool before returning them to the caller or pool.
- * If specified, this query does not have to return any data,
- * it just can't throw a SQLException.
- * The default value is null.
- * Example values are SELECT 1(mysql),
- * select 1 from dual(oracle),
+ * The SQL query that will be used to validate connections from this
+ * pool before returning them to the caller or pool.
+ * If specified, this query does not have to return any data,
+ * it just can't throw a SQLException.
+ * The default value is null.
+ * Example values are SELECT 1(mysql),
+ * select 1 from dual(oracle),
* SELECT 1(MS Sql Server)
* @return the query used for validation or null if no validation is performed
*/
public String getValidationQuery();
-
+
/**
- * The SQL query that will be used to validate connections from this
- * pool before returning them to the caller or pool.
- * If specified, this query does not have to return any data,
- * it just can't throw a SQLException.
- * The default value is null.
- * Example values are SELECT 1(mysql),
- * select 1 from dual(oracle),
+ * The SQL query that will be used to validate connections from this
+ * pool before returning them to the caller or pool.
+ * If specified, this query does not have to return any data,
+ * it just can't throw a SQLException.
+ * The default value is null.
+ * Example values are SELECT 1(mysql),
+ * select 1 from dual(oracle),
* SELECT 1(MS Sql Server)
* @param validationQuery the query used for validation or null if no validation is performed
*/
public void setValidationQuery(String validationQuery);
-
+
/**
* Return the name of the optional validator class - may be null.
- *
+ *
* @return the name of the optional validator class - may be null
*/
public String getValidatorClassName();
-
+
/**
* Set the name for an optional validator class which will be used in place of test queries. If set to
* null, standard validation will be used.
- *
+ *
* @param className the name of the optional validator class
*/
public void setValidatorClassName(String className);
-
+
/**
* @return the optional validator object - may be null
*/
public Validator getValidator();
-
+
/**
* Sets the validator object
* If this is a non null object, it will be used as a validator instead of the validationQuery
@@ -551,36 +551,36 @@ public interface PoolConfiguration {
public void setValidator(Validator validator);
/**
- * avoid excess validation, only run validation at most at this frequency - time in milliseconds.
- * If a connection is due for validation, but has been validated previously
- * within this interval, it will not be validated again.
+ * avoid excess validation, only run validation at most at this frequency - time in milliseconds.
+ * If a connection is due for validation, but has been validated previously
+ * within this interval, it will not be validated again.
* The default value is 30000 (30 seconds).
* @return the validation interval in milliseconds
*/
public long getValidationInterval();
-
+
/**
- * avoid excess validation, only run validation at most at this frequency - time in milliseconds.
- * If a connection is due for validation, but has been validated previously
- * within this interval, it will not be validated again.
+ * avoid excess validation, only run validation at most at this frequency - time in milliseconds.
+ * If a connection is due for validation, but has been validated previously
+ * within this interval, it will not be validated again.
* The default value is 30000 (30 seconds).
* @param validationInterval the validation interval in milliseconds
*/
public void setValidationInterval(long validationInterval);
-
+
/**
* A custom query to be run when a connection is first created. The default value is null.
* This query only runs once per connection, and that is when a new connection is established to the database.
- * If this value is non null, it will replace the validation query during connection creation.
- * @return the init SQL used to run against the DB or null if not set
+ * If this value is non null, it will replace the validation query during connection creation.
+ * @return the init SQL used to run against the DB or null if not set
*/
public String getInitSQL();
-
+
/**
* A custom query to be run when a connection is first created. The default value is null.
* This query only runs once per connection, and that is when a new connection is established to the database.
- * If this value is non null, it will replace the validation query during connection creation.
- * @param initSQL the init SQL used to run against the DB or null if no query should be executed
+ * If this value is non null, it will replace the validation query during connection creation.
+ * @param initSQL the init SQL used to run against the DB or null if no query should be executed
*/
public void setInitSQL(String initSQL);
@@ -598,11 +598,11 @@ public interface PoolConfiguration {
* @param testOnConnect set to true if we should run the validation query upon connect
*/
public void setTestOnConnect(boolean testOnConnect);
-
+
/**
- * A semicolon separated list of classnames extending {@link org.apache.tomcat.jdbc.pool.JdbcInterceptor} class.
+ * A semicolon separated list of classnames extending {@link org.apache.tomcat.jdbc.pool.JdbcInterceptor} class.
* These interceptors will be inserted as an interceptor into the chain of operations on a java.sql.Connection object.
- * Example interceptors are {@link org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer StatementFinalizer} to close all
+ * Example interceptors are {@link org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer StatementFinalizer} to close all
* used statements during the session.
* {@link org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer ResetAbandonedTimer} resets the timer upon every operation
* on the connection or a statement.
@@ -612,11 +612,11 @@ public interface PoolConfiguration {
* Example format: 'ConnectionState(useEquals=true,fast=yes);ResetAbandonedTimer'
*/
public String getJdbcInterceptors();
-
+
/**
- * A semicolon separated list of classnames extending {@link org.apache.tomcat.jdbc.pool.JdbcInterceptor} class.
+ * A semicolon separated list of classnames extending {@link org.apache.tomcat.jdbc.pool.JdbcInterceptor} class.
* These interceptors will be inserted as an interceptor into the chain of operations on a java.sql.Connection object.
- * Example interceptors are {@link org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer StatementFinalizer} to close all
+ * Example interceptors are {@link org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer StatementFinalizer} to close all
* used statements during the session.
* {@link org.apache.tomcat.jdbc.pool.interceptor.ResetAbandonedTimer ResetAbandonedTimer} resets the timer upon every operation
* on the connection or a statement.
@@ -633,9 +633,9 @@ public interface PoolConfiguration {
*/
public InterceptorDefinition[] getJdbcInterceptorsAsArray();
-
+
/**
- * If set to true, the connection pool creates a {@link org.apache.tomcat.jdbc.pool.jmx.ConnectionPoolMBean} object
+ * If set to true, the connection pool creates a {@link org.apache.tomcat.jdbc.pool.jmx.ConnectionPoolMBean} object
* that can be registered with JMX to receive notifications and state about the pool.
* The ConnectionPool object doesn't register itself, as there is no way to keep a static non changing ObjectName across JVM restarts.
* @return true if the mbean object will be created upon startup.
@@ -643,7 +643,7 @@ public interface PoolConfiguration {
public boolean isJmxEnabled();
/**
- * If set to true, the connection pool creates a {@link org.apache.tomcat.jdbc.pool.jmx.ConnectionPoolMBean} object
+ * If set to true, the connection pool creates a {@link org.apache.tomcat.jdbc.pool.jmx.ConnectionPoolMBean} object
* that can be registered with JMX to receive notifications and state about the pool.
* The ConnectionPool object doesn't register itself, as there is no way to keep a static non changing ObjectName across JVM restarts.
* @param jmxEnabled set to to if the mbean object should be created upon startup.
@@ -658,15 +658,15 @@ public interface PoolConfiguration {
result = result && (isRemoveAbandoned() && getRemoveAbandonedTimeout()>0);
result = result || (isTestWhileIdle() && getValidationQuery()!=null);
return result;
- </source>
+ </source>
*
* @return true if a background thread is or will be enabled for this pool
*/
public boolean isPoolSweeperEnabled();
/**
- * Set to true if you wish the <code>ProxyConnection</code> class to use <code>String.equals</code> instead of
- * <code>==</code> when comparing method names.
+ * Set to true if you wish the <code>ProxyConnection</code> class to use <code>String.equals</code> instead of
+ * <code>==</code> when comparing method names.
* This property does not apply to added interceptors as those are configured individually.
* The default value is <code>false</code>.
* @return true if pool uses {@link String#equals(Object)} instead of == when comparing method names on {@link java.sql.Connection} methods
@@ -674,8 +674,8 @@ public interface PoolConfiguration {
public boolean isUseEquals();
/**
- * Set to true if you wish the <code>ProxyConnection</code> class to use <code>String.equals</code> instead of
- * <code>==</code> when comparing method names.
+ * Set to true if you wish the <code>ProxyConnection</code> class to use <code>String.equals</code> instead of
+ * <code>==</code> when comparing method names.
* This property does not apply to added interceptors as those are configured individually.
* The default value is <code>false</code>.
* @param useEquals set to true if the pool should use {@link String#equals(Object)} instead of ==
@@ -684,11 +684,11 @@ public interface PoolConfiguration {
public void setUseEquals(boolean useEquals);
/**
- * Time in milliseconds to keep this connection alive even when used.
- * When a connection is returned to the pool, the pool will check to see if the
- * ((now - time-when-connected) > maxAge) has been reached, and if so,
- * it closes the connection rather than returning it to the pool.
- * The default value is 0, which implies that connections will be left open and no
+ * Time in milliseconds to keep this connection alive even when used.
+ * When a connection is returned to the pool, the pool will check to see if the
+ * ((now - time-when-connected) > maxAge) has been reached, and if so,
+ * it closes the connection rather than returning it to the pool.
+ * The default value is 0, which implies that connections will be left open and no
* age check will be done upon returning the connection to the pool.
* This is a useful setting for database sessions that leak memory as it ensures that the session
* will have a finite life span.
@@ -697,11 +697,11 @@ public interface PoolConfiguration {
public long getMaxAge();
/**
- * Time in milliseconds to keep this connection alive even when used.
- * When a connection is returned to the pool, the pool will check to see if the
- * ((now - time-when-connected) > maxAge) has been reached, and if so,
- * it closes the connection rather than returning it to the pool.
- * The default value is 0, which implies that connections will be left open and no
+ * Time in milliseconds to keep this connection alive even when used.
+ * When a connection is returned to the pool, the pool will check to see if the
+ * ((now - time-when-connected) > maxAge) has been reached, and if so,
+ * it closes the connection rather than returning it to the pool.
+ * The default value is 0, which implies that connections will be left open and no
* age check will be done upon returning the connection to the pool.
* This is a useful setting for database sessions that leak memory as it ensures that the session
* will have a finite life span.
@@ -724,75 +724,75 @@ public interface PoolConfiguration {
* @param useLock set to true if a lock should be used on connection operations
*/
public void setUseLock(boolean useLock);
-
+
/**
* Similar to {@link #setRemoveAbandonedTimeout(int)} but instead of treating the connection
- * as abandoned, and potentially closing the connection, this simply logs the warning if
- * {@link #isLogAbandoned()} returns true. If this value is equal or less than 0, no suspect
+ * as abandoned, and potentially closing the connection, this simply logs the warning if
+ * {@link #isLogAbandoned()} returns true. If this value is equal or less than 0, no suspect
* checking will be performed. Suspect checking only takes place if the timeout value is larger than 0 and
* the connection was not abandoned or if abandon check is disabled. If a connection is suspect a WARN message gets
- * logged and a JMX notification gets sent once.
- * @param seconds - the amount of time in seconds that has to pass before a connection is marked suspect.
+ * logged and a JMX notification gets sent once.
+ * @param seconds - the amount of time in seconds that has to pass before a connection is marked suspect.
*/
public void setSuspectTimeout(int seconds);
-
+
/**
* Returns the time in seconds to pass before a connection is marked an abanoned suspect.
- * Any value lesser than or equal to 0 means the check is disabled.
+ * Any value lesser than or equal to 0 means the check is disabled.
* @return Returns the time in seconds to pass before a connection is marked an abanoned suspect.
*/
public int getSuspectTimeout();
-
+
/**
* Injects a datasource that will be used to retrieve/create connections.
* If a data source is set, the {@link PoolConfiguration#getUrl()} and {@link PoolConfiguration#getDriverClassName()} methods are ignored
* and not used by the pool. If the {@link PoolConfiguration#getUsername()} and {@link PoolConfiguration#getPassword()}
* values are set, the method {@link javax.sql.DataSource#getConnection(String, String)} method will be called instead of the
* {@link javax.sql.DataSource#getConnection()} method.
- * If the data source implements {@link javax.sql.XADataSource} the methods
+ * If the data source implements {@link javax.sql.XADataSource} the methods
* {@link javax.sql.XADataSource#getXAConnection()} and {@link javax.sql.XADataSource#getXAConnection(String,String)}
- * will be invoked.
+ * will be invoked.
* @param ds the {@link javax.sql.DataSource} to be used for creating connections to be pooled.
*/
public void setDataSource(Object ds);
-
+
/**
* Returns a datasource, if one exists that is being used to create connections.
* This method will return null if the pool is using a {@link java.sql.Driver}
* @return the {@link javax.sql.DataSource} to be used for creating connections to be pooled or null if a Driver is used.
*/
public Object getDataSource();
-
+
/**
* Configure the connection pool to use a DataSource according to {@link PoolConfiguration#setDataSource(Object)}
* But instead of injecting the object, specify the JNDI location.
- * After a successful JNDI look, the {@link PoolConfiguration#getDataSource()} will not return null.
+ * After a successful JNDI look, the {@link PoolConfiguration#getDataSource()} will not return null.
* @param jndiDS -the JNDI string @TODO specify the rules here.
*/
public void setDataSourceJNDI(String jndiDS);
-
+
/**
* Returns the JNDI string configured for data source usage.
* @return the JNDI string or null if not set
*/
public String getDataSourceJNDI();
-
+
/**
- * Returns true if the call {@link DataSource#getConnection(String, String) getConnection(username,password)} is
+ * Returns true if the call {@link DataSource#getConnection(String, String) getConnection(username,password)} is
* allowed. This is used for when the pool is used by an application accessing multiple schemas.
* There is a performance impact turning this option on.
* @return true if {@link DataSource#getConnection(String, String) getConnection(username,password)} is honored, false if it is ignored.
*/
public boolean isAlternateUsernameAllowed();
-
+
/**
- * Set to true if the call {@link DataSource#getConnection(String, String) getConnection(username,password)} is
+ * Set to true if the call {@link DataSource#getConnection(String, String) getConnection(username,password)} is
* allowed and honored.. This is used for when the pool is used by an application accessing multiple schemas.
* There is a performance impact turning this option on, even when not used due to username checks.
- * @param alternateUsernameAllowed - set true if {@link DataSource#getConnection(String, String) getConnection(username,password)} is honored,
+ * @param alternateUsernameAllowed - set true if {@link DataSource#getConnection(String, String) getConnection(username,password)} is honored,
* false if it is to be ignored.
*/
public void setAlternateUsernameAllowed(boolean alternateUsernameAllowed);
-
+
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org