/** * Copyright (c) 2006 by Know-Center, Graz, Austria * * This software is the confidential and proprietary information of Know-Center, * Graz, Austria. You shall not disclose such Confidential Information and shall * use it only in accordance with the terms of the license agreement you entered * into with Know-Center. * * KNOW-CENTER MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR * NON-INFRINGEMENT. KNOW-CENTER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. * * $Id: PdfASServletContextListener.java,v 1.3 2006/10/31 08:22:04 wprinz Exp $ */ package at.knowcenter.wag.egov.egiz.web; import java.io.File; import java.io.IOException; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; import at.knowcenter.wag.egov.egiz.cfg.ConfigLogger; import at.knowcenter.wag.egov.egiz.cfg.SettingsReader; /** * The ServletContextListener is notified when the webapplication starts up and shuts down. * *

* Maintainance work is performed. *

* * @author wprinz */ public class PdfASServletContextListener implements ServletContextListener { /** * The logger. */ private static final Logger logger = ConfigLogger.getLogger(PdfASServletContextListener.class); /** * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) */ public void contextInitialized(ServletContextEvent sce) { logger.info("PDF-AS Context init"); //$NON-NLS-1$ String work_dir = sce.getServletContext().getInitParameter("work-dir"); //$NON-NLS-1$ logger.info("PDF-AS work-dir context parameter = " + work_dir); //$NON-NLS-1$ String base_dir = sce.getServletContext().getRealPath("/"); //$NON-NLS-1$ logger.info("PDF-AS real path = " + base_dir); //$NON-NLS-1$ try { logger.info("PDF-AS work directory = " + new File(work_dir).getCanonicalPath()); //$NON-NLS-1$ logger.info("PDF-AS base directory = " + new File(base_dir).getCanonicalPath()); //$NON-NLS-1$ } catch (IOException e) { e.printStackTrace(); } if (work_dir != null && work_dir.length() > 0) { logger.info("The PDF-AS work-dir context parameter is present (and not empty)."); base_dir = work_dir; } logger.info("The PDF-AS application will be initialized for the directory: " + base_dir); SettingsReader.initializeForWeb(base_dir); PropertyConfigurator.configure(SettingsReader.CONFIG_PATH + "log4j.properties"); SettingsReader.clearTemporaryDirectory(); } /** * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent) */ public void contextDestroyed(ServletContextEvent sce) { SettingsReader.clearTemporaryDirectory(); logger.info("PDF-AS Context exit"); //$NON-NLS-1$ } }