1 23 24 25 package com.sun.enterprise.tools.verifier.tests.ejb.messagebean; 26 27 import com.sun.enterprise.tools.verifier.Result; 28 import com.sun.enterprise.tools.verifier.SpecVersionMapper; 29 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 30 import com.sun.enterprise.deployment.EjbMessageBeanDescriptor; 31 import com.sun.enterprise.deployment.EjbDescriptor; 32 import com.sun.enterprise.deployment.MethodDescriptor; 33 import com.sun.enterprise.deployment.ContainerTransaction; 34 35 import java.util.Collection ; 36 import java.util.Iterator ; 37 38 45 public class HasValidMethodDescriptor extends MessageBeanTest { 46 47 54 public Result check(EjbMessageBeanDescriptor descriptor) { 55 56 Result result = getInitializedResult(); 57 ComponentNameConstructor compName = 58 getVerifierContext().getComponentNameConstructor(); 59 60 if (descriptor.getTransactionType().equals 61 (EjbDescriptor.CONTAINER_TRANSACTION_TYPE)) { 62 63 Collection methods = descriptor.getTransactionMethodDescriptors(); 66 67 if (methods.size()==0) { 68 addNaDetails(result, compName); 69 result.notApplicable(smh.getLocalString 70 (getClass().getName()+".notApplicable1", 71 "Message-driven bean [ {0} ] does not define any method", 72 new Object [] {descriptor.getName()})); 73 return result; 74 } 75 76 Iterator iterator = methods.iterator(); 77 while(iterator.hasNext()) 78 { 79 MethodDescriptor method = (MethodDescriptor) iterator.next(); 80 85 if( descriptor.isTimedObject() && 86 (method.getName()).equals("ejbTimeout") ) 87 continue; 88 ContainerTransaction txAttr = descriptor. 89 getContainerTransactionFor(method); 90 if(txAttr == null) 91 { 92 if(getVerifierContext().getJavaEEVersion().compareTo(SpecVersionMapper.JavaEEVersion_5)<0) { 93 addErrorDetails(result, compName); 95 result.failed(smh.getLocalString 96 (getClass().getName()+".failed4", 97 "Error : Message-driven bean [ {0} ] method definition [ {1} ] does not have a valid container transaction descriptor.", 98 new Object [] {descriptor.getName(), method.getName()})); 99 } continue; 101 } 102 String ta = txAttr.getTransactionAttribute(); 103 if (ContainerTransaction.REQUIRED.equals(ta) || 104 ContainerTransaction.NOT_SUPPORTED.equals(ta)) { 105 addGoodDetails(result, compName); 106 result.passed(smh.getLocalString 107 (getClass().getName()+".passed", 108 "Message-driven bean [ {0} ] method definition [ {1} ] in assembly-descriptor is correct", 109 new Object [] {descriptor.getName(), method.getName()})); 110 } else { 111 addErrorDetails(result, compName); 112 result.failed(smh.getLocalString 113 (getClass().getName()+".failed3", 114 "Error : Message-driven bean [ {0} ] method definition [ {1} ] transaction attribute must be Required or NotSupported", 115 new Object [] {descriptor.getName(), method.getName()})); 116 } 117 } 118 return result; 119 } else { 120 addNaDetails(result, compName); 121 result.notApplicable(smh.getLocalString 122 (getClass().getName()+".notApplicable2", 123 "Message-driven bean [ {0} ] does not use container-managed transaction", 124 new Object [] {descriptor.getName()})); 125 } 126 return result; 127 } 128 } 129 | Popular Tags |