FileDocCategorySizeDatePackage
ASEjbRefreshPeriod.javaAPI DocGlassfish v2 API8283Fri May 04 22:34:04 BST 2007com.sun.enterprise.tools.verifier.tests.ejb.runtime

ASEjbRefreshPeriod

public class ASEjbRefreshPeriod extends com.sun.enterprise.tools.verifier.tests.ejb.EjbTest implements com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck
ejb [0,n] refresh-period-in-seconds ? [String] The refresh-period-in-seconds denotes the rate at which a read-only-bean is refreshed. Is applicable only if it is a ROB. The value should be between 0 and MAX_INT
author

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(com.sun.enterprise.deployment.EjbDescriptor descriptor)

	Result result = getInitializedResult();
	ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();

        boolean oneWarning = false;
        boolean oneFailed = false;
        boolean isReadOnly = false;
        String refreshPeriod = null;
        try{
            String s1 = ("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/refresh-period-in-seconds");
            refreshPeriod = getXPathValue(s1);
            
            IASEjbExtraDescriptors iasEjbExtraDesc = descriptor.getIASEjbExtraDescriptors();
            isReadOnly = iasEjbExtraDesc.isIsReadOnlyBean();
            
            if(refreshPeriod!=null)
            {
                refreshPeriod=refreshPeriod.trim();
                if(refreshPeriod.length()==0)
                {
                    oneFailed = true;
                    result.addErrorDetails(smh.getLocalString
				   ("tests.componentNameConstructor",
				    "For [ {0} ]",
				    new Object[] {compName.toString()}));
                    result.failed(smh.getLocalString(getClass().getName()+".failed",
                        "FAILED [AS-EJB ejb] : refresh-period-in-seconds is invalid. It should be between 0 and " + Integer.MAX_VALUE));
                }else{
                    if(!(descriptor instanceof EjbEntityDescriptor
                    && isReadOnly)) 
                    {
                            oneWarning = true;
                            result.addWarningDetails(smh.getLocalString
                                       ("tests.componentNameConstructor",
                                        "For [ {0} ]",
                                        new Object[] {compName.toString()}));
                            result.warning(smh.getLocalString(getClass().getName()+".warning",
                            "WARNING [AS-EJB ejb] : refresh-period-in-seconds should be defined for Read Only Beans."));
                        return result;
                    }
                    try{
                        int refValue = Integer.parseInt(refreshPeriod);
                        if(refValue<0 || refValue>Integer.MAX_VALUE)
                        {
                            oneFailed = true;
                            result.addErrorDetails(smh.getLocalString
				   ("tests.componentNameConstructor",
				    "For [ {0} ]",
				    new Object[] {compName.toString()}));
                            result.failed(smh.getLocalString(getClass().getName()+".failed1",
                                "FAILED [AS-EJB ejb] : refresh-period-in-seconds cannot be greater than " + Integer.MAX_VALUE + " or less than 0"));
                        }
                        else
                            result.addGoodDetails(smh.getLocalString
                                ("tests.componentNameConstructor",
                                "For [ {0} ]",
                                new Object[] {compName.toString()}));
                            result.passed(smh.getLocalString(getClass().getName()+".passed",
                                "PASSED [AS-EJB ejb] : refresh-period-in-seconds is {0}",new Object[]{new Integer(refValue)}));
                    }catch(NumberFormatException nfex){
                        oneFailed = true;
                        Verifier.debug(nfex);
                        result.addErrorDetails(smh.getLocalString
				   ("tests.componentNameConstructor",
				    "For [ {0} ]",
				    new Object[] {compName.toString()}));
                        result.failed(smh.getLocalString(getClass().getName()+".failed",
                            "FAILED [AS-EJB ejb] : refresh-period-in-seconds is invalid. It should be between 0 and " + Integer.MAX_VALUE ));
                    }
                }
            }else {
                if((descriptor instanceof EjbEntityDescriptor)
                        && (isReadOnly))
                {
                    oneWarning = true;
                    result.addWarningDetails(smh.getLocalString
                                       ("tests.componentNameConstructor",
                                        "For [ {0} ]",
                                        new Object[] {compName.toString()}));
                    result.warning(smh.getLocalString(getClass().getName()+".warning",
                    "WARNING [AS-EJB ejb] : refresh-period-in-seconds should be defined for Read Only Beans"));
                }
                else
                {
                    result.addNaDetails(smh.getLocalString
				("tests.componentNameConstructor",
				 "For [ {0} ]",
				 new Object[] {compName.toString()}));
                    result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
                        "NOT APPLICABLE [AS-EJB ejb] : refresh-period-in-seconds is not defined"));
                }
            }
            if(oneWarning)
                result.setStatus(Result.WARNING);
            if(oneFailed)
                result.setStatus(Result.FAILED);
        }catch(Exception ex){
            result.addErrorDetails(smh.getLocalString
				   ("tests.componentNameConstructor",
				    "For [ {0} ]",
				    new Object[] {compName.toString()}));
            result.failed(smh.getLocalString(getClass().getName()+".notRun",
                "NOT RUN [AS-EJB cmp] Could not create descriptor Object."));
        }
        return result;