/**
*
* 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 sysPropWorkdir = System.getProperty("pdf-as.work-dir"); String work_dir; if (sysPropWorkdir != null && sysPropWorkdir.length() > 0) { work_dir = sysPropWorkdir; logger.info("Work-dir configuration via system property."); logger.info("PDF-AS work-dir via system property = " + work_dir); //$NON-NLS-1$ } else { 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) { 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$ } }