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