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

EjbClassConstructor

public class EjbClassConstructor extends com.sun.enterprise.tools.verifier.tests.ejb.EjbTest
Enterprise Java Bean class constuctor test. The class must have a public constructor that takes no parameters.

Fields Summary
Constructors Summary
Methods Summary
public com.sun.enterprise.tools.verifier.Resultcheck(com.sun.enterprise.deployment.EjbDescriptor descriptor)
Enterprise Java Bean class constuctor test. The class must have a public constructor that takes no parameters.

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


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

        Class c = loadEjbClass(descriptor, result);
        if (c!=null) {

            boolean foundOne = false;
            Constructor [] constructors = c.getConstructors();
            for (int i = 0; i < constructors.length; i++) {
                int modifiers = constructors[i].getModifiers();
                if (Modifier.isPublic(modifiers)) {
                    Class [] constructorParameterTypes;
                    constructorParameterTypes = constructors[i].getParameterTypes();
                    if (constructorParameterTypes.length > 0) {
                        continue;
                    } else {
                        foundOne = true;
                        break;
                    }
                }
            }

            if (foundOne) {
		result.addGoodDetails(smh.getLocalString
				      ("tests.componentNameConstructor",
				       "For [ {0} ]",
				       new Object[] {compName.toString()}));
		result.passed(smh.getLocalString
			      (getClass().getName() + ".passed",
			       "Valid: This bean [ {0} ] has a public constructor method with no "
			       + " \n parameters.  Enterprise beans must have a public constructor "
			       + " \n method with no parameters.",
			       new Object[] {descriptor.getEjbClassName()}));
            } else {
		result.addErrorDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
                result.failed(smh.getLocalString
                    (getClass().getName() + ".failed",
                    "Error: There is no public constructor method with no parameters"
                    + "\n defined within bean [ {0} ].  Enterprise beans must have a "
                    + "\n public constructor methods with no parameters.",
                    new Object[] {descriptor.getEjbClassName()}));
            }
        }
        return result;