1 23 package com.sun.enterprise.tools.verifier.tests.ejb.entity; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import java.util.logging.Level ; 27 28 import com.sun.enterprise.tools.verifier.tests.*; 29 import com.sun.enterprise.deployment.*; 30 import com.sun.enterprise.tools.verifier.*; 31 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 32 33 41 public class EjbClassImplementsComponentInterface extends EjbTest implements EjbCheck { 42 Result result = null; 43 ComponentNameConstructor compName = null; 44 56 public Result check(EjbDescriptor descriptor) { 57 58 result = getInitializedResult(); 59 compName = getVerifierContext().getComponentNameConstructor(); 60 61 if (descriptor instanceof EjbEntityDescriptor) { 62 if(descriptor.getRemoteClassName() != null && !"".equals(descriptor.getRemoteClassName())) 63 commonToBothInterfaces(descriptor.getRemoteClassName(),(EjbEntityDescriptor)descriptor); 64 if(descriptor.getLocalClassName() != null && !"".equals(descriptor.getLocalClassName())) 65 commonToBothInterfaces(descriptor.getLocalClassName(),(EjbEntityDescriptor)descriptor); 66 67 return result; 68 69 } else { 70 result.addNaDetails(smh.getLocalString 71 ("tests.componentNameConstructor", 72 "For [ {0} ]", 73 new Object [] {compName.toString()})); 74 result.notApplicable(smh.getLocalString 75 (getClass().getName() + ".notApplicable", 76 "[ {0} ] expected {1} bean, but called with {2} bean.", 77 new Object [] {getClass(),"Entity","Session"})); 78 return result; 79 } 80 } 81 82 private void commonToBothInterfaces(String component, EjbDescriptor descriptor) { 83 try { 84 Class c = Class.forName(descriptor.getEjbClassName(), false, getVerifierContext().getClassLoader()); 85 Class rc = Class.forName(component, false, getVerifierContext().getClassLoader()); 86 boolean foundOne = false; 87 do { 89 Class [] interfaces = c.getInterfaces(); 90 91 for (int i = 0; i < interfaces.length; i++) { 92 logger.log(Level.FINE, getClass().getName() + ".debug1", 93 new Object [] {interfaces[i].getName()}); 94 95 if (interfaces[i].getName().equals(rc.getName()) && 96 descriptor instanceof EjbEntityDescriptor) { 97 result.addWarningDetails(smh.getLocalString 99 ("tests.componentNameConstructor", 100 "For [ {0} ]", 101 new Object [] {compName.toString()})); 102 result.warning(smh.getLocalString 103 (getClass().getName() + ".warning", 104 "Warning: [ {0} ] class implments the enterprise Bean's remote interface [ {1} ]. It is recommended that the enterprise bean class not implement the remote interface to prevent inadvertent passing of this as a method argument or result. The class must provide no-op implementations of the methods defined in the javax.ejb.EJBObject interface.", 105 new Object [] {descriptor.getEjbClassName(),rc.getName()})); 106 foundOne = true; 107 break; 108 } 109 } 110 } while ((c=c.getSuperclass()) != null); 111 112 if (!foundOne) { 113 result.addNaDetails(smh.getLocalString 115 ("tests.componentNameConstructor", 116 "For [ {0} ]", 117 new Object [] {compName.toString()})); 118 result.notApplicable(smh.getLocalString 119 (getClass().getName() + ".notApplicable2", 120 "[ {0} ] does not optionally implement bean class remote interface [ {1} ]", 121 new Object [] {descriptor.getEjbClassName(),rc.getName()})); 122 } else { 123 127 } 131 } catch (ClassNotFoundException e) { 132 Verifier.debug(e); 133 result.addErrorDetails(smh.getLocalString 134 ("tests.componentNameConstructor", 135 "For [ {0} ]", 136 new Object [] {compName.toString()})); 137 result.failed(smh.getLocalString 138 (getClass().getName() + ".failedException", 139 "Error: [ {0} ] class not found.", 140 new Object [] {descriptor.getEjbClassName()})); 141 } 142 } 143 } 144 | Popular Tags |