1 23 24 package com.sun.enterprise.config.serverbeans.validation.tests; 25 26 import java.util.Locale ; 27 import java.util.Map ; 28 29 import com.sun.enterprise.config.serverbeans.validation.GenericValidator; 30 import com.sun.enterprise.config.serverbeans.validation.ValidationDescriptor; 31 import com.sun.enterprise.config.serverbeans.validation.ValidationContext; 32 import com.sun.enterprise.config.serverbeans.validation.PropertyHelper; 33 import com.sun.enterprise.config.serverbeans.validation.Result; 34 35 import com.sun.enterprise.config.serverbeans.JdbcConnectionPool; 36 import com.sun.enterprise.config.serverbeans.ElementProperty; 37 38 import com.sun.enterprise.config.ConfigBean; 39 import com.sun.enterprise.config.ConfigContextEvent; 40 import com.sun.enterprise.config.ConfigContext; 41 import com.sun.enterprise.config.ConfigException; 42 43 44 import java.util.logging.Level ; 45 46 52 53 public class JdbcConnectionPoolTest extends GenericValidator { 54 55 static boolean checked = false; 56 int maxPoolSize = 0; 57 58 public JdbcConnectionPoolTest(ValidationDescriptor desc) { 59 super(desc); 60 } 61 62 public void validate(ValidationContext valCtx) { 63 super.validate(valCtx); 65 if(valCtx.isVALIDATE() || valCtx.isADD() || valCtx.isSET()) 66 { 67 JdbcConnectionPool pool = (JdbcConnectionPool)valCtx.getTargetBean(); 68 if(pool.isIsConnectionValidationRequired() && pool.getConnectionValidationMethod().equals("table")) { 69 if(pool.getValidationTableName() == null || pool.getValidationTableName().equals("")) 70 reportValidationError(valCtx, "requiredTableName", 71 "Table Name is required Jdbc Connection Pool if Connection validation method is Table", 72 null); 73 } 74 checkLazyConnectionProps(valCtx); 75 } 76 } 77 78 static final String LAZY_CONN_ASSOCIATION = "LazyConnectionAssociation"; 80 static final String LAZY_CONN_ENLISTMENT = "LazyConnectionEnlistment"; 81 82 public void validatePropertyChanges(ValidationContext propValCtx) 83 { 84 85 if(propValCtx.isDELETE() || propValCtx.isVALIDATE()) return; 87 88 if(!PropertyHelper.isPropertyChanged(propValCtx, LAZY_CONN_ASSOCIATION) && 89 !PropertyHelper.isPropertyChanged(propValCtx, LAZY_CONN_ENLISTMENT)) 90 return; 91 92 checkLazyConnectionProps(propValCtx); 94 } 95 96 private void checkLazyConnectionProps(ValidationContext valCtx) 97 { 98 Map map; 99 ConfigBean targetBean = valCtx.getTargetBean(); 100 if(targetBean==null) 101 return; 102 if(targetBean instanceof ElementProperty) 103 map = PropertyHelper.getFuturePropertiesMap(valCtx); 104 else 105 map = PropertyHelper.getPropertiesMap(targetBean); 106 String newAsso = (String )map.get(LAZY_CONN_ASSOCIATION); 107 String newEnlist = (String )map.get(LAZY_CONN_ENLISTMENT); 108 if(newAsso!=null && newEnlist!=null && 109 Boolean.parseBoolean(newAsso) && !Boolean.parseBoolean(newEnlist)) 110 { 111 reportValidationError(valCtx, "PropsConflict", 112 "Combination of properties {0}={1} and {2}={3} is not allowed.", 113 new Object []{LAZY_CONN_ASSOCIATION, newAsso, 114 LAZY_CONN_ENLISTMENT, newEnlist}); 115 } 116 } 117 } 118 | Popular Tags |