1 23 package com.sun.enterprise.tools.verifier.tests.ejb; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import com.sun.enterprise.deployment.*; 27 import com.sun.enterprise.tools.verifier.*; 28 import java.util.*; 29 import com.sun.enterprise.tools.verifier.tests.*; 30 31 32 36 public class TransactionDemarcationBeanManaged extends EjbTest implements EjbCheck { 37 38 39 47 public Result check(EjbDescriptor descriptor) { 48 49 Result result = getInitializedResult(); 50 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 51 52 try { 58 if ((descriptor instanceof EjbSessionDescriptor) || 61 (descriptor instanceof EjbEntityDescriptor)) { 62 String transactionType = descriptor.getTransactionType(); 63 if (EjbDescriptor.BEAN_TRANSACTION_TYPE.equals(transactionType)) { 64 ContainerTransaction containerTransaction = null; 65 if (!descriptor.getMethodContainerTransactions().isEmpty()) { 66 for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements();) { 67 MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement(); 68 containerTransaction = 69 (ContainerTransaction) descriptor.getMethodContainerTransactions().get(methodDescriptor); 70 71 try { 72 String transactionAttribute = 73 containerTransaction.getTransactionAttribute(); 74 75 if (ContainerTransaction.NOT_SUPPORTED.equals(transactionAttribute) 81 || ContainerTransaction.SUPPORTS.equals(transactionAttribute) 82 || ContainerTransaction.REQUIRED.equals(transactionAttribute) 83 || ContainerTransaction.REQUIRES_NEW.equals(transactionAttribute) 84 || ContainerTransaction.MANDATORY.equals(transactionAttribute) 85 || ContainerTransaction.NEVER.equals(transactionAttribute) 86 || (!transactionAttribute.equals(""))) { 87 result.addErrorDetails(smh.getLocalString 88 ("tests.componentNameConstructor", 89 "For [ {0} ]", 90 new Object [] {compName.toString()})); 91 result.failed(smh.getLocalString 92 (getClass().getName() + ".failed", 93 "Error: TransactionAttribute [ {0} ] for method [ {1} ] is not valid. The Application Assembler must not define transaction attributes for an enterprise bean [ {2} ] with bean-managed transaction demarcation.", 94 new Object [] {transactionAttribute, methodDescriptor.getName(),descriptor.getName()})); 95 } else { 96 result.addGoodDetails(smh.getLocalString 97 ("tests.componentNameConstructor", 98 "For [ {0} ]", 99 new Object [] {compName.toString()})); 100 result.passed(smh.getLocalString 101 (getClass().getName() + ".passed", 102 "Valid: TransactionAttribute [ {0} ] for method [ {1} ] is not defined for an enterprise bean [ {2} ] with bean-managed transaction demarcation.", 103 new Object [] {transactionAttribute, methodDescriptor.getName(),descriptor.getName()})); 104 } 105 } catch (NullPointerException e) { 106 result.addGoodDetails(smh.getLocalString 107 ("tests.componentNameConstructor", 108 "For [ {0} ]", 109 new Object [] {compName.toString()})); 110 result.passed(smh.getLocalString 111 (getClass().getName() + ".passed1", 112 "Valid: TransactionAttribute is null for method [ {0} ] in bean [ {1} ]", 113 new Object [] {methodDescriptor.getName(),descriptor.getName()})); 114 return result; 115 } 116 } 117 } else { 118 result.addGoodDetails(smh.getLocalString 119 ("tests.componentNameConstructor", 120 "For [ {0} ]", 121 new Object [] {compName.toString()})); 122 result.passed(smh.getLocalString 123 (getClass().getName() + ".passed2", 124 "Valid: There are no method permissions within this bean [ {0} ]", 125 new Object [] {descriptor.getName()})); 126 } 127 return result; 128 } else { 129 result.addNaDetails(smh.getLocalString 131 ("tests.componentNameConstructor", 132 "For [ {0} ]", 133 new Object [] {compName.toString()})); 134 result.notApplicable(smh.getLocalString 135 (getClass().getName() + ".notApplicable2", 136 "Bean [ {0} ] is not [ {1} ] managed, it is [ {2} ] managed.", 137 new Object [] {descriptor.getName(),EjbDescriptor.BEAN_TRANSACTION_TYPE,transactionType})); 138 } 139 return result; 140 } else { 141 result.addNaDetails(smh.getLocalString 142 ("tests.componentNameConstructor", 143 "For [ {0} ]", 144 new Object [] {compName.toString()})); 145 result.notApplicable(smh.getLocalString 146 (getClass().getName() + ".notApplicable", 147 "[ {0} ] not called \n with a Session or Entity bean.", 148 new Object [] {getClass()})); 149 return result; 150 } 151 } catch (Throwable t) { 152 result.addErrorDetails(smh.getLocalString 153 ("tests.componentNameConstructor", 154 "For [ {0} ]", 155 new Object [] {compName.toString()})); 156 result.failed(smh.getLocalString 157 (getClass().getName() + ".failedException", 158 "Error: [ {0} ] does not contain class [ {1} ] within bean [ {2} ]", 159 new Object [] {descriptor.getName(), t.getMessage(), descriptor.getName()})); 160 return result; 161 } 162 } 163 } 164 | Popular Tags |