1 23 package com.sun.enterprise.tools.verifier.tests.ejb.session; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import java.lang.ClassLoader ; 27 import java.util.logging.Level ; 28 29 import com.sun.enterprise.tools.verifier.tests.*; 30 import javax.ejb.SessionBean ; 31 import com.sun.enterprise.deployment.EjbDescriptor; 32 import com.sun.enterprise.deployment.EjbSessionDescriptor; 33 import com.sun.enterprise.tools.verifier.*; 34 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 35 36 41 public class SessionBeanInterface extends EjbTest implements EjbCheck { 42 43 52 public Result check(EjbDescriptor descriptor) { 53 54 Result result = getInitializedResult(); 55 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 56 57 if (descriptor instanceof EjbSessionDescriptor) { 58 try { 59 Context context = getVerifierContext(); 60 ClassLoader jcl = context.getClassLoader(); 61 Class c = Class.forName(descriptor.getEjbClassName(), false, getVerifierContext().getClassLoader()); 62 63 boolean validBean = false; 64 do { 66 Class [] interfaces = c.getInterfaces(); 67 68 for (int i = 0; i < interfaces.length; i++) { 69 logger.log(Level.FINE, getClass().getName() + ".debug1", 70 new Object [] {interfaces[i].getName()}); 71 if (interfaces[i].getName().equals("javax.ejb.SessionBean") && 72 descriptor instanceof EjbSessionDescriptor) { 73 validBean = true; 74 result.addGoodDetails(smh.getLocalString 75 ("tests.componentNameConstructor", 76 "For [ {0} ]", 77 new Object [] {compName.toString()})); 78 result.passed(smh.getLocalString 79 (getClass().getName() + ".passed", 80 "[ {0} ] properly implements the SessionBean interface.", 81 new Object [] {descriptor.getEjbClassName()})); 82 break; 83 } 84 } 85 } while ((((c=c.getSuperclass()) != null) && (!validBean))); 86 87 if (!validBean) { 88 result.addErrorDetails(smh.getLocalString 89 ("tests.componentNameConstructor", 90 "For [ {0} ]", 91 new Object [] {compName.toString()})); 92 result.failed(smh.getLocalString 93 (getClass().getName() + ".failed", 94 "Error: [ {0} ] does not properly implement the SessionBean interface. All session Beans must implement the SessionBean interface. [ {1} ] is not a valid bean.", 95 new Object [] {descriptor.getEjbClassName(),descriptor.getEjbClassName()})); 96 } 97 } catch (ClassNotFoundException e) { 98 Verifier.debug(e); 99 result.addErrorDetails(smh.getLocalString 100 ("tests.componentNameConstructor", 101 "For [ {0} ]", 102 new Object [] {compName.toString()})); 103 result.failed(smh.getLocalString 104 (getClass().getName() + ".failedException", 105 "Error: [ {0} ] class not found.", 106 new Object [] {descriptor.getEjbClassName()})); 107 } 108 return result; 109 110 } else { 111 result.addNaDetails(smh.getLocalString 112 ("tests.componentNameConstructor", 113 "For [ {0} ]", 114 new Object [] {compName.toString()})); 115 result.notApplicable(smh.getLocalString 116 (getClass().getName() + ".notApplicable", 117 "[ {0} ] expected {1} bean, but called with {2} bean.", 118 new Object [] {getClass(),"Session","Entity"})); 119 return result; 120 } 121 } 122 } 123 | Popular Tags |