annotate flys-client/src/main/java/de/intevation/flys/client/server/BaseServletContextListener.java @ 4284:7a94d5e7fc3d

Write the "hidden" attribute of a style into the collection's attribute when using the theme editor. Otherwise, the next time using the theme editor, the hidden attributes that should not be changed by the user are visible.
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 29 Oct 2012 07:18:42 +0100
parents 763789a9acca
children
rev   line source
3478
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.server;
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
2
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
3 import java.io.IOException;
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
4
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
5 import javax.servlet.ServletContext;
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
6 import javax.servlet.ServletContextEvent;
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
7 import javax.servlet.ServletContextListener;
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
8
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
9 import org.apache.log4j.Logger;
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
10
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
11 import de.intevation.flys.client.server.LoggingConfigurator;
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
12 import de.intevation.flys.client.server.features.Features;
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
13 import de.intevation.flys.client.server.features.XMLFileFeatures;
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
14
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
15 /**
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
16 * ServletContextListenter to initalize the Features globally for
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
17 * all Servlets
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
18 */
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
19 public class BaseServletContextListener implements ServletContextListener {
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
20
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
21 public static final String LOG4J_PROPERTIES = "FLYS_CLIENT_LOG4J_PROPERIES";
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
22
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
23 public static final Logger logger = Logger.getLogger(BaseServletContextListener.class);
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
24
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
25 @Override
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
26 public void contextInitialized(ServletContextEvent sce) {
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
27 ServletContext sc = sce.getServletContext();
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
28
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
29 this.initLogging(sc);
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
30
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
31 String filename = sc.getInitParameter("features-file");
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
32
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
33 logger.debug("Initializing ServletContext");
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
34 try {
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
35 XMLFileFeatures features = new XMLFileFeatures(sc.getRealPath(filename));
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
36 sc.setAttribute(Features.CONTEXT_ATTRIBUTE, features);
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
37 } catch(IOException e) {
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
38 logger.error(e);
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
39 }
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
40 }
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
41
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
42 @Override
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
43 public void contextDestroyed(ServletContextEvent sce) {
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
44 //DO NOTHING
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
45 }
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
46
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
47
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
48 private void initLogging(ServletContext sc) {
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
49 String log4jProperties = System.getenv(LOG4J_PROPERTIES);
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
50
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
51 if (log4jProperties == null || log4jProperties.length() == 0) {
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
52 String file = sc.getInitParameter("log4j-properties");
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
53
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
54 if (file != null && file.length() > 0) {
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
55 log4jProperties = sc.getRealPath(file);
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
56 }
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
57 }
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
58 System.out.println(log4jProperties);
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
59
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
60 LoggingConfigurator.init(log4jProperties);
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
61 }
763789a9acca Rename FeatureServletContextListener and move it out of the features package
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
62 }

http://dive4elements.wald.intevation.org