1 23 package com.sun.enterprise.tools.verifier.tests.webservices; 24 25 import com.sun.enterprise.deployment.*; 26 import com.sun.enterprise.tools.verifier.*; 27 import java.util.*; 28 import com.sun.enterprise.tools.verifier.tests.*; 29 import java.lang.reflect.*; 30 31 34 35 43 public class SEIEJBTxAttrChk extends WSTest implements WSCheck { 44 45 49 public Result check (WebServiceEndpoint wsdescriptor) { 50 51 Result result = getInitializedResult(); 52 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 53 54 boolean pass = true; 55 56 if (wsdescriptor.implementedByEjbComponent()) { 57 58 EjbDescriptor descriptor = wsdescriptor.getEjbComponentImpl(); 59 60 try { 61 ContainerTransaction ctx = descriptor.getContainerTransaction(); 62 63 if ((ctx != null) && 64 (ContainerTransaction.MANDATORY.equals(ctx.getTransactionAttribute()))) { 65 result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor", 67 "For [ {0} ]", new Object [] {compName.toString()})); 68 result.failed(smh.getLocalString (getClass().getName() + ".failed", 69 "[{0}] of this WebService [{1}] have Mandatory Transaction Attribute.", 70 new Object [] {"All the methods", compName.toString()})); 71 72 return result; 73 } 74 75 Collection txMethDescs = descriptor.getTransactionMethodDescriptors(); 76 77 String s = descriptor.getWebServiceEndpointInterfaceName(); 79 80 if (s == null) { 81 result.addErrorDetails(smh.getLocalString 83 ("com.sun.enterprise.tools.verifier.tests.webservices.Error", 84 "Error: Unexpected error occurred [ {0} ]", 85 new Object [] {"Service Endpoint Interface Class Name Null"})); 86 pass = false; 87 } 88 ClassLoader cl = getVerifierContext().getClassLoader(); 89 Class sei = null; 90 91 try { 92 sei = Class.forName(s, false, cl); 93 }catch(ClassNotFoundException e) { 94 result.addErrorDetails(smh.getLocalString 95 ("com.sun.enterprise.tools.verifier.tests.webservices.Error", 96 "Error: Unexpected error occurred [ {0} ]", 97 new Object [] {"Could not Load Service Endpoint Interface Class"})); 98 pass = false; 99 } 100 101 Iterator it = txMethDescs.iterator(); 102 while (it.hasNext()) { 103 MethodDescriptor methdesc =(MethodDescriptor)it.next(); 105 if (isSEIMethod(methdesc, descriptor, sei, cl)) { 106 ctx = descriptor.getContainerTransactionFor(methdesc); 107 if ((ctx != null) && 108 (ContainerTransaction.MANDATORY.equals(ctx.getTransactionAttribute()))) { 109 result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor", 111 "For [ {0} ]", new Object [] {compName.toString()})); 112 result.failed(smh.getLocalString (getClass().getName() + ".failed", 113 "[{0}] of this WebService [{1}] have Mandatory Transaction Attribute.", 114 new Object [] {methdesc.getName(), compName.toString()})); 115 pass = false; 116 } 117 } 118 } 119 } catch (Exception e) { 120 result.addErrorDetails(smh.getLocalString 122 ("com.sun.enterprise.tools.verifier.tests.webservices.Error", 123 "Error: Unexpected error occurred [ {0} ]", 124 new Object [] {e.getMessage()})); 125 pass = false; 126 } 127 128 if (pass) { 129 130 result.addGoodDetails(smh.getLocalString 131 ("tests.componentNameConstructor", 132 "For [ {0} ]", 133 new Object [] {compName.toString()})); 134 result.passed(smh.getLocalString (getClass().getName() + ".passed", 135 "None of the methods of this WebService [{0}] have Mandatory Transaction Attribute.", 136 new Object [] {compName.toString()})); 137 138 } 139 140 return result; 141 } 142 else { 143 result.addNaDetails(smh.getLocalString 145 ("tests.componentNameConstructor", "For [ {0} ]", 146 new Object [] {compName.toString()})); 147 result.notApplicable(smh.getLocalString (getClass().getName() + ".notapp", 148 "Not applicable since this is not an EJB Service Endpoint.")); 149 150 return result; 151 } 152 } 153 } 154 155 | Popular Tags |