1 23 package com.sun.enterprise.tools.verifier.tests.ejb.session; 24 25 import java.lang.reflect.Method ; 26 27 import com.sun.enterprise.deployment.EjbDescriptor; 28 import com.sun.enterprise.deployment.EjbSessionDescriptor; 29 import com.sun.enterprise.tools.verifier.Result; 30 import com.sun.enterprise.tools.verifier.Verifier; 31 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 32 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 33 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 34 35 45 public class HomeInterfaceNoFinderMethodNames extends EjbTest implements EjbCheck { 46 Result result = null; 47 ComponentNameConstructor compName = null; 48 49 63 public Result check(EjbDescriptor descriptor) { 64 65 result = getInitializedResult(); 66 compName = getVerifierContext().getComponentNameConstructor(); 67 68 if (descriptor instanceof EjbSessionDescriptor) { 69 if(descriptor.getHomeClassName() != null && !"".equals(descriptor.getHomeClassName())) 72 commonToBothInterfaces(descriptor.getHomeClassName(),(EjbSessionDescriptor)descriptor); 73 if(descriptor.getLocalHomeClassName() != null && !"".equals(descriptor.getLocalHomeClassName())) 74 commonToBothInterfaces(descriptor.getLocalHomeClassName(),(EjbSessionDescriptor)descriptor); 75 } 76 if(result.getStatus() != Result.FAILED) { 77 addGoodDetails(result, compName); 78 result.passed(smh.getLocalString 79 (getClass().getName() + ".passed", 80 "Valid: no finder methods were found. Session bean's home interface" + 81 " is not allowed to have any finder methods.")); 82 } 83 return result; 84 } 85 86 91 92 private void commonToBothInterfaces(String home, EjbSessionDescriptor descriptor) { 93 try { 94 Class c = Class.forName(home, 95 false, 96 getVerifierContext().getClassLoader()); 97 for(Method methods : c.getDeclaredMethods()) { 98 if(methods.getName().startsWith("find")) { 99 addErrorDetails(result, compName); 100 result.failed(smh.getLocalString 101 (getClass().getName() + ".debug1", 102 "For Home Interface [ {0} ] Method [ {1} ]", 103 new Object [] {c.getName(),methods.getName()})); 104 result.addErrorDetails(smh.getLocalString 105 (getClass().getName() + ".failed", 106 "Improperly named method [ {0} ] was found. Session bean's home interface is not allowed to have any finder methods.", 107 new Object [] {methods.getName()})); 108 } 109 } 110 111 } catch (ClassNotFoundException e) { 112 Verifier.debug(e); 113 addErrorDetails(result, compName); 114 result.failed(smh.getLocalString 115 (getClass().getName() + ".failedException", 116 "Error: Home interface [ {0} ] does not exist or is not loadable within bean [ {1} ]", 117 new Object [] {home, descriptor.getName()})); 118 } 119 } 120 } 121 | Popular Tags |