1 23 package com.sun.enterprise.tools.verifier.tests.ejb.homeintf; 24 25 import com.sun.enterprise.deployment.EjbDescriptor; 26 import com.sun.enterprise.tools.verifier.Result; 27 import com.sun.enterprise.tools.verifier.Verifier; 28 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 29 30 import java.lang.ClassLoader ; 31 import java.lang.reflect.Method ; 32 import java.lang.reflect.Modifier ; 33 34 40 abstract public class HomeMethodModifiers extends HomeMethodTest { 41 42 51 52 protected void runIndividualHomeMethodTest(Method method, EjbDescriptor descriptor, Result result) { 53 54 Method m; 55 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 56 57 try { 58 ClassLoader jcl = getVerifierContext().getClassLoader(); 60 Class ejbClass = Class.forName(descriptor.getEjbClassName(), false, jcl); 61 62 String methodName = method.getName().replaceFirst(method.getName().substring(0,1), 64 method.getName().substring(0,1).toUpperCase()); 65 String expectedMethodName = "ejbHome" + methodName; 66 do { 67 m = getMethod(ejbClass, expectedMethodName, method.getParameterTypes()); 69 } while (((ejbClass = ejbClass.getSuperclass()) != null) && (m==null)); 70 71 if (m != null) { 72 int modifiers = m.getModifiers(); 73 if (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers)) { 74 addGoodDetails(result, compName); 75 result.addGoodDetails(smh.getLocalString 76 (getClass().getName() + ".passed", 77 "For method [ {1} ] in Home Interface [ {0} ], ejbHome method is public and not static", 78 new Object [] {method.getDeclaringClass().getName(), method.getName()})); 79 result.setStatus(Result.PASSED); 80 } else { 82 addErrorDetails(result, compName); 83 result.addErrorDetails(smh.getLocalString 84 (getClass().getName() + ".notApplicable", 85 "Error : For method [ {1} ] defined in Home Interface [ {0} ], the ejbHome method is either static or not public", 86 new Object [] {method.getDeclaringClass().getName(), method.getName()})); 87 result.setStatus(Result.FAILED); 88 } 90 } else { 91 addErrorDetails(result, compName); 92 result.addErrorDetails(smh.getLocalString 93 (getClass().getName() + ".failed", 94 "Error : For method [ {1} ] defined in Home Interface [ {0} ], no ejbHome name matching method was found" , 95 new Object [] {method.getDeclaringClass().getName(), method.getName()})); 96 result.setStatus(Result.FAILED); 97 } 99 } catch (ClassNotFoundException e) { 100 Verifier.debug(e); 101 addErrorDetails(result, compName); 102 result.failed(smh.getLocalString( 103 getClass().getName() + ".failedException", 104 "Error: Home interface [ {0} ] does not exist or is not loadable within bean [ {1} ]", 105 new Object [] {getClassName(descriptor),descriptor.getName()})); 106 result.setStatus(Result.FAILED); 108 } 109 } 110 111 private String getClassName(EjbDescriptor descriptor) { 112 return getHomeInterfaceName(descriptor); 113 } 114 } 115 | Popular Tags |