KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > webservices > HandlerChainClassCheck


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.tools.verifier.tests.webservices;
25
26 import java.util.List JavaDoc;
27 import java.util.Iterator JavaDoc;
28
29 import com.sun.enterprise.tools.verifier.Result;
30 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
31 import com.sun.enterprise.deployment.WebServiceEndpoint;
32 import com.sun.enterprise.deployment.WebServiceHandler;
33 import com.sun.enterprise.deployment.WebServiceHandlerChain;
34
35 /**
36  * @author Sudipto Ghosh
37  */

38 public class HandlerChainClassCheck extends WSTest implements WSCheck {
39
40     public Result check (WebServiceEndpoint descriptor) {
41
42         Result result = getInitializedResult();
43         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
44         //Handler chains are applicable only in the context of JAX-WS 2.0. So
45
// version check for this test is not required.
46
List JavaDoc handlerChain = descriptor.getHandlerChain();
47         for (Iterator JavaDoc it = handlerChain.iterator(); it.hasNext();) {
48             List JavaDoc handlers = ((WebServiceHandlerChain)it.next()).getHandlers();
49             for(Iterator JavaDoc itr = handlers.iterator(); itr.hasNext();) {
50                 String JavaDoc hClass = ((WebServiceHandler)itr.next()).getHandlerClass();
51                 try {
52                     Class JavaDoc cl = Class.forName(hClass, false, getVerifierContext().getClassLoader());
53                     if (!((javax.xml.ws.handler.Handler.class).isAssignableFrom(cl))) {
54                         addErrorDetails(result, compName);
55                         result.failed(smh.getLocalString (getClass().getName() + ".failed",
56                                 "Handler Class [{0}] does not implement " +
57                                 "javax.xml.ws.handler.Handler Interface",
58                                 new Object JavaDoc[] {hClass}));
59                     }
60                 } catch (ClassNotFoundException JavaDoc e) {
61                     // result.fail, handler class not found
62
addErrorDetails(result, compName);
63                     result.failed(smh.getLocalString (
64                             "com.sun.enterprise.tools.verifier.tests.webservices.clfailed",
65                             "The [{0}] Class [{1}] could not be Loaded",
66                             new Object JavaDoc[] {"Handler Class", hClass}));
67                 }
68             }
69         }
70         if (result.getStatus() != Result.FAILED) {
71             addGoodDetails(result, compName);
72             result.passed(smh.getLocalString (getClass().getName() + ".passed1",
73                     "Handler chains, if any, are defined properly"));
74         }
75         return result;
76     }
77 }
78
Popular Tags