FileDocCategorySizeDatePackage
HomeInterfaceNoFinderMethodNames.javaAPI DocGlassfish v2 API6450Fri May 04 22:34:06 BST 2007com.sun.enterprise.tools.verifier.tests.ejb.session

HomeInterfaceNoFinderMethodNames

public class HomeInterfaceNoFinderMethodNames extends com.sun.enterprise.tools.verifier.tests.ejb.EjbTest implements com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck
Session beans home interface no finder methods name test. The following are the requirements for the enterprise Bean's home interface signature: Since all session objects hide their identity, there is no need to provide a finder for them. The home interface for a session object must not define any finder methods.

Fields Summary
com.sun.enterprise.tools.verifier.Result
result
com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor
compName
Constructors Summary
Methods Summary
public com.sun.enterprise.tools.verifier.Resultcheck(com.sun.enterprise.deployment.EjbDescriptor descriptor)
Session beans home interface no finder methods name test. The following are the requirements for the enterprise Bean's home interface signature: Since all session objects hide their identity, there is no need to provide a finder for them. The home interface for a session object must not define any finder methods.

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


                                                                                     
        

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

        if (descriptor instanceof EjbSessionDescriptor) {
            // RULE: Session home interface are not allowed to have any
            //       finder methods
            if(descriptor.getHomeClassName() != null && !"".equals(descriptor.getHomeClassName()))
                commonToBothInterfaces(descriptor.getHomeClassName(),(EjbSessionDescriptor)descriptor);
            if(descriptor.getLocalHomeClassName() != null && !"".equals(descriptor.getLocalHomeClassName()))
                commonToBothInterfaces(descriptor.getLocalHomeClassName(),(EjbSessionDescriptor)descriptor);
        }
        if(result.getStatus() != Result.FAILED) {
            addGoodDetails(result, compName);
            result.passed(smh.getLocalString
                    (getClass().getName() + ".passed",
                    "Valid: no finder methods were found.  Session bean's home interface" +
                    " is not allowed to have any finder methods."));
        }
        return result;
    
private voidcommonToBothInterfaces(java.lang.String home, com.sun.enterprise.deployment.EjbSessionDescriptor descriptor)
This method is responsible for the logic of the test. It is called for both local and remote interfaces.

param
descriptor the Enterprise Java Bean deployment descriptor
param
home for the Home interface of the Ejb.

        try {
            Class c = Class.forName(home,
                                false,
                                getVerifierContext().getClassLoader());
            for(Method methods : c.getDeclaredMethods()) {
                if(methods.getName().startsWith("find")) {
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString
                            (getClass().getName() + ".debug1",
                                    "For Home Interface [ {0} ] Method [ {1} ]",
                                    new Object[] {c.getName(),methods.getName()}));
                    result.addErrorDetails(smh.getLocalString
                            (getClass().getName() + ".failed",
                                    "Improperly named method [ {0} ] was found. Session bean's home interface is not allowed to have any finder methods.",
                                    new Object[] {methods.getName()}));
                }
            }

        } catch (ClassNotFoundException e) {
            Verifier.debug(e);
            addErrorDetails(result, compName);
            result.failed(smh.getLocalString
                    (getClass().getName() + ".failedException",
                            "Error: Home interface [ {0} ] does not exist or is not loadable within bean [ {1} ]",
                            new Object[] {home, descriptor.getName()}));
        }