Preserve programmatically set context config locations

Prior to this fix, ContextLoader(Listener)'s would overwrite any
value set directly against a WebApplicationContext's #setConfigLocation
method. This is a likely scenario when using Spring 3.1's new
WebApplicationInitializer support.

Now a check is performed to ensure that the ContextLoader init-param
value is non-null before doing the overwriting.

Added tests to ensure that all expected precedence, overwriting and
defaulting of context config locations works as expected.

Issue: SPR-8510
This commit is contained in:
Chris Beams
2011-12-12 14:42:24 +00:00
parent ec1b016602
commit 23e58aa718
3 changed files with 192 additions and 1 deletions

View File

@@ -376,7 +376,10 @@ public class ContextLoader {
wac.setParent(parent);
wac.setServletContext(sc);
wac.setConfigLocation(sc.getInitParameter(CONFIG_LOCATION_PARAM));
String initParameter = sc.getInitParameter(CONFIG_LOCATION_PARAM);
if (initParameter != null) {
wac.setConfigLocation(initParameter);
}
customizeContext(sc, wac);
wac.refresh();
}