Mercurial > dive4elements > river
view gwt-client/src/main/java/org/dive4elements/river/client/server/BaseServletContextListener.java @ 9063:b6919e3c2d86
work on uinfo-inundation_duration states
author | gernotbelger |
---|---|
date | Tue, 08 May 2018 15:21:23 +0200 |
parents | 5e38e2924c07 |
children | 654aaa0d7576 |
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.client.server; import java.io.IOException; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import org.apache.log4j.Logger; import org.dive4elements.river.client.server.features.Features; import org.dive4elements.river.client.server.features.XMLFileFeatures; /** * ServletContextListenter to initalize the Features globally for * all Servlets */ public class BaseServletContextListener implements ServletContextListener { public static final String LOG4J_PROPERTIES = "FLYS_CLIENT_LOG4J_PROPERIES"; public static final Logger log = Logger.getLogger( BaseServletContextListener.class); @Override public void contextInitialized(ServletContextEvent sce) { ServletContext sc = sce.getServletContext(); this.initLogging(sc); String filename = sc.getInitParameter("features-file"); log.debug("Initializing ServletContext"); try { XMLFileFeatures features = new XMLFileFeatures( sc.getRealPath(filename)); sc.setAttribute(Features.CONTEXT_ATTRIBUTE, features); } catch(IOException e) { log.error(e); } } @Override public void contextDestroyed(ServletContextEvent sce) { //DO NOTHING } private void initLogging(ServletContext sc) { String log4jProperties = System.getenv(LOG4J_PROPERTIES); if (log4jProperties == null || log4jProperties.length() == 0) { String file = sc.getInitParameter("log4j-properties"); if (file != null && file.length() > 0) { log4jProperties = sc.getRealPath(file); } } System.out.println(log4jProperties); LoggingConfigurator.init(log4jProperties); } }