1 23 package com.sun.enterprise.tools.verifier.tests.ejb.businessmethod; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import java.lang.reflect.*; 27 import java.util.Set ; 28 29 import com.sun.enterprise.deployment.*; 30 import com.sun.enterprise.tools.verifier.*; 31 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 32 import com.sun.enterprise.tools.verifier.tests.*; 33 34 43 public class BusinessMethodName extends EjbTest implements EjbCheck { 44 45 46 Result result = null; 47 ComponentNameConstructor compName = null; 48 49 61 public Result check(EjbDescriptor descriptor) { 62 63 result = getInitializedResult(); 64 compName = getVerifierContext().getComponentNameConstructor(); 65 66 if ((descriptor instanceof EjbSessionDescriptor) || 67 (descriptor instanceof EjbEntityDescriptor)) { 68 69 if(descriptor.getRemoteClassName() != null && !"".equals(descriptor.getRemoteClassName())) 70 commonToBothInterfaces(descriptor.getRemoteClassName(),descriptor); 71 if(descriptor.getLocalClassName() != null && !"".equals(descriptor.getLocalClassName())) 72 commonToBothInterfaces(descriptor.getLocalClassName(),descriptor); 73 Set <String > localAndRemoteInterfaces = descriptor.getLocalBusinessClassNames(); 74 localAndRemoteInterfaces.addAll(descriptor.getRemoteBusinessClassNames()); 75 76 for (String localOrRemoteIntf : localAndRemoteInterfaces) { 77 commonToBothInterfaces(localOrRemoteIntf, descriptor); 78 } 79 } 80 if(result.getStatus() != Result.FAILED) { 81 addGoodDetails(result, compName); 82 result.passed(smh.getLocalString 83 (getClass().getName() + ".passed", 84 "Proper declaration of business method(s) found.")); 85 } 86 return result; 87 } 88 89 97 98 private void commonToBothInterfaces(String intf,EjbDescriptor descriptor) { 99 try { 100 Class intfClass = Class.forName(intf, false, getVerifierContext().getClassLoader()); 101 102 for (Method remoteMethod : intfClass.getMethods()) { 103 104 if (remoteMethod.getDeclaringClass().getName().equals("javax.ejb.EJBObject")) 106 continue; 107 108 Class beanClass = Class.forName(descriptor.getEjbClassName(), 109 false, 110 getVerifierContext().getClassLoader()); 111 for (Method method : beanClass.getMethods()) { 112 if (method.getName().equals(remoteMethod.getName())) { 113 114 if (method.getName().startsWith("ejb") || 118 method.getName().equals("class$") || 119 method.getName().equals("setSessionContext")) { 120 121 addErrorDetails(result, compName); 122 result.failed(smh.getLocalString 123 (getClass().getName() + ".failed", 124 "Error: Business method [ {0} ] was " + 125 "found, but was not properly named. " + 126 "[ {1} ] must not conflict with the " + 127 "names of the methods defined by the " + 128 "EJB architecture", 129 new Object [] {method.getName(),method.getName()})); 130 } 131 } 132 } 133 } 134 135 } catch (ClassNotFoundException e) { 136 Verifier.debug(e); 137 addErrorDetails(result, compName); 138 result.failed(smh.getLocalString 139 (getClass().getName() + ".failedException", 140 "Error: Remote interface [ {0} ] or bean class [ {1} ] " + 141 "does not exist or is not loadable within bean [ {2} ].", 142 new Object [] {intf,descriptor.getEjbClassName(),descriptor.getName()})); 143 } 144 } 145 } 146 | Popular Tags |