1 23 24 31 32 package com.sun.enterprise.admin.verifier.tests; 33 34 37 38 import com.sun.enterprise.config.serverbeans.Server; 41 import com.sun.enterprise.config.serverbeans.*; 42 import com.sun.enterprise.config.ConfigContext; 43 import com.sun.enterprise.config.ConfigException; 44 import com.sun.enterprise.config.serverbeans.*; 45 import com.sun.enterprise.config.ConfigContextEvent; 46 47 import com.sun.enterprise.admin.verifier.*; 48 49 import java.util.logging.Logger ; 51 import java.util.logging.Level ; 52 import com.sun.logging.LogDomains; 53 54 public class EjbContainerTest extends ServerXmlTest implements ServerCheck { 55 56 static Logger _logger = LogDomains.getLogger(LogDomains.APPVERIFY_LOGGER); 58 static int ejbSteadyQty = 0; 60 static int ejbMaxCacheSize = 0; 61 static int ejbResizeQty = 0; 62 63 public EjbContainerTest() { 64 } 65 66 public Result check(ConfigContext context) { 68 Result result; 69 result = super.getInitializedResult(); 70 151 return result; 152 } 153 154 public Result check(ConfigContextEvent ccce) { 156 Object value = ccce.getObject(); 157 ConfigContext context = ccce.getConfigContext(); 158 Result result = new Result(); 159 result.passed("Passed ** "); 160 String beanName = ccce.getBeanName(); 161 if(beanName!=null) { 162 String name = ccce.getName(); 163 if(name != null && value != null) 164 result = validateAttribute(name, (String )value); 165 return result; 166 } 167 168 return result; 169 } 170 171 public Result validateAttribute(String name, String value) { 172 Result result = new Result(); 173 boolean isFailed = false; 174 result.passed("Passed **"); 175 if(name.equals(ServerTags.STEADY_POOL_SIZE)) { 176 try { 177 int steadyQty = Integer.parseInt(value); 178 if(steadyQty < 0) { 179 result.failed(smh.getLocalString(getClass().getName()+".steadyPoolNegative","Steady Pool size cannot be a negative number")); 180 isFailed = true; 181 } 182 else { result.passed("Passed ***"); 184 EjbContainerTest.ejbSteadyQty = steadyQty; 185 } 186 } catch(NumberFormatException e) { 187 result.failed(smh.getLocalString(getClass().getName()+".steadyPoolInvalid","Steady Pool Size : invalid number")); 188 isFailed = true; 189 } 190 } 191 if(name.equals(ServerTags.MAX_POOL_SIZE)) { 192 try { 193 int maxQty = Integer.parseInt(value); 194 if(maxQty < 0) { 195 result.failed(smh.getLocalString(getClass().getName()+".maxPoolNegative","Max Pool Size cannot be a negative number")); 196 isFailed = true; 197 } 198 else if(maxQty < EjbContainerTest.ejbSteadyQty) { 200 result.failed(smh.getLocalString(getClass().getName()+".steadyPoolMaxPoolError","Steady Pool Size should be less than or equal to Maximum Pool Size")); 201 isFailed = true; 202 } 203 else if(maxQty < EjbContainerTest.ejbResizeQty) { 204 result.failed(smh.getLocalString(getClass().getName()+".resizePoolMaxPoolError","Pool Resize Qty should be less than or equal to Maximum Pool Size")); 205 isFailed = true; 206 } 207 else 208 result.passed("Passed ***"); 209 } catch(NumberFormatException e) { 210 result.failed(smh.getLocalString(getClass().getName()+".maxPoolInvalid","Max. Pool Size : invalid number ")); 211 isFailed = true; 212 } 213 } 214 if(name.equals(ServerTags.POOL_RESIZE_QUANTITY)){ 215 try { 216 int resizeQty = Integer.parseInt(value); 217 if(resizeQty < 0) { 218 result.failed(smh.getLocalString(getClass().getName()+".resizeQtyNegative","Pool resize quantity cannot be negative number")); 219 isFailed = true; 220 } 221 else { result.passed("Passed ***"); 223 EjbContainerTest.ejbResizeQty = resizeQty; 224 } 225 } catch(NumberFormatException e) { 226 result.failed(smh.getLocalString(getClass().getName()+".resizeQtyInvalid","Pool Resize Quantity : invalid number ")); 227 isFailed = true; 228 } 229 230 } 231 if(name.equals(ServerTags.POOL_IDLE_TIMEOUT_IN_SECONDS)) { 232 try { 233 if(Integer.parseInt(value) < 0) { 234 result.failed(smh.getLocalString(getClass().getName()+".idleTimeoutNegative","Pool Idle Timeout cannot be negative number")); 235 isFailed = true; 236 } 237 else 238 result.passed("Passed ***"); 239 } catch(NumberFormatException e) { 240 result.failed(smh.getLocalString(getClass().getName()+".idleTimeoutInvalid","Pool Idle timeout : invalid number")); 241 isFailed = true; 242 } 243 } 244 if(name.equals(ServerTags.MAX_CACHE_SIZE)) { 245 try { 246 int maxCache = Integer.parseInt(value); 247 if(maxCache < 0) { 248 result.failed(smh.getLocalString(getClass().getName()+".maxCacheNegative","Max Cache Size cannot be negative number")); 249 isFailed = true; 250 } 251 else { 252 result.passed("Passed ***"); 253 EjbContainerTest.ejbMaxCacheSize = maxCache; 254 } 255 } catch(NumberFormatException e) { 256 result.failed(smh.getLocalString(getClass().getName()+".maxCacheInvalid","Max Cache Size : invalid number ")); 257 isFailed = true; 258 } 259 } 260 if(name.equals(ServerTags.CACHE_RESIZE_QUANTITY)) { 261 try { 262 int cacheResize = Integer.parseInt(value); 263 if(Integer.parseInt(value) < 0) { 264 result.failed(smh.getLocalString(getClass().getName()+".cacheResizeNegative","Cache Resize Qty cannot be negative number")); 265 isFailed = true; 266 } 267 else if( cacheResize > EjbContainerTest.ejbMaxCacheSize) { 268 result.failed(smh.getLocalString(getClass().getName()+".cacheResizeMaxCacheError","Cache Resize Quantity should be less than or equal to Maximum Cache Size")); 269 isFailed = true; 270 } 271 else 272 result.passed("Passed ***"); 273 } catch(NumberFormatException e) { 274 result.failed(smh.getLocalString(getClass().getName()+".cacheResizeInvalid","Cache Resize Qty : invalid number ")); 275 isFailed = true; 276 } 277 } 278 if(name.equals(ServerTags.REMOVAL_TIMEOUT_IN_SECONDS)) { 279 try { 280 if(Integer.parseInt(value) < 0) { 281 result.failed(smh.getLocalString(getClass().getName()+".removalTimeNegative","Removal Timeout cannot be negative number")); 282 isFailed = true; 283 } 284 else 285 result.passed("Passed ***"); 286 } catch(NumberFormatException e) { 287 result.failed(smh.getLocalString(getClass().getName()+".removalTimeInvalid","Removal Timeout : invalid number")); 288 isFailed = true; 289 } 290 } 291 if(name.equals(ServerTags.CACHE_IDLE_TIMEOUT_IN_SECONDS)) { 292 try { 293 if(Integer.parseInt(value) < 0) { 294 result.failed(smh.getLocalString(getClass().getName()+".cacheIdleTimeoutNegative","Cache Idle Timeout cannot be negative number")); 295 isFailed = true; 296 } 297 else 298 result.passed("Passed ***"); 299 } catch(NumberFormatException e) { 300 result.failed(smh.getLocalString(getClass().getName()+".cacheIdleTimeoutInvalid","Cache Idle Timeout : invalid number ")); 301 isFailed = true; 302 } 303 } 304 if(isFailed) 305 result.setStatus(Result.FAILED); 306 return result; 307 } 308 309 } 310 | Popular Tags |