View Javadoc

1   /*
2    *  Copyright 2004 University of Hannover
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  
17  package olr;
18  
19  import java.io.IOException;
20  
21  import olr.rdf.Definitions;
22  import olr.rdf.OLR3Definitions;
23  
24  import org.apache.commons.configuration.PropertiesConfiguration;
25  import org.apache.log4j.Logger;
26  import org.apache.torque.Torque;
27  
28  import com.lutris.appserver.server.ApplicationException;
29  import com.lutris.appserver.server.StandardApplication;
30  import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
31  import com.lutris.util.Config;
32  
33  /***
34   * @version $Id: Olr.java,v 1.11 2004/08/02 19:01:18 roku Exp $
35   */
36  public final class Olr extends StandardApplication {
37  
38      private static final String TORQUE_PROPERTIES_FILENAME = "Torque.properties";
39  
40      public void startup(Config appConfig) throws ApplicationException {
41          super.startup(appConfig);
42          Definitions.setValuesFromConfig();
43          OLR3Definitions.setValuesFromConfig();
44  
45          try {
46              Olr.initTorque();
47          } catch (Exception e) {
48              throw new ApplicationException(e);
49          }
50      }
51  
52      public boolean requestPreprocessor(HttpPresentationComms comms) throws Exception {
53          return super.requestPreprocessor(comms);
54      }
55  
56      public static void initTorque() throws Exception {
57  
58          try {
59              PropertiesConfiguration config = new PropertiesConfiguration();
60              config.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(
61                      TORQUE_PROPERTIES_FILENAME));
62              Torque.init(config);
63          } catch (IOException e) {
64              e.fillInStackTrace();
65              Logger.getLogger(Olr.class).error("Exception setting up torque: " + e);
66              throw new Exception(e.toString());
67          }
68      }
69  }