KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > appclient > AppClientCheckMgrImpl


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 package com.sun.enterprise.tools.verifier.appclient;
24
25 import java.io.File JavaDoc;
26 import java.io.FileInputStream JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import java.util.Set JavaDoc;
29
30 import com.sun.enterprise.deployment.ApplicationClientDescriptor;
31 import com.sun.enterprise.deployment.Descriptor;
32 import com.sun.enterprise.deployment.RootDeploymentDescriptor;
33 import com.sun.enterprise.deployment.ServiceReferenceDescriptor;
34 import com.sun.enterprise.deployment.io.AppClientDeploymentDescriptorFile;
35 import com.sun.enterprise.tools.verifier.CheckMgr;
36 import com.sun.enterprise.tools.verifier.FrameworkContext;
37 import com.sun.enterprise.tools.verifier.JarCheck;
38 import com.sun.enterprise.tools.verifier.Result;
39 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
40 import com.sun.enterprise.tools.verifier.tests.dd.ParseDD;
41 import com.sun.enterprise.tools.verifier.wsclient.WebServiceClientCheckMgrImpl;
42
43 /**
44  * Application Client harness
45  */

46 public class AppClientCheckMgrImpl extends CheckMgr implements JarCheck {
47
48     /**
49      * name of the file containing the list of tests for the application client
50      * architecture
51      */

52     private static final String JavaDoc testsListFileName = "TestNamesAppClient.xml"; // NOI18N
53
private static final String JavaDoc sunONETestsListFileName = getSunPrefix()
54             .concat(testsListFileName);
55
56     public AppClientCheckMgrImpl(FrameworkContext frameworkContext) {
57         this.frameworkContext = frameworkContext;
58     }
59
60     /**
61      * Check method introduced for WebServices integration
62      *
63      * @param descriptor appclient descriptor
64      */

65     public void check(Descriptor descriptor) throws Exception JavaDoc {
66         // run persistence tests first.
67
checkPersistenceUnits(ApplicationClientDescriptor.class.cast(descriptor));
68         //An ApplicationClient can have WebService References
69
checkWebServicesClient(descriptor);
70
71         if (frameworkContext.isPartition() &&
72                 !frameworkContext.isAppClient())
73             return;
74         // run the ParseDD test
75
if (getSchemaVersion(descriptor).compareTo("1.4") < 0) { // NOI18N
76
AppClientDeploymentDescriptorFile ddf = new AppClientDeploymentDescriptorFile();
77             File JavaDoc file = new File JavaDoc(getAbstractArchiveUri(descriptor),
78                     ddf.getDeploymentDescriptorPath());
79             FileInputStream JavaDoc is = new FileInputStream JavaDoc(file);
80             try {
81                 if (is != null) {
82                     Result result = new ParseDD().validateAppClientDescriptor(is);
83                     result.setComponentName(getArchiveUri(descriptor));
84                     setModuleName(result);
85                     frameworkContext.getResultManager().add(result);
86                 }
87             } finally {
88                 try {
89                     if(is!=null)
90                         is.close();
91                 } catch(Exception JavaDoc e) {}
92             }
93         }
94
95         super.check(descriptor);
96     }
97
98     /**
99      * return the configuration file name for the list of tests pertinent to the
100      * connector architecture
101      *
102      * @return <code>String</code> filename containing the list of tests
103      */

104     protected String JavaDoc getTestsListFileName() {
105         return testsListFileName;
106     }
107
108     /**
109      * return the configuration file name for the list of tests pertinent to the
110      * application client architecture
111      *
112      * @return <code>String</code> filename containing the list of tests
113      */

114     protected String JavaDoc getSunONETestsListFileName() {
115         return sunONETestsListFileName;
116     }
117
118     protected String JavaDoc getSchemaVersion(Descriptor descriptor) {
119         return ((RootDeploymentDescriptor) descriptor).getSpecVersion();
120     }
121
122     protected void setModuleName(Result r) {
123         r.setModuleName(Result.APPCLIENT);
124     }
125
126     protected void checkWebServicesClient(Descriptor descriptor)
127             throws Exception JavaDoc {
128         if (frameworkContext.isPartition() &&
129                 !frameworkContext.isWebServicesClient())
130             return;
131         WebServiceClientCheckMgrImpl webServiceClientCheckMgr =
132                                 new WebServiceClientCheckMgrImpl(frameworkContext);
133         ApplicationClientDescriptor desc = (ApplicationClientDescriptor) descriptor;
134         if (desc.hasWebServiceClients()) {
135             Set JavaDoc serviceRefDescriptors = desc.getServiceReferenceDescriptors();
136             Iterator JavaDoc it = serviceRefDescriptors.iterator();
137             while (it.hasNext()) {
138                 webServiceClientCheckMgr.setVerifierContext(context);
139                 webServiceClientCheckMgr.check(
140                         (ServiceReferenceDescriptor) it.next());
141             }
142         } else // set not applicable for all tests in WebServices for this Appclient Bundle
143
webServiceClientCheckMgr.setVerifierContext(context);
144     }
145
146     protected ComponentNameConstructor getComponentNameConstructor(
147             Descriptor descriptor) {
148         return new ComponentNameConstructor((ApplicationClientDescriptor)descriptor);
149     }
150
151 }
152
Popular Tags