01: /*
02: * $Id: OxyusInitializerServlet.java,v 1.8 2004/10/10 14:20:37 csaltos Exp $
03: *
04: * Copyright 1999 PUCE [http://www.puce.edu.ec]
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18: package org.oxyus.web;
19:
20: import java.io.IOException;
21:
22: import javax.servlet.ServletConfig;
23: import javax.servlet.ServletContext;
24: import javax.servlet.ServletException;
25: import javax.servlet.http.HttpServlet;
26: import javax.servlet.http.HttpServletRequest;
27: import javax.servlet.http.HttpServletResponse;
28:
29: import org.apache.log4j.Logger;
30: import org.oxyus.admin.Configuration;
31: import org.oxyus.admin.ConfigurationException;
32: import org.oxyus.admin.Manager;
33:
34: /**
35: * @author Carlos Saltos (csaltos[@]users.sourceforge.net)
36: */
37: public class OxyusInitializerServlet extends HttpServlet {
38:
39: public void init(ServletConfig config) throws ServletException {
40: super .init(config);
41: // Set the oxyus home relative to the web module path
42: // FIXING 1039108: using direct set home statements instead of
43: // system properties for establishing the oxyus home
44: ServletContext context = config.getServletContext();
45: String oxyusHome = context.getRealPath("/WEB-INF/oxyus");
46: Configuration.setHome(oxyusHome);
47: // Initialize the Oxyus environment
48: try {
49: this .log("Starting Oxyus");
50: Manager.initEnvironment();
51: } catch (ConfigurationException ce) {
52: if (Configuration.isLoggerActive()) {
53: Logger log = Logger
54: .getLogger(OxyusInitializerServlet.class);
55: log.error("Unable to initialize oxyus", ce);
56: } else {
57: this .log("Unable to initialize oxyus", ce);
58: throw new ServletException(
59: "Unable to initialize oxyus", ce);
60: }
61: }
62: }
63:
64: public void destroy() {
65: this .log("Stopping Oxyus");
66: Manager.shutdownEnvironment();
67: }
68:
69: public void doGet(HttpServletRequest request,
70: HttpServletResponse response) throws ServletException,
71: IOException {
72: response.sendError(HttpServletResponse.SC_FORBIDDEN);
73: }
74:
75: public void doPost(HttpServletRequest request,
76: HttpServletResponse response) throws ServletException,
77: IOException {
78: response.sendError(HttpServletResponse.SC_FORBIDDEN);
79: }
80:
81: }
|