|
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
|
|
From: Juergen H. <ju...@in...> - 2005-08-20 18:59:54
|
Thanks for the suggestion! While we do not generally recommend to access
system environment variables in Spring placeholders, this is nevertheless
worth to be available as an out-of-the-box option.
Hence, I've just added a "searchSystemEnvironment" bean property to
PropertyPlaceholderConfigurer, activating an additional check against system
environment variables after checking JVM system properties.
Environment variables will be checked at the configured time of the system
properties mode, i.e. either overriding local properties or as fallback
after checking local properties.
As a consequence, placeholders like ${JAVA_HOME} will work now, provided
that PropertyPlaceholderConfigurer is configured with
"searchSystemEnvironment=true".
This will be included in the upcoming Spring 1.2.4.
Juergen
-----Original Message-----
From: spr...@li...
[mailto:spr...@li...] On Behalf Of
tk...@tk...
Sent: Friday, August 19, 2005 9:26 PM
To: spr...@li...
Subject: [Springframework-developer] ENV support in config files
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
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September
19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile &
Plan-Driven Development * Managing Projects & Teams * Testing & QA Security
* Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|