1 23 24 package com.sun.enterprise.tools.verifier.tests.ejb.ejb30; 25 26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 27 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 28 import com.sun.enterprise.tools.verifier.Result; 29 import com.sun.enterprise.tools.verifier.Verifier; 30 import com.sun.enterprise.deployment.EjbDescriptor; 31 32 import java.lang.reflect.Method ; 33 import java.util.Set ; 34 35 46 public class BusinessInterfaceException extends EjbTest { 47 48 public Result check(EjbDescriptor descriptor) { 49 Result result = getInitializedResult(); 50 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 51 52 Set <String > localAndRemoteClassNames = descriptor.getLocalBusinessClassNames(); 53 localAndRemoteClassNames.addAll(descriptor.getRemoteBusinessClassNames()); 54 55 for (String localOrRemoteClass : localAndRemoteClassNames) 56 checkForRemoteException(localOrRemoteClass,result,compName); 57 58 if(result.getStatus() != Result.WARNING) { 59 addGoodDetails(result, compName); 60 result.passed(smh.getLocalString 61 (getClass().getName() + ".passed", 62 "Business interface(s) if any are valid.")); 63 } 64 return result; 65 } 66 67 private void checkForRemoteException(String className, 68 Result result, 69 ComponentNameConstructor compName) { 70 try { 71 Class c = Class.forName(className, 72 false, 73 getVerifierContext().getClassLoader()); 74 if(java.rmi.Remote .class.isAssignableFrom(c)) 76 return; 77 Method [] methods = c.getMethods(); 78 for (Method method : methods) { 79 Class [] exceptions = method.getExceptionTypes(); 80 for (Class exception : exceptions) { 81 if(java.rmi.RemoteException .class.isAssignableFrom(exception)) { 82 addWarningDetails(result, compName); 83 result.warning(smh.getLocalString 84 (getClass().getName() + ".warning", 85 "java.rmi.RemoteException is thrown " + 86 "in method [ {0} ] of business interface [ {1} ]", 87 new Object [] {method.getName(), className})); 88 } 89 } 90 } 91 } catch (ClassNotFoundException e) { 92 Verifier.debug(e); 93 addErrorDetails(result, compName); 94 result.failed(smh.getLocalString 95 (getClass().getName() + ".failed1", 96 "[ {0} ] not found.", 97 new Object [] {className})); 98 } 99 } 100 } 101 | Popular Tags |