1 23 package com.sun.enterprise.tools.verifier.tests.ejb.session.stateless; 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 java.lang.ClassLoader ; 29 import com.sun.enterprise.tools.verifier.tests.*; 30 import java.lang.reflect.*; 31 import com.sun.enterprise.tools.verifier.*; 32 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 33 34 37 public class StatelessCreateNoArgs extends EjbTest implements EjbCheck { 38 Result result = null; 39 ComponentNameConstructor compName = null; 40 41 48 public Result check(EjbDescriptor descriptor) { 49 50 result = getInitializedResult(); 51 compName = getVerifierContext().getComponentNameConstructor(); 52 53 if (descriptor instanceof EjbSessionDescriptor) { 54 String stateType = ((EjbSessionDescriptor)descriptor).getSessionType(); 55 if (EjbSessionDescriptor.STATELESS.equals(stateType)) { 56 if(descriptor.getHomeClassName() != null && !"".equals(descriptor.getHomeClassName())) 59 commonToBothInterfaces(descriptor.getHomeClassName(),(EjbSessionDescriptor)descriptor); 60 if(descriptor.getLocalHomeClassName() != null && !"".equals(descriptor.getLocalHomeClassName())) 61 commonToBothInterfaces(descriptor.getLocalHomeClassName(),(EjbSessionDescriptor)descriptor); 62 } 63 } 64 if (result.getStatus()!=Result.FAILED) { 65 addGoodDetails(result, compName); 66 result.passed(smh.getLocalString 67 (getClass().getName() + ".passed", 68 "The bean's Home Interface properly defines one create Method with no args")); 69 } 70 return result; 71 } 72 73 79 80 81 private void commonToBothInterfaces(String home, EjbSessionDescriptor descriptor) { 82 try { 83 84 Class c = Class.forName(home, false, getVerifierContext().getClassLoader()); 85 Method m = null; 86 for(Method methods : c.getDeclaredMethods()) { 87 if (methods.getName().equals("create")) { 88 m = methods; 89 break; 90 } 91 } 92 if (m != null) { 94 Class cc[] = m.getParameterTypes(); 95 if (cc.length > 0) { 96 addErrorDetails(result, compName); 97 result.failed(smh.getLocalString 98 (getClass().getName() + ".failed", 99 "Error: The create method has one or more parameters \n" + 100 "within bean [ {0} ]. Stateless session are only allowed \n" + 101 "to have create methods with no arguments.", 102 new Object [] {home})); 103 } 104 } else { 105 addErrorDetails(result, compName); 108 result.failed(smh.getLocalString 109 (getClass().getName() + ".failed1", 110 "Error: No Create method exists within bean [ {0} ]", 111 new Object [] {home})); 112 } 113 } catch (ClassNotFoundException e) { 114 Verifier.debug(e); 115 addErrorDetails(result, compName); 116 result.failed(smh.getLocalString 117 (getClass().getName() + ".failedException", 118 "Error: Class [ {0} ] not found within bean [ {1} ]", 119 new Object [] {home, descriptor.getName()})); 120 } 121 } 122 } 123 | Popular Tags |