mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add druid-wrap project
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package com.mchange.v2.c3p0;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSourceC3P0Adapter;
|
||||
|
||||
public class ComboPooledDataSource extends DruidDataSourceC3P0Adapter implements PooledDataSource {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.mchange.v2.c3p0;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
|
||||
public interface PooledDataSource extends DataSource {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.apache.commons.dbcp;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
|
||||
public class BasicDataSource extends DruidDataSource implements BasicDataSourceMBean {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package org.apache.commons.dbcp;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSourceFactory;
|
||||
|
||||
public class BasicDataSourceFactory extends DruidDataSourceFactory {
|
||||
public static DataSource createDataSource(Properties properties) throws Exception {
|
||||
BasicDataSource dataSource = new BasicDataSource();
|
||||
config(dataSource, properties);
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
protected DataSource createDataSourceInternal(Properties properties) throws Exception {
|
||||
BasicDataSource dataSource = new BasicDataSource();
|
||||
config(dataSource, properties);
|
||||
return dataSource;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package org.apache.commons.dbcp;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSourceMBean;
|
||||
|
||||
public interface BasicDataSourceMBean extends DruidDataSourceMBean {
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package org.apache.commons.dbcp;
|
||||
|
||||
public class ManagedBasicDataSource extends BasicDataSource implements BasicDataSourceMBean {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package org.apache.commons.dbcp;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
public class ManagedBasicDataSourceFactory extends BasicDataSourceFactory {
|
||||
|
||||
public static DataSource createDataSource(Properties properties) throws Exception {
|
||||
ManagedBasicDataSource dataSource = new ManagedBasicDataSource();
|
||||
config(dataSource, properties);
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
protected DataSource createDataSourceInternal(Properties properties) throws Exception {
|
||||
ManagedBasicDataSource dataSource = new ManagedBasicDataSource();
|
||||
config(dataSource, properties);
|
||||
return dataSource;
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package org.apache.commons.dbcp;
|
||||
|
||||
|
||||
public interface ManagedBasicDataSourceMBean extends BasicDataSourceMBean {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package org.apache.commons.dbcp2;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
|
||||
public class BasicDataSource extends DruidDataSource implements BasicDataSourceMBean {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package org.apache.commons.dbcp2;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSourceFactory;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Properties;
|
||||
|
||||
public class BasicDataSourceFactory extends DruidDataSourceFactory {
|
||||
public static BasicDataSource createDataSource(Properties properties) throws Exception {
|
||||
BasicDataSource dataSource = new BasicDataSource();
|
||||
config(dataSource, properties);
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
protected BasicDataSource createDataSourceInternal(Properties properties) throws Exception {
|
||||
BasicDataSource dataSource = new BasicDataSource();
|
||||
config(dataSource, properties);
|
||||
return dataSource;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package org.apache.commons.dbcp2;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSourceMBean;
|
||||
|
||||
public interface BasicDataSourceMBean extends DruidDataSourceMBean {
|
||||
|
||||
}
|
||||
+303
@@ -0,0 +1,303 @@
|
||||
/*
|
||||
* This software is released under a licence similar to the Apache Software Licence.
|
||||
* See org.logicalcobwebs.proxool.package.html for details.
|
||||
* The latest version is available at http://proxool.sourceforge.net
|
||||
*/
|
||||
package org.logicalcobwebs.proxool;
|
||||
|
||||
|
||||
public interface ProxoolConstants {
|
||||
|
||||
public final String PROXOOL = "proxool";
|
||||
|
||||
/**
|
||||
* The namespace uri associated with namepace aware Proxool xml configurations.<br>
|
||||
* Value: The latest version is available at http://proxool.sourceforge.net/xml-namespace
|
||||
*/
|
||||
public final String PROXOOL_XML_NAMESPACE_URI = "The latest version is available at http://proxool.sourceforge.net/xml-namespace";
|
||||
|
||||
public final String ALIAS_DELIMITER = ".";
|
||||
|
||||
public final String PROPERTY_PREFIX = PROXOOL + ".";
|
||||
|
||||
public final String URL_DELIMITER = ":";
|
||||
|
||||
/** Standard JDBC property */
|
||||
public final String USER_PROPERTY = "user";
|
||||
|
||||
/** Standard JDBC property */
|
||||
public final String PASSWORD_PROPERTY = "password";
|
||||
|
||||
/** Used to build up URL */
|
||||
public final String ALIAS_PROPERTY = PROPERTY_PREFIX + "alias";
|
||||
|
||||
/** Instead of defining the driver in the url you can also use this property */
|
||||
public final String DELEGATE_DRIVER = "driver";
|
||||
|
||||
public final String DELEGATE_DRIVER_PROPERTY = PROPERTY_PREFIX + DELEGATE_DRIVER;
|
||||
|
||||
public final String DELEGATE_URL = "url";
|
||||
|
||||
public final String DELEGATE_URL_PROPERTY = PROPERTY_PREFIX + DELEGATE_URL;
|
||||
|
||||
public final String HOUSE_KEEPING_SLEEP_TIME = "house-keeping-sleep-time";
|
||||
|
||||
public final String HOUSE_KEEPING_SLEEP_TIME_PROPERTY = PROPERTY_PREFIX + HOUSE_KEEPING_SLEEP_TIME;
|
||||
|
||||
public final String HOUSE_KEEPING_TEST_SQL = "house-keeping-test-sql";
|
||||
|
||||
public final String HOUSE_KEEPING_TEST_SQL_PROPERTY = PROPERTY_PREFIX + HOUSE_KEEPING_TEST_SQL;
|
||||
|
||||
public final String TEST_BEFORE_USE = "test-before-use";
|
||||
|
||||
public final String TEST_BEFORE_USE_PROPERTY = PROPERTY_PREFIX + TEST_BEFORE_USE;
|
||||
|
||||
public final String TEST_AFTER_USE = "test-after-use";
|
||||
|
||||
public final String TEST_AFTER_USE_PROPERTY = PROPERTY_PREFIX + TEST_AFTER_USE;
|
||||
|
||||
public final String MAXIMUM_CONNECTION_COUNT = "maximum-connection-count";
|
||||
|
||||
public final String MAXIMUM_CONNECTION_COUNT_PROPERTY = PROPERTY_PREFIX + MAXIMUM_CONNECTION_COUNT;
|
||||
|
||||
public final String MAXIMUM_CONNECTION_LIFETIME = "maximum-connection-lifetime";
|
||||
|
||||
public final String MAXIMUM_CONNECTION_LIFETIME_PROPERTY = PROPERTY_PREFIX + MAXIMUM_CONNECTION_LIFETIME;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #SIMULTANEOUS_BUILD_THROTTLE} instead
|
||||
*/
|
||||
public final String MAXIMUM_NEW_CONNECTIONS = "maximum-new-connections";
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #SIMULTANEOUS_BUILD_THROTTLE_PROPERTY} instead
|
||||
*/
|
||||
public final String MAXIMUM_NEW_CONNECTIONS_PROPERTY = PROPERTY_PREFIX + MAXIMUM_NEW_CONNECTIONS;
|
||||
|
||||
public final String SIMULTANEOUS_BUILD_THROTTLE = "simultaneous-build-throttle";
|
||||
|
||||
public final String SIMULTANEOUS_BUILD_THROTTLE_PROPERTY = PROPERTY_PREFIX + SIMULTANEOUS_BUILD_THROTTLE;
|
||||
|
||||
/** @see #MINIMUM_CONNECTION_COUNT_PROPERTY */
|
||||
public final String MINIMUM_CONNECTION_COUNT = "minimum-connection-count";
|
||||
|
||||
public final String MINIMUM_CONNECTION_COUNT_PROPERTY = PROPERTY_PREFIX + MINIMUM_CONNECTION_COUNT;
|
||||
|
||||
/** @see #PROTOTYPE_COUNT_PROPERTY */
|
||||
public final String PROTOTYPE_COUNT = "prototype-count";
|
||||
|
||||
public final String PROTOTYPE_COUNT_PROPERTY = PROPERTY_PREFIX + PROTOTYPE_COUNT;
|
||||
|
||||
public final String RECENTLY_STARTED_THRESHOLD = "recently-started-threshold";
|
||||
|
||||
public final String RECENTLY_STARTED_THRESHOLD_PROPERTY = PROPERTY_PREFIX + RECENTLY_STARTED_THRESHOLD;
|
||||
|
||||
public final String OVERLOAD_WITHOUT_REFUSAL_LIFETIME = "overload-without-refusal-lifetime";
|
||||
|
||||
public final String OVERLOAD_WITHOUT_REFUSAL_LIFETIME_PROPERTY = PROPERTY_PREFIX + OVERLOAD_WITHOUT_REFUSAL_LIFETIME;
|
||||
|
||||
public final String MAXIMUM_ACTIVE_TIME = "maximum-active-time";
|
||||
|
||||
public final String MAXIMUM_ACTIVE_TIME_PROPERTY = PROPERTY_PREFIX + MAXIMUM_ACTIVE_TIME;
|
||||
|
||||
public final String INJECTABLE_CONNECTION_INTERFACE_NAME = "injectable-connection-interface";
|
||||
|
||||
public final String INJECTABLE_CONNECTION_INTERFACE_NAME_PROPERTY = PROPERTY_PREFIX + INJECTABLE_CONNECTION_INTERFACE_NAME;
|
||||
|
||||
public final String INJECTABLE_STATEMENT_INTERFACE_NAME = "injectable-statement-interface";
|
||||
|
||||
public final String INJECTABLE_STATEMENT_INTERFACE_NAME_PROPERTY = PROPERTY_PREFIX + INJECTABLE_STATEMENT_INTERFACE_NAME;
|
||||
|
||||
public final String INJECTABLE_PREPARED_STATEMENT_INTERFACE_NAME = "injectable-prepared-statement-interface";
|
||||
|
||||
public final String INJECTABLE_PREPARED_STATEMENT_INTERFACE_NAME_PROPERTY = PROPERTY_PREFIX + INJECTABLE_PREPARED_STATEMENT_INTERFACE_NAME;
|
||||
|
||||
public final String INJECTABLE_CALLABLE_STATEMENT_INTERFACE_NAME = "injectable-callable-statement-interface";
|
||||
|
||||
public final String INJECTABLE_CALLABLE_STATEMENT_INTERFACE_NAME_PROPERTY = PROPERTY_PREFIX + INJECTABLE_CALLABLE_STATEMENT_INTERFACE_NAME;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #VERBOSE_PROPERTY verbose} instead.
|
||||
*/
|
||||
public final String DEBUG_LEVEL_PROPERTY = PROPERTY_PREFIX + "debug-level";
|
||||
|
||||
/** @see #VERBOSE_PROPERTY */
|
||||
public final String VERBOSE = "verbose";
|
||||
|
||||
public final String VERBOSE_PROPERTY = PROPERTY_PREFIX + VERBOSE;
|
||||
|
||||
/** @see #TRACE_PROPERTY */
|
||||
public final String TRACE = "trace";
|
||||
|
||||
public final String TRACE_PROPERTY = PROPERTY_PREFIX + TRACE;
|
||||
|
||||
/** @see #FATAL_SQL_EXCEPTION_PROPERTY **/
|
||||
public final String FATAL_SQL_EXCEPTION = "fatal-sql-exception";
|
||||
|
||||
public final String FATAL_SQL_EXCEPTION_PROPERTY = PROPERTY_PREFIX + FATAL_SQL_EXCEPTION;
|
||||
|
||||
/** @see #FATAL_SQL_EXCEPTION_WRAPPER_CLASS_PROPERTY**/
|
||||
public final String FATAL_SQL_EXCEPTION_WRAPPER_CLASS = "fatal-sql-exception-wrapper-class";
|
||||
|
||||
public final String FATAL_SQL_EXCEPTION_WRAPPER_CLASS_PROPERTY = PROPERTY_PREFIX + FATAL_SQL_EXCEPTION_WRAPPER_CLASS;
|
||||
|
||||
public static final String STATISTICS = "statistics";
|
||||
|
||||
public final String STATISTICS_PROPERTY = PROPERTY_PREFIX + STATISTICS;
|
||||
|
||||
public static final String STATISTICS_LOG_LEVEL = "statistics-log-level";
|
||||
|
||||
public final String STATISTICS_LOG_LEVEL_PROPERTY = PROPERTY_PREFIX + STATISTICS_LOG_LEVEL;
|
||||
|
||||
public static final String JNDI_NAME = "jndi-name";
|
||||
|
||||
/** Prefix for generic JNDI properties. */
|
||||
public static final String JNDI_PROPERTY_PREFIX = "jndi-";
|
||||
|
||||
public final String JNDI_NAME_PROPERTY = PROPERTY_PREFIX + JNDI_NAME;
|
||||
|
||||
// End JNDI
|
||||
|
||||
public static final String STATISTICS_LOG_LEVEL_TRACE = "TRACE";
|
||||
|
||||
public static final String STATISTICS_LOG_LEVEL_DEBUG = "DEBUG";
|
||||
|
||||
public static final String STATISTICS_LOG_LEVEL_INFO = "INFO";
|
||||
|
||||
/**
|
||||
* Element name for the container of properties passed directlry to the delegate driver.
|
||||
*/
|
||||
public static final String DRIVER_PROPERTIES = "driver-properties";
|
||||
|
||||
|
||||
/**
|
||||
* Configuration attribute used to indicate that a pool should be registered with JMX.
|
||||
*/
|
||||
public static final String JMX = "jmx";
|
||||
|
||||
/**
|
||||
* "proxool." prefixed version of {@link #JMX}.
|
||||
*/
|
||||
public final String JMX_PROPERTY = PROPERTY_PREFIX + JMX;
|
||||
|
||||
public static final String JMX_AGENT_ID = "jmx-agent-id";
|
||||
|
||||
/**
|
||||
* "proxool." prefixed version of {@link #JMX_AGENT_ID}.
|
||||
*/
|
||||
public final String JMX_AGENT_PROPERTY = PROPERTY_PREFIX + JMX_AGENT_ID;
|
||||
|
||||
/**
|
||||
* Un-prefixed propety name for the Proxool alias configuration property. Value: alias
|
||||
*/
|
||||
public final String ALIAS = "alias";
|
||||
|
||||
/**
|
||||
* Un-prefixed propety name for the Proxool driver class configuration property. Value: driver-class
|
||||
*/
|
||||
public final String DRIVER_CLASS = "driver-class";
|
||||
/**
|
||||
* Prefixed propety name for the Proxool driver class configuration property. Value: proxool.driver-class
|
||||
*/
|
||||
public final String DRIVER_CLASS_PROPERTY = PROPERTY_PREFIX + DRIVER_CLASS;;
|
||||
/**
|
||||
* Un-prefixed propety name for the Proxool driver url configuration property. Value: driver-url
|
||||
*/
|
||||
public final String DRIVER_URL = "driver-url";
|
||||
/**
|
||||
* Prefixed propety name for the Proxool driver url configuration property. Value: proxool.driver-url
|
||||
*/
|
||||
public final String DRIVER_URL_PROPERTY = PROPERTY_PREFIX + DRIVER_URL;
|
||||
}
|
||||
|
||||
/*
|
||||
Revision history:
|
||||
$Log: ProxoolConstants.java,v $
|
||||
Revision 1.21 2004/06/02 20:39:17 billhorsman
|
||||
New injectable interface constants
|
||||
|
||||
Revision 1.20 2004/03/15 02:43:47 chr32
|
||||
Removed explicit JNDI properties. Going for a generic approach instead.
|
||||
Added constant for JNDI properties prefix.
|
||||
|
||||
Revision 1.19 2003/09/30 18:39:08 billhorsman
|
||||
New test-before-use, test-after-use and fatal-sql-exception-wrapper-class properties.
|
||||
|
||||
Revision 1.18 2003/09/29 17:48:21 billhorsman
|
||||
New fatal-sql-exception-wrapper-class allows you to define what exception is used as a wrapper. This means that you
|
||||
can make it a RuntimeException if you need to.
|
||||
|
||||
Revision 1.17 2003/09/05 17:00:42 billhorsman
|
||||
New wrap-fatal-sql-exceptions property.
|
||||
|
||||
Revision 1.16 2003/07/23 06:54:48 billhorsman
|
||||
draft JNDI changes (shouldn't effect normal operation)
|
||||
|
||||
Revision 1.15 2003/03/05 23:28:56 billhorsman
|
||||
deprecated maximum-new-connections property in favour of
|
||||
more descriptive simultaneous-build-throttle
|
||||
|
||||
Revision 1.14 2003/03/03 11:11:58 billhorsman
|
||||
fixed licence
|
||||
|
||||
Revision 1.13 2003/02/26 16:05:52 billhorsman
|
||||
widespread changes caused by refactoring the way we
|
||||
update and redefine pool definitions.
|
||||
|
||||
Revision 1.12 2003/02/24 18:02:24 chr32
|
||||
Added JMX related constants.
|
||||
|
||||
Revision 1.11 2003/02/24 01:16:15 chr32
|
||||
Added constant for "driver-properties" property.
|
||||
|
||||
Revision 1.10 2003/02/06 15:41:17 billhorsman
|
||||
add statistics-log-level
|
||||
|
||||
Revision 1.9 2003/01/30 17:22:03 billhorsman
|
||||
new statistics property
|
||||
|
||||
Revision 1.8 2003/01/23 10:41:05 billhorsman
|
||||
changed use of pool-name to alias for consistency
|
||||
|
||||
Revision 1.7 2002/12/26 11:32:22 billhorsman
|
||||
Moved ALIAS, DRIVER_URL and DRIVER_CLASS constants
|
||||
from XMLConfgiurator to ProxoolConstants.
|
||||
|
||||
Revision 1.6 2002/12/15 19:22:51 chr32
|
||||
Added constant for proxool xml namespace.
|
||||
|
||||
Revision 1.5 2002/12/11 01:47:12 billhorsman
|
||||
extracted property names without proxool. prefix for use
|
||||
by XMLConfigurators.
|
||||
|
||||
Revision 1.4 2002/11/09 15:50:49 billhorsman
|
||||
new trace constant
|
||||
|
||||
Revision 1.3 2002/10/27 13:29:38 billhorsman
|
||||
deprecated debug-level in favour of verbose
|
||||
|
||||
Revision 1.2 2002/10/25 15:59:32 billhorsman
|
||||
made non-public where possible
|
||||
|
||||
Revision 1.1.1.1 2002/09/13 08:13:06 billhorsman
|
||||
new
|
||||
|
||||
Revision 1.3 2002/08/24 19:57:15 billhorsman
|
||||
checkstyle changes
|
||||
|
||||
Revision 1.2 2002/07/12 23:03:22 billhorsman
|
||||
added doc headers
|
||||
|
||||
Revision 1.7 2002/07/10 16:14:47 billhorsman
|
||||
widespread layout changes and move constants into ProxoolConstants
|
||||
|
||||
Revision 1.6 2002/07/02 11:19:08 billhorsman
|
||||
layout code and imports
|
||||
|
||||
Revision 1.5 2002/07/02 08:27:47 billhorsman
|
||||
bug fix when settiong definition, displayStatistics now available to ProxoolFacade, prototyper no longer attempts to make connections when maximum is reached
|
||||
|
||||
Revision 1.4 2002/06/28 11:19:47 billhorsman
|
||||
improved doc
|
||||
|
||||
*/
|
||||
+412
@@ -0,0 +1,412 @@
|
||||
package org.logicalcobwebs.proxool;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.SQLFeatureNotSupportedException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.Name;
|
||||
import javax.naming.RefAddr;
|
||||
import javax.naming.Reference;
|
||||
import javax.naming.StringRefAddr;
|
||||
import javax.naming.spi.ObjectFactory;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
|
||||
public class ProxoolDataSource implements DataSource, ObjectFactory {
|
||||
|
||||
private DruidDataSource druid = new DruidDataSource();
|
||||
|
||||
private Properties delegateProperties = new Properties();
|
||||
|
||||
public ProxoolDataSource(){
|
||||
|
||||
}
|
||||
|
||||
public ProxoolDataSource(String alias){
|
||||
druid.setName(alias);
|
||||
}
|
||||
|
||||
public PrintWriter getLogWriter() throws SQLException {
|
||||
return druid.getLogWriter();
|
||||
}
|
||||
|
||||
public void setLogWriter(PrintWriter out) throws SQLException {
|
||||
druid.setLogWriter(out);
|
||||
}
|
||||
|
||||
public int getLoginTimeout() throws SQLException {
|
||||
return druid.getLoginTimeout();
|
||||
}
|
||||
|
||||
public void setLoginTimeout(int seconds) throws SQLException {
|
||||
druid.setLoginTimeout(seconds);
|
||||
}
|
||||
|
||||
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
|
||||
return druid.getParentLogger();
|
||||
}
|
||||
|
||||
public <T> T unwrap(Class<T> iface) throws SQLException {
|
||||
return druid.unwrap(iface);
|
||||
}
|
||||
|
||||
public boolean isWrapperFor(Class<?> iface) throws SQLException {
|
||||
return druid.isWrapperFor(iface);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Object getObjectInstance(Object refObject, Name name, Context context, Hashtable hashtable) throws Exception {
|
||||
if (!(refObject instanceof Reference)) {
|
||||
return null;
|
||||
}
|
||||
Reference reference = (Reference) refObject;
|
||||
populatePropertiesFromReference(reference);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Connection getConnection() throws SQLException {
|
||||
return druid.getConnection();
|
||||
}
|
||||
|
||||
public Connection getConnection(String username, String password) throws SQLException {
|
||||
return druid.getConnection(username, password);
|
||||
}
|
||||
|
||||
public String getAlias() {
|
||||
return druid.getName();
|
||||
}
|
||||
|
||||
public void setAlias(String alias) {
|
||||
druid.setName(alias);
|
||||
}
|
||||
|
||||
public String getDriverUrl() {
|
||||
return druid.getUrl();
|
||||
}
|
||||
|
||||
public void setDriverUrl(String url) {
|
||||
druid.setUrl(url);
|
||||
}
|
||||
|
||||
public String getDriver() {
|
||||
return druid.getDriverClassName();
|
||||
}
|
||||
|
||||
public void setDriver(String driver) {
|
||||
druid.setDriverClassName(driver);
|
||||
}
|
||||
|
||||
public long getMaximumConnectionLifetime() {
|
||||
return Long.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setMaximumConnectionLifetime(int maximumConnectionLifetime) {
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getPrototypeCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setPrototypeCount(int prototypeCount) {
|
||||
|
||||
}
|
||||
|
||||
public int getMinimumConnectionCount() {
|
||||
return druid.getMinIdle();
|
||||
}
|
||||
|
||||
public void setMinimumConnectionCount(int minimumConnectionCount) {
|
||||
druid.setMinIdle(minimumConnectionCount);
|
||||
}
|
||||
|
||||
public int getMaximumConnectionCount() {
|
||||
return druid.getMaxActive();
|
||||
}
|
||||
|
||||
public void setMaximumConnectionCount(int maximumConnectionCount) {
|
||||
druid.setMaxActive(maximumConnectionCount);
|
||||
}
|
||||
|
||||
public long getHouseKeepingSleepTime() {
|
||||
return druid.getTimeBetweenEvictionRunsMillis();
|
||||
}
|
||||
|
||||
public void setHouseKeepingSleepTime(int houseKeepingSleepTime) {
|
||||
druid.setTimeBetweenEvictionRunsMillis(houseKeepingSleepTime);
|
||||
}
|
||||
|
||||
public int getSimultaneousBuildThrottle() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setSimultaneousBuildThrottle(int simultaneousBuildThrottle) {
|
||||
|
||||
}
|
||||
|
||||
public long getRecentlyStartedThreshold() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setRecentlyStartedThreshold(int recentlyStartedThreshold) {
|
||||
|
||||
}
|
||||
|
||||
public long getOverloadWithoutRefusalLifetime() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setOverloadWithoutRefusalLifetime(int overloadWithoutRefusalLifetime) {
|
||||
|
||||
}
|
||||
|
||||
public long getMaximumActiveTime() {
|
||||
return druid.getRemoveAbandonedTimeoutMillis();
|
||||
}
|
||||
|
||||
public void setMaximumActiveTime(long maximumActiveTime) {
|
||||
druid.setRemoveAbandonedTimeoutMillis(maximumActiveTime);
|
||||
}
|
||||
|
||||
public boolean isVerbose() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setVerbose(boolean verbose) {
|
||||
|
||||
}
|
||||
|
||||
public boolean isTrace() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setTrace(boolean trace) {
|
||||
}
|
||||
|
||||
public String getStatistics() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setStatistics(String statistics) {
|
||||
}
|
||||
|
||||
public String getStatisticsLogLevel() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setStatisticsLogLevel(String statisticsLogLevel) {
|
||||
}
|
||||
|
||||
public String getFatalSqlExceptionsAsString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setFatalSqlExceptionsAsString(String fatalSqlExceptionsAsString) {
|
||||
|
||||
}
|
||||
|
||||
public String getFatalSqlExceptionWrapperClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setFatalSqlExceptionWrapperClass(String fatalSqlExceptionWrapperClass) {
|
||||
|
||||
}
|
||||
|
||||
public String getHouseKeepingTestSql() {
|
||||
return druid.getValidationQuery();
|
||||
}
|
||||
|
||||
public void setHouseKeepingTestSql(String houseKeepingTestSql) {
|
||||
druid.setValidationQuery(houseKeepingTestSql);
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return druid.getUsername();
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
druid.setUsername(user);
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return druid.getPassword();
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
druid.setPassword(password);
|
||||
}
|
||||
|
||||
public boolean isJmx() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setJmx(boolean jmx) {
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getJmxAgentId() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setJmxAgentId(String jmxAgentId) {
|
||||
|
||||
}
|
||||
|
||||
public boolean isTestBeforeUse() {
|
||||
return druid.isTestOnBorrow();
|
||||
}
|
||||
|
||||
public void setTestBeforeUse(boolean testBeforeUse) {
|
||||
druid.setTestOnBorrow(testBeforeUse);
|
||||
}
|
||||
|
||||
public boolean isTestAfterUse() {
|
||||
return druid.isTestOnReturn();
|
||||
}
|
||||
|
||||
public void setTestAfterUse(boolean testAfterUse) {
|
||||
druid.setTestOnReturn(testAfterUse);
|
||||
}
|
||||
|
||||
private void populatePropertiesFromReference(Reference reference) {
|
||||
RefAddr property = reference.get(ProxoolConstants.ALIAS_PROPERTY);
|
||||
if (property != null) {
|
||||
setAlias(property.getContent().toString());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.DRIVER_CLASS_PROPERTY);
|
||||
if (property != null) {
|
||||
setDriver(property.getContent().toString());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.FATAL_SQL_EXCEPTION_WRAPPER_CLASS_PROPERTY);
|
||||
if (property != null) {
|
||||
setFatalSqlExceptionWrapperClass(property.getContent().toString());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.HOUSE_KEEPING_SLEEP_TIME_PROPERTY);
|
||||
if (property != null) {
|
||||
setHouseKeepingSleepTime(Integer.valueOf(property.getContent().toString()).intValue());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.HOUSE_KEEPING_TEST_SQL_PROPERTY);
|
||||
if (property != null) {
|
||||
setHouseKeepingTestSql(property.getContent().toString());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.MAXIMUM_CONNECTION_COUNT_PROPERTY);
|
||||
if (property != null) {
|
||||
setMaximumConnectionCount(Integer.valueOf(property.getContent().toString()).intValue());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.MAXIMUM_CONNECTION_LIFETIME_PROPERTY);
|
||||
if (property != null) {
|
||||
setMaximumConnectionLifetime(Integer.valueOf(property.getContent().toString()).intValue());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.MAXIMUM_ACTIVE_TIME_PROPERTY);
|
||||
if (property != null) {
|
||||
setMaximumActiveTime(Long.valueOf(property.getContent().toString()).intValue());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.MINIMUM_CONNECTION_COUNT_PROPERTY);
|
||||
if (property != null) {
|
||||
setMinimumConnectionCount(Integer.valueOf(property.getContent().toString()).intValue());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.OVERLOAD_WITHOUT_REFUSAL_LIFETIME_PROPERTY);
|
||||
if (property != null) {
|
||||
setOverloadWithoutRefusalLifetime(Integer.valueOf(property.getContent().toString()).intValue());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.PASSWORD_PROPERTY);
|
||||
if (property != null) {
|
||||
setPassword(property.getContent().toString());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.PROTOTYPE_COUNT_PROPERTY);
|
||||
if (property != null) {
|
||||
setPrototypeCount(Integer.valueOf(property.getContent().toString()).intValue());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.RECENTLY_STARTED_THRESHOLD_PROPERTY);
|
||||
if (property != null) {
|
||||
setRecentlyStartedThreshold(Integer.valueOf(property.getContent().toString()).intValue());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.SIMULTANEOUS_BUILD_THROTTLE_PROPERTY);
|
||||
if (property != null) {
|
||||
setSimultaneousBuildThrottle(Integer.valueOf(property.getContent().toString()).intValue());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.STATISTICS_PROPERTY);
|
||||
if (property != null) {
|
||||
setStatistics(property.getContent().toString());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.STATISTICS_LOG_LEVEL_PROPERTY);
|
||||
if (property != null) {
|
||||
setStatisticsLogLevel(property.getContent().toString());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.TRACE_PROPERTY);
|
||||
if (property != null) {
|
||||
setTrace("true".equalsIgnoreCase(property.getContent().toString()));
|
||||
}
|
||||
property = reference.get(ProxoolConstants.DRIVER_URL_PROPERTY);
|
||||
if (property != null) {
|
||||
setDriverUrl(property.getContent().toString());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.USER_PROPERTY);
|
||||
if (property != null) {
|
||||
setUser(property.getContent().toString());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.VERBOSE_PROPERTY);
|
||||
if (property != null) {
|
||||
setVerbose("true".equalsIgnoreCase(property.getContent().toString()));
|
||||
}
|
||||
property = reference.get(ProxoolConstants.JMX_PROPERTY);
|
||||
if (property != null) {
|
||||
setJmx("true".equalsIgnoreCase(property.getContent().toString()));
|
||||
}
|
||||
property = reference.get(ProxoolConstants.JMX_AGENT_PROPERTY);
|
||||
if (property != null) {
|
||||
setJmxAgentId(property.getContent().toString());
|
||||
}
|
||||
property = reference.get(ProxoolConstants.TEST_BEFORE_USE_PROPERTY);
|
||||
if (property != null) {
|
||||
setTestBeforeUse("true".equalsIgnoreCase(property.getContent().toString()));
|
||||
}
|
||||
property = reference.get(ProxoolConstants.TEST_AFTER_USE_PROPERTY);
|
||||
if (property != null) {
|
||||
setTestAfterUse("true".equalsIgnoreCase(property.getContent().toString()));
|
||||
}
|
||||
// Pick up any properties that we don't recognise
|
||||
Enumeration<?> e = reference.getAll();
|
||||
while (e.hasMoreElements()) {
|
||||
StringRefAddr stringRefAddr = (StringRefAddr) e.nextElement();
|
||||
String name = stringRefAddr.getType();
|
||||
String content = stringRefAddr.getContent().toString();
|
||||
if (name.indexOf(ProxoolConstants.PROPERTY_PREFIX) != 0) {
|
||||
delegateProperties.put(name, content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setDelegateProperties(String properties) {
|
||||
StringTokenizer stOuter = new StringTokenizer(properties, ",");
|
||||
while (stOuter.hasMoreTokens()) {
|
||||
StringTokenizer stInner = new StringTokenizer(stOuter.nextToken(), "=");
|
||||
if (stInner.countTokens() == 1) {
|
||||
// Allow blank string to be a valid value
|
||||
delegateProperties.put(stInner.nextToken().trim(), "");
|
||||
} else if (stInner.countTokens() == 2) {
|
||||
delegateProperties.put(stInner.nextToken().trim(), stInner.nextToken().trim());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unexpected delegateProperties value: '" + properties
|
||||
+ "'. Expected 'name=value'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user