You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by rj...@apache.org on 2008/11/03 23:38:56 UTC
svn commit: r710199 [3/4] - in /tomcat/trunk/modules/jdbc-pool: ./ doc/
java/org/apache/tomcat/jdbc/pool/ java/org/apache/tomcat/jdbc/pool/jmx/
test/org/apache/tomcat/jdbc/test/
Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java?rev=710199&r1=710198&r2=710199&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java Mon Nov 3 14:38:55 2008
@@ -1,397 +1,397 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.jdbc.pool;
-
-
-import java.lang.reflect.Method;
-import java.util.Properties;
-/**
- * @author Filip Hanik
- *
- */
-public class PoolProperties {
- protected static volatile int poolCounter = 1;
- protected Properties dbProperties = new Properties();
- protected String url = null;
- protected String driverClassName = null;
- protected Boolean defaultAutoCommit = null;
- protected Boolean defaultReadOnly = null;
- protected int defaultTransactionIsolation = DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION;
- protected String defaultCatalog = null;
- protected String connectionProperties;
- protected int initialSize = 10;
- protected int maxActive = 100;
- protected int maxIdle = maxActive;
- protected int minIdle = initialSize;
- protected int maxWait = 30000;
- protected String validationQuery;
- protected boolean testOnBorrow = false;
- protected boolean testOnReturn = false;
- protected boolean testWhileIdle = false;
- protected int timeBetweenEvictionRunsMillis = 5000;
- protected int numTestsPerEvictionRun;
- protected int minEvictableIdleTimeMillis = 60000;
- protected boolean accessToUnderlyingConnectionAllowed;
- protected boolean removeAbandoned = false;
- protected int removeAbandonedTimeout = 60;
- protected boolean logAbandoned = false;
- protected int loginTimeout = 10000;
- protected String name = "Filip Connection Pool["+(poolCounter++)+"]";
- protected String password;
- protected String username;
- protected long validationInterval = 30000;
- protected boolean jmxEnabled = true;
- protected String initSQL;
- protected boolean testOnConnect =false;
- private String jdbcInterceptors=null;
- private boolean fairQueue = false;
-
- public boolean isFairQueue() {
- return fairQueue;
- }
-
- public void setFairQueue(boolean fairQueue) {
- this.fairQueue = fairQueue;
- }
-
- public boolean isAccessToUnderlyingConnectionAllowed() {
- return accessToUnderlyingConnectionAllowed;
- }
-
- public String getConnectionProperties() {
- return connectionProperties;
- }
-
- public Properties getDbProperties() {
- return dbProperties;
- }
-
- public boolean isDefaultAutoCommit() {
- return defaultAutoCommit;
- }
-
- public String getDefaultCatalog() {
- return defaultCatalog;
- }
-
- public boolean isDefaultReadOnly() {
- return defaultReadOnly;
- }
-
- public int getDefaultTransactionIsolation() {
- return defaultTransactionIsolation;
- }
-
- public String getDriverClassName() {
- return driverClassName;
- }
-
- public int getInitialSize() {
- return initialSize;
- }
-
- public boolean isLogAbandoned() {
- return logAbandoned;
- }
-
- public int getLoginTimeout() {
- return loginTimeout;
- }
-
- public int getMaxActive() {
- return maxActive;
- }
-
- public int getMaxIdle() {
- return maxIdle;
- }
-
- public int getMaxWait() {
- return maxWait;
- }
-
- public int getMinEvictableIdleTimeMillis() {
- return minEvictableIdleTimeMillis;
- }
-
- public int getMinIdle() {
- return minIdle;
- }
-
- public String getName() {
- return name;
- }
-
- public int getNumTestsPerEvictionRun() {
- return numTestsPerEvictionRun;
- }
-
- public String getPassword() {
- return password;
- }
-
- public String getPoolName() {
- return getName();
- }
-
- public boolean isRemoveAbandoned() {
- return removeAbandoned;
- }
-
- public int getRemoveAbandonedTimeout() {
- return removeAbandonedTimeout;
- }
-
- public boolean isTestOnBorrow() {
- return testOnBorrow;
- }
-
- public boolean isTestOnReturn() {
- return testOnReturn;
- }
-
- public boolean isTestWhileIdle() {
- return testWhileIdle;
- }
-
- public int getTimeBetweenEvictionRunsMillis() {
- return timeBetweenEvictionRunsMillis;
- }
-
- public String getUrl() {
- return url;
- }
-
- public String getUsername() {
- return username;
- }
-
- public String getValidationQuery() {
- return validationQuery;
- }
-
- public long getValidationInterval() {
- return validationInterval;
- }
-
- public String getInitSQL() {
- return initSQL;
- }
-
- public boolean isTestOnConnect() {
- return testOnConnect;
- }
-
- public String getJdbcInterceptors() {
- return jdbcInterceptors;
- }
-
- public String[] getJdbcInterceptorsAsArray() {
- if (jdbcInterceptors==null) return new String[0];
- else {
- return jdbcInterceptors.split(";");
- }
- }
-
- public void setAccessToUnderlyingConnectionAllowed(boolean
- accessToUnderlyingConnectionAllowed) {
- this.accessToUnderlyingConnectionAllowed =
- accessToUnderlyingConnectionAllowed;
- }
-
- public void setConnectionProperties(String connectionProperties) {
- this.connectionProperties = connectionProperties;
- }
-
- public void setDbProperties(Properties dbProperties) {
- this.dbProperties = dbProperties;
- }
-
- public void setDefaultAutoCommit(Boolean defaultAutoCommit) {
- this.defaultAutoCommit = defaultAutoCommit;
- }
-
- public void setDefaultCatalog(String defaultCatalog) {
- this.defaultCatalog = defaultCatalog;
- }
-
- public void setDefaultReadOnly(Boolean defaultReadOnly) {
- this.defaultReadOnly = defaultReadOnly;
- }
-
- public void setDefaultTransactionIsolation(int defaultTransactionIsolation) {
- this.defaultTransactionIsolation = defaultTransactionIsolation;
- }
-
- public void setDriverClassName(String driverClassName) {
- this.driverClassName = driverClassName;
- }
-
- public void setInitialSize(int initialSize) {
- this.initialSize = initialSize;
- }
-
- public void setLogAbandoned(boolean logAbandoned) {
- this.logAbandoned = logAbandoned;
- }
-
- public void setLoginTimeout(int loginTimeout) {
- this.loginTimeout = loginTimeout;
- }
-
- public void setMaxActive(int maxActive) {
- this.maxActive = maxActive;
- }
-
- public void setMaxIdle(int maxIdle) {
- this.maxIdle = maxIdle;
- }
-
- public void setMaxWait(int maxWait) {
- this.maxWait = maxWait;
- }
-
- public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) {
- this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
- }
-
- public void setMinIdle(int minIdle) {
- this.minIdle = minIdle;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
- this.numTestsPerEvictionRun = numTestsPerEvictionRun;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public void setRemoveAbandoned(boolean removeAbandoned) {
- this.removeAbandoned = removeAbandoned;
- }
-
- public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
- this.removeAbandonedTimeout = removeAbandonedTimeout;
- }
-
- public void setTestOnBorrow(boolean testOnBorrow) {
- this.testOnBorrow = testOnBorrow;
- }
-
- public void setTestWhileIdle(boolean testWhileIdle) {
- this.testWhileIdle = testWhileIdle;
- }
-
- public void setTestOnReturn(boolean testOnReturn) {
- this.testOnReturn = testOnReturn;
- }
-
- public void setTimeBetweenEvictionRunsMillis(int
- timeBetweenEvictionRunsMillis) {
- this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public void setValidationInterval(long validationInterval) {
- this.validationInterval = validationInterval;
- }
-
- public void setValidationQuery(String validationQuery) {
- this.validationQuery = validationQuery;
- }
-
- public void setInitSQL(String initSQL) {
- this.initSQL = initSQL;
- }
-
- public void setTestOnConnect(boolean testOnConnect) {
- this.testOnConnect = testOnConnect;
- }
-
- public void setJdbcInterceptors(String jdbcInterceptors) {
- this.jdbcInterceptors = jdbcInterceptors;
- }
-
- public String toString() {
- StringBuffer buf = new StringBuffer("ConnectionPool[");
- try {
- String[] fields = DataSourceFactory.ALL_PROPERTIES;
- for (int i=0; i<fields.length; i++) {
- final String[] prefix = new String[] {"get","is"};
- for (int j=0; j<prefix.length; j++) {
-
- String name = prefix[j] + fields[i].substring(0, 1).toUpperCase() +
- fields[i].substring(1);
- Method m = null;
- try {
- m = getClass().getMethod(name);
- }catch (NoSuchMethodException nm) {
- continue;
- }
- buf.append(fields[i]);
- buf.append("=");
- buf.append(m.invoke(this, new Object[0]));
- buf.append("; ");
- break;
- }
- }
- }catch (Exception x) {
- //shouldn;t happen
- x.printStackTrace();
- }
- return buf.toString();
- }
-
- public static int getPoolCounter() {
- return poolCounter;
- }
-
- public boolean isJmxEnabled() {
- return jmxEnabled;
- }
-
- public void setJmxEnabled(boolean jmxEnabled) {
- this.jmxEnabled = jmxEnabled;
- }
-
- public Boolean getDefaultAutoCommit() {
- return defaultAutoCommit;
- }
-
- public Boolean getDefaultReadOnly() {
- return defaultReadOnly;
- }
-
- public boolean isPoolSweeperEnabled() {
- boolean result = getTimeBetweenEvictionRunsMillis()>0;
- result = result && (isRemoveAbandoned() && getRemoveAbandonedTimeout()>0);
- result = result && (isTestWhileIdle() && getValidationQuery()!=null);
- return result;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.jdbc.pool;
+
+
+import java.lang.reflect.Method;
+import java.util.Properties;
+/**
+ * @author Filip Hanik
+ *
+ */
+public class PoolProperties {
+ protected static volatile int poolCounter = 1;
+ protected Properties dbProperties = new Properties();
+ protected String url = null;
+ protected String driverClassName = null;
+ protected Boolean defaultAutoCommit = null;
+ protected Boolean defaultReadOnly = null;
+ protected int defaultTransactionIsolation = DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION;
+ protected String defaultCatalog = null;
+ protected String connectionProperties;
+ protected int initialSize = 10;
+ protected int maxActive = 100;
+ protected int maxIdle = maxActive;
+ protected int minIdle = initialSize;
+ protected int maxWait = 30000;
+ protected String validationQuery;
+ protected boolean testOnBorrow = false;
+ protected boolean testOnReturn = false;
+ protected boolean testWhileIdle = false;
+ protected int timeBetweenEvictionRunsMillis = 5000;
+ protected int numTestsPerEvictionRun;
+ protected int minEvictableIdleTimeMillis = 60000;
+ protected boolean accessToUnderlyingConnectionAllowed;
+ protected boolean removeAbandoned = false;
+ protected int removeAbandonedTimeout = 60;
+ protected boolean logAbandoned = false;
+ protected int loginTimeout = 10000;
+ protected String name = "Filip Connection Pool["+(poolCounter++)+"]";
+ protected String password;
+ protected String username;
+ protected long validationInterval = 30000;
+ protected boolean jmxEnabled = true;
+ protected String initSQL;
+ protected boolean testOnConnect =false;
+ private String jdbcInterceptors=null;
+ private boolean fairQueue = false;
+
+ public boolean isFairQueue() {
+ return fairQueue;
+ }
+
+ public void setFairQueue(boolean fairQueue) {
+ this.fairQueue = fairQueue;
+ }
+
+ public boolean isAccessToUnderlyingConnectionAllowed() {
+ return accessToUnderlyingConnectionAllowed;
+ }
+
+ public String getConnectionProperties() {
+ return connectionProperties;
+ }
+
+ public Properties getDbProperties() {
+ return dbProperties;
+ }
+
+ public boolean isDefaultAutoCommit() {
+ return defaultAutoCommit;
+ }
+
+ public String getDefaultCatalog() {
+ return defaultCatalog;
+ }
+
+ public boolean isDefaultReadOnly() {
+ return defaultReadOnly;
+ }
+
+ public int getDefaultTransactionIsolation() {
+ return defaultTransactionIsolation;
+ }
+
+ public String getDriverClassName() {
+ return driverClassName;
+ }
+
+ public int getInitialSize() {
+ return initialSize;
+ }
+
+ public boolean isLogAbandoned() {
+ return logAbandoned;
+ }
+
+ public int getLoginTimeout() {
+ return loginTimeout;
+ }
+
+ public int getMaxActive() {
+ return maxActive;
+ }
+
+ public int getMaxIdle() {
+ return maxIdle;
+ }
+
+ public int getMaxWait() {
+ return maxWait;
+ }
+
+ public int getMinEvictableIdleTimeMillis() {
+ return minEvictableIdleTimeMillis;
+ }
+
+ public int getMinIdle() {
+ return minIdle;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getNumTestsPerEvictionRun() {
+ return numTestsPerEvictionRun;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public String getPoolName() {
+ return getName();
+ }
+
+ public boolean isRemoveAbandoned() {
+ return removeAbandoned;
+ }
+
+ public int getRemoveAbandonedTimeout() {
+ return removeAbandonedTimeout;
+ }
+
+ public boolean isTestOnBorrow() {
+ return testOnBorrow;
+ }
+
+ public boolean isTestOnReturn() {
+ return testOnReturn;
+ }
+
+ public boolean isTestWhileIdle() {
+ return testWhileIdle;
+ }
+
+ public int getTimeBetweenEvictionRunsMillis() {
+ return timeBetweenEvictionRunsMillis;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public String getValidationQuery() {
+ return validationQuery;
+ }
+
+ public long getValidationInterval() {
+ return validationInterval;
+ }
+
+ public String getInitSQL() {
+ return initSQL;
+ }
+
+ public boolean isTestOnConnect() {
+ return testOnConnect;
+ }
+
+ public String getJdbcInterceptors() {
+ return jdbcInterceptors;
+ }
+
+ public String[] getJdbcInterceptorsAsArray() {
+ if (jdbcInterceptors==null) return new String[0];
+ else {
+ return jdbcInterceptors.split(";");
+ }
+ }
+
+ public void setAccessToUnderlyingConnectionAllowed(boolean
+ accessToUnderlyingConnectionAllowed) {
+ this.accessToUnderlyingConnectionAllowed =
+ accessToUnderlyingConnectionAllowed;
+ }
+
+ public void setConnectionProperties(String connectionProperties) {
+ this.connectionProperties = connectionProperties;
+ }
+
+ public void setDbProperties(Properties dbProperties) {
+ this.dbProperties = dbProperties;
+ }
+
+ public void setDefaultAutoCommit(Boolean defaultAutoCommit) {
+ this.defaultAutoCommit = defaultAutoCommit;
+ }
+
+ public void setDefaultCatalog(String defaultCatalog) {
+ this.defaultCatalog = defaultCatalog;
+ }
+
+ public void setDefaultReadOnly(Boolean defaultReadOnly) {
+ this.defaultReadOnly = defaultReadOnly;
+ }
+
+ public void setDefaultTransactionIsolation(int defaultTransactionIsolation) {
+ this.defaultTransactionIsolation = defaultTransactionIsolation;
+ }
+
+ public void setDriverClassName(String driverClassName) {
+ this.driverClassName = driverClassName;
+ }
+
+ public void setInitialSize(int initialSize) {
+ this.initialSize = initialSize;
+ }
+
+ public void setLogAbandoned(boolean logAbandoned) {
+ this.logAbandoned = logAbandoned;
+ }
+
+ public void setLoginTimeout(int loginTimeout) {
+ this.loginTimeout = loginTimeout;
+ }
+
+ public void setMaxActive(int maxActive) {
+ this.maxActive = maxActive;
+ }
+
+ public void setMaxIdle(int maxIdle) {
+ this.maxIdle = maxIdle;
+ }
+
+ public void setMaxWait(int maxWait) {
+ this.maxWait = maxWait;
+ }
+
+ public void setMinEvictableIdleTimeMillis(int minEvictableIdleTimeMillis) {
+ this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
+ }
+
+ public void setMinIdle(int minIdle) {
+ this.minIdle = minIdle;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
+ this.numTestsPerEvictionRun = numTestsPerEvictionRun;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public void setRemoveAbandoned(boolean removeAbandoned) {
+ this.removeAbandoned = removeAbandoned;
+ }
+
+ public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
+ this.removeAbandonedTimeout = removeAbandonedTimeout;
+ }
+
+ public void setTestOnBorrow(boolean testOnBorrow) {
+ this.testOnBorrow = testOnBorrow;
+ }
+
+ public void setTestWhileIdle(boolean testWhileIdle) {
+ this.testWhileIdle = testWhileIdle;
+ }
+
+ public void setTestOnReturn(boolean testOnReturn) {
+ this.testOnReturn = testOnReturn;
+ }
+
+ public void setTimeBetweenEvictionRunsMillis(int
+ timeBetweenEvictionRunsMillis) {
+ this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public void setValidationInterval(long validationInterval) {
+ this.validationInterval = validationInterval;
+ }
+
+ public void setValidationQuery(String validationQuery) {
+ this.validationQuery = validationQuery;
+ }
+
+ public void setInitSQL(String initSQL) {
+ this.initSQL = initSQL;
+ }
+
+ public void setTestOnConnect(boolean testOnConnect) {
+ this.testOnConnect = testOnConnect;
+ }
+
+ public void setJdbcInterceptors(String jdbcInterceptors) {
+ this.jdbcInterceptors = jdbcInterceptors;
+ }
+
+ public String toString() {
+ StringBuffer buf = new StringBuffer("ConnectionPool[");
+ try {
+ String[] fields = DataSourceFactory.ALL_PROPERTIES;
+ for (int i=0; i<fields.length; i++) {
+ final String[] prefix = new String[] {"get","is"};
+ for (int j=0; j<prefix.length; j++) {
+
+ String name = prefix[j] + fields[i].substring(0, 1).toUpperCase() +
+ fields[i].substring(1);
+ Method m = null;
+ try {
+ m = getClass().getMethod(name);
+ }catch (NoSuchMethodException nm) {
+ continue;
+ }
+ buf.append(fields[i]);
+ buf.append("=");
+ buf.append(m.invoke(this, new Object[0]));
+ buf.append("; ");
+ break;
+ }
+ }
+ }catch (Exception x) {
+ //shouldn;t happen
+ x.printStackTrace();
+ }
+ return buf.toString();
+ }
+
+ public static int getPoolCounter() {
+ return poolCounter;
+ }
+
+ public boolean isJmxEnabled() {
+ return jmxEnabled;
+ }
+
+ public void setJmxEnabled(boolean jmxEnabled) {
+ this.jmxEnabled = jmxEnabled;
+ }
+
+ public Boolean getDefaultAutoCommit() {
+ return defaultAutoCommit;
+ }
+
+ public Boolean getDefaultReadOnly() {
+ return defaultReadOnly;
+ }
+
+ public boolean isPoolSweeperEnabled() {
+ boolean result = getTimeBetweenEvictionRunsMillis()>0;
+ result = result && (isRemoveAbandoned() && getRemoveAbandonedTimeout()>0);
+ result = result && (isTestWhileIdle() && getValidationQuery()!=null);
+ return result;
+ }
+}
Propchange: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PoolProperties.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java?rev=710199&r1=710198&r2=710199&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java Mon Nov 3 14:38:55 2008
@@ -1,304 +1,304 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.jdbc.pool;
-
-
-import java.lang.ref.WeakReference;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import org.apache.juli.logging.Log;
-import org.apache.juli.logging.LogFactory;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * @author Filip Hanik
- * @version 1.0
- */
-public class PooledConnection {
-
- public static final int VALIDATE_BORROW = 1;
- public static final int VALIDATE_RETURN = 2;
- public static final int VALIDATE_IDLE = 3;
- public static final int VALIDATE_INIT = 4;
-
- protected static Log log = LogFactory.getLog(PooledConnection.class);
- protected static volatile int counter = 1;
-
- protected PoolProperties poolProperties;
- protected java.sql.Connection connection;
- protected String abandonTrace = null;
- protected long timestamp;
- protected ReentrantReadWriteLock lock = new ReentrantReadWriteLock(false);
- protected boolean discarded = false;
- protected long lastValidated = System.currentTimeMillis();
- protected int instanceCount = 0;
- protected ConnectionPool parent;
-
- protected WeakReference<JdbcInterceptor> handler = null;
-
- public PooledConnection(PoolProperties prop, ConnectionPool parent) throws SQLException {
- instanceCount = counter++;
- poolProperties = prop;
- this.parent = parent;
- }
-
- protected void connect() throws SQLException {
- if (connection != null) {
- try {
- this.disconnect(false);
- } catch (Exception x) {
- log.error("Unable to disconnect previous connection.", x);
- } //catch
- } //end if
- java.sql.Driver driver = null;
- try {
- driver = (java.sql.Driver) Class.forName(poolProperties.getDriverClassName(),
- true, PooledConnection.class.getClassLoader()).newInstance();
- } catch (java.lang.Exception cn) {
- log.error("Unable to instantiate JDBC driver.", cn);
- throw new SQLException(cn.getMessage());
- }
- String driverURL = poolProperties.getUrl();
- String usr = poolProperties.getUsername();
- String pwd = poolProperties.getPassword();
- poolProperties.getDbProperties().setProperty("user", usr);
- poolProperties.getDbProperties().setProperty("password", pwd);
- connection = driver.connect(driverURL, poolProperties.getDbProperties());
- //set up the default state
- if (poolProperties.getDefaultReadOnly()!=null) connection.setReadOnly(poolProperties.getDefaultReadOnly().booleanValue());
- if (poolProperties.getDefaultAutoCommit()!=null) connection.setAutoCommit(poolProperties.getDefaultAutoCommit().booleanValue());
- if (poolProperties.getDefaultCatalog()!=null) connection.setCatalog(poolProperties.getDefaultCatalog());
- if (poolProperties.getDefaultTransactionIsolation()!=DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION) connection.setTransactionIsolation(poolProperties.getDefaultTransactionIsolation());
-
- this.discarded = false;
- }
-
- protected void reconnect() throws SQLException {
- this.disconnect(false);
- this.connect();
- } //reconnect
-
- protected synchronized void disconnect(boolean finalize) throws SQLException {
- if (isDiscarded()) {
- return;
- }
- setDiscarded(true);
- if (connection != null) {
- connection.close();
- }
- connection = null;
- if (finalize) parent.finalize(this);
- }
-
-
-//============================================================================
-// com.filip.util.IPoolObject methods
-//============================================================================
-
- public long getAbandonTimeout() {
- if (poolProperties.getRemoveAbandonedTimeout() <= 0) {
- return Long.MAX_VALUE;
- } else {
- return poolProperties.getRemoveAbandonedTimeout()*1000;
- } //end if
- }
-
- public boolean abandon() {
- try {
- disconnect(true);
- } catch (SQLException x) {
- log.error("", x);
- } //catch
- return false;
- }
-
- protected boolean doValidate(int action) {
- if (action == PooledConnection.VALIDATE_BORROW &&
- poolProperties.isTestOnBorrow())
- return true;
- else if (action == PooledConnection.VALIDATE_RETURN &&
- poolProperties.isTestOnReturn())
- return true;
- else if (action == PooledConnection.VALIDATE_IDLE &&
- poolProperties.isTestWhileIdle())
- return true;
- else if (action == PooledConnection.VALIDATE_INIT &&
- poolProperties.isTestOnConnect())
- return true;
- else if (action == PooledConnection.VALIDATE_INIT &&
- poolProperties.getInitSQL()!=null)
- return true;
- else
- return false;
- }
-
- /**Returns true if the object is still valid. if not
- * the pool will call the getExpiredAction() and follow up with one
- * of the four expired methods
- */
- public boolean validate(int validateAction) {
- return validate(validateAction,null);
- }
-
- public boolean validate(int validateAction,String sql) {
- if (this.isDiscarded()) {
- return false;
- }
-
- if (!doValidate(validateAction)) {
- //no validation required, no init sql and props not set
- return true;
- }
-
- String query = (VALIDATE_INIT==validateAction && (poolProperties.getInitSQL()!=null))?poolProperties.getInitSQL():sql;
-
- if (query==null) query = poolProperties.getValidationQuery();
-
- if (query == null) {
- //no validation possible
- return true;
- }
- long now = System.currentTimeMillis();
- if (this.poolProperties.getValidationInterval() > 0 &&
- (now - this.lastValidated) <
- this.poolProperties.getValidationInterval()) {
- return true;
- }
- try {
- Statement stmt = connection.createStatement();
- boolean exec = stmt.execute(query);
- stmt.close();
- this.lastValidated = now;
- return true;
- } catch (Exception ignore) {
- if (log.isDebugEnabled())
- log.debug("Unable to validate object:",ignore);
- }
- return false;
- } //validate
-
- /**
- * The time limit for how long the object
- * can remain unused before it is released
- */
- public long getReleaseTime() {
- return this.poolProperties.getMinEvictableIdleTimeMillis();
- }
-
- /**
- * This method is called if (Now - timeCheckedIn > getReleaseTime())
- */
- public void release() {
- try {
- disconnect(true);
- } catch (SQLException x) {
- if (log.isDebugEnabled()) {
- log.debug("Unable to close SQL connection",x);
- }
- } catch (Exception x) {
- if (log.isDebugEnabled()) {
- log.debug("Unable to close SQL connection",x);
- }
- }
-
- }
-
- /**
- * The pool will set the stack trace when it is check out and
- * checked in
- */
-
- public void setStackTrace(String trace) {
- abandonTrace = trace;
- }
-
- public String getStackTrace() {
- return abandonTrace;
- }
-
- public void setTimestamp(long timestamp) {
- this.timestamp = timestamp;
- }
-
- public void setDiscarded(boolean discarded) {
- if (this.discarded && !discarded) throw new IllegalStateException("Unable to change the state once the connection has been discarded");
- this.discarded = discarded;
- }
-
- public void setLastValidated(long lastValidated) {
- this.lastValidated = lastValidated;
- }
-
- public void setPoolProperties(PoolProperties poolProperties) {
- this.poolProperties = poolProperties;
- }
-
- public long getTimestamp() {
- return timestamp;
- }
-
- public boolean isDiscarded() {
- return discarded;
- }
-
- public long getLastValidated() {
- return lastValidated;
- }
-
- public PoolProperties getPoolProperties() {
- return poolProperties;
- }
-
- public void lock() {
- if (this.poolProperties.isPoolSweeperEnabled()) {
- //optimized, only use a lock when there is concurrency
- lock.writeLock().lock();
- }
- }
-
- public void unlock() {
- if (this.poolProperties.isPoolSweeperEnabled()) {
- //optimized, only use a lock when there is concurrency
- lock.writeLock().unlock();
- }
- }
-
- public java.sql.Connection getConnection() {
- return this.connection;
- }
-
- public JdbcInterceptor getHandler() {
- return (handler!=null)?handler.get():null;
- }
-
- public void setHandler(JdbcInterceptor handler) {
- if (handler==null) {
- if (this.handler!=null) this.handler.clear();
- } else if (this.handler==null) {
- this.handler = new WeakReference<JdbcInterceptor>(handler);
- } else if (this.handler.get()==null) {
- this.handler.clear();
- this.handler = new WeakReference<JdbcInterceptor>(handler);
- } else if (this.handler.get()!=handler) {
- this.handler.clear();
- this.handler = new WeakReference<JdbcInterceptor>(handler);
- }
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.jdbc.pool;
+
+
+import java.lang.ref.WeakReference;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * @author Filip Hanik
+ * @version 1.0
+ */
+public class PooledConnection {
+
+ public static final int VALIDATE_BORROW = 1;
+ public static final int VALIDATE_RETURN = 2;
+ public static final int VALIDATE_IDLE = 3;
+ public static final int VALIDATE_INIT = 4;
+
+ protected static Log log = LogFactory.getLog(PooledConnection.class);
+ protected static volatile int counter = 1;
+
+ protected PoolProperties poolProperties;
+ protected java.sql.Connection connection;
+ protected String abandonTrace = null;
+ protected long timestamp;
+ protected ReentrantReadWriteLock lock = new ReentrantReadWriteLock(false);
+ protected boolean discarded = false;
+ protected long lastValidated = System.currentTimeMillis();
+ protected int instanceCount = 0;
+ protected ConnectionPool parent;
+
+ protected WeakReference<JdbcInterceptor> handler = null;
+
+ public PooledConnection(PoolProperties prop, ConnectionPool parent) throws SQLException {
+ instanceCount = counter++;
+ poolProperties = prop;
+ this.parent = parent;
+ }
+
+ protected void connect() throws SQLException {
+ if (connection != null) {
+ try {
+ this.disconnect(false);
+ } catch (Exception x) {
+ log.error("Unable to disconnect previous connection.", x);
+ } //catch
+ } //end if
+ java.sql.Driver driver = null;
+ try {
+ driver = (java.sql.Driver) Class.forName(poolProperties.getDriverClassName(),
+ true, PooledConnection.class.getClassLoader()).newInstance();
+ } catch (java.lang.Exception cn) {
+ log.error("Unable to instantiate JDBC driver.", cn);
+ throw new SQLException(cn.getMessage());
+ }
+ String driverURL = poolProperties.getUrl();
+ String usr = poolProperties.getUsername();
+ String pwd = poolProperties.getPassword();
+ poolProperties.getDbProperties().setProperty("user", usr);
+ poolProperties.getDbProperties().setProperty("password", pwd);
+ connection = driver.connect(driverURL, poolProperties.getDbProperties());
+ //set up the default state
+ if (poolProperties.getDefaultReadOnly()!=null) connection.setReadOnly(poolProperties.getDefaultReadOnly().booleanValue());
+ if (poolProperties.getDefaultAutoCommit()!=null) connection.setAutoCommit(poolProperties.getDefaultAutoCommit().booleanValue());
+ if (poolProperties.getDefaultCatalog()!=null) connection.setCatalog(poolProperties.getDefaultCatalog());
+ if (poolProperties.getDefaultTransactionIsolation()!=DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION) connection.setTransactionIsolation(poolProperties.getDefaultTransactionIsolation());
+
+ this.discarded = false;
+ }
+
+ protected void reconnect() throws SQLException {
+ this.disconnect(false);
+ this.connect();
+ } //reconnect
+
+ protected synchronized void disconnect(boolean finalize) throws SQLException {
+ if (isDiscarded()) {
+ return;
+ }
+ setDiscarded(true);
+ if (connection != null) {
+ connection.close();
+ }
+ connection = null;
+ if (finalize) parent.finalize(this);
+ }
+
+
+//============================================================================
+// com.filip.util.IPoolObject methods
+//============================================================================
+
+ public long getAbandonTimeout() {
+ if (poolProperties.getRemoveAbandonedTimeout() <= 0) {
+ return Long.MAX_VALUE;
+ } else {
+ return poolProperties.getRemoveAbandonedTimeout()*1000;
+ } //end if
+ }
+
+ public boolean abandon() {
+ try {
+ disconnect(true);
+ } catch (SQLException x) {
+ log.error("", x);
+ } //catch
+ return false;
+ }
+
+ protected boolean doValidate(int action) {
+ if (action == PooledConnection.VALIDATE_BORROW &&
+ poolProperties.isTestOnBorrow())
+ return true;
+ else if (action == PooledConnection.VALIDATE_RETURN &&
+ poolProperties.isTestOnReturn())
+ return true;
+ else if (action == PooledConnection.VALIDATE_IDLE &&
+ poolProperties.isTestWhileIdle())
+ return true;
+ else if (action == PooledConnection.VALIDATE_INIT &&
+ poolProperties.isTestOnConnect())
+ return true;
+ else if (action == PooledConnection.VALIDATE_INIT &&
+ poolProperties.getInitSQL()!=null)
+ return true;
+ else
+ return false;
+ }
+
+ /**Returns true if the object is still valid. if not
+ * the pool will call the getExpiredAction() and follow up with one
+ * of the four expired methods
+ */
+ public boolean validate(int validateAction) {
+ return validate(validateAction,null);
+ }
+
+ public boolean validate(int validateAction,String sql) {
+ if (this.isDiscarded()) {
+ return false;
+ }
+
+ if (!doValidate(validateAction)) {
+ //no validation required, no init sql and props not set
+ return true;
+ }
+
+ String query = (VALIDATE_INIT==validateAction && (poolProperties.getInitSQL()!=null))?poolProperties.getInitSQL():sql;
+
+ if (query==null) query = poolProperties.getValidationQuery();
+
+ if (query == null) {
+ //no validation possible
+ return true;
+ }
+ long now = System.currentTimeMillis();
+ if (this.poolProperties.getValidationInterval() > 0 &&
+ (now - this.lastValidated) <
+ this.poolProperties.getValidationInterval()) {
+ return true;
+ }
+ try {
+ Statement stmt = connection.createStatement();
+ boolean exec = stmt.execute(query);
+ stmt.close();
+ this.lastValidated = now;
+ return true;
+ } catch (Exception ignore) {
+ if (log.isDebugEnabled())
+ log.debug("Unable to validate object:",ignore);
+ }
+ return false;
+ } //validate
+
+ /**
+ * The time limit for how long the object
+ * can remain unused before it is released
+ */
+ public long getReleaseTime() {
+ return this.poolProperties.getMinEvictableIdleTimeMillis();
+ }
+
+ /**
+ * This method is called if (Now - timeCheckedIn > getReleaseTime())
+ */
+ public void release() {
+ try {
+ disconnect(true);
+ } catch (SQLException x) {
+ if (log.isDebugEnabled()) {
+ log.debug("Unable to close SQL connection",x);
+ }
+ } catch (Exception x) {
+ if (log.isDebugEnabled()) {
+ log.debug("Unable to close SQL connection",x);
+ }
+ }
+
+ }
+
+ /**
+ * The pool will set the stack trace when it is check out and
+ * checked in
+ */
+
+ public void setStackTrace(String trace) {
+ abandonTrace = trace;
+ }
+
+ public String getStackTrace() {
+ return abandonTrace;
+ }
+
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public void setDiscarded(boolean discarded) {
+ if (this.discarded && !discarded) throw new IllegalStateException("Unable to change the state once the connection has been discarded");
+ this.discarded = discarded;
+ }
+
+ public void setLastValidated(long lastValidated) {
+ this.lastValidated = lastValidated;
+ }
+
+ public void setPoolProperties(PoolProperties poolProperties) {
+ this.poolProperties = poolProperties;
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public boolean isDiscarded() {
+ return discarded;
+ }
+
+ public long getLastValidated() {
+ return lastValidated;
+ }
+
+ public PoolProperties getPoolProperties() {
+ return poolProperties;
+ }
+
+ public void lock() {
+ if (this.poolProperties.isPoolSweeperEnabled()) {
+ //optimized, only use a lock when there is concurrency
+ lock.writeLock().lock();
+ }
+ }
+
+ public void unlock() {
+ if (this.poolProperties.isPoolSweeperEnabled()) {
+ //optimized, only use a lock when there is concurrency
+ lock.writeLock().unlock();
+ }
+ }
+
+ public java.sql.Connection getConnection() {
+ return this.connection;
+ }
+
+ public JdbcInterceptor getHandler() {
+ return (handler!=null)?handler.get():null;
+ }
+
+ public void setHandler(JdbcInterceptor handler) {
+ if (handler==null) {
+ if (this.handler!=null) this.handler.clear();
+ } else if (this.handler==null) {
+ this.handler = new WeakReference<JdbcInterceptor>(handler);
+ } else if (this.handler.get()==null) {
+ this.handler.clear();
+ this.handler = new WeakReference<JdbcInterceptor>(handler);
+ } else if (this.handler.get()!=handler) {
+ this.handler.clear();
+ this.handler = new WeakReference<JdbcInterceptor>(handler);
+ }
+ }
+
+}
Propchange: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/PooledConnection.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ProxyConnection.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ProxyConnection.java?rev=710199&r1=710198&r2=710199&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ProxyConnection.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ProxyConnection.java Mon Nov 3 14:38:55 2008
@@ -1,93 +1,93 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.jdbc.pool;
-
-import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.sql.SQLException;
-/**
- * @author Filip Hanik
- */
-public class ProxyConnection extends JdbcInterceptor {
-
- protected PooledConnection connection = null;
-
- protected ConnectionPool pool = null;
-
- public PooledConnection getConnection() {
- return connection;
- }
-
- public void setConnection(PooledConnection connection) {
- this.connection = connection;
- }
-
- public ConnectionPool getPool() {
- return pool;
- }
-
- public void setPool(ConnectionPool pool) {
- this.pool = pool;
- }
-
- protected ProxyConnection(ConnectionPool parent, PooledConnection con) throws SQLException {
- pool = parent;
- connection = con;
- }
-
- public void reset(ConnectionPool parent, PooledConnection con) {
- this.pool = parent;
- this.connection = con;
- }
-
- public boolean isWrapperFor(Class<?> iface) throws SQLException {
- return (iface.isInstance(connection.getConnection()));
- }
-
-
- public Object unwrap(Class iface) throws SQLException {
- if (isWrapperFor(iface)) {
- return connection.getConnection();
- } else {
- throw new SQLException("Not a wrapper of "+iface.getName());
- }
- }
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- if (isClosed()) throw new SQLException("Connection has already been closed.");
- if (CLOSE_VAL==method.getName()) {
- PooledConnection poolc = this.connection;
- this.connection = null;
- pool.returnConnection(poolc);
- return null;
- }
- return method.invoke(connection.getConnection(),args);
- }
-
- public boolean isClosed() {
- return connection==null || connection.isDiscarded();
- }
-
- public PooledConnection getDelegateConnection() {
- return connection;
- }
-
- public ConnectionPool getParentPool() {
- return pool;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.jdbc.pool;
+
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.SQLException;
+/**
+ * @author Filip Hanik
+ */
+public class ProxyConnection extends JdbcInterceptor {
+
+ protected PooledConnection connection = null;
+
+ protected ConnectionPool pool = null;
+
+ public PooledConnection getConnection() {
+ return connection;
+ }
+
+ public void setConnection(PooledConnection connection) {
+ this.connection = connection;
+ }
+
+ public ConnectionPool getPool() {
+ return pool;
+ }
+
+ public void setPool(ConnectionPool pool) {
+ this.pool = pool;
+ }
+
+ protected ProxyConnection(ConnectionPool parent, PooledConnection con) throws SQLException {
+ pool = parent;
+ connection = con;
+ }
+
+ public void reset(ConnectionPool parent, PooledConnection con) {
+ this.pool = parent;
+ this.connection = con;
+ }
+
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ return (iface.isInstance(connection.getConnection()));
+ }
+
+
+ public Object unwrap(Class iface) throws SQLException {
+ if (isWrapperFor(iface)) {
+ return connection.getConnection();
+ } else {
+ throw new SQLException("Not a wrapper of "+iface.getName());
+ }
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if (isClosed()) throw new SQLException("Connection has already been closed.");
+ if (CLOSE_VAL==method.getName()) {
+ PooledConnection poolc = this.connection;
+ this.connection = null;
+ pool.returnConnection(poolc);
+ return null;
+ }
+ return method.invoke(connection.getConnection(),args);
+ }
+
+ public boolean isClosed() {
+ return connection==null || connection.isDiscarded();
+ }
+
+ public PooledConnection getDelegateConnection() {
+ return connection;
+ }
+
+ public ConnectionPool getParentPool() {
+ return pool;
+ }
+
+}
Propchange: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ProxyConnection.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/ProxyConnection.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java?rev=710199&r1=710198&r2=710199&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java Mon Nov 3 14:38:55 2008
@@ -1,171 +1,171 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.jdbc.pool.jmx;
-/**
- * @author Filip Hanik
- */
-import java.util.Properties;
-
-import javax.management.DynamicMBean;
-
-import org.apache.tomcat.jdbc.pool.JdbcInterceptor;
-
-public class ConnectionPool implements ConnectionPoolMBean {
- protected org.apache.tomcat.jdbc.pool.ConnectionPool pool = null;
-
- public ConnectionPool(org.apache.tomcat.jdbc.pool.ConnectionPool pool) {
- this.pool = pool;
- }
-
- public org.apache.tomcat.jdbc.pool.ConnectionPool getPool() {
- return pool;
- }
-
- //=================================================================
- // POOL STATS
- //=================================================================
-
- public int getSize() {
- return pool.getSize();
- }
-
- public int getIdle() {
- return pool.getIdle();
- }
-
- public int getActive() {
- return pool.getActive();
- }
-
- public boolean isPoolSweeperEnabled() {
- return pool.getPoolProperties().isPoolSweeperEnabled();
- }
-
- //=================================================================
- // POOL OPERATIONS
- //=================================================================
- public void checkIdle() {
- pool.checkIdle();
- }
-
- public void checkAbandoned() {
- pool.checkAbandoned();
- }
-
- public void testIdle() {
- pool.testAllIdle();
- }
- //=================================================================
- // POOL PROPERTIES
- //=================================================================
- public Properties getDbProperties() {
- return pool.getPoolProperties().getDbProperties();
- }
- public String getUrl() {
- return pool.getPoolProperties().getUrl();
- }
- public String getDriverClassName() {
- return pool.getPoolProperties().getDriverClassName();
- }
- public boolean isDefaultAutoCommit() {
- return pool.getPoolProperties().isDefaultAutoCommit();
- }
- public boolean isDefaultReadOnly() {
- return pool.getPoolProperties().isDefaultReadOnly();
- }
- public int getDefaultTransactionIsolation() {
- return pool.getPoolProperties().getDefaultTransactionIsolation();
- }
- public String getConnectionProperties() {
- return pool.getPoolProperties().getConnectionProperties();
- }
- public String getDefaultCatalog() {
- return pool.getPoolProperties().getDefaultCatalog();
- }
- public int getInitialSize() {
- return pool.getPoolProperties().getInitialSize();
- }
- public int getMaxActive() {
- return pool.getPoolProperties().getMaxActive();
- }
- public int getMaxIdle() {
- return pool.getPoolProperties().getMaxIdle();
- }
- public int getMinIdle() {
- return pool.getPoolProperties().getMinIdle();
- }
- public int getMaxWait() {
- return pool.getPoolProperties().getMaxWait();
- }
- public String getValidationQuery() {
- return pool.getPoolProperties().getValidationQuery();
- }
- public boolean isTestOnBorrow() {
- return pool.getPoolProperties().isTestOnBorrow();
- }
- public boolean isTestOnReturn() {
- return pool.getPoolProperties().isTestOnReturn();
- }
- public boolean isTestWhileIdle() {
- return pool.getPoolProperties().isTestWhileIdle();
- }
- public int getTimeBetweenEvictionRunsMillis() {
- return pool.getPoolProperties().getTimeBetweenEvictionRunsMillis();
- }
- public int getNumTestsPerEvictionRun() {
- return pool.getPoolProperties().getNumTestsPerEvictionRun();
- }
- public int getMinEvictableIdleTimeMillis() {
- return pool.getPoolProperties().getMinEvictableIdleTimeMillis();
- }
- public boolean isAccessToUnderlyingConnectionAllowed() {
- return pool.getPoolProperties().isAccessToUnderlyingConnectionAllowed();
- }
- public boolean isRemoveAbandoned() {
- return pool.getPoolProperties().isRemoveAbandoned();
- }
- public int getRemoveAbandonedTimeout() {
- return pool.getPoolProperties().getRemoveAbandonedTimeout();
- }
- public boolean isLogAbandoned() {
- return pool.getPoolProperties().isLogAbandoned();
- }
- public int getLoginTimeout() {
- return pool.getPoolProperties().getLoginTimeout();
- }
- public String getName() {
- return pool.getPoolProperties().getName();
- }
- public String getPassword() {
- return pool.getPoolProperties().getPassword();
- }
- public String getUsername() {
- return pool.getPoolProperties().getUsername();
- }
- public long getValidationInterval() {
- return pool.getPoolProperties().getValidationInterval();
- }
- public String getInitSQL() {
- return pool.getPoolProperties().getInitSQL();
- }
- public boolean isTestOnConnect() {
- return pool.getPoolProperties().isTestOnConnect();
- }
- public String getJdbcInterceptors() {
- return pool.getPoolProperties().getJdbcInterceptors();
- }
-
-}
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.jdbc.pool.jmx;
+/**
+ * @author Filip Hanik
+ */
+import java.util.Properties;
+
+import javax.management.DynamicMBean;
+
+import org.apache.tomcat.jdbc.pool.JdbcInterceptor;
+
+public class ConnectionPool implements ConnectionPoolMBean {
+ protected org.apache.tomcat.jdbc.pool.ConnectionPool pool = null;
+
+ public ConnectionPool(org.apache.tomcat.jdbc.pool.ConnectionPool pool) {
+ this.pool = pool;
+ }
+
+ public org.apache.tomcat.jdbc.pool.ConnectionPool getPool() {
+ return pool;
+ }
+
+ //=================================================================
+ // POOL STATS
+ //=================================================================
+
+ public int getSize() {
+ return pool.getSize();
+ }
+
+ public int getIdle() {
+ return pool.getIdle();
+ }
+
+ public int getActive() {
+ return pool.getActive();
+ }
+
+ public boolean isPoolSweeperEnabled() {
+ return pool.getPoolProperties().isPoolSweeperEnabled();
+ }
+
+ //=================================================================
+ // POOL OPERATIONS
+ //=================================================================
+ public void checkIdle() {
+ pool.checkIdle();
+ }
+
+ public void checkAbandoned() {
+ pool.checkAbandoned();
+ }
+
+ public void testIdle() {
+ pool.testAllIdle();
+ }
+ //=================================================================
+ // POOL PROPERTIES
+ //=================================================================
+ public Properties getDbProperties() {
+ return pool.getPoolProperties().getDbProperties();
+ }
+ public String getUrl() {
+ return pool.getPoolProperties().getUrl();
+ }
+ public String getDriverClassName() {
+ return pool.getPoolProperties().getDriverClassName();
+ }
+ public boolean isDefaultAutoCommit() {
+ return pool.getPoolProperties().isDefaultAutoCommit();
+ }
+ public boolean isDefaultReadOnly() {
+ return pool.getPoolProperties().isDefaultReadOnly();
+ }
+ public int getDefaultTransactionIsolation() {
+ return pool.getPoolProperties().getDefaultTransactionIsolation();
+ }
+ public String getConnectionProperties() {
+ return pool.getPoolProperties().getConnectionProperties();
+ }
+ public String getDefaultCatalog() {
+ return pool.getPoolProperties().getDefaultCatalog();
+ }
+ public int getInitialSize() {
+ return pool.getPoolProperties().getInitialSize();
+ }
+ public int getMaxActive() {
+ return pool.getPoolProperties().getMaxActive();
+ }
+ public int getMaxIdle() {
+ return pool.getPoolProperties().getMaxIdle();
+ }
+ public int getMinIdle() {
+ return pool.getPoolProperties().getMinIdle();
+ }
+ public int getMaxWait() {
+ return pool.getPoolProperties().getMaxWait();
+ }
+ public String getValidationQuery() {
+ return pool.getPoolProperties().getValidationQuery();
+ }
+ public boolean isTestOnBorrow() {
+ return pool.getPoolProperties().isTestOnBorrow();
+ }
+ public boolean isTestOnReturn() {
+ return pool.getPoolProperties().isTestOnReturn();
+ }
+ public boolean isTestWhileIdle() {
+ return pool.getPoolProperties().isTestWhileIdle();
+ }
+ public int getTimeBetweenEvictionRunsMillis() {
+ return pool.getPoolProperties().getTimeBetweenEvictionRunsMillis();
+ }
+ public int getNumTestsPerEvictionRun() {
+ return pool.getPoolProperties().getNumTestsPerEvictionRun();
+ }
+ public int getMinEvictableIdleTimeMillis() {
+ return pool.getPoolProperties().getMinEvictableIdleTimeMillis();
+ }
+ public boolean isAccessToUnderlyingConnectionAllowed() {
+ return pool.getPoolProperties().isAccessToUnderlyingConnectionAllowed();
+ }
+ public boolean isRemoveAbandoned() {
+ return pool.getPoolProperties().isRemoveAbandoned();
+ }
+ public int getRemoveAbandonedTimeout() {
+ return pool.getPoolProperties().getRemoveAbandonedTimeout();
+ }
+ public boolean isLogAbandoned() {
+ return pool.getPoolProperties().isLogAbandoned();
+ }
+ public int getLoginTimeout() {
+ return pool.getPoolProperties().getLoginTimeout();
+ }
+ public String getName() {
+ return pool.getPoolProperties().getName();
+ }
+ public String getPassword() {
+ return pool.getPoolProperties().getPassword();
+ }
+ public String getUsername() {
+ return pool.getPoolProperties().getUsername();
+ }
+ public long getValidationInterval() {
+ return pool.getPoolProperties().getValidationInterval();
+ }
+ public String getInitSQL() {
+ return pool.getPoolProperties().getInitSQL();
+ }
+ public boolean isTestOnConnect() {
+ return pool.getPoolProperties().isTestOnConnect();
+ }
+ public String getJdbcInterceptors() {
+ return pool.getPoolProperties().getJdbcInterceptors();
+ }
+
+}
Propchange: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPoolMBean.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPoolMBean.java?rev=710199&r1=710198&r2=710199&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPoolMBean.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPoolMBean.java Mon Nov 3 14:38:55 2008
@@ -1,115 +1,115 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.jdbc.pool.jmx;
-
-import java.util.Properties;
-
-import javax.management.DynamicMBean;
-
-import org.apache.tomcat.jdbc.pool.ConnectionPool;
-import org.apache.tomcat.jdbc.pool.JdbcInterceptor;
-
-public interface ConnectionPoolMBean {
-
- //=================================================================
- // POOL STATS
- //=================================================================
-
- public int getSize();
-
- public int getIdle();
-
- public int getActive();
-
- public boolean isPoolSweeperEnabled();
-
- //=================================================================
- // POOL OPERATIONS
- //=================================================================
- public void checkIdle();
-
- public void checkAbandoned();
-
- public void testIdle();
-
- //=================================================================
- // POOL PROPERTIES
- //=================================================================
- public Properties getDbProperties();
-
- public String getUrl();
-
- public String getDriverClassName();
-
- public boolean isDefaultAutoCommit();
-
- public boolean isDefaultReadOnly();
-
- public int getDefaultTransactionIsolation();
-
- public String getConnectionProperties();
-
- public String getDefaultCatalog();
-
- public int getInitialSize();
-
- public int getMaxActive();
-
- public int getMaxIdle();
-
- public int getMinIdle();
-
- public int getMaxWait();
-
- public String getValidationQuery();
-
- public boolean isTestOnBorrow();
-
- public boolean isTestOnReturn();
-
- public boolean isTestWhileIdle();
-
- public int getTimeBetweenEvictionRunsMillis();
-
- public int getNumTestsPerEvictionRun();
-
- public int getMinEvictableIdleTimeMillis();
-
- public boolean isAccessToUnderlyingConnectionAllowed();
-
- public boolean isRemoveAbandoned();
-
- public int getRemoveAbandonedTimeout();
-
- public boolean isLogAbandoned();
-
- public int getLoginTimeout();
-
- public String getName();
-
- public String getPassword();
-
- public String getUsername();
-
- public long getValidationInterval();
-
- public String getInitSQL();
-
- public boolean isTestOnConnect();
-
- public String getJdbcInterceptors();
-
-}
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.jdbc.pool.jmx;
+
+import java.util.Properties;
+
+import javax.management.DynamicMBean;
+
+import org.apache.tomcat.jdbc.pool.ConnectionPool;
+import org.apache.tomcat.jdbc.pool.JdbcInterceptor;
+
+public interface ConnectionPoolMBean {
+
+ //=================================================================
+ // POOL STATS
+ //=================================================================
+
+ public int getSize();
+
+ public int getIdle();
+
+ public int getActive();
+
+ public boolean isPoolSweeperEnabled();
+
+ //=================================================================
+ // POOL OPERATIONS
+ //=================================================================
+ public void checkIdle();
+
+ public void checkAbandoned();
+
+ public void testIdle();
+
+ //=================================================================
+ // POOL PROPERTIES
+ //=================================================================
+ public Properties getDbProperties();
+
+ public String getUrl();
+
+ public String getDriverClassName();
+
+ public boolean isDefaultAutoCommit();
+
+ public boolean isDefaultReadOnly();
+
+ public int getDefaultTransactionIsolation();
+
+ public String getConnectionProperties();
+
+ public String getDefaultCatalog();
+
+ public int getInitialSize();
+
+ public int getMaxActive();
+
+ public int getMaxIdle();
+
+ public int getMinIdle();
+
+ public int getMaxWait();
+
+ public String getValidationQuery();
+
+ public boolean isTestOnBorrow();
+
+ public boolean isTestOnReturn();
+
+ public boolean isTestWhileIdle();
+
+ public int getTimeBetweenEvictionRunsMillis();
+
+ public int getNumTestsPerEvictionRun();
+
+ public int getMinEvictableIdleTimeMillis();
+
+ public boolean isAccessToUnderlyingConnectionAllowed();
+
+ public boolean isRemoveAbandoned();
+
+ public int getRemoveAbandonedTimeout();
+
+ public boolean isLogAbandoned();
+
+ public int getLoginTimeout();
+
+ public String getName();
+
+ public String getPassword();
+
+ public String getUsername();
+
+ public long getValidationInterval();
+
+ public String getInitSQL();
+
+ public boolean isTestOnConnect();
+
+ public String getJdbcInterceptors();
+
+}
Propchange: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPoolMBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPoolMBean.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org