annotate flys-client/src/main/java/de/intevation/flys/client/server/BaseServlet.java @ 1586:dbdf954dbe94

Cosmetics. flys-client/trunk@3873 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 02 Feb 2012 07:40:44 +0000
parents 42d6cf6e10b7
children fba76f4afca9
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
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 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
10
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 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
12
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13
1372
2ba44c1b2bab Added a environment variable that might be used to use an alternative log4j properties file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
14 public static final String LOG4J_PROPERTIES = "FLYS_CLIENT_LOG4J_PROPERIES";
2ba44c1b2bab Added a environment variable that might be used to use an alternative log4j properties file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
15
2ba44c1b2bab Added a environment variable that might be used to use an alternative log4j properties file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
16
1366
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17 @Override
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 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
19 throws ServletException
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 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
22
1368
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
23 initLogging();
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
24 initConfigParameters();
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
25 }
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
26
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
27
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
28 protected void initLogging() {
1372
2ba44c1b2bab Added a environment variable that might be used to use an alternative log4j properties file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
29 String log4jProperties = System.getenv(LOG4J_PROPERTIES);
2ba44c1b2bab Added a environment variable that might be used to use an alternative log4j properties file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
30
2ba44c1b2bab Added a environment variable that might be used to use an alternative log4j properties file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
31 if (log4jProperties == null || log4jProperties.length() == 0) {
2ba44c1b2bab Added a environment variable that might be used to use an alternative log4j properties file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
32 String file = getInitParameter("log4j-properties");
2ba44c1b2bab Added a environment variable that might be used to use an alternative log4j properties file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
33
2ba44c1b2bab Added a environment variable that might be used to use an alternative log4j properties file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
34 if (file != null && file.length() > 0) {
2ba44c1b2bab Added a environment variable that might be used to use an alternative log4j properties file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
35 log4jProperties = getServletContext().getRealPath(file);
2ba44c1b2bab Added a environment variable that might be used to use an alternative log4j properties file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
36 }
2ba44c1b2bab Added a environment variable that might be used to use an alternative log4j properties file.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1368
diff changeset
37 }
1366
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
1417
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1372
diff changeset
39 LoggingConfigurator.init(log4jProperties);
1366
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 }
1368
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
41
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
42
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
43 protected void initConfigParameters() {
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
44 String url = getInitParameter("server-url");
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
45 logger.debug("Found server url: " + url);
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
46
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
47 getServletContext().setAttribute("server-url", url);
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
48 }
1366
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49 }
1417
42d6cf6e10b7 Moved code to parse WMS Capabilities to an own class 'CapabilitiesParser' and added code to parse SRS definitions.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1372
diff changeset
50 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org