/**
*
* Maintainance work is performed. *
* * @author wprinz */ public class PdfASServletContextListener implements ServletContextListener { /** * The logger. */ private static final Logger logger = ConfigLogger.getLogger(PdfASServletContextListener.class); /** * The servlet init parameter that may be used to declare the pdf-as configuration folder. The * init parameter may be set in web.xml or in META-INF/context.xml resp. * conf/Catalina/localhost/pdf-as.xml if deployed. */ private final static String CONFIG_SERVLET_INIT_PARAMETER = "work-dir"; /** * @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(Constants.CONFIG_SYSTEM_PROPERTY); String scWorkdir = sce.getServletContext().getInitParameter(CONFIG_SERVLET_INIT_PARAMETER); String work_dir; // search for system property if (sysPropWorkdir != null && sysPropWorkdir.length() > 0) { work_dir = sysPropWorkdir; logger.debug("Work-dir configuration via system property \"" + Constants.CONFIG_SYSTEM_PROPERTY + "\" = \"" + sysPropWorkdir + "\"."); // search for servlet parameter } else if (scWorkdir != null && scWorkdir.length() > 0){ work_dir = scWorkdir; logger.debug("Work-dir configuration via servlet init parameter \"" + CONFIG_SERVLET_INIT_PARAMETER + "\" = \"" + scWorkdir + "\"."); // assume configuration to be located in webapp path } else { work_dir = sce.getServletContext().getRealPath("/"); logger.debug("PDF-AS work-dir not explicitely given. Assuming configuration is located in webapp folder \"" + work_dir + "\"."); } logger.info("PDF-AS configuration location = \"" + work_dir + "\""); // 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(); // } SettingsReader.initializeForWeb(work_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$ } }