KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > AppVerifier


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;
25
26 import com.sun.enterprise.deployment.Application;
27 import com.sun.enterprise.deployment.deploy.shared.AbstractArchive;
28 import com.sun.logging.LogDomains;
29
30 import java.util.logging.Logger JavaDoc;
31 import java.util.logging.Level JavaDoc;
32 import java.util.List JavaDoc;
33 import java.lang.reflect.Method JavaDoc;
34 import java.lang.reflect.Constructor JavaDoc;
35 import java.io.File JavaDoc;
36
37 public class AppVerifier {
38
39     static Logger JavaDoc _logger=LogDomains.getLogger(LogDomains.APPVERIFY_LOGGER);
40     Method JavaDoc verify = null;
41     Object JavaDoc verifier =null;
42     
43     public AppVerifier() throws Exception JavaDoc {
44         init();
45     }
46
47     private void init() throws Exception JavaDoc {
48         String JavaDoc name = "com.sun.enterprise.tools.verifier.Verifier";
49         try {
50             Class JavaDoc verifierClass = Class.forName(name);
51             verify = verifierClass.getDeclaredMethod("verify",
52                     new Class JavaDoc[] {Application.class,
53                                  AbstractArchive.class,
54                                  List JavaDoc.class,
55                                  File JavaDoc.class});
56             Constructor JavaDoc constructor = verifierClass.getDeclaredConstructor();
57             verifier = constructor.newInstance();
58         } catch (ClassNotFoundException JavaDoc e) {
59             _logger.log(Level.SEVERE,"verifier.class.notfound",
60                     new Object JavaDoc[] {name});
61             throw e;
62         }
63         catch (NoSuchMethodException JavaDoc e) {
64             _logger.log(Level.SEVERE,"verifier.method.notfound",e);
65             throw e;
66         } catch (Exception JavaDoc e) {
67             _logger.log(Level.SEVERE,"verifier.intialization.error", e);
68             throw e;
69         }
70     }
71
72     public void verify(Application application,
73                        AbstractArchive abstractArchive,
74                        List JavaDoc classPath,
75                        File JavaDoc jspOutDir) throws Exception JavaDoc{
76         Object JavaDoc result = verify.invoke(verifier,
77                 new Object JavaDoc[] {application, abstractArchive, classPath, jspOutDir});
78         if(((Integer JavaDoc)result).intValue() > 0)
79             throw new Exception JavaDoc("Some verifier tests Failed.");
80     }
81 }
82
Popular Tags