mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUACAMOLE-641: Merge correct regressions in custom pooled datasource behavior.
This commit is contained in:
@@ -24,9 +24,12 @@ import com.google.inject.Singleton;
|
||||
import com.google.inject.name.Named;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.ibatis.datasource.pooled.PooledDataSource;
|
||||
import org.apache.ibatis.datasource.unpooled.UnpooledDataSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Pooled DataSource implementation which dynamically retrieves the database
|
||||
@@ -36,6 +39,11 @@ import org.apache.ibatis.datasource.unpooled.UnpooledDataSource;
|
||||
@Singleton
|
||||
public class DynamicallyAuthenticatedDataSource extends PooledDataSource {
|
||||
|
||||
/**
|
||||
* Logger for this class.
|
||||
*/
|
||||
private static final Logger logger = LoggerFactory.getLogger(DynamicallyAuthenticatedDataSource.class);
|
||||
|
||||
/**
|
||||
* Creates a new DynamicallyAuthenticatedDataSource which dynamically
|
||||
* retrieves database credentials from the given JDBCEnvironment each time
|
||||
@@ -62,6 +70,7 @@ public class DynamicallyAuthenticatedDataSource extends PooledDataSource {
|
||||
@Override
|
||||
public Connection getConnection() throws SQLException {
|
||||
try {
|
||||
logger.debug("Creating new database connection for pool.");
|
||||
return super.getConnection(environment.getUsername(), environment.getPassword());
|
||||
}
|
||||
catch (GuacamoleException e) {
|
||||
@@ -71,6 +80,77 @@ public class DynamicallyAuthenticatedDataSource extends PooledDataSource {
|
||||
|
||||
});
|
||||
|
||||
// Force recalculation of expectedConnectionTypeCode. The
|
||||
// PooledDataSource constructor accepting a single UnpooledDataSource
|
||||
// will otherwise leave this value uninitialized, resulting in all
|
||||
// connections failing to pass sanity checks and never being returned
|
||||
// to the pool.
|
||||
super.forceCloseAll();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Inject(optional=true)
|
||||
public void setPoolPingConnectionsNotUsedFor(
|
||||
@Named("mybatis.pooled.pingConnectionsNotUsedFor") int milliseconds) {
|
||||
super.setPoolPingConnectionsNotUsedFor(milliseconds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Inject(optional=true)
|
||||
public void setPoolPingEnabled(@Named("mybatis.pooled.pingEnabled") boolean poolPingEnabled) {
|
||||
super.setPoolPingEnabled(poolPingEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Inject(optional=true)
|
||||
public void setPoolPingQuery(@Named("mybatis.pooled.pingQuery") String poolPingQuery) {
|
||||
super.setPoolPingQuery(poolPingQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Inject(optional=true)
|
||||
public void setPoolTimeToWait(@Named("mybatis.pooled.timeToWait") int poolTimeToWait) {
|
||||
super.setPoolTimeToWait(poolTimeToWait);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Inject(optional=true)
|
||||
public void setPoolMaximumCheckoutTime(
|
||||
@Named("mybatis.pooled.maximumCheckoutTime") int poolMaximumCheckoutTime) {
|
||||
super.setPoolMaximumCheckoutTime(poolMaximumCheckoutTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Inject(optional=true)
|
||||
public void setPoolMaximumIdleConnections(
|
||||
@Named("mybatis.pooled.maximumIdleConnections") int poolMaximumIdleConnections) {
|
||||
super.setPoolMaximumIdleConnections(poolMaximumIdleConnections);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Inject(optional=true)
|
||||
public void setPoolMaximumActiveConnections(
|
||||
@Named("mybatis.pooled.maximumActiveConnections") int poolMaximumActiveConnections) {
|
||||
super.setPoolMaximumActiveConnections(poolMaximumActiveConnections);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Inject(optional=true)
|
||||
public void setDriverProperties(@Named("JDBC.driverProperties") Properties driverProps) {
|
||||
super.setDriverProperties(driverProps);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Inject(optional=true)
|
||||
public void setDefaultAutoCommit(@Named("JDBC.autoCommit") boolean defaultAutoCommit) {
|
||||
super.setDefaultAutoCommit(defaultAutoCommit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Inject(optional=true)
|
||||
public void setLoginTimeout(@Named("JDBC.loginTimeout") int loginTimeout) {
|
||||
super.setLoginTimeout(loginTimeout);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user