FileDocCategorySizeDatePackage
ServletLinkedToOnePortCompCheck.javaAPI DocGlassfish v2 API5459Fri May 04 22:34:16 BST 2007com.sun.enterprise.tools.verifier.tests.webservices

ServletLinkedToOnePortCompCheck

public class ServletLinkedToOnePortCompCheck extends WSTest implements WSCheck

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(WebServiceEndpoint descriptor)

param
descriptor the WebServices descriptor
return
Result the results for this assertion


	Result result = getInitializedResult();
        ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();

        if (descriptor.implementedByEjbComponent()) {
           result.addNaDetails(smh.getLocalString
                     ("tests.componentNameConstructor", "For [ {0} ]",
                      new Object[] {compName.toString()}));
           result.notApplicable(smh.getLocalString
                 (getClass().getName() + ".notapp",
                 "This is an EJB Service Endpoint"));
           return result;
        }

    
        if (isLinkedToSinglePortComp(getAllEndPointsInApp(descriptor),descriptor.getLinkName())) {
           // result.pass
           result.addGoodDetails(smh.getLocalString
                                  ("tests.componentNameConstructor",
                                   "For [ {0} ]",
                                   new Object[] {compName.toString()}));
           result.passed(smh.getLocalString
                   (getClass().getName() + ".passed",
           "The Servlet associated with this end-point is linked to by a single port-component."));

        }
        else {
          // result.fail
          result.addErrorDetails(smh.getLocalString
                                  ("tests.componentNameConstructor",
                                   "For [ {0} ]",
                                   new Object[] {compName.toString()}));
          result.failed(smh.getLocalString
                (getClass().getName() + ".failed",
                "The Servlet associated with this end-point is linked to by multiple port-components."));

        }

        return result;
    
java.util.CollectiongetAllEndPointsInApp(WebServiceEndpoint desc)

       Collection allWebServices = desc.getWebService().getWebServicesDescriptor().getWebServices();
       Collection ret = new Vector();
       for (Iterator it = allWebServices.iterator(); it.hasNext();) {
           ret.addAll(((WebService)it.next()).getEndpoints());
       }

     return ret;
    
booleanisLinkedToSinglePortComp(java.util.Collection endPoints, java.lang.String compLink)

       boolean single = true;
       boolean linkAlreadySeen = false;
       for (Iterator it = endPoints.iterator(); it.hasNext();) {
           String myCompLink = ((WebServiceEndpoint)it.next()).getLinkName();

           if (myCompLink.equals(compLink)) {
              if (!linkAlreadySeen) {
                 linkAlreadySeen = true;
              }
              else {
                 single = false;
                 break;
              }
           }
       }
     return single;