Author: echatellier Date: 2013-07-18 23:19:21 +0200 (Thu, 18 Jul 2013) New Revision: 147 Url: http://nuiton.org/projects/nuiton-js/repository/revisions/147 Log: Better fix of servlet context loading (still used by maven plugin) Modified: trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/NuitonJsWroConfigurationFactory.java Modified: trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/NuitonJsWroConfigurationFactory.java =================================================================== --- trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/NuitonJsWroConfigurationFactory.java 2013-07-17 15:58:54 UTC (rev 146) +++ trunk/nuiton-js-wro/src/main/java/org/nuiton/js/wro/NuitonJsWroConfigurationFactory.java 2013-07-18 21:19:21 UTC (rev 147) @@ -66,16 +66,16 @@ @Override public final WroConfiguration create() { - return new PropertyWroConfigurationFactory(initProperties()).create(); + Properties properties = initProperties(); + properties = loadContextProperties(properties); + return new PropertyWroConfigurationFactory(properties).create(); } /** - * @return default path to configuration file relative to {@link ServletContext} location. - * @deprecated since 1.0.1 with no remplacment, will be removed in 1.1+ + * @return default path to configuration file relative to classpath / location. */ - @Deprecated protected String getUserConfigPath() { - return "/WEB-INF/nuiton-js.properties"; + return "/nuiton-js.properties"; } protected Properties getDefaultConfig() { @@ -94,10 +94,10 @@ Properties result = getDefaultConfig(); InputStream propertyStream = null; - String file = "/nuiton-js.properties"; + String file = getUserConfigPath(); try { LOG.debug("loading config resource from: {}", file); - propertyStream = NuitonJsWroConfigurationFactory.class.getResourceAsStream(file); + propertyStream = loadAsStream(file); if (propertyStream != null) { Properties props = new Properties(); props.load(propertyStream); @@ -109,7 +109,7 @@ IOUtils.closeQuietly(propertyStream); } - return loadContextProperties(result); + return result; } /** @@ -121,10 +121,10 @@ @Deprecated protected Properties loadContextProperties(Properties current) { InputStream propertyStream = null; - String file = getUserConfigPath(); + String file = "/WEB-INF/nuiton-js.properties"; try { LOG.debug("loading config resource from: {}", file); - propertyStream = loadAsStream(file); + propertyStream = getServletContext().getResourceAsStream(file); if (propertyStream != null) { LOG.warn("Loading configuration from deprecated {} location. Update configuration to use classpath '/nuiton-js.properties' instead", file); @@ -140,15 +140,14 @@ return current; } - /** - * @deprecated since 1.0.1 with no remplacment, will be removed in 1.1+ - */ - @Deprecated protected InputStream loadAsStream(String file) throws Exception { - InputStream result = getServletContext().getResourceAsStream(file); + InputStream result = NuitonJsWroConfigurationFactory.class.getResourceAsStream(file); return result; } + /** + * @deprecated since 1.0.1 file moved to classpath, remove servlet context loading in 1.1+ + */ protected ServletContext getServletContext() { ServletContext result; if (filterConfig != null) {
participants (1)
-
echatellier@users.nuiton.org