1 23 package com.sun.enterprise.tools.verifier.tests.ejb.homeintf.remotehomeintf; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import java.lang.ClassLoader ; 27 import java.util.logging.Level ; 28 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 29 import com.sun.enterprise.tools.verifier.tests.ejb.RmiIIOPUtils; 30 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 31 import com.sun.enterprise.tools.verifier.Result; 32 import com.sun.enterprise.tools.verifier.Verifier; 33 import com.sun.enterprise.deployment.EjbDescriptor; 34 import com.sun.enterprise.deployment.EjbSessionDescriptor; 35 import com.sun.enterprise.deployment.EjbEntityDescriptor; 36 37 47 public class RemoteHomeInterfaceSuperInterface extends EjbTest implements EjbCheck { 48 49 62 public Result check(EjbDescriptor descriptor) { 63 64 Result result = getInitializedResult(); 65 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 66 67 if(descriptor.getHomeClassName() == null || "".equals(descriptor.getHomeClassName())){ 68 addNaDetails(result, compName); 69 result.notApplicable(smh.getLocalString 70 ("com.sun.enterprise.tools.verifier.tests.ejb.localinterfaceonly.notapp", 71 "Not Applicable because, EJB [ {0} ] has Local Interfaces only.", 72 new Object [] {descriptor.getEjbClassName()})); 73 return result; 74 } 75 76 if ((descriptor instanceof EjbSessionDescriptor) || 77 (descriptor instanceof EjbEntityDescriptor)) { 78 79 boolean oneFailed = false; 80 boolean ok = false; 81 try { 82 ClassLoader jcl = getVerifierContext().getClassLoader(); 83 Class c = Class.forName(descriptor.getHomeClassName(), false, jcl); 84 Class remote = c; 85 boolean validHomeInterface = false; 86 do { 88 Class [] interfaces = c.getInterfaces(); 89 if ( interfaces.length == 0 ) { 90 ok = true; 91 } 92 for (Class intf: interfaces) { 93 logger.log(Level.FINE, getClass().getName() + ".debug1", 94 new Object [] {intf.getName()}); 95 96 if (!ok) { 99 ok = RmiIIOPUtils.isValidRmiIIOPInterface(intf); 100 } 101 102 if (RmiIIOPUtils.isValidRmiIIOPInterfaceMethods(intf)) { 103 if (intf.getName().equals("javax.ejb.EJBHome")) { 105 validHomeInterface = true; 106 break; 107 } 108 } else { 109 oneFailed = true; 112 addErrorDetails(result, compName); 113 result.addErrorDetails(smh.getLocalString 114 (getClass().getName() + ".failed", 115 "Error: [ {0} ] does not properly conform to " + 116 "rules of RMI-IIOP for superinterfaces. All " + 117 "enterprise beans home interfaces are allowed " + 118 "to have superinterfaces that conform to the " + 119 "rules of RMI-IIOP for superinterfaces . [ {1} ] " + 120 "is not a valid home interface.", 121 new Object [] {intf.getName(),descriptor.getHomeClassName()})); 122 } 123 } 124 } while ((((c=c.getSuperclass()) != null) && (!validHomeInterface))); 125 if ( !ok ) { 127 oneFailed = true; 128 addErrorDetails(result, compName); 129 result.addErrorDetails(smh.getLocalString 130 (getClass().getName() + ".failed", 131 "Error: [ {0} ] does not properly conform to rules of " + 132 "RMI-IIOP for superinterfaces. All enterprise beans " + 133 "home interfaces are allowed to have superinterfaces " + 134 "that conform to the rules of RMI-IIOP for superinterfaces . " + 135 " [{1} ] is not a valid home interface.", 136 new Object [] {remote.getName(),descriptor.getHomeClassName()})); 137 } 138 139 140 if (validHomeInterface) { 142 addGoodDetails(result, compName); 143 result.addGoodDetails(smh.getLocalString 144 (getClass().getName() + ".passed", 145 "[ {0} ] properly conforms to rules of RMI-IIOP for superinterfaces.", 146 new Object [] {descriptor.getHomeClassName()})); 147 } 148 149 } catch (ClassNotFoundException e) { 150 Verifier.debug(e); 151 addErrorDetails(result, compName); 152 result.failed(smh.getLocalString 153 (getClass().getName() + ".failedException", 154 "Error: Home interface [ {0} ] does not exist or is not " + 155 "loadable within bean [ {1} ]", 156 new Object [] {descriptor.getHomeClassName(), descriptor.getName()})); 157 oneFailed = true; 158 } 159 if (oneFailed) { 160 result.setStatus(Result.FAILED); 161 } else { 162 result.setStatus(Result.PASSED); 163 } 164 return result; 165 166 } else { 167 addNaDetails(result, compName); 168 result.notApplicable(smh.getLocalString 169 (getClass().getName() + ".notApplicable", 170 "{0} expected {1} bean or {2} bean, but called with {3}.", 171 new Object [] {getClass(),"Session","Entity",descriptor.getName()})); 172 return result; 173 } 174 } 175 } 176 | Popular Tags |