|
From: <tk...@tk...> - 2005-08-19 19:29:59
|
I am pioneering Spring at a big corporation and I need to be able
to use system environment properties like JAVA_HOME instead of just
java system properties like path.seperator or user.dir ...
I've checked the forums and there were threads on this topic and
it seemed the consensus was that it was not supported and it was
not simple to fix.
This is a requirement for my application, so I've got to resolve
it regardless of wether using ENV properties is a best practice or
not. :) So the first question is wether this is functionality that
the community would like added to Spring or falls into the category
of "Won't Fix".
In support of adding ENV support, JDK 1.5 actually undeprecates
getEnv(), as pointed out in the forums. It's extremely rare for
Sun to undeprecate something and usually only as a result of user
outcry. I was obviously not the first to need this functionality
since the forums already had a thread on it. Ant also supports the
use of ENV properties.
The way any deals with it configuration wise is to have
<property environment="env">
Then variables like {env.JAVA_HOME} can be used.
So depending on the above answer, I'll either try to help this problem getting
solved as part of the distribution on my own time, or I'll be creating a
custom solution just for my employer.
Implementation wise it seems there are two most obvious approaches:
1. extends org.springframework.beans.factory.config.PropertyResourceConfigurer
2. enhance org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
Already there are static variables to set behavior on getting java system
properties like path.seperator, using them as a fallback, etc. Additional
constants could be added to support wether to use environmental properties
or something like a env: URL, like you can do file: .
If I am overlooking something and there is already support somehow, let me know.
Paul Sundling
|