Top Description Fields Constructors Methods
org.apache.tomcat.jdbc.pool

public Class DataSource

extends DataSourceProxy
implements DataSource, MBeanRegistration, ConnectionPoolMBean, ConnectionPoolDataSource
Class Inheritance
All Implemented Interfaces
javax.sql.ConnectionPoolDataSource, javax.sql.CommonDataSource, org.apache.tomcat.jdbc.pool.jmx.ConnectionPoolMBean, org.apache.tomcat.jdbc.pool.PoolConfiguration, javax.management.MBeanRegistration, javax.sql.DataSource, java.sql.Wrapper
Known Direct Subclasses
org.apache.tomcat.jdbc.pool.XADataSource
Imports
java.util.Hashtable, javax.management.MBeanRegistration, .MBeanServer, .MalformedObjectNameException, .ObjectName, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.jdbc.pool.jmx.JmxUtil

A DataSource that can be instantiated through IoC and implements the DataSource interface since the DataSourceProxy is used as a generic proxy. The DataSource simply wraps a ConnectionPool in order to provide a standard interface to the user.

Field Summary

Modifier and TypeField and Description
private static final Log
protected volatile ObjectName
Inherited from org.apache.tomcat.jdbc.pool.DataSourceProxy:
poolpoolProperties

Constructor Summary

AccessConstructor and Description
public
DataSource()

Constructor for reflection only.

public
DataSource(PoolConfiguration
The pool properties
poolProperties
)

Constructs a DataSource object wrapping a connection

Method Summary

Modifier and TypeMethod and Description
public ObjectName

Returns:

the ObjectName for the ConnectionPoolMBean
createObjectName
(ObjectName
the ObjectName for the DataSource
original
)

Creates the ObjectName for the ConnectionPoolMBean object to be registered

public void
postDeregister()

Implements javax.management.MBeanRegistration.postDeregister.

Unregisters the underlying connection pool mbean.

public void
postRegister(Boolean
Indicates whether or not the MBean has been successfully registered in the MBean server. The value false means that the registration phase has failed.
registrationDone
)

Implements javax.management.MBeanRegistration.postRegister.

no-op Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.

public void
preDeregister()

Implements javax.management.MBeanRegistration.preDeregister.

no-op Allows the MBean to perform any operations it needs before being unregistered by the MBean server.

public ObjectName
preRegister(MBeanServer
The MBean Server in which the MBean will be registered.
server
,
ObjectName
The object name of the MBean. This name is null if the name parameter to one of the createMBean or registerMBean methods in the MBeanServer interface is null. In that case, this method must return a non-null ObjectName for the new MBean.
name
)

Implements javax.management.MBeanRegistration.preRegister.

If the connection pool MBean exists, it will be registered during this operation.

protected void
registerJmx()

Registers the ConnectionPoolMBean under a unique name based on the ObjectName for the DataSource

protected void
Inherited from org.apache.tomcat.jdbc.pool.DataSourceProxy:
checkAbandonedcheckIdlecloseclosecreatePoolgetAbandonWhenPercentageFullgetActivegetBorrowedCountgetCommitOnReturngetConnectiongetConnectiongetConnectionAsyncgetConnectionPropertiesgetCreatedCountgetDataSourcegetDataSourceJNDIgetDbPropertiesgetDefaultAutoCommitgetDefaultCataloggetDefaultReadOnlygetDefaultTransactionIsolationgetDriverClassNamegetIdlegetInitialSizegetInitSQLgetJdbcInterceptorsgetJdbcInterceptorsAsArraygetLoginTimeoutgetLogValidationErrorsgetLogWritergetMaxActivegetMaxAgegetMaxIdlegetMaxWaitgetMinEvictableIdleTimeMillisgetMinIdlegetNamegetNumActivegetNumIdlegetNumTestsPerEvictionRungetParentLoggergetPasswordgetPoolgetPooledConnectiongetPooledConnectiongetPoolNamegetPoolPropertiesgetPoolSizegetPropagateInterruptStategetReconnectedCountgetReleasedCountgetReleasedIdleCountgetRemoveAbandonedCountgetRemoveAbandonedTimeoutgetReturnedCountgetRollbackOnReturngetSizegetSuspectTimeoutgetTimeBetweenEvictionRunsMillisgetUrlgetUseDisposableConnectionFacadegetUseLockgetUsernamegetUseStatementFacadegetValidationIntervalgetValidationQuerygetValidationQueryTimeoutgetValidatorgetValidatorClassNamegetWaitCountgetXAConnectiongetXAConnectionisAccessToUnderlyingConnectionAllowedisAlternateUsernameAllowedisDefaultAutoCommitisDefaultReadOnlyisFairQueueisIgnoreExceptionOnPreLoadisJmxEnabledisLogAbandonedisPoolSweeperEnabledisRemoveAbandonedisTestOnBorrowisTestOnConnectisTestOnReturnisTestWhileIdleisUseEqualsisWrapperForpurgepurgeOnReturnresetStatssetAbandonWhenPercentageFullsetAccessToUnderlyingConnectionAllowedsetAlternateUsernameAllowedsetCommitOnReturnsetConnectionPropertiessetDataSourcesetDataSourceJNDIsetDbPropertiessetDefaultAutoCommitsetDefaultCatalogsetDefaultReadOnlysetDefaultTransactionIsolationsetDriverClassNamesetFairQueuesetIgnoreExceptionOnPreLoadsetInitialSizesetInitSQLsetJdbcInterceptorssetJmxEnabledsetLogAbandonedsetLoginTimeoutsetLogValidationErrorssetLogWritersetMaxActivesetMaxAgesetMaxIdlesetMaxWaitsetMinEvictableIdleTimeMillissetMinIdlesetNamesetNumTestsPerEvictionRunsetPasswordsetPoolPropertiessetPropagateInterruptStatesetRemoveAbandonedsetRemoveAbandonedTimeoutsetRollbackOnReturnsetSuspectTimeoutsetTestOnBorrowsetTestOnConnectsetTestOnReturnsetTestWhileIdlesetTimeBetweenEvictionRunsMillissetUrlsetUseDisposableConnectionFacadesetUseEqualssetUseLocksetUsernamesetUseStatementFacadesetValidationIntervalsetValidationQuerysetValidationQueryTimeoutsetValidatorsetValidatorClassNametestIdletoStringunwrap

