1 23 24 25 package com.sun.enterprise.tools.verifier.tests.ejb.timer; 26 27 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 28 import com.sun.enterprise.deployment.*; 29 import com.sun.enterprise.tools.verifier.*; 30 import com.sun.enterprise.tools.verifier.tests.*; 31 32 33 41 public class HasValidEjbTimeoutDescriptor extends EjbTest { 42 Result result = null; 43 ComponentNameConstructor compName = null; 44 53 public Result check(EjbDescriptor descriptor) { 54 55 result = getInitializedResult(); 56 compName = getVerifierContext().getComponentNameConstructor(); 57 58 if(descriptor.isTimedObject()) { 59 60 if (descriptor.getTransactionType().equals 61 (EjbDescriptor.CONTAINER_TRANSACTION_TYPE)) { 62 MethodDescriptor methodDesc = descriptor.getEjbTimeoutMethod(); 63 ContainerTransaction txAttr = 64 descriptor.getContainerTransactionFor(methodDesc); 65 String version = getVerifierContext().getJavaEEVersion(); 66 if(txAttr != null) { 67 String ta = txAttr.getTransactionAttribute(); 68 if ((version.compareTo(SpecVersionMapper.JavaEEVersion_5) >= 0) && 69 !(ContainerTransaction.REQUIRES_NEW.equals(ta) 70 || ContainerTransaction.NOT_SUPPORTED.equals(ta) 71 || ContainerTransaction.REQUIRED.equals(ta))) { 72 addErrorDetails(result, compName); 73 result.failed(smh.getLocalString 74 (getClass().getName()+".failed1", 75 "Error : Bean [ {0} ] Transaction attribute for timeout method" + 76 "must be Required, RequiresNew or NotSupported", 77 new Object [] {descriptor.getName()})); 78 } else if ((version.compareTo(SpecVersionMapper.JavaEEVersion_5) < 0) && 79 !(ContainerTransaction.REQUIRES_NEW.equals(ta) 80 || ContainerTransaction.NOT_SUPPORTED.equals(ta))) { 81 addErrorDetails(result, compName); 82 result.failed(smh.getLocalString 83 (getClass().getName()+".failed2", 84 "Error : Bean [ {0} ] Transaction attribute for ejbTimeout " + 85 "must be RequiresNew or NotSupported", 86 new Object [] {descriptor.getName()})); 87 88 } 89 } else if(version.compareTo(SpecVersionMapper.JavaEEVersion_5)<0) { 90 addErrorDetails(result, compName); 92 result.failed(smh.getLocalString 93 (getClass().getName()+".failed3", 94 "Transaction attribute for Timeout is not specified for [ {0} ]", 95 new Object [] {descriptor.getName()})); 96 } 97 } 98 } 99 100 if (result.getStatus() != Result.FAILED) { 101 addGoodDetails(result, compName); 102 result.passed(smh.getLocalString 103 (getClass().getName()+".passed", 104 "Transaction attributes are properly specified")); 105 106 } 107 return result; 108 } 109 } 110 | Popular Tags |