?? combopooleddatasource.java
字號:
/* * Distributed as part of c3p0 v.0.9.1-pre6 * * Copyright (C) 2005 Machinery For Change, Inc. * * Author: Steve Waldman <swaldman@mchange.com> * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License version 2.1, as * published by the Free Software Foundation. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this software; see the file LICENSE. If not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. */package com.mchange.v2.c3p0;import java.beans.*;import java.io.*;import java.sql.*;import java.util.*;import javax.naming.*;import com.mchange.v2.log.*;import com.mchange.v2.naming.*;import com.mchange.v2.c3p0.impl.*;import com.mchange.v2.beans.BeansUtils;import com.mchange.v2.c3p0.cfg.C3P0Config;// WrapperConnectionPoolDataSource properties -- count: 24//// ("checkoutTimeout");// ("acquireIncrement");// ("acquireRetryAttempts");// ("acquireRetryDelay");// ("autoCommitOnClose");// ("connectionTesterClassName");// ("forceIgnoreUnresolvedTransactions");// ("idleConnectionTestPeriod");// ("initialPoolSize");// ("maxIdleTime");// ("maxPoolSize");// ("maxStatements");// ("maxStatementsPerConnection");// ("minPoolSize");// ("propertyCycle");// ("breakAfterAcquireFailure");// ("testConnectionOnCheckout");// ("testConnectionOnCheckin");// ("usesTraditionalReflectiveProxies");// ("preferredTestQuery");// ("automaticTestTable");// ("userOverridesAsString");// ("overrideDefaultUser");// ("overrideDefaultPassword");/** * <p>For the meaning of most of these properties, please see {@link PoolConfig}!</p> */public final class ComboPooledDataSource extends IdentityTokenResolvable implements PooledDataSource, Serializable, Referenceable{ final static MLogger logger = MLog.getLogger( ComboPooledDataSource.class ); final static Set TO_STRING_IGNORE_PROPS = new HashSet( Arrays.asList( new String[] { "connection", "logWriter", "loginTimeout", "numBusyConnections", "numBusyConnectionsAllUsers", "numBusyConnectionsDefaultUser", "numConnections", "numConnectionsAllUsers", "numConnectionsDefaultUser", "numIdleConnections", "numIdleConnectionsAllUsers", "numIdleConnectionsDefaultUser", "numUnclosedOrphanedConnections", "numUnclosedOrphanedConnectionsAllUsers", "numUnclosedOrphanedConnectionsDefaultUser", "numUserPools", "overrideDefaultUser", "overrideDefaultPassword", "password", "reference", "user", "userOverridesAsString" } ) ); // not reassigned post-ctor; mutable elements protected by their own locks // when (very rarely) necessery, we sync pbds -> wcpds -> dmds DriverManagerDataSource dmds; WrapperConnectionPoolDataSource wcpds; PoolBackedDataSource pbds; String identityToken; { // System.err.println("...Initializing ComboPooledDataSource."); dmds = new DriverManagerDataSource(); wcpds = new WrapperConnectionPoolDataSource(); pbds = new PoolBackedDataSource( this ); wcpds.setNestedDataSource( dmds ); pbds.setConnectionPoolDataSource( wcpds ); this.identityToken = C3P0ImplUtils.identityToken( this ); C3P0Registry.register( this ); } public ComboPooledDataSource() {} public ComboPooledDataSource(String configName) { try { if (configName != null) { C3P0Config.bindNamedConfigToBean( this, configName ); if ( this.getDataSourceName().equals( this.getIdentityToken() ) ) //dataSourceName has not been specified in config this.setDataSourceName( configName ); } } catch (Exception e) { if (logger.isLoggable( MLevel.WARNING )) logger.log( MLevel.WARNING, "Error binding ComboPooledDataSource to named-config '" + configName + "'. Some default-config values may be used.", e); } } // DriverManagerDataSourceProperties (count: 4) public String getDescription() { return dmds.getDescription(); } public void setDescription( String description ) { dmds.setDescription( description ); } public String getDriverClass() { return dmds.getDriverClass(); } public void setDriverClass( String driverClass ) throws PropertyVetoException { dmds.setDriverClass( driverClass ); // System.err.println("setting driverClass: " + driverClass); } public String getJdbcUrl() { // System.err.println("getting jdbcUrl: " + dmds.getJdbcUrl()); return dmds.getJdbcUrl(); } public void setJdbcUrl( String jdbcUrl ) { dmds.setJdbcUrl( jdbcUrl ); // System.err.println("setting jdbcUrl: " + jdbcUrl + " [dmds@" + C3P0ImplUtils.identityToken( dmds ) + "]"); // if (jdbcUrl == null)// new Exception("*** NULL SETTER ***").printStackTrace(); } public Properties getProperties() { //System.err.println("getting properties: " + dmds.getProperties()); return dmds.getProperties(); } public void setProperties( Properties properties ) { dmds.setProperties( properties ); //System.err.println("setting properties: " + properties); } // DriverManagerDataSource "virtual properties" based on properties public String getUser() { return dmds.getUser(); } public void setUser( String user ) { dmds.setUser( user ); } public String getPassword() { return dmds.getPassword(); } public void setPassword( String password ) { dmds.setPassword( password ); } // WrapperConnectionPoolDataSource properties (count: 21) public int getCheckoutTimeout() { return wcpds.getCheckoutTimeout(); } public void setCheckoutTimeout( int checkoutTimeout ) { synchronized ( pbds ) { wcpds.setCheckoutTimeout( checkoutTimeout ); pbds.resetPoolManager( false ); } } public int getAcquireIncrement() { return wcpds.getAcquireIncrement(); } public void setAcquireIncrement( int acquireIncrement ) { synchronized ( pbds ) { wcpds.setAcquireIncrement( acquireIncrement ); pbds.resetPoolManager( false ); } } public int getAcquireRetryAttempts() { return wcpds.getAcquireRetryAttempts(); } public void setAcquireRetryAttempts( int acquireRetryAttempts ) { synchronized ( pbds ) { wcpds.setAcquireRetryAttempts( acquireRetryAttempts ); pbds.resetPoolManager( false ); } } public int getAcquireRetryDelay() { return wcpds.getAcquireRetryDelay(); } public void setAcquireRetryDelay( int acquireRetryDelay ) { synchronized ( pbds ) { wcpds.setAcquireRetryDelay( acquireRetryDelay ); pbds.resetPoolManager( false ); } } public boolean isAutoCommitOnClose() { return wcpds.isAutoCommitOnClose(); } public void setAutoCommitOnClose( boolean autoCommitOnClose ) { synchronized ( pbds ) { wcpds.setAutoCommitOnClose( autoCommitOnClose ); pbds.resetPoolManager( false ); } } public String getConnectionTesterClassName() { return wcpds.getConnectionTesterClassName(); } public void setConnectionTesterClassName( String connectionTesterClassName ) throws PropertyVetoException { synchronized ( pbds ) { wcpds.setConnectionTesterClassName( connectionTesterClassName ); pbds.resetPoolManager( false ); } } public String getAutomaticTestTable() { return wcpds.getAutomaticTestTable(); } public void setAutomaticTestTable( String automaticTestTable ) { synchronized ( pbds ) { wcpds.setAutomaticTestTable( automaticTestTable ); pbds.resetPoolManager( false ); } } public boolean isForceIgnoreUnresolvedTransactions() { return wcpds.isForceIgnoreUnresolvedTransactions(); } public void setForceIgnoreUnresolvedTransactions( boolean forceIgnoreUnresolvedTransactions ) { synchronized ( pbds ) { wcpds.setForceIgnoreUnresolvedTransactions( forceIgnoreUnresolvedTransactions ); pbds.resetPoolManager( false ); } } public int getIdleConnectionTestPeriod() { return wcpds.getIdleConnectionTestPeriod(); } public void setIdleConnectionTestPeriod( int idleConnectionTestPeriod ) { synchronized ( pbds ) { wcpds.setIdleConnectionTestPeriod( idleConnectionTestPeriod ); pbds.resetPoolManager( false ); } } public int getInitialPoolSize() { return wcpds.getInitialPoolSize(); } public void setInitialPoolSize( int initialPoolSize ) { synchronized ( pbds ) { wcpds.setInitialPoolSize( initialPoolSize ); pbds.resetPoolManager( false ); } } public int getMaxIdleTime() { return wcpds.getMaxIdleTime(); } public void setMaxIdleTime( int maxIdleTime ) { synchronized ( pbds ) { wcpds.setMaxIdleTime( maxIdleTime ); pbds.resetPoolManager( false ); } } public int getMaxPoolSize() { return wcpds.getMaxPoolSize(); } public void setMaxPoolSize( int maxPoolSize ) { synchronized ( pbds ) { wcpds.setMaxPoolSize( maxPoolSize ); pbds.resetPoolManager( false ); } } public int getMaxStatements() { return wcpds.getMaxStatements(); } public void setMaxStatements( int maxStatements ) { synchronized ( pbds ) { wcpds.setMaxStatements( maxStatements ); pbds.resetPoolManager( false ); } }
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -