1 package com.sun.enterprise.tools.verifier.tests.ejb.ias; 2 3 25 26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 27 import java.util.*; 28 import com.sun.enterprise.deployment.EjbDescriptor; 29 import com.sun.enterprise.deployment.EjbSessionDescriptor; 30 import com.sun.enterprise.tools.verifier.*; 31 import com.sun.enterprise.tools.verifier.tests.*; 32 33 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 34 35 import com.sun.enterprise.tools.common.dd.ejb.SunEjbJar; 36 import com.sun.enterprise.tools.common.dd.ejb.Ejb; 37 import com.sun.enterprise.tools.common.dd.ResourceRef; 38 import com.sun.enterprise.tools.common.dd.DefaultResourcePrincipal; 39 import com.sun.enterprise.deployment.ResourceReferenceDescriptor; 40 import com.sun.enterprise.deployment.EjbEntityDescriptor; 41 42 51 public class ASEjbRefreshPeriod extends EjbTest implements EjbCheck { 52 53 public Result check(EjbDescriptor descriptor) 54 { 55 Result result = getInitializedResult(); 56 ComponentNameConstructor compName = new ComponentNameConstructor(descriptor); 57 58 SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject(); 59 boolean oneWarning = false; 60 boolean oneFailed = false; 61 62 if(ejbJar!=null) 63 { 64 Ejb testCase = getEjb(descriptor.getName(), ejbJar); 65 String refreshPeriod = testCase.getRefreshPeriodInSeconds(); 66 67 boolean isReadOnly = false; 68 String beanType = testCase.getIsReadOnlyBean(); 69 if(beanType!=null && beanType.equals("true")) 70 isReadOnly = true; 71 else 72 isReadOnly=false; 73 74 if(refreshPeriod!=null) 75 { 76 if(refreshPeriod.length()==0) 77 { 78 oneFailed = true; 79 result.failed(smh.getLocalString(getClass().getName()+".failed3", 80 "FAILED [AS-EJB ejb] : refresh-period-in-seconds is invalid. It shoud be between 0 and " + Integer.MAX_VALUE)); 81 } 82 else 83 { 84 if(!(descriptor instanceof EjbEntityDescriptor 85 && isReadOnly)) 86 { 87 oneWarning = true; 88 result.warning(smh.getLocalString(getClass().getName()+".warning", 89 "WARNING [AS-EJB ejb] : refresh-period-in-seconds should be defined for Read Only Beans.")); 90 } 91 try 92 { 93 int refValue = Integer.parseInt(refreshPeriod); 94 if(refValue<0 || refValue>Integer.MAX_VALUE) 95 { 96 oneFailed = true; 97 result.failed(smh.getLocalString(getClass().getName()+".failed4", 98 "FAILED [AS-EJB ejb] : refresh-period-in-seconds cannot be greater than " + Integer.MAX_VALUE + 99 " or less than 0")); 100 } 101 else 102 result.passed(smh.getLocalString(getClass().getName()+".passed4", 103 "PASSED [AS-EJB ejb] : refresh-period-in-seconds is {0}",new Object []{new Integer (refValue)})); 104 } 105 catch(NumberFormatException nfex) 106 { 107 oneFailed = true; 108 Verifier.debug(nfex); 109 result.failed(smh.getLocalString(getClass().getName()+".failed5", 110 "FAILED [AS-EJB ejb] : refresh-period-in-seconds is invalid. It should be between 0 and "+Integer.MAX_VALUE )); 111 } 112 } 113 } 114 else 115 { 116 if((descriptor instanceof EjbEntityDescriptor) 117 && (isReadOnly)) 118 { 119 result.warning(smh.getLocalString(getClass().getName()+".warning1", 120 "WARNING [AS-EJB ejb] : refresh-period-in-seconds should be defined for Read Only Beans")); 121 } 122 else 123 { 124 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable", 125 "NOT APPLICABLE [AS-EJB ejb] : refresh-period-in-seconds is not defined")); 126 } 127 } 128 if(oneWarning) 129 result.setStatus(Result.WARNING); 130 if(oneFailed) 131 result.setStatus(Result.FAILED); 132 } 133 else 134 { 135 result.addErrorDetails(smh.getLocalString 136 (getClass().getName() + ".notRun", 137 "NOT RUN [AS-EJB] : Could not create an SunEjbJar object")); 138 } 139 return result; 140 } 141 } 142 | Popular Tags |