1 23 package com.sun.enterprise.tools.verifier.tests.ejb.beanclass; 24 25 26 import com.sun.enterprise.deployment.*; 27 import com.sun.enterprise.tools.verifier.*; 28 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 29 import java.lang.reflect.Method ; 30 import com.sun.enterprise.tools.verifier.tests.*; 31 32 37 public class EjbClassExposed extends EjbTest { 38 39 Result result = null; 40 ComponentNameConstructor compName = null; 41 47 public Result check(EjbDescriptor descriptor) { 48 49 result = getInitializedResult(); 50 compName = getVerifierContext().getComponentNameConstructor(); 51 52 if (descriptor instanceof EjbSessionDescriptor || 53 descriptor instanceof EjbEntityDescriptor) { 54 if (descriptor.getRemoteClassName() != null && 55 !((descriptor.getRemoteClassName()).equals(""))) 56 commonToBothInterfaces(descriptor.getRemoteClassName(),descriptor); 57 if (descriptor.getLocalClassName() != null && 58 !((descriptor.getLocalClassName()).equals(""))) 59 commonToBothInterfaces(descriptor.getLocalClassName(),descriptor); 60 } 61 62 if(result.getStatus() != Result.FAILED) { 63 addGoodDetails(result, compName); 64 result.passed(smh.getLocalString( 65 getClass().getName() + ".passed", 66 "Ejb Bean Class [{0}] is valid.", 67 new Object [] {descriptor.getEjbClassName()})); 68 } 69 return result; 70 71 } 72 73 79 80 private void commonToBothInterfaces(String remote, EjbDescriptor descriptor) { 81 try { 82 Class c = Class.forName(remote, 83 false, 84 getVerifierContext().getClassLoader()); 85 86 for (Method method : c.getDeclaredMethods()) { 87 String ejbClassName = descriptor.getEjbClassName(); 88 if(((method.getReturnType()).getName()).equals(ejbClassName)) { 89 addErrorDetails(result, compName); 90 result.failed(smh.getLocalString( 91 getClass().getName() + ".failed", 92 "Error: Ejb Bean Class [{0}] is exposed through interface [{1}]", 93 new Object [] {ejbClassName, remote})); 94 } 95 } 96 }catch (ClassNotFoundException e) { 97 addErrorDetails(result, compName); 98 result.failed(smh.getLocalString( 99 getClass().getName() + ".failedException", 100 "Error: interface class [{0}] not found", 101 new Object [] {remote})); 102 } 103 } 104 } 105 | Popular Tags |