I'm having a conceptual (?) problem with properties and injection:
I'm converting a legacy system to use spring and have done a lot of
DI using Spring to great effect, removing a lot of singletons in the
process...
However, there's one area in the application which I cannot seem to get
my head around and that is the use of properties (as in System properties)
together with Spring. The application is deployed onto some installation
directory (it is a stand alone application), and it requires references to
names of directories in which it can find resources, or into which it can
create new files. These directory names are resolved during installation
and are placed using some known property names in the global property
file, which is read during startup to bring this info into the application.
My problem is two fold, essentially:
1. What is a good practice to replace calls like GlobalProperties.get(KEY),
using Spring? Basically a typical pattern of current code in the Legacy
system is:
The reason is that there are many such properties andCode:... private static final String DIR_NAME = GlobalProperties.get(KEY); ... void method() { ... new File(DIR_NAME, fileName); ...}
so configuring using Spring would require a large number of injections,
into a large number of classes, or essentially copying from the
propery file into a singleton which holds
these values. There is of course the intention to avoid
dependency on/knowledge of the Spring application context
as much as possible (this is why we use this IoC in the first place).
2. How does Spring address the issue of run time configuration values in
a way that does not expose the Spring xml configuration files to the
end user? This, in my mind, the difference between the role Spring plays
to wire up application components (which is fixed) and usage of these
run time parameters, which is fairly dynamic and may be unknown at
coniguration time.
Thanks for any answer / clarification


Reply With Quote
. I suppose what I'm asking is what should I replace my