Field Detail

logback to summary
private static final Log log

Hides org.apache.tomcat.jdbc.pool.DataSourceProxy.log.

onameback to summary
protected volatile ObjectName oname

Constructor Detail

DataSourceback to summary
public DataSource()

Constructor for reflection only. A default set of pool properties will be created.

DataSourceback to summary
public DataSource(PoolConfiguration poolProperties)

Constructs a DataSource object wrapping a connection

Parameters
poolProperties:PoolConfiguration

The pool properties

Method Detail

createObjectNameback to summary
public ObjectName createObjectName(ObjectName original) throws MalformedObjectNameException

Creates the ObjectName for the ConnectionPoolMBean object to be registered

Parameters
original:ObjectName

the ObjectName for the DataSource

Returns:ObjectName

the ObjectName for the ConnectionPoolMBean

Exceptions
MalformedObjectNameException:
Invalid object name
postDeregisterback to summary
public void postDeregister()

Implements javax.management.MBeanRegistration.postDeregister.

Doc from javax.management.MBeanRegistration.postDeregister.

Unregisters the underlying connection pool mbean.
Allows the MBean to perform any operations needed after having been unregistered in the MBean server.

If the implementation of this method throws a RuntimeException or an Error, the MBean Server will rethrow those inside a RuntimeMBeanException or RuntimeErrorException, respectively. However, throwing an exception in postDeregister will not change the state of the MBean: the MBean was already successfully deregistered and will remain so.

This might be confusing for the code calling unregisterMBean(), as it might assume that MBean deregistration has failed. Therefore it is recommended that implementations of postDeregister do not throw Runtime Exceptions or Errors if it can be avoided.

Annotations
@Override
postRegisterback to summary
public void postRegister(Boolean registrationDone)

Implements javax.management.MBeanRegistration.postRegister.

Doc from javax.management.MBeanRegistration.postRegister.

no-op
Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.

If the implementation of this method throws a RuntimeException or an Error, the MBean Server will rethrow those inside a RuntimeMBeanException or RuntimeErrorException, respectively. However, throwing an exception in postRegister will not change the state of the MBean: if the MBean was already registered (registrationDone is true), the MBean will remain registered.

This might be confusing for the code calling createMBean() or registerMBean(), as such code might assume that MBean registration has failed when such an exception is raised. Therefore it is recommended that implementations of postRegister do not throw Runtime Exceptions or Errors if it can be avoided.

Parameters
registrationDone:Boolean

Indicates whether or not the MBean has been successfully registered in the MBean server. The value false means that the registration phase has failed.

Annotations
@Override
preDeregisterback to summary
public void preDeregister() throws Exception

Implements javax.management.MBeanRegistration.preDeregister.

Doc from javax.management.MBeanRegistration.preDeregister.

no-op
Allows the MBean to perform any operations it needs before being unregistered by the MBean server.

Annotations
@Override
Exceptions
Exception:
This exception will be caught by the MBean server and re-thrown as an MBeanRegistrationException.
preRegisterback to summary
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception

Implements javax.management.MBeanRegistration.preRegister.

Doc from javax.management.MBeanRegistration.preRegister.

If the connection pool MBean exists, it will be registered during this operation.
Allows the MBean to perform any operations it needs before being registered in the MBean Server. If the name of the MBean is not specified, the MBean can provide a name for its registration. If any exception is raised, the MBean will not be registered in the MBean Server.

Parameters
server:MBeanServer

The MBean Server in which the MBean will be registered.

name:ObjectName

The object name of the MBean. This name is null if the name parameter to one of the createMBean or registerMBean methods in the MBeanServer interface is null. In that case, this method must return a non-null ObjectName for the new MBean.

Returns:ObjectName

The name under which the MBean is to be registered. This value must not be null. If the name parameter is not null, it will usually but not necessarily be the returned value.

Annotations
@Override
Exceptions
Exception:
This exception will be caught by the MBean Server and re-thrown as an MBeanRegistrationException.
registerJmxback to summary
protected void registerJmx()

Registers the ConnectionPoolMBean under a unique name based on the ObjectName for the DataSource

unregisterJmxback to summary
protected void unregisterJmx()