version.major=1
version.minor=0
version.build=8
-version.patch=.2
+version.patch=.3
version.suffix=
# ----- Default Base Path for Dependent Packages -----
public static DataSource createDataSource(Properties properties,Context context) throws Exception {
PoolConfiguration poolProperties = DataSourceFactory.parsePoolProperties(properties);
if (poolProperties.getDataSourceJNDI()!=null && poolProperties.getDataSource()==null) {
- javax.sql.DataSource jndiDS = null;
+ javax.sql.CommonDataSource jndiDS = null;
try {
if (context!=null) {
- jndiDS = (javax.sql.DataSource)context.lookup(poolProperties.getDataSourceJNDI());
+ jndiDS = (javax.sql.CommonDataSource)context.lookup(poolProperties.getDataSourceJNDI());
} else {
log.warn("dataSourceJNDI property is configued, but local JNDI context is null.");
}
if (jndiDS==null) {
try {
context = (Context) (new InitialContext());
- jndiDS = (javax.sql.DataSource)context.lookup(poolProperties.getDataSourceJNDI());
+ jndiDS = (javax.sql.CommonDataSource)context.lookup(poolProperties.getDataSourceJNDI());
} catch (NamingException e) {
log.warn("The name \""+poolProperties.getDataSourceJNDI()+"\" can not be found in the InitialContext.");
}
import java.util.Properties;
import java.util.concurrent.Future;
+import javax.sql.CommonDataSource;
import javax.sql.XAConnection;
import org.apache.juli.logging.Log;
/**
* {@inheritDoc}
*/
- public void setDataSource(javax.sql.DataSource ds) {
+ public void setDataSource(javax.sql.CommonDataSource ds) {
getPoolProperties().setDataSource(ds);
}
/**
* {@inheritDoc}
*/
- public javax.sql.DataSource getDataSource() {
+ public CommonDataSource getDataSource() {
return getPoolProperties().getDataSource();
}
import java.util.Properties;
+import javax.sql.CommonDataSource;
+
import org.apache.tomcat.jdbc.pool.PoolProperties.InterceptorDefinition;
/**
* will be invoked.
* @param ds the {@link javax.sql.DataSource} to be used for creating connections to be pooled.
*/
- public void setDataSource(javax.sql.DataSource ds);
+ public void setDataSource(CommonDataSource ds);
/**
* Returns a datasource, if one exists that is being used to create connections.
* This method will return null if the pool is using a {@link java.sql.Driver}
* @return the {@link javax.sql.DataSource} to be used for creating connections to be pooled or null if a Driver is used.
*/
- public javax.sql.DataSource getDataSource();
+ public CommonDataSource getDataSource();
/**
- * Configure the connection pool to use a DataSource according to {@link PoolConfiguration#setDataSource(javax.sql.DataSource)}
+ * Configure the connection pool to use a DataSource according to {@link PoolConfiguration#setDataSource(CommonDataSource)}
* But instead of injecting the object, specify the JNDI location.
* After a successful JNDI look, the {@link PoolConfiguration#getDataSource()} will not return null.
* @param jndiDS -the JNDI string @TODO specify the rules here.
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
+import javax.sql.CommonDataSource;
+
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
protected boolean useLock = false;
protected InterceptorDefinition[] interceptors = null;
protected int suspectTimeout = 0;
- protected javax.sql.DataSource dataSource = null;
+ protected javax.sql.CommonDataSource dataSource = null;
protected String dataSourceJNDI = null;
/**
* {@inheritDoc}
*/
- public void setDataSource(javax.sql.DataSource ds) {
+ public void setDataSource(javax.sql.CommonDataSource ds) {
this.dataSource = ds;
}
/**
* {@inheritDoc}
*/
- public javax.sql.DataSource getDataSource() {
+ public CommonDataSource getDataSource() {
return dataSource;
}
xaConnection = xds.getXAConnection();
connection = xaConnection.getConnection();
}
- } else {
- javax.sql.DataSource ds = poolProperties.getDataSource();
+ } else if (poolProperties.getDataSource() instanceof javax.sql.DataSource){
+ javax.sql.DataSource ds = (javax.sql.DataSource)poolProperties.getDataSource();
if (poolProperties.getUsername()!=null && poolProperties.getPassword()!=null) {
connection = ds.getConnection(poolProperties.getUsername(), poolProperties.getPassword());
} else {
connection = ds.getConnection();
}
+ } else if (poolProperties.getDataSource() instanceof javax.sql.ConnectionPoolDataSource){
+ javax.sql.ConnectionPoolDataSource ds = (javax.sql.ConnectionPoolDataSource)poolProperties.getDataSource();
+ if (poolProperties.getUsername()!=null && poolProperties.getPassword()!=null) {
+ connection = ds.getPooledConnection(poolProperties.getUsername(), poolProperties.getPassword()).getConnection();
+ } else {
+ connection = ds.getPooledConnection().getConnection();
+ }
+ } else {
+ throw new SQLException("DataSource is of unknown class:"+(poolProperties.getDataSource()!=null?poolProperties.getDataSource().getClass():"null"));
}
}
protected void connectUsingDriver() throws SQLException {
import javax.management.Notification;
import javax.management.NotificationBroadcasterSupport;
import javax.management.NotificationListener;
+import javax.sql.CommonDataSource;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
/**
* {@inheritDoc}
*/
- public void setDataSource(javax.sql.DataSource ds) {
+ public void setDataSource(javax.sql.CommonDataSource ds) {
getPoolProperties().setDataSource(ds);
}
/**
* {@inheritDoc}
*/
- public javax.sql.DataSource getDataSource() {
+ public CommonDataSource getDataSource() {
return getPoolProperties().getDataSource();
}