FileDocCategorySizeDatePackage
ASEjbRefreshPeriod.javaAPI DocGlassfish v2 API6995Fri May 04 22:35:14 BST 2007com.sun.enterprise.tools.verifier.tests.ejb.ias

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
Irfan Ahmed

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

	Result result = getInitializedResult();
	ComponentNameConstructor compName = new ComponentNameConstructor(descriptor);

        SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject();
        boolean oneWarning = false;
        boolean oneFailed = false;
        
        if(ejbJar!=null)
        {
            Ejb testCase = getEjb(descriptor.getName(), ejbJar);
            String refreshPeriod = testCase.getRefreshPeriodInSeconds();
            
            boolean isReadOnly = false;
            String beanType = testCase.getIsReadOnlyBean();
            if(beanType!=null && beanType.equals("true"))
                isReadOnly = true;
            else
                isReadOnly=false;
            
            if(refreshPeriod!=null)
            {
                if(refreshPeriod.length()==0)
                {
                    oneFailed = true;
                    result.failed(smh.getLocalString(getClass().getName()+".failed3",
                        "FAILED [AS-EJB ejb] : refresh-period-in-seconds is invalid. It shoud be between 0 and " + Integer.MAX_VALUE));
                }
                else
                {
                    if(!(descriptor instanceof EjbEntityDescriptor 
                            && isReadOnly))
                    {
                        oneWarning = true;
                        result.warning(smh.getLocalString(getClass().getName()+".warning",
                        "WARNING [AS-EJB ejb] : refresh-period-in-seconds should be defined for Read Only Beans."));
                    }
                    try
                    {
                        int refValue = Integer.parseInt(refreshPeriod);
                        if(refValue<0 || refValue>Integer.MAX_VALUE)
                        {
                            oneFailed = true;
                            result.failed(smh.getLocalString(getClass().getName()+".failed4",
                                "FAILED [AS-EJB ejb] : refresh-period-in-seconds cannot be greater than " + Integer.MAX_VALUE + 
                                " or less than 0"));
                        }
                        else
                            result.passed(smh.getLocalString(getClass().getName()+".passed4",
                                "PASSED [AS-EJB ejb] : refresh-period-in-seconds is {0}",new Object[]{new Integer(refValue)}));
                    }
                    catch(NumberFormatException nfex)
                    {
                        oneFailed = true;
                        Verifier.debug(nfex);
                        result.failed(smh.getLocalString(getClass().getName()+".failed5",
                            "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))
                {
                    result.warning(smh.getLocalString(getClass().getName()+".warning1",
                    "WARNING [AS-EJB ejb] : refresh-period-in-seconds should be defined for Read Only Beans"));
                }
                else
                {
                    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);
        }
        else
        {
            result.addErrorDetails(smh.getLocalString
                 (getClass().getName() + ".notRun",
                  "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
        }
        return result;