1 23 package com.sun.enterprise.tools.verifier.tests.ejb.intf; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import com.sun.enterprise.deployment.EjbDescriptor; 27 import com.sun.enterprise.deployment.EjbSessionDescriptor; 28 import com.sun.enterprise.deployment.EjbEntityDescriptor; 29 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 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 34 import java.lang.ClassLoader ; 35 36 40 abstract public class InterfaceClassExist extends EjbTest implements EjbCheck { 41 42 43 47 abstract protected String getInterfaceName(EjbDescriptor descriptor); 48 abstract protected String getInterfaceType(); 49 50 57 public Result check(EjbDescriptor descriptor) { 58 59 Result result = getInitializedResult(); 60 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 61 62 if (!(descriptor instanceof EjbSessionDescriptor) && 63 !(descriptor instanceof EjbEntityDescriptor)) { 64 addNaDetails(result, compName); 65 result.notApplicable(smh.getLocalString 66 ("com.sun.enterprise.tools.verifier.tests.ejb.intf.InterfaceClassExist.notApplicable1", 67 "Test apply only to session or entity beans.")); 68 return result; 69 } 70 71 if(getInterfaceName(descriptor) == null || "".equals(getInterfaceName(descriptor))){ 72 addNaDetails(result, compName); 73 result.notApplicable(smh.getLocalString 74 ("com.sun.enterprise.tools.verifier.tests.ejb.intf.InterfaceClassExist.notApplicable2", 75 "Not Applicable because, EJB [ {0} ] does not have {1} Interface.", 76 new Object [] {descriptor.getEjbClassName(), getInterfaceType()})); 77 return result; 78 } 79 80 try { 82 ClassLoader jcl = getVerifierContext().getClassLoader(); 83 Class c = Class.forName(getClassName(descriptor), false, jcl); 84 if(!c.isInterface()) { 85 addErrorDetails(result, compName); 86 result.failed(smh.getLocalString 87 ("com.sun.enterprise.tools.verifier.tests.ejb.intf.InterfaceClassExist.failed", 88 "[ {0} ] is defined as a class. It should be an interface.", 89 new Object [] {getClassName(descriptor)})); 90 } 91 } catch (ClassNotFoundException e) { 92 Verifier.debug(e); 93 addErrorDetails(result, compName); 94 result.failed(smh.getLocalString 95 (getClass().getName() + ".failed", 96 "Error: "+ getInterfaceType() +" interface [ {0} ] does not exist or is not loadable.", 97 new Object [] {getClassName(descriptor)})); 98 } 99 if(result.getStatus() != Result.FAILED) { 100 addGoodDetails(result, compName); 101 result.passed(smh.getLocalString 102 (getClass().getName() + ".passed", 103 getInterfaceType() + " interface [ {0} ] exist and is loadable.", 104 new Object [] {getClassName(descriptor)})); 105 } 106 return result; 107 } 108 109 private String getClassName(EjbDescriptor descriptor) { 110 return getInterfaceName(descriptor); 111 } 112 } 113 | Popular Tags |