Spring PropertySource and Environment

Brent Putman putmanb at georgetown.edu
Fri May 2 21:07:41 EDT 2014


On 5/2/14 5:45 PM, Cantor, Scott wrote:
>> Anyway, I don't know if this is useful, or solves any problems or makes things
>> cleaner, but worth looking at.  One advantage I think is that you could then
>> just have generic boilerplate:
>>
>> <context:property-placeholder />
>>
>> declared once in each app context config XML, without referencing any
>> specific 'location', etc.
> I sent a note about this to Tom and Rod since it's more internal discussion at this point, but we actually may need to figure out how to do that,



I think the above pretty much just works if you configure any
PropertySource(s) on the context, since in recent versions of Spring the
above context: schema element actually installs by default an instance
of PropertySourcesPlaceholderConfigurer (which is PropertySource-aware),
rather than the older PropertyPlaceholderConfigurer (which isn't).



>  because right now we have some degree of disconnect between treating Windows paths as actual paths and treating them as file:/ URLs.


I don't know if this helps for the Windows cases, but what I'm actually
doing in one of my components (CLI) is just setting some base paths like
app.home and app.configDir using the PropertySource, and then in the XML
wiring I just have:

<context:property-placeholder
location="file:${app.configDir}/app.properties"/>

Just lets me abstract away the app.home and so forth, for example by
allowing it to be specified by a command-line argument.



Fwiw, I also supply the same base properties (which includes an
app.logDir) to the code that bootstraps my Logback config, and set those
properties natively in the LoggerContext like so:

loggerContext.putProperty(propName, properties.getProperty(propName))


which then lets me reference those in my logback.xml.


>
> You can get away with some things when you use them as URLs that don't work when you try and do path weaving with the Path class.
>
> I'm going to need to review what V2 is doing with IDP_HOME, if anything.
>
>


Yeah, I don't know what we did in V2 vis-a-via Windows, but I guess it
must be working somehow...






-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://shibboleth.net/pipermail/dev/attachments/20140502/635f48b7/attachment.html 


More information about the dev mailing list