
| Key: |
SPR-4268
|
| Type: |
New Feature
|
| Status: |
Open
|
| Priority: |
Major
|
| Assignee: |
Unassigned
|
| Reporter: |
David Goblirsch
|
| Votes: |
0
|
| Watchers: |
0
|
|
If you were logged in you would be able to see more operations.
|
|
|
|
Environment:
|
JSE instead of JEE
|
|
|
ClassPathXmlApplicationContext will detect PropertyPlaceholderConfigurers that are
configured in the XML file, but these beans point to files.
For those of us using JSE instead of JEE, we often have programs for which some properties
are configured by command line parameters. It would therefore be convenient to be able to
pass a PropertyPlaceholderConfigurer to the ClassPathXmlApplicationContext upon construction
for those properties that change from run-to-run. The main program would
o parse the command line
o set up Properties from the command line arguments
o construct a PropertyPlaceholderConfigurer
o then create the ClassPathXmlApplicationContext with the configurer as one
of the constructor parameters.
This way, configuration can be divided into 2 sets of parameters: those configurable by file because they are common
to all the runs of a given application (and thus they can be configured in the config file) and those configurable from the
command line but still allowing the flexibility and non-lazy instantation of beans offered by an ApplicationContext.
Currently, the only way I see to do this is to use a BeanFactory and explicitly post process it. But the ApplicationContext
offers some useful features above and beyond the BeanFactory. That is, it appears that the only way to apply
a PropertyPlaceholderConfigurer to an AppicationContext is to configure it in the XML.
|
|
Description
|
ClassPathXmlApplicationContext will detect PropertyPlaceholderConfigurers that are
configured in the XML file, but these beans point to files.
For those of us using JSE instead of JEE, we often have programs for which some properties
are configured by command line parameters. It would therefore be convenient to be able to
pass a PropertyPlaceholderConfigurer to the ClassPathXmlApplicationContext upon construction
for those properties that change from run-to-run. The main program would
o parse the command line
o set up Properties from the command line arguments
o construct a PropertyPlaceholderConfigurer
o then create the ClassPathXmlApplicationContext with the configurer as one
of the constructor parameters.
This way, configuration can be divided into 2 sets of parameters: those configurable by file because they are common
to all the runs of a given application (and thus they can be configured in the config file) and those configurable from the
command line but still allowing the flexibility and non-lazy instantation of beans offered by an ApplicationContext.
Currently, the only way I see to do this is to use a BeanFactory and explicitly post process it. But the ApplicationContext
offers some useful features above and beyond the BeanFactory. That is, it appears that the only way to apply
a PropertyPlaceholderConfigurer to an AppicationContext is to configure it in the XML.
|
Show » |
|
java -Dfoo=bar YourProgram
in your configuration refer to ${foo} and it should work.
Next to that (depending on your JRE version) you could pass them to your programm and before instantiating the ApplicationContext call System.setProperty(name, value) to set properties, those will also be picked up by the already configured PropertyPlaceHolder.