KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > connector > ConnectorCheckMgrImpl


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 * ConnectorCheckMgrImpl.java
25 *
26 * Created on September 18, 2000, 3:59 PM
27 */

28
29 package com.sun.enterprise.tools.verifier.connector;
30
31 import java.io.File JavaDoc;
32 import java.io.FileInputStream JavaDoc;
33
34 import com.sun.enterprise.deployment.ConnectorDescriptor;
35 import com.sun.enterprise.deployment.Descriptor;
36 import com.sun.enterprise.deployment.io.ConnectorDeploymentDescriptorFile;
37 import com.sun.enterprise.tools.verifier.CheckMgr;
38 import com.sun.enterprise.tools.verifier.FrameworkContext;
39 import com.sun.enterprise.tools.verifier.JarCheck;
40 import com.sun.enterprise.tools.verifier.Result;
41 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
42 import com.sun.enterprise.tools.verifier.tests.dd.ParseDD;
43
44 /**
45  * <p/>
46  * This manager is responsible for performing compliance tests on rar files. rar
47  * files contains resource adpaters. </p>
48  *
49  * @author Jerome Dochez
50  */

51 public class ConnectorCheckMgrImpl extends CheckMgr implements JarCheck {
52
53     /**
54      * name of the file containing the list of tests for the connector
55      * architecture
56      */

57     private static final String JavaDoc testsListFileName = "TestNamesConnector.xml"; // NOI18N
58
private static final String JavaDoc sunONETestsListFileName = getSunPrefix()
59             .concat(testsListFileName);
60
61     public ConnectorCheckMgrImpl(FrameworkContext frameworkContext) {
62         this.frameworkContext = frameworkContext;
63     }
64
65     public void check(Descriptor descriptor) throws Exception JavaDoc {
66         // run the ParseDD test
67
if (getSchemaVersion(descriptor).compareTo("1.5") < 0) { // NOI18N
68
ConnectorDeploymentDescriptorFile ddf = new ConnectorDeploymentDescriptorFile();
69             File JavaDoc file = new File JavaDoc(getAbstractArchiveUri(descriptor),
70                     ddf.getDeploymentDescriptorPath());
71             FileInputStream JavaDoc is = new FileInputStream JavaDoc(file);
72             try {
73                 if (is != null) {
74                     Result result = new ParseDD().validateConnectorDescriptor(is);
75                     result.setComponentName(getArchiveUri(descriptor));
76                     setModuleName(result);
77                     frameworkContext.getResultManager().add(result);
78                 }
79             } finally {
80                try {
81                     if(is!=null)
82                         is.close();
83                 } catch(Exception JavaDoc e) {}
84             }
85         }
86
87         super.check(descriptor);
88     }
89
90     /**
91      * return the configuration file name for the list of tests pertinent to the
92      * connector architecture
93      *
94      * @return <code>String</code> filename containing the list of tests
95      */

96     protected String JavaDoc getTestsListFileName() {
97         return testsListFileName;
98     }
99
100     /**
101      * return the configuration file name for the list of tests pertinent to the
102      * connector architecture (SunONE)
103      *
104      * @return <code>String</code> filename containing the list of tests
105      */

106     protected String JavaDoc getSunONETestsListFileName() {
107         if ((System.getProperty("verifier.tests.sunconnector", "false")).equals(
108                 "true")) // NOI18N
109
return sunONETestsListFileName;
110         else
111             return null;
112     }
113
114     protected String JavaDoc getSchemaVersion(Descriptor descriptor) {
115         return ((ConnectorDescriptor) descriptor).getSpecVersion();
116     }
117
118     protected void setModuleName(Result r) {
119         r.setModuleName(Result.CONNECTOR);
120     }
121
122     protected ComponentNameConstructor getComponentNameConstructor(
123             Descriptor descriptor) {
124         return new ComponentNameConstructor((ConnectorDescriptor)descriptor);
125     }
126
127 }
128
Popular Tags