FileDocCategorySizeDatePackage
ApplicationExceptionHomeInterfaceMethods.javaAPI DocGlassfish v2 API6653Fri May 04 22:33:32 BST 2007com.sun.enterprise.tools.verifier.tests.ejb

ApplicationExceptionHomeInterfaceMethods

public class ApplicationExceptionHomeInterfaceMethods extends EjbTest implements EjbCheck
The Bean Provider defines the application exceptions in the throws clauses of the methods of the home interface. An application exception is an exception defined in the throws clause of a method in the Bean's home interface, other than java.rmi.RemoteException. An application exception must not be defined as a subclass of the java.lang.RuntimeException, or of the java.rmi.RemoteException. These are reserved for system exceptions. The javax.ejb.CreateException, javax.ejb.RemoveException, javax.ejb.FinderException, and subclasses thereof, are considered to be application exceptions.

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)
The Bean Provider defines the application exceptions in the throws clauses of the methods of the home interface. An application exception is an exception defined in the throws clause of a method in the Bean's home interface, other than java.rmi.RemoteException. An application exception must not be defined as a subclass of the java.lang.RuntimeException, or of the java.rmi.RemoteException. These are reserved for system exceptions. The javax.ejb.CreateException, javax.ejb.RemoveException, javax.ejb.FinderException, and subclasses thereof, are considered to be application exceptions.

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


                                                                                                              
        

        result = getInitializedResult();
        compName = getVerifierContext().getComponentNameConstructor();
        if ((descriptor instanceof EjbSessionDescriptor) ||
                (descriptor instanceof EjbEntityDescriptor)) {
            if(descriptor.getHomeClassName() != null)
                commonToBothInterfaces(descriptor.getHomeClassName(),descriptor);
            if(descriptor.getLocalHomeClassName() != null)
                commonToBothInterfaces(descriptor.getLocalHomeClassName(), descriptor);
        }

        if(result.getStatus() != Result.FAILED) {
            addGoodDetails(result, compName);
            result.passed(smh.getLocalString
                    (getClass().getName() + ".passed",
                    "All the methods of Home interface are defined properly"));
        }
        return result;
    
private voidcommonToBothInterfaces(java.lang.String home, com.sun.enterprise.deployment.EjbDescriptor 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 This parameter may be optional depending on the test


        try {
            Class c = Class.forName(home, false, getVerifierContext().getClassLoader());
            Class [] methodExceptionTypes;

            for(Method methods : c.getDeclaredMethods()) {
                methodExceptionTypes = methods.getExceptionTypes();
                // methods must also throw java.rmi.RemoteException
                if (!(EjbUtils.isValidApplicationException(methodExceptionTypes))) {
                    addErrorDetails(result, compName);
                    result.failed(smh.getLocalString
                            (getClass().getName() + ".failed",
                            "For the Interface [ {0} ] Method [ {1} ] does" +
                            " not throw valid application exceptions",
                            new Object[] {home, methods.getName()}));
                }
            } // for all the methods within the home interface class, loop

        } catch (Exception 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()}));
        }