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 41 public class BusinessMethodStatic extends EjbTest implements EjbCheck { 42 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 70 Set <String > localAndRemoteInterfaces = descriptor.getLocalBusinessClassNames(); 71 localAndRemoteInterfaces.addAll(descriptor.getRemoteBusinessClassNames()); 72 73 for (String localOrRemoteIntf : localAndRemoteInterfaces) 74 commonToBothInterfaces(localOrRemoteIntf, descriptor); 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 92 private void commonToBothInterfaces(String intf, EjbDescriptor descriptor) { 93 try { 94 Class intfClass = Class.forName(intf, false, getVerifierContext().getClassLoader()); 95 96 for (Method remoteMethod : intfClass.getMethods()) { 97 98 if (remoteMethod.getDeclaringClass().getName().equals("javax.ejb.EJBObject")|| 100 remoteMethod.getDeclaringClass().getName().equals("javax.ejb.EJBLocalObject")) 101 continue; 102 103 Class beanClass = Class.forName(descriptor.getEjbClassName(), 104 false, 105 getVerifierContext().getClassLoader()); 106 for (Method method : beanClass.getMethods()) { 107 if (method.getName().equals(remoteMethod.getName()) && 108 Modifier.isStatic(method.getModifiers())) { 109 addErrorDetails(result, compName); 111 result.failed(smh.getLocalString 112 (getClass().getName() + ".failed", 113 "Error: static business method [ {0} ] was found, " + 114 "but business method cannot be declared as static.", 115 new Object [] {method.getName()})); 116 } 117 } 118 } 119 120 } catch (ClassNotFoundException e) { 121 Verifier.debug(e); 122 addErrorDetails(result, compName); 123 result.failed(smh.getLocalString 124 (getClass().getName() + ".failedException", 125 "Error: Remote interface [ {0} ] or bean class [ {1} ] does " + 126 "not exist or is not loadable within bean [ {2} ].", 127 new Object [] {intf,descriptor.getEjbClassName(),descriptor.getName()})); 128 } 129 } 130 } 131 | Popular Tags |