1 23 package com.sun.enterprise.tools.verifier.tests.ejb.intf.localintf; 24 25 import com.sun.enterprise.tools.verifier.Result; 26 import com.sun.enterprise.tools.verifier.Verifier; 27 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 28 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 29 import com.sun.enterprise.deployment.EjbDescriptor; 30 31 import java.lang.reflect.Method ; 32 33 40 public class LocalInterfaceRemoteException extends EjbTest { 41 42 public Result check(EjbDescriptor descriptor) { 43 Result result = getInitializedResult(); 44 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 45 ClassLoader cl = getVerifierContext().getClassLoader(); 46 String localClassName = descriptor.getLocalHomeClassName(); 47 if (localClassName!=null) { 48 try { 49 Class localHome = Class.forName(localClassName, false, cl); 50 Method [] methods = localHome.getMethods(); 51 for (int i = 0; i < methods.length; i++) { 52 if(containsRemote(methods[i].getExceptionTypes())) { 53 addErrorDetails(result, compName); 54 result.failed(smh.getLocalString 55 (getClass().getName()+".failed", 56 "Method [ {0} ] throws a RemoteException.", 57 new Object []{methods[i]})); 58 } 59 60 } 61 } catch (ClassNotFoundException e) { 62 Verifier.debug(e); 63 addErrorDetails(result, compName); 64 result.failed(smh.getLocalString 65 (getClass().getName()+".failed1", 66 "LocalHome class [ {0} ] not found.", 67 new Object []{localClassName})); 68 } 69 } 70 71 if(result.getStatus() != Result.FAILED) { 72 addGoodDetails(result, compName); 73 result.passed(smh.getLocalString 74 (getClass().getName() + ".passed", 75 "Valid LocalInterface.")); 76 } 77 return result; 78 } 79 80 81 private boolean containsRemote(Class [] exceptions) { 82 for (int i = 0; i < exceptions.length; i++) 83 if(exceptions[i].getName().equals("java.rmi.RemoteException")) 84 return true; 85 86 return false; 87 } 88 } | Popular Tags |