I wonder if there is a way to extract properties from Spring Environment (e.g. obtained from ApplicationContext) in the form of Properties instance? Or, at least, is there a way to enumerate the properties in Spring Environment, or get them all as a map, or any other way I can turn a [initially unknown] set of properties into a Properties object?
I need this in order to create a jclouds Context
by calling org.jclouds.ContextBuilder.newBuilder()
and .overrides(Properties)
. The idea is to configure the actual cloud provider solely by means of .properties file, and I don't want to couple application logic with provider-specific properties.
[UPDATE]
The .properties files to be used are configured using <context:property-placeholder>
, and it actually specifies a list of paths, like this:
< context:property-placeholder location=
"classpath:/jdbc.properties,
file:${jboss.server.config.dir}/jdbc.properties,
file:${catalina.home}/conf/jdbc.properties"
ignore-resource-not-found="true"/>
which suggests that the .properties file is searched in the mentioned list of locations in order. I would like to achieve the following:
- keep the list of .properties files and their possible locations in this XML definition file only;
- allow to place jclouds related properties in any of the .properties files mentioned in the XML;
- access the properties, resolved and loaded by Spring, in the form of Properties object so I am able to feed that to jclouds
ContextBuilder
.
Please let me know if all of this is feasible. Thank you in advance!
-Vlad