1 23 package com.sun.enterprise.tools.verifier.tests.ejb.beanclass; 24 25 26 import java.lang.reflect.Constructor ; 27 import java.lang.reflect.Modifier ; 28 import com.sun.enterprise.deployment.EjbDescriptor; 29 import com.sun.enterprise.tools.verifier.Result; 30 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 31 import com.sun.enterprise.tools.verifier.tests.*; 32 33 37 public class EjbClassConstructor extends EjbTest { 38 39 40 48 public Result check(EjbDescriptor descriptor) { 49 50 Result result = getInitializedResult(); 51 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 52 53 Class c = loadEjbClass(descriptor, result); 54 if (c!=null) { 55 56 boolean foundOne = false; 57 Constructor [] constructors = c.getConstructors(); 58 for (int i = 0; i < constructors.length; i++) { 59 int modifiers = constructors[i].getModifiers(); 60 if (Modifier.isPublic(modifiers)) { 61 Class [] constructorParameterTypes; 62 constructorParameterTypes = constructors[i].getParameterTypes(); 63 if (constructorParameterTypes.length > 0) { 64 continue; 65 } else { 66 foundOne = true; 67 break; 68 } 69 } 70 } 71 72 if (foundOne) { 73 result.addGoodDetails(smh.getLocalString 74 ("tests.componentNameConstructor", 75 "For [ {0} ]", 76 new Object [] {compName.toString()})); 77 result.passed(smh.getLocalString 78 (getClass().getName() + ".passed", 79 "Valid: This bean [ {0} ] has a public constructor method with no " 80 + " \n parameters. Enterprise beans must have a public constructor " 81 + " \n method with no parameters.", 82 new Object [] {descriptor.getEjbClassName()})); 83 } else { 84 result.addErrorDetails(smh.getLocalString 85 ("tests.componentNameConstructor", 86 "For [ {0} ]", 87 new Object [] {compName.toString()})); 88 result.failed(smh.getLocalString 89 (getClass().getName() + ".failed", 90 "Error: There is no public constructor method with no parameters" 91 + "\n defined within bean [ {0} ]. Enterprise beans must have a " 92 + "\n public constructor methods with no parameters.", 93 new Object [] {descriptor.getEjbClassName()})); 94 } 95 } 96 return result; 97 98 } 99 } 100 | Popular Tags |