KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > web > TaglibListenerClassExists


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.web;
25
26 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
27 import com.sun.enterprise.tools.verifier.Context;
28 import com.sun.enterprise.tools.verifier.Result;
29 import com.sun.enterprise.tools.verifier.TagLibDescriptor;
30 import com.sun.enterprise.deployment.WebBundleDescriptor;
31
32
33 /**
34  * Listener class exists tests.
35  * Verify that the Listener class exists inside the .tld file and is loadable.
36  * @author Sudipto Ghosh
37  */

38
39 public class TaglibListenerClassExists extends WebTest implements WebCheck {
40
41     public Result check(WebBundleDescriptor descriptor) {
42         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
43         Context context = getVerifierContext();
44         Result result = getInitializedResult();
45         TagLibDescriptor tlds[] = context.getTagLibDescriptors();
46         ClassLoader JavaDoc cl = context.getClassLoader();
47
48         if (tlds == null) {
49             addGoodDetails(result, compName);
50             result.passed(smh.getLocalString
51                     (getClass().getName() + ".passed",
52                             "No tag lib files are specified"));
53             return result;
54         }
55
56         for (TagLibDescriptor tld:tlds) {
57             String JavaDoc[] classes = tld.getListenerClasses();
58             if(classes != null) {
59                 for ( String JavaDoc s : classes ) {
60                     Class JavaDoc c = null;
61                     try {
62                         c = Class.forName(s, false, cl);
63                     } catch (ClassNotFoundException JavaDoc e) {
64                         addErrorDetails(result, compName);
65                         result.failed(smh.getLocalString
66                                 (getClass().getName() + ".failed",
67                                         "Taglib listener class [ {0} ] found in " +
68                                 "[ {1} ] is not loadable ",
69                                         new Object JavaDoc[] {s, tld.getUri()}));
70                     }
71                 }
72             }
73         }
74         if (result.getStatus()!=Result.FAILED) {
75             addGoodDetails(result, compName);
76             result.passed(smh.getLocalString
77                     (getClass().getName() + ".passed1",
78                             "taglib listener classes, if any, specified in tlds are loadable"));
79         }
80         return result;
81     }
82 }
83
Popular Tags