KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fops > Fopes


1 /*
2  * fopes
3  *
4  * Enhydra super-servlet
5  *
6  */

7
8 package fops;
9
10 import com.lutris.appserver.server.*;
11 import com.lutris.appserver.server.httpPresentation.*;
12 import com.lutris.appserver.server.session.*;
13 import com.lutris.logging.Logger;
14 import com.lutris.util.*;
15
16 import java.io.*;
17
18
19 /**
20  * The application object.
21  *
22  * Application-wide data would go here.
23  */

24 public class Fopes extends StandardApplication {
25
26    File userConfigFile;
27    
28    protected String JavaDoc DEFAULT_FILE = "userconfig.xml";
29    protected String JavaDoc FOP_BASE_DIR = "Config";
30    
31    String JavaDoc fopBaseDir;
32     /*
33      * A few methods you might want to add to.
34      * See StandardApplication for more details.
35      */

36     public void startup(Config appConfig) throws ApplicationException {
37         super.startup(appConfig);
38         
39         if (logChannel != null) {
40             logChannel.write(Logger.INFO,
41                              "Welcome to FopApplet Enhydra Application!");
42         }
43         
44         // Here is where you would read application-specific settings from
45
// your config file.
46

47         String JavaDoc tempString = null;
48         String JavaDoc file = null;
49         File tempFile=null;
50         
51         // FopBaseDir parameter initialization
52

53         try{
54             fopBaseDir = appConfig.getString("FopBaseDir");
55             tempFile = new File(fopBaseDir+File.separator+FOP_BASE_DIR);
56             if (!tempFile.exists()||!tempFile.isDirectory()){
57                 // in case a relative path is given (relative from configuration file)
58
tempString = appConfig.getConfigFile().getFile().getParent();
59                 fopBaseDir = tempString+File.separator+fopBaseDir;
60                 tempFile = new File(fopBaseDir+File.separator+FOP_BASE_DIR);
61                 
62                 if (!tempFile.exists()||!tempFile.isDirectory()){
63                     fopBaseDir = null;
64                     if (logChannel != null) {
65                         logChannel.write(Logger.INFO,
66                                          "FopBaseDir application parameter not initialized - will be red from UserConfigFile!");
67                     }
68                 }
69             }
70        } catch (ConfigException e) {
71             fopBaseDir = null;
72             if (logChannel != null) {
73                 logChannel.write(Logger.INFO,
74                         "FopBaseDir application parameter not initialized - will be red from UserConfigFile!");
75             }
76        }
77            
78         // UserConfigFilePath parameter initialization
79

80         try{
81             file = appConfig.getString("UserConfigFilePath");
82             userConfigFile = new File(file);
83
84          if (!userConfigFile.exists()){
85             // in case a relative path is given (relative from configuration file)
86
tempString = appConfig.getConfigFile().getFile().getParent();
87             file = tempString+File.separator+file;
88             userConfigFile = new File(file);
89             
90             if (!userConfigFile.exists()){
91                 try{
92                     tempString = this.getClass().getClassLoader().getResource(DEFAULT_FILE).getPath();
93                     file = tempString;
94                     userConfigFile = new File(file);
95                 } catch (NullPointerException JavaDoc exc){
96                     file = DEFAULT_FILE;
97                     userConfigFile = new File(file);
98                     if (logChannel != null) {
99                         logChannel.write(Logger.INFO,
100                                          "UserConfigFilePath application parameter isn't properly initialized!");
101                     }
102                 }
103             }
104          }
105         } catch (ConfigException e) {
106             try{
107                 tempString = this.getClass().getClassLoader().getResource(DEFAULT_FILE).getPath();
108                 file = tempString;
109                 userConfigFile = new File(file);
110             } catch (NullPointerException JavaDoc exc){
111                 file = DEFAULT_FILE;
112                 userConfigFile = new File(file);
113                 if (logChannel != null) {
114                     logChannel.write(Logger.INFO,
115                                      "UserConfigFilePath application parameter isn't properly initialized!");
116                 }
117             }
118         }
119         
120     }
121     
122     public boolean requestPreprocessor(HttpPresentationComms comms)
123                    throws Exception JavaDoc {
124         return super.requestPreprocessor(comms);
125     }
126
127     /**
128      * This is an optional function, used only by the Multiserver's graphical
129      * administration. This bit of HTML appears in the status page for this
130      * application. You could add extra status info, for example
131      * a list of currently logged in users.
132      *
133      * @return HTML that is displayed in the status page of the Multiserver.
134      */

135     public String JavaDoc toHtml() {
136         return "This is <I>fopes</I>";
137     }
138
139    public File getUserConfigFile () {
140       return userConfigFile;
141    }
142    
143    public String JavaDoc getFopBaseDir () {
144     return fopBaseDir;
145  }
146 }
147
148
Popular Tags