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