public boolean isValid(final ResourcePool pool,
final ConstraintValidatorContext constraintValidatorContext) {
if(poolFaults == ConnectionPoolErrorMessages.MAX_STEADY_INVALID) {
if(pool instanceof JdbcConnectionPool) {
JdbcConnectionPool jdbcPool = (JdbcConnectionPool) pool;
String maxPoolSize = jdbcPool.getMaxPoolSize();
String steadyPoolSize = jdbcPool.getSteadyPoolSize();
if(steadyPoolSize == null) {
steadyPoolSize = Constants.DEFAULT_STEADY_POOL_SIZE;
}
if (maxPoolSize == null) {
maxPoolSize = Constants.DEFAULT_MAX_POOL_SIZE;
}
if (Integer.parseInt(maxPoolSize) <
(Integer.parseInt(steadyPoolSize))) {
//max pool size fault
return false;
}
} else if(pool instanceof ConnectorConnectionPool) {
ConnectorConnectionPool connPool = (ConnectorConnectionPool) pool;
String maxPoolSize = connPool.getMaxPoolSize();
String steadyPoolSize = connPool.getSteadyPoolSize();
if(steadyPoolSize == null) {
steadyPoolSize = Constants.DEFAULT_STEADY_POOL_SIZE;
}
if (maxPoolSize == null) {
maxPoolSize = Constants.DEFAULT_MAX_POOL_SIZE;
}
if (Integer.parseInt(maxPoolSize) <
(Integer.parseInt(steadyPoolSize))) {
//max pool size fault
return false;
}
}
}
if(poolFaults == ConnectionPoolErrorMessages.STMT_WRAPPING_DISABLED) {
if(pool instanceof JdbcConnectionPool) {
JdbcConnectionPool jdbcPool = (JdbcConnectionPool) pool;
String stmtCacheSize = jdbcPool.getStatementCacheSize();
String stmtLeakTimeout = jdbcPool.getStatementLeakTimeoutInSeconds();
if (jdbcPool.getSqlTraceListeners() != null) {
if (!Boolean.valueOf(jdbcPool.getWrapJdbcObjects())) {
return false;
}
}
if (stmtCacheSize != null && Integer.valueOf(stmtCacheSize) != 0) {
if (!Boolean.valueOf(jdbcPool.getWrapJdbcObjects())) {
return false;
}
}
if (stmtLeakTimeout != null && Integer.valueOf(stmtLeakTimeout) != 0) {
if (!Boolean.valueOf(jdbcPool.getWrapJdbcObjects())) {
return false;
}
}
if (Boolean.valueOf(jdbcPool.getStatementLeakReclaim())) {
if (!Boolean.valueOf(jdbcPool.getWrapJdbcObjects())) {
return false;
}
}
}
}
if(poolFaults == ConnectionPoolErrorMessages.TABLE_NAME_MANDATORY){
if(pool instanceof JdbcConnectionPool){
JdbcConnectionPool jdbcPool = (JdbcConnectionPool) pool;
if (Boolean.valueOf(jdbcPool.getIsConnectionValidationRequired())) {
if ("table".equals(jdbcPool.getConnectionValidationMethod())) {
if(jdbcPool.getValidationTableName() == null || jdbcPool.getValidationTableName().equals("")){
return false;
}
}
}
}
}
if(poolFaults == ConnectionPoolErrorMessages.CUSTOM_VALIDATION_CLASS_NAME_MANDATORY){
if(pool instanceof JdbcConnectionPool){
JdbcConnectionPool jdbcPool = (JdbcConnectionPool) pool;
if (Boolean.valueOf(jdbcPool.getIsConnectionValidationRequired())) {
if ("custom-validation".equals(jdbcPool.getConnectionValidationMethod())) {
if(jdbcPool.getValidationClassname() == null || jdbcPool.getValidationClassname().equals("")){
return false;
}
}
}
}
}
if (poolFaults == ConnectionPoolErrorMessages.RES_TYPE_MANDATORY) {
if (pool instanceof JdbcConnectionPool) {
JdbcConnectionPool jdbcPool = (JdbcConnectionPool) pool;
String resType = jdbcPool.getResType();
String dsClassName = jdbcPool.getDatasourceClassname();
String driverClassName = jdbcPool.getDriverClassname();
if (resType == null) {
//One of datasource/driver classnames must be provided.
if ((dsClassName == null || dsClassName.equals("")) &&
(driverClassName == null || driverClassName.equals(""))) {
return false;