1 23 package com.sun.enterprise.tools.verifier.tests.ejb; 24 25 import java.lang.reflect.Method ; 26 import java.util.Set ; 27 28 import com.sun.enterprise.deployment.EjbDescriptor; 29 import com.sun.enterprise.deployment.EjbEntityDescriptor; 30 import com.sun.enterprise.deployment.EjbSessionDescriptor; 31 import com.sun.enterprise.tools.verifier.Result; 32 import com.sun.enterprise.tools.verifier.Verifier; 33 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 34 35 36 48 public class ApplicationExceptionComponentInterfaceMethods extends EjbTest implements EjbCheck { 49 50 Result result = null; 51 ComponentNameConstructor compName = null; 52 68 public Result check(EjbDescriptor descriptor) { 69 result = getInitializedResult(); 70 compName = getVerifierContext().getComponentNameConstructor(); 71 72 if ((descriptor instanceof EjbSessionDescriptor) || 73 (descriptor instanceof EjbEntityDescriptor)) { 74 75 if(descriptor.getRemoteClassName() != null) 76 commonToBothInterfaces(descriptor.getRemoteClassName(),descriptor); 77 if(descriptor.getLocalClassName() != null) 78 commonToBothInterfaces(descriptor.getLocalClassName(),descriptor); 79 Set <String > localAndRemoteInterfaces = descriptor.getLocalBusinessClassNames(); 81 localAndRemoteInterfaces.addAll(descriptor.getRemoteBusinessClassNames()); 82 83 for (String localOrRemoteIntf : localAndRemoteInterfaces) 84 commonToBothInterfaces(localOrRemoteIntf, descriptor); 85 } 86 if(result.getStatus() != Result.FAILED) { 87 addGoodDetails(result, compName); 88 result.passed(smh.getLocalString 89 (getClass().getName() + ".passed", 90 "All the business methods are defined properly")); 91 } 92 return result; 93 } 94 95 101 102 private void commonToBothInterfaces(String remote, EjbDescriptor descriptor) { 103 try { 104 Class c = Class.forName(remote, false, getVerifierContext().getClassLoader()); 105 Class [] methodExceptionTypes; 106 for(Method methods : c.getDeclaredMethods()) { 107 methodExceptionTypes = methods.getExceptionTypes(); 108 if (!(EjbUtils.isValidApplicationException(methodExceptionTypes))) { 110 addErrorDetails(result, compName); 111 result.failed(smh.getLocalString 112 (getClass().getName() + ".failed", 113 "For the Interface [ {0} ] Method [ {1} ] does not throw " + 114 "valid application exceptions", 115 new Object [] {remote, methods.getName()})); 116 117 } 118 } 120 } catch (Exception e) { 121 Verifier.debug(e); 122 addErrorDetails(result, compName); 123 result.failed(smh.getLocalString 124 (getClass().getName() + ".failedException", 125 "Error: Remote interface [ {0} ] does not exist or is not " + 126 "loadable within bean [ {1} ]", 127 new Object [] {remote, descriptor.getName()})); 128 } 129 } 130 } 131 | Popular Tags |