/** * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) */ public void contextInitialized(ServletContextEvent sce) { ServletContext context = sce.getServletContext(); Properties boot = loadBootProperties(context); String contineoHome = boot.getProperty(CONTINEO_HOME); // replace system properties if (contineoHome.indexOf("$") != -1) { contineoHome = StrSubstitutor.replaceSystemProperties(contineoHome); } boot.setProperty(CONTINEO_HOME, initContineoHomePath(contineoHome)); boot.setProperty(CONTINEO_APP_ROOTDIR, initRootPath(context)); boot.setProperty(CONTINEO_APP_PLUGINSDIR, initPluginsPath(context)); boot.setProperty(CONTINEO_APP_PLUGINREGISTRY, initPluginRegistry()); try { String log4jPath = context.getRealPath("/WEB-INF/classes/log4j.xml"); System.out.println("log4jPath = " + log4jPath); Log4jConfigurer.initLogging(log4jPath); } catch (FileNotFoundException e) { e.printStackTrace(); } saveBootProperties(boot, context); // Initialize plugins org.contineo.util.PluginRegistry.getInstance().init(); }
/** * Reads the {@link InputStream} and substitutes system properties. * * @return {@link Reader} */ private static Reader loadInputStream(InputStream propertiesStream) throws IOException { StringBuilder buff = new StringBuilder(); try (InputStreamReader isr = new InputStreamReader(propertiesStream, Charset.defaultCharset()); BufferedReader reader = new BufferedReader(isr)) { String line; while ((line = reader.readLine()) != null) { buff.append(line).append("\n"); } } return new StringReader(StrSubstitutor.replaceSystemProperties(buff.toString())); }