<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<div class="moz-cite-prefix">On 6/12/14 2:37 PM, Tom Zeller wrote:<br>
</div>
<blockquote
cite="mid:CAMNmQDSb11-2URMEeQyXqCvpx_AROrK05m+8kyomLHENaA=ogg@mail.gmail.com"
type="cite">
<pre wrap="">Hey Brent,
It looks to me like contextConfigLocation property replacement does
not work for property sources added by an
ApplicationContextInitializer. Do you know if that is true ?</pre>
</blockquote>
<br>
No, I've not thought about that specifically. However, thinking
about it now, I wouldn't necessarily expect it to work. It only
works in application context XML because you load the property
placeholder configurer to do the property replacement there. (See
below, it looks like property replacement does happen on the
location values but it's happening too early, read on...)<br>
<br>
However I *think* you can make it work right in your
ApplicationContextInitializer impl. Looking at their code in
org.springframework.web.context.ContextLoader#configureAndRefreshWebApplicationContext,
they pull that init param out of web.xml and set it on the context
prior to calling the ACIs and doing the refresh().<br>
<br>
So I imagine you could do your own property replacement on the
context config location string(s) by using
ConfigurableWebApplicationContext #getConfigLocations() and
#setConfigLocations(). <br>
<br>
Actually, it looks like setConfigLocations() might actually do
property replacement at the time it is called - but in the init of
the root web application context that is called before the ACIs get
called, so your custom PropertySource isn't there yet. Forcing the
property replacement on those in your ACI might be as simple as
calling context.setConfigLocations(context.getConfigLocations())
*after* you've added your custom property source, to force that
property replacement to happen again with the newly updated
Environment.<br>
<br>
If not, then I'm pretty sure you can just manually do replacement on
the values from getConfigLocations() and set them back using
setConfigLocation(). <br>
<br>
--Brent<br>
<br>
<br>
<br>
<pre wrap="">
</pre>
<br>
</body>
</html>