1 23 24 package com.sun.enterprise.tools.verifier.tests.ejb.runtime.beancache; 25 26 import com.sun.enterprise.deployment.EjbDescriptor; 27 import com.sun.enterprise.tools.verifier.Result; 28 import com.sun.enterprise.tools.verifier.Verifier; 29 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 30 31 43 44 public class ASEjbBCMaxCacheSize extends ASEjbBeanCache 45 { 46 47 public Result check(EjbDescriptor descriptor) 48 { 49 50 Result result = getInitializedResult(); 51 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 52 String beanCache = null; 53 String maxCacheSize = null; 54 try 55 { 56 beanCache = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/bean-cache"); 57 if(beanCache!=null) 58 { 59 maxCacheSize=getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/bean-cache/max-cache-size"); 60 if(maxCacheSize!=null) 61 { 62 maxCacheSize=maxCacheSize.trim(); 63 if(maxCacheSize.length()==0) 64 { 65 addErrorDetails(result, compName); 66 result.failed(smh.getLocalString(getClass().getName()+".failed1", 67 "FAILED [AS-EJB bean-pool] : max-cache-size cannot be empty")); 68 }else 69 { 70 try{ 71 int cacheValue=new Integer (maxCacheSize).intValue(); 72 if(cacheValue <= 1 || cacheValue > Integer.MAX_VALUE) 73 { 74 addErrorDetails(result, compName); 75 result.failed(smh.getLocalString(getClass().getName()+".failed", 76 "FAILED [AS-EJB bean-cache] : max-cache-size should be greater than 1 and less than MAX_INT")); 77 } 78 else 79 { 80 addGoodDetails(result, compName); 81 result.passed(smh.getLocalString(getClass().getName()+".passed", 82 "PASSED [AS-EJB bean-cache] : max-cache-size is {0}",new Object []{(new Integer (maxCacheSize))})); 83 } 84 }catch(NumberFormatException nfex) 85 { 86 Verifier.debug(nfex); 87 addErrorDetails(result, compName); 88 result.failed(smh.getLocalString(getClass().getName()+".failed2", 89 "FAILED [AS-EJB bean-pool] : The value {0} for max-pool-size is not a valid Integer number",new Object []{maxCacheSize})); 90 91 } 92 } 93 }else { 95 addNaDetails(result, compName); 96 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable", 97 "NOT APPLICABLE [AS-EJB bean-cache] : max-cache-size is element not defined")); 98 99 } 100 101 }else { 103 addNaDetails(result, compName); 104 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable1", 105 "NOT APPLICABLE [AS-EJB] : bean-cache element not defined")); 106 } 107 }catch(Exception ex){ 108 109 addErrorDetails(result, compName); 110 result.addErrorDetails(smh.getLocalString 111 (getClass().getName() + ".notRun", 112 "NOT RUN [AS-EJB] : Could not create the descriptor object")); 113 } 114 return result; 115 } 116 } 117 | Popular Tags |