KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xalanDoc > XalanDoc


1 /*
2  * Copyright (c) 1999-2001 Lutris Technologies, Inc. All Rights
3  * Reserved.
4  *
5  * This source code file is distributed by Lutris Technologies, Inc. for
6  * use only by licensed users of product(s) that include this source
7  * file. Use of this source file or the software that uses it is covered
8  * by the terms and conditions of the Lutris Enhydra Development License
9  * Agreement included with this product.
10  *
11  * This Software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
12  * ANY KIND, either express or implied. See the License for the specific terms
13  * governing rights and limitations under the License.
14  *
15  * Contributor(s):
16  *
17  * $Id: XalanDoc.java,v 1.2 2005/01/17 14:03:39 slobodan Exp $
18  */

19
20 /*
21  * xalanDoc
22  * A sample Enhydra Application
23  *
24  */

25
26 package xalanDoc;
27
28 import java.io.File JavaDoc;
29
30 import com.lutris.appserver.server.*;
31 import com.lutris.appserver.server.httpPresentation.*;
32 import com.lutris.appserver.server.session.*;
33 import com.lutris.util.*;
34
35 import com.lutris.logging.Logger;
36 /**
37  * The application object.
38  *
39  * Application-wide data would go here.
40  */

41 public class XalanDoc extends StandardApplication {
42     
43     protected static Config config = null;
44     
45     protected static String JavaDoc contactsDir="";
46     protected String JavaDoc DEFAULT_DIRECTORY = "contacts";
47     
48     /*
49      * A few methods you might want to add to.
50      * See StandardApplication for more details.
51      */

52     public void startup(Config appConfig) throws ApplicationException {
53         super.startup(appConfig);
54         
55         if (logChannel != null) {
56             logChannel.write(Logger.INFO,
57                              "Welcome to the XalanDoc application!");
58         }
59         
60         // Here is where you would read application-specific settings from
61
// your config file.
62
config = appConfig;
63         
64         File JavaDoc tempFile = null;
65         String JavaDoc tempString = null;
66         
67         // XalanDoc.Contacts.Directory parameter initialization
68

69         try{
70          contactsDir = XalanDoc.config.getString("XalanDoc.Contacts.Directory");
71          tempFile = new File JavaDoc(contactsDir+File.separator+"contact-table.xsl");
72
73          if (!tempFile.exists()){
74             // in case a relative path is given (relative from configuration file)
75
tempString = XalanDoc.config.getConfigFile().getFile().getParent();
76             contactsDir = tempString+File.separator+contactsDir;
77             tempFile = new File JavaDoc(contactsDir+File.separator+"contact-table.xsl");
78             
79             if (!tempFile.exists()){
80                 try{
81                     tempString = this.getClass().getClassLoader().getResource(DEFAULT_DIRECTORY).getPath();
82                     contactsDir = tempString;
83                     tempFile = new File JavaDoc(contactsDir+File.separator+"contact-table.xsl");
84                 } catch (NullPointerException JavaDoc exc){
85                     contactsDir = DEFAULT_DIRECTORY;
86                     if (logChannel != null) {
87                         logChannel.write(Logger.INFO,
88                                          "XalanDoc.Contacts.Directory application parameter isn't properly initialized!");
89                     }
90                 }
91             }
92          }
93         } catch (ConfigException e) {
94             try{
95                 tempString = this.getClass().getClassLoader().getResource(DEFAULT_DIRECTORY).getPath();
96                 contactsDir = tempString;
97                 tempFile = new File JavaDoc(contactsDir+File.separator+"contact-table.xsl");
98             } catch (NullPointerException JavaDoc exc){
99                 contactsDir = DEFAULT_DIRECTORY;
100                 if (logChannel != null) {
101                     logChannel.write(Logger.INFO,
102                                      "XalanDoc.Contacts.Directory application parameter isn't properly initialized!");
103                 }
104             }
105         }
106     }
107     public boolean requestPreprocessor(HttpPresentationComms comms)
108                    throws Exception JavaDoc {
109         return super.requestPreprocessor(comms);
110     }
111
112     /**
113      * This is an optional function, used only by the Multiserver's graphical
114      * administration. This bit of HTML appears in the status page for this
115      * application. You could add extra status info, for example
116      * a list of currently logged in users.
117      *
118      * @return HTML that is displayed in the status page of the Multiserver.
119      */

120     public String JavaDoc toHtml() {
121         return "This is <I>xalanDoc</I>";
122     }
123     
124     public static String JavaDoc getContactsDir() {
125         return contactsDir;
126     }
127 }
128
129
Popular Tags