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

EJBLinkedToOnePortCompCheck

public class EJBLinkedToOnePortCompCheck 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 a JAX-RPC Service Endpoint"));
           return result;
        }

        if (isLinkedToSinglePortComp(getAllEndPointsInApp(descriptor),descriptor.getLinkName())) {
           result.addGoodDetails(smh.getLocalString
                                  ("tests.componentNameConstructor",
                                   "For [ {0} ]",
                                   new Object[] {compName.toString()}));
           result.passed(smh.getLocalString
                   (getClass().getName() + ".passed",
           "The session EJB 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 session EJB associated with this end-point is linked to by a multiple port-components."));

        }

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

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

     return endPoints;
    
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;