FileDocCategorySizeDatePackage
InterfaceClassExist.javaAPI DocGlassfish v2 API5966Fri May 04 22:33:54 BST 2007com.sun.enterprise.tools.verifier.tests.ejb.intf

InterfaceClassExist

public abstract class InterfaceClassExist extends com.sun.enterprise.tools.verifier.tests.ejb.EjbTest implements com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck
Interface test. Verify that the bean local or remote interface class exist and is loadable.

Fields Summary
Constructors Summary
Methods Summary
public com.sun.enterprise.tools.verifier.Resultcheck(com.sun.enterprise.deployment.EjbDescriptor descriptor)
Local Interface test. Verify that the bean remote or local interface class exist and is loadable.

param
descriptor the Enterprise Java Bean deployment descriptor
return
Result the results for this assertion

        
        Result result = getInitializedResult();
        ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
        
        if (!(descriptor instanceof EjbSessionDescriptor) &&
                !(descriptor instanceof EjbEntityDescriptor)) { 
            addNaDetails(result, compName);
            result.notApplicable(smh.getLocalString
                    ("com.sun.enterprise.tools.verifier.tests.ejb.intf.InterfaceClassExist.notApplicable1",
                    "Test apply only to session or entity beans."));
            return result;
        }
        
        if(getInterfaceName(descriptor) == null || "".equals(getInterfaceName(descriptor))){
            addNaDetails(result, compName);
            result.notApplicable(smh.getLocalString
                    ("com.sun.enterprise.tools.verifier.tests.ejb.intf.InterfaceClassExist.notApplicable2",
                    "Not Applicable because, EJB [ {0} ] does not have {1} Interface.",
                    new Object[] {descriptor.getEjbClassName(), getInterfaceType()}));
            return result;
        }
        
        // verify that the local or remote interface class exist and is loadable
        try {
            ClassLoader jcl = getVerifierContext().getClassLoader();
            Class c = Class.forName(getClassName(descriptor), false, jcl);
            if(!c.isInterface()) {
                addErrorDetails(result, compName);
                result.failed(smh.getLocalString
                        ("com.sun.enterprise.tools.verifier.tests.ejb.intf.InterfaceClassExist.failed",
                        "[ {0} ] is defined as a class. It should be an interface.",
                        new Object[] {getClassName(descriptor)}));
            }
        } catch (ClassNotFoundException e) {
            Verifier.debug(e);
            addErrorDetails(result, compName);
            result.failed(smh.getLocalString
                    (getClass().getName() + ".failed",
                    "Error: "+ getInterfaceType() +" interface [ {0} ] does not exist or is not loadable.",
                    new Object[] {getClassName(descriptor)}));
        }
        if(result.getStatus() != Result.FAILED) {
            addGoodDetails(result, compName);	
            result.passed(smh.getLocalString
                    (getClass().getName() + ".passed",
                    getInterfaceType() + " interface [ {0} ] exist and is loadable.",
                    new Object[] {getClassName(descriptor)}));
        }
        return result;
    
private java.lang.StringgetClassName(com.sun.enterprise.deployment.EjbDescriptor descriptor)

        return getInterfaceName(descriptor);
    
protected abstract java.lang.StringgetInterfaceName(com.sun.enterprise.deployment.EjbDescriptor descriptor)
Following 2 methods are used to determine whether this method is being called by local/remote interface.

protected abstract java.lang.StringgetInterfaceType()