annotate flys-client/src/main/java/de/intevation/flys/client/server/BaseServlet.java @ 1366:d0eb2202ffbe

Added a BaseServlet that is used to setup config things like log4j. flys-client/trunk@3067 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 25 Oct 2011 11:07:14 +0000
parents
children ec0c81f2c7a4
rev   line source
1366
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.server;
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import javax.servlet.ServletException;
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import javax.servlet.http.HttpServlet;
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import org.apache.log4j.Logger;
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import org.apache.log4j.PropertyConfigurator;
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 public class BaseServlet extends HttpServlet {
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 private static Logger logger = Logger.getLogger(BaseServlet.class);
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15 @Override
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16 public void init()
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 throws ServletException
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 {
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 System.out.println("BaseServlet.init");
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 String log4jProperties = getInitParameter("log4j-properties");
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23 if (log4jProperties != null && log4jProperties.length() > 0) {
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 String file = getServletContext().getRealPath(log4jProperties);
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 PropertyConfigurator.configure(file);
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 logger.info("Log4J logging initialized.");
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 }
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 else {
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 System.out.println("Error while setting up Log4J configuration.");
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 }
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 System.out.println("BaseServlet.init finished");
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 }
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 }

http://dive4elements.wald.intevation.org