Class BasicManagedDataSource
- All Implemented Interfaces:
AutoCloseable
,Wrapper
,MBeanRegistration
,CommonDataSource
,DataSource
,BasicDataSourceMXBean
BasicManagedDataSource is an extension of BasicDataSource which creates ManagedConnections. This data source can create either full two-phase-commit XA connections or one-phase-commit local connections. Both types of connections are committed or rolled back as part of the global transaction (a.k.a. XA transaction or JTA Transaction), but only XA connections can be recovered in the case of a system crash.
BasicManagedDataSource adds the TransactionManager and XADataSource properties. The TransactionManager property is required and is used to enlist connections in global transactions. The XADataSource is optional and if set is the class name of the XADataSource class for a two-phase-commit JDBC driver. If the XADataSource property is set, the driverClassName is ignored and a DataSourceXAConnectionFactory is created. Otherwise, a standard DriverConnectionFactory is created and wrapped with a LocalXAConnectionFactory.
- Since:
- 2.0
- Version:
- $Id: BasicManagedDataSource.java 1675737 2015-04-24 00:34:03Z psteitz $
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjavax.transaction.TransactionManager
Gets the required transaction manager property.Gets the optional XADataSource class name.Gets the XADataSource instance used by the XAConnectionFactory.void
setTransactionManager
(javax.transaction.TransactionManager transactionManager) Sets the required transaction manager property.void
setXADataSource
(String xaDataSource) Sets the optional XADataSource class name.void
setXaDataSourceInstance
(XADataSource xaDataSourceInstance) Sets the XADataSource instance used by the XAConnectionFactory.Methods inherited from class org.apache.commons.dbcp2.BasicDataSource
addConnectionProperty, close, getAbandonedLogWriter, getAbandonedUsageTracking, getCacheState, getConnection, getConnection, getConnectionInitSqls, getConnectionInitSqlsAsArray, getDefaultAutoCommit, getDefaultCatalog, getDefaultQueryTimeout, getDefaultReadOnly, getDefaultTransactionIsolation, getDisconnectionSqlCodes, getDisconnectionSqlCodesAsArray, getDriver, getDriverClassLoader, getDriverClassName, getEnableAutoCommitOnReturn, getEvictionPolicyClassName, getFastFailValidation, getInitialSize, getJmxName, getLifo, getLogAbandoned, getLogExpiredConnections, getLoginTimeout, getLogWriter, getMaxConnLifetimeMillis, getMaxIdle, getMaxOpenPreparedStatements, getMaxTotal, getMaxWaitMillis, getMinEvictableIdleTimeMillis, getMinIdle, getNumActive, getNumIdle, getNumTestsPerEvictionRun, getParentLogger, getPassword, getRemoveAbandonedOnBorrow, getRemoveAbandonedOnMaintenance, getRemoveAbandonedTimeout, getRollbackOnReturn, getSoftMinEvictableIdleTimeMillis, getTestOnBorrow, getTestOnCreate, getTestOnReturn, getTestWhileIdle, getTimeBetweenEvictionRunsMillis, getUrl, getUsername, getValidationQuery, getValidationQueryTimeout, invalidateConnection, isAccessToUnderlyingConnectionAllowed, isClosed, isPoolPreparedStatements, isWrapperFor, postDeregister, postRegister, preDeregister, preRegister, removeConnectionProperty, setAbandonedLogWriter, setAbandonedUsageTracking, setAccessToUnderlyingConnectionAllowed, setCacheState, setConnectionInitSqls, setConnectionProperties, setDefaultAutoCommit, setDefaultCatalog, setDefaultQueryTimeout, setDefaultReadOnly, setDefaultTransactionIsolation, setDisconnectionSqlCodes, setDriver, setDriverClassLoader, setDriverClassName, setEnableAutoCommitOnReturn, setEvictionPolicyClassName, setFastFailValidation, setInitialSize, setJmxName, setLifo, setLogAbandoned, setLogExpiredConnections, setLoginTimeout, setLogWriter, setMaxConnLifetimeMillis, setMaxIdle, setMaxOpenPreparedStatements, setMaxTotal, setMaxWaitMillis, setMinEvictableIdleTimeMillis, setMinIdle, setNumTestsPerEvictionRun, setPassword, setPoolPreparedStatements, setRemoveAbandonedOnBorrow, setRemoveAbandonedOnMaintenance, setRemoveAbandonedTimeout, setRollbackOnReturn, setSoftMinEvictableIdleTimeMillis, setTestOnBorrow, setTestOnCreate, setTestOnReturn, setTestWhileIdle, setTimeBetweenEvictionRunsMillis, setUrl, setUsername, setValidationQuery, setValidationQueryTimeout, unwrap
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.sql.CommonDataSource
createShardingKeyBuilder
Methods inherited from interface javax.sql.DataSource
createConnectionBuilder
-
Constructor Details
-
BasicManagedDataSource
public BasicManagedDataSource()
-
-
Method Details
-
getXaDataSourceInstance
Gets the XADataSource instance used by the XAConnectionFactory.- Returns:
- the XADataSource
-
setXaDataSourceInstance
Sets the XADataSource instance used by the XAConnectionFactory.
Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first time one of the following methods is invoked:
getConnection, setLogwriter, setLoginTimeout, getLoginTimeout, getLogWriter.
- Parameters:
xaDataSourceInstance
- XADataSource instance
-
getTransactionManager
public javax.transaction.TransactionManager getTransactionManager()Gets the required transaction manager property.- Returns:
- the transaction manager used to enlist connections
-
setTransactionManager
public void setTransactionManager(javax.transaction.TransactionManager transactionManager) Sets the required transaction manager property.- Parameters:
transactionManager
- the transaction manager used to enlist connections
-
getXADataSource
Gets the optional XADataSource class name.- Returns:
- the optional XADataSource class name
-
setXADataSource
Sets the optional XADataSource class name.- Parameters:
xaDataSource
- the optional XADataSource class name
-