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.ejb.MethodUtils; 33 import com.sun.enterprise.tools.verifier.tests.*; 34 35 42 public class BusinessMethodPublic extends EjbTest implements EjbCheck { 43 Result result = null; 44 ComponentNameConstructor compName = null; 45 46 57 public Result check(EjbDescriptor descriptor) { 58 59 result = getInitializedResult(); 60 compName = getVerifierContext().getComponentNameConstructor(); 61 62 if ((descriptor instanceof EjbSessionDescriptor) || 63 (descriptor instanceof EjbEntityDescriptor)) { 64 65 if(descriptor.getRemoteClassName() != null && !"".equals(descriptor.getRemoteClassName())) 66 commonToBothInterfaces(descriptor.getRemoteClassName(),descriptor); 67 if(descriptor.getLocalClassName() != null && !"".equals(descriptor.getLocalClassName())) 68 commonToBothInterfaces(descriptor.getLocalClassName(),descriptor); 69 Set <String > localAndRemoteInterfaces = descriptor.getLocalBusinessClassNames(); 70 localAndRemoteInterfaces.addAll(descriptor.getRemoteBusinessClassNames()); 71 72 for (String localOrRemoteIntf : localAndRemoteInterfaces) { 73 commonToBothInterfaces(localOrRemoteIntf, descriptor); 74 } 75 } 76 if(result.getStatus() != Result.FAILED) { 77 addGoodDetails(result, compName); 78 result.passed(smh.getLocalString 79 (getClass().getName() + ".passed", 80 "Proper declaration of business method(s) found.")); 81 } 82 return result; 83 } 84 85 91 private void commonToBothInterfaces(String intf,EjbDescriptor descriptor) { 92 try { 93 Class intfClass = Class.forName(intf, false, getVerifierContext().getClassLoader()); 94 95 for (Method remoteMethod : intfClass.getMethods()) { 96 if (remoteMethod.getDeclaringClass().getName().equals("javax.ejb.EJBObject")|| 98 remoteMethod.getDeclaringClass().getName().equals("javax.ejb.EJBLocalObject")) 99 continue; 100 101 Class beanClass = Class.forName(descriptor.getEjbClassName(), 102 false, 103 getVerifierContext().getClassLoader()); 104 boolean foundOne = false; 105 for (Method method : beanClass.getMethods()) { if(MethodUtils.methodEquals(method, remoteMethod)) { 107 foundOne = true; 108 break; 109 } 110 } 111 if (!foundOne) { 112 String methodToString = remoteMethod.toString().replace("abstract ",""); 113 addErrorDetails(result, compName); 114 result.failed(smh.getLocalString 115 (getClass().getName() + ".failed", 116 "Error: public business method [ {0} ] not found in [ {1} ].", 117 new Object [] {methodToString, beanClass.getName()})); 118 } 119 } 120 121 } catch (ClassNotFoundException e) { 122 Verifier.debug(e); 123 addErrorDetails(result, compName); 124 result.failed(smh.getLocalString 125 (getClass().getName() + ".failedException", 126 "Error: Remote interface [ {0} ] or bean class [ {1} ] " + 127 "does not exist or is not loadable within bean [ {2} ].", 128 new Object [] {intf,descriptor.getEjbClassName(),descriptor.getName()})); 129 130 } 131 } 132 } 133 | Popular Tags |