1 21 package com.sun.enterprise.tools.verifier.tests.ejb.ejb30; 22 23 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 24 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 25 import com.sun.enterprise.tools.verifier.Result; 26 import com.sun.enterprise.deployment.EjbDescriptor; 27 28 import javax.ejb.Remote ; 29 import javax.ejb.Local ; 30 import java.util.Set ; 31 32 38 public class BusinessIntfAnnotationValue extends EjbTest { 39 40 private Result result; 41 private ComponentNameConstructor compName; 42 private Class <Remote > remoteAnn = Remote .class; 43 private Class <Local > localAnn = Local .class; 44 45 public Result check(EjbDescriptor descriptor) { 46 result = getInitializedResult(); 47 compName = getVerifierContext().getComponentNameConstructor(); 48 49 testInterfaces(descriptor.getLocalBusinessClassNames(), remoteAnn); 50 testInterfaces(descriptor.getRemoteBusinessClassNames(), localAnn); 51 52 if(result.getStatus() != Result.FAILED) { 53 addGoodDetails(result, compName); 54 result.passed(smh.getLocalString 55 (getClass().getName() + ".passed", 56 "Valid annotations used in business interface(s).")); 57 } 58 return result; 59 } 60 61 private void testInterfaces(Set <String > interfaces, Class annot) { 62 Class cls = (annot.equals(localAnn))? remoteAnn : localAnn; 64 65 for (String intf : interfaces) { 66 try { 67 Class intfCls = Class.forName(intf, 68 false, 69 getVerifierContext().getClassLoader()); 70 if(intfCls.getAnnotation(annot)!=null) { 71 addErrorDetails(result, compName); 72 result.failed(smh.getLocalString 73 (getClass().getName() + ".failed", 74 "{0} annotation is used in {1} interface [ {2} ].", 75 new Object []{annot.getSimpleName(), 76 cls.getSimpleName(), 77 intfCls.getName()})); 78 } 79 } catch (ClassNotFoundException e) { 80 } 82 } 83 } 84 } 85 | Popular Tags |