annotate flys-client/src/main/java/de/intevation/flys/client/server/BaseServlet.java @ 1414:3484cbfaf369

Create new Artifacts for selected WMS layers of the ExternalWMSWindow. flys-client/trunk@3304 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 22 Nov 2011 20:13:16 +0000
parents 2ba44c1b2bab
children 42d6cf6e10b7
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
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
15 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
16
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
17
1366
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 @Override
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 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
20 throws ServletException
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 {
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 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
23
1368
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
24 initLogging();
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
25 initConfigParameters();
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
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
29 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
30 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
31
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 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
33 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
34
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 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
36 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
37 }
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
38 }
1366
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 if (log4jProperties != null && log4jProperties.length() > 0) {
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
41 PropertyConfigurator.configure(log4jProperties);
1366
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 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
43 }
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 else {
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 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
46 }
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 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
49 }
1368
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
50
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
51
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
52 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
53 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
54 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
55
ec0c81f2c7a4 Replaced stdout and stderr logging with log4j loggers in server classes.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1366
diff changeset
56 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
57 }
1366
d0eb2202ffbe Added a BaseServlet that is used to setup config things like log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 }

http://dive4elements.wald.intevation.org