KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > deployment > backend > DOLLoadingContext


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.deployment.backend;
25
26 import java.io.File JavaDoc;
27 import java.io.FileInputStream JavaDoc;
28 import java.io.IOException JavaDoc;
29 import java.util.logging.Level JavaDoc;
30
31 import com.sun.enterprise.deployment.WebBundleDescriptor;
32 import com.sun.enterprise.deployment.Application;
33 import com.sun.enterprise.deployment.util.DOLUtils;
34 import com.sun.enterprise.deployment.io.WebDeploymentDescriptorFile;
35 import com.sun.enterprise.deployment.deploy.shared.FileArchive;
36 import com.sun.enterprise.deployment.util.DOLLoadingContextFactory;
37
38 import com.sun.enterprise.instance.InstanceEnvironment;
39 import com.sun.enterprise.server.ApplicationServer;
40
41 public class DOLLoadingContext {
42     private static final String JavaDoc DEFAULT_WEB_XML = "default-web.xml";
43
44     /**
45      * initialize the default WebBundleDescriptor from
46      * default-web.xml
47      */

48     public static WebBundleDescriptor initDefaultWebBundleDescriptor() {
49         DOLLoadingContextFactory.setParsingDefaultWebXML(true);
50
51         FileInputStream JavaDoc fis = null;
52
53         WebBundleDescriptor wbd = null;
54         try {
55             // parse default-web.xml contents
56
// (this path will not be invoked by portable static verifier)
57
if (ApplicationServer.getServerContext() != null) {
58                 InstanceEnvironment iEnv = ApplicationServer.getServerContext(
59                     ).getInstanceEnvironment();
60
61                 String JavaDoc defaultWebXMLPath = iEnv.getConfigDirPath() +
62                     File.separator + DEFAULT_WEB_XML;
63                 File JavaDoc file = new File JavaDoc(defaultWebXMLPath);
64                 if (file.exists()) {
65                     fis = new FileInputStream JavaDoc(file);
66                     WebDeploymentDescriptorFile wddf =
67                         new WebDeploymentDescriptorFile();
68                     wddf.setXMLValidation(false);
69                     wbd = (WebBundleDescriptor) wddf.read(fis);
70                 }
71             }
72             return wbd;
73         } catch (Exception JavaDoc e) {
74             DOLUtils.getDefaultLogger().log(Level.WARNING,
75                 "enterprise.deployment.default.web.xml.not.parsed",
76                  new Object JavaDoc[] {e.getMessage()});
77             return null;
78         } finally {
79             DOLLoadingContextFactory.setParsingDefaultWebXML(false);
80             try {
81                 if (fis != null) {
82                     fis.close();
83                 }
84             } catch (IOException JavaDoc ioe) {
85                 // do nothing
86
}
87         }
88     }
89 }
90
Popular Tags