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 42 public class EJBLinkedToOnePortCompCheck extends WSTest implements WSCheck { 43 44 48 public Result check (WebServiceEndpoint descriptor) { 49 50 Result result = getInitializedResult(); 51 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 52 53 if (!descriptor.implementedByEjbComponent()) { 54 result.addNaDetails(smh.getLocalString 55 ("tests.componentNameConstructor", "For [ {0} ]", 56 new Object [] {compName.toString()})); 57 result.notApplicable(smh.getLocalString 58 (getClass().getName() + ".notapp", 59 "This is a JAX-RPC Service Endpoint")); 60 return result; 61 } 62 63 if (isLinkedToSinglePortComp(getAllEndPointsInApp(descriptor),descriptor.getLinkName())) { 64 result.addGoodDetails(smh.getLocalString 65 ("tests.componentNameConstructor", 66 "For [ {0} ]", 67 new Object [] {compName.toString()})); 68 result.passed(smh.getLocalString 69 (getClass().getName() + ".passed", 70 "The session EJB associated with this end-point is linked to by a single port-component.")); 71 72 } 73 else { 74 result.addErrorDetails(smh.getLocalString 76 ("tests.componentNameConstructor", 77 "For [ {0} ]", 78 new Object [] {compName.toString()})); 79 result.failed(smh.getLocalString 80 (getClass().getName() + ".failed", 81 "The session EJB associated with this end-point is linked to by a multiple port-components.")); 82 83 } 84 85 return result; 86 } 87 88 Collection getAllEndPointsInApp(WebServiceEndpoint desc) { 89 Collection endPoints = new Vector(); 90 Collection allWebServices = desc.getWebService().getWebServicesDescriptor().getWebServices(); 91 for (Iterator it = allWebServices.iterator(); it.hasNext();) { 92 endPoints.addAll(((WebService)it.next()).getEndpoints()); 93 } 94 95 return endPoints; 96 } 97 98 boolean isLinkedToSinglePortComp(Collection endPoints, String compLink) { 100 boolean single = true; 101 boolean linkAlreadySeen = false; 102 for (Iterator it = endPoints.iterator(); it.hasNext();) { 103 String myCompLink = ((WebServiceEndpoint)it.next()).getLinkName(); 104 105 if (myCompLink.equals(compLink)) { 106 if (!linkAlreadySeen) { 107 linkAlreadySeen = true; 108 } 109 else { 110 single = false; 111 break; 112 } 113 } 114 } 115 return single; 116 } 117 } 118 119 | Popular Tags |