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

JAXRPCServiceImplBeanChk

public class JAXRPCServiceImplBeanChk extends WSTest implements WSCheck

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

param
descriptor the WebService deployment descriptor
return
Result the results for this assertion

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

      boolean pass = true;

      if (descriptor.implementedByWebComponent()) {

          Class<?> bean = loadImplBeanClass(descriptor, result);
          if (bean == null) {
            result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
                                   "For [ {0} ]", new Object[] {compName.toString()}));
            result.failed(smh.getLocalString
              ("com.sun.enterprise.tools.verifier.tests.webservices.failed", "[{0}]",
              new Object[] {"Could not Load the Service Implementation Bean class for the JAX-RPC Endpoint"}));
 
          }
          else {
        
          // get hold of the SEI Class
          String s = descriptor.getServiceEndpointInterface();

          if ((s == null)  || (s.length() == 0)){
               // internal error, should never happen
               result.addErrorDetails(smh.getLocalString
               ("com.sun.enterprise.tools.verifier.tests.webservices.Error",
                "Error: Unexpected error occurred [ {0} ]",
                new Object[] {"SEI Class Name is Null"}));
          }

          Class<?> sei = loadSEIClass(descriptor, result);

          if (sei == null) {
             result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
                                   "For [ {0} ]", new Object[] {compName.toString()}));
             result.failed(smh.getLocalString
                ("com.sun.enterprise.tools.verifier.tests.webservices.WSTest.SEIClassExists",
                 "Error: Service Endpoint Interface class [ {0} ]  not found.",
                 new Object[] {descriptor.getServiceEndpointInterface()}));
           }
           else {
            boolean implementsSEI = sei.isAssignableFrom(bean);
            EndPointImplBeanClassChecker checker = 
            new EndPointImplBeanClassChecker(sei,bean,result,false); 
            if (implementsSEI) {
              // result.passed 
               result.addGoodDetails(smh.getLocalString
                                  ("tests.componentNameConstructor",
                                   "For [ {0} ]",
                                   new Object[] {compName.toString()}));
               result.passed(smh.getLocalString (
                          "com.sun.enterprise.tools.verifier.tests.webservices.passed", "[{0}]",
                           new Object[] {"The Service Impl Bean implements SEI"}));

            }
            else {
         
               // business methods of the bean should be public, not final and not static
               // This check will happen as part of this call
               Vector notImpl = checker.getSEIMethodsNotImplemented();
               if (notImpl.size() > 0) {
                 // result.fail, Set the not implemented methods into the result info??
                 result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
                                   "For [ {0} ]", new Object[] {compName.toString()}));
                 result.failed(smh.getLocalString
                 ("com.sun.enterprise.tools.verifier.tests.webservices.failed", "[{0}]",
                 new Object[] {"The Service Implementation Bean Does not Implement ALL SEI Methods"}));

               }
               else {
                 // result.pass :All SEI methods implemented
                 result.addGoodDetails(smh.getLocalString
                                  ("tests.componentNameConstructor",
                                   "For [ {0} ]",
                                   new Object[] {compName.toString()}));
                 result.passed(smh.getLocalString (
                          "com.sun.enterprise.tools.verifier.tests.webservices.passed", "[{0}]",
                           new Object[] {"The Service Impl Bean implements  all Methods of the SEI"}));

               }
            }

            // class should be public, not final and not abstract
            // should not define finalize()	
           if (checker.check(compName)) {
                // result.passed  stuff done inside the check() method nothing todo here
              result.setStatus(Result.PASSED);
            }
            else {
                // result.fail :  stuff done inside the check() method nothing todo here
                result.setStatus(Result.FAILED);
            }
         }
       }
    }
    else {
         // result.notapplicable
         result.addNaDetails(smh.getLocalString
                     ("tests.componentNameConstructor", "For [ {0} ]",
                      new Object[] {compName.toString()}));
         result.notApplicable(smh.getLocalString
                 ("com.sun.enterprise.tools.verifier.tests.webservices.notapp",
                 "[{0}]", new Object[] {"Not Applicable since this is an EJB Service Endpoint"}));
    }

   return result;