FileDocCategorySizeDatePackage
HandlerClassCheck.javaAPI DocGlassfish v2 API5640Fri May 04 22:34:16 BST 2007com.sun.enterprise.tools.verifier.tests.wsclients

HandlerClassCheck

public class HandlerClassCheck extends WSClientTest implements WSClientCheck

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

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


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

        if (descriptor.hasHandlers()) {
           List handlerChain = descriptor.getHandlerChain();
           for (Iterator it = handlerChain.iterator(); it.hasNext();) {
                String hClass = ((WebServiceHandler)it.next()).getHandlerClass();
                Class cl = null;
                try {
                  cl = Class.forName(hClass, false, getVerifierContext().getClassLoader());
                  if ((cl != null) && ((javax.xml.rpc.handler.Handler.class).isAssignableFrom(cl))) {
                    //result.pass
                    result.addGoodDetails(smh.getLocalString
                                  ("tests.componentNameConstructor",
                                   "For [ {0} ]",
                                   new Object[] {compName.toString()}));
                    result.passed(smh.getLocalString (getClass().getName() + ".passed",
             "The Handler Class [{0}] exists and implements the javax.xml.rpc.handler.Handler Interface.",
                     new Object[] {hClass}));

                  }
                  else {
                     result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
                         "For [ {0} ]", new Object[] {compName.toString()}));
                        result.failed(smh.getLocalString (getClass().getName() + ".failed",
                        "Handler Class [{0}] does not implement javax.xml.rpc.handler.Handler",
                        new Object[] {hClass}));
                    
                  }
                }
                catch (ClassNotFoundException e) {
                    // result.fail, handler class not found
                     result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor",
                 "For [ {0} ]", new Object[] {compName.toString()}));
                 result.failed(smh.getLocalString (
                 "com.sun.enterprise.tools.verifier.tests.webservices.clfailed",
                 "The [{0}] Class [{1}] could not be Loaded",
                  new Object[] {"Handler Class", hClass}));

                }
           }
        }
        else {
         // result.NotApplicable
          result.addNaDetails(smh.getLocalString
                     ("tests.componentNameConstructor", "For [ {0} ]",
                      new Object[] {compName.toString()}));
          result.notApplicable(smh.getLocalString
                ( getClass().getName() + ".notapp",
                 "Not Applicable since No handlers defined in this WebService"));
        }

        return result;