FileDocCategorySizeDatePackage
JdbcConnectionPoolTest.javaAPI DocGlassfish v2 API5626Fri May 04 22:24:38 BST 2007com.sun.enterprise.config.serverbeans.validation.tests

JdbcConnectionPoolTest

public class JdbcConnectionPoolTest extends com.sun.enterprise.config.serverbeans.validation.GenericValidator
Custom Test for Jdbc Connection Pool Test which calls the Generic Validation before performing custom tests
author
Srinivas Krishnan
version
2.0

Fields Summary
static boolean
checked
int
maxPoolSize
static final String
LAZY_CONN_ASSOCIATION
static final String
LAZY_CONN_ENLISTMENT
Constructors Summary
public JdbcConnectionPoolTest(com.sun.enterprise.config.serverbeans.validation.ValidationDescriptor desc)

    
       
        super(desc);
    
Methods Summary
private voidcheckLazyConnectionProps(com.sun.enterprise.config.serverbeans.validation.ValidationContext valCtx)

        Map map;
        ConfigBean targetBean = valCtx.getTargetBean();
        if(targetBean==null)
            return;
        if(targetBean instanceof ElementProperty)
            map = PropertyHelper.getFuturePropertiesMap(valCtx);
        else
            map = PropertyHelper.getPropertiesMap(targetBean);
        String newAsso = (String)map.get(LAZY_CONN_ASSOCIATION);
        String newEnlist = (String)map.get(LAZY_CONN_ENLISTMENT);
        if(newAsso!=null &&  newEnlist!=null &&
           Boolean.parseBoolean(newAsso) && !Boolean.parseBoolean(newEnlist))
        {
            reportValidationError(valCtx, "PropsConflict", 
                "Combination of properties {0}={1} and {2}={3} is not allowed.",
                new Object[]{LAZY_CONN_ASSOCIATION, newAsso,
                             LAZY_CONN_ENLISTMENT, newEnlist});
        }
    
public voidvalidate(com.sun.enterprise.config.serverbeans.validation.ValidationContext valCtx)

        super.validate(valCtx); // Before doing custom validation do basic validation
        
        if(valCtx.isVALIDATE() || valCtx.isADD() || valCtx.isSET())
        {
            JdbcConnectionPool pool = (JdbcConnectionPool)valCtx.getTargetBean();
            if(pool.isIsConnectionValidationRequired() && pool.getConnectionValidationMethod().equals("table")) {
                if(pool.getValidationTableName() == null || pool.getValidationTableName().equals(""))
                    reportValidationError(valCtx, "requiredTableName", 
                    "Table Name is required Jdbc Connection Pool if Connection validation method is Table",
                    null);
            }
            checkLazyConnectionProps(valCtx);
        }
    
public voidvalidatePropertyChanges(com.sun.enterprise.config.serverbeans.validation.ValidationContext propValCtx)

    
        
    
        
        if(propValCtx.isDELETE() || propValCtx.isVALIDATE()) //no validation
            return;
        
        if(!PropertyHelper.isPropertyChanged(propValCtx, LAZY_CONN_ASSOCIATION) &&
           !PropertyHelper.isPropertyChanged(propValCtx, LAZY_CONN_ENLISTMENT))
            return;
        
        //here we are only if some changes with testing props occured
        checkLazyConnectionProps(propValCtx);