@lumpynose:
You don't have to set up the PropertyPlaceholderConfigurer programmatically.
The recipe goes as follows:
Define a name binding in your web server/app server. The value of the string is the position of the property file e.g. classpath:development.properties
Define a resource environment reference in your web.xml/ejb-jar.xml
Code:
<resource-env-ref>
<description></description>
<resource-env-ref-name>string/propertytest</resource-env-ref-name>
<resource-env-ref-type>java.lang.String</resource-env-ref-type>
</resource-env-ref>
Define a string that comes from JNDI in the context.xml
Code:
<bean id="defaultJndiString" class="java.lang.String">
<constructor-arg type="java.lang.String" value="error.string" />
</bean>
<bean id="jndiString" class="org.springframework.jndi.JndiObjectFactoryBean" abstract="true">
<property name="defaultObject" ref="defaultJndiString"/>
</bean>
<bean id="propertytest" parent="jndiString">
<property name="jndiName" value="java:comp/env/string/propertytest"/>
</bean>
Define the PropertyPlaceholderConfigurer with a ref to the JNDI string as location
Code:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" lazy-init="false">
<property name="location" ref="propertytest"/>
</bean>
Now if you want to reference a different property file, say for acceptance tests, you go to the app server and change the value of the name binding to classpath:acceptance.properties.
As I said earlier the deployment resource contains all configurations yet the app server decides which one to use by the value of the name binding.
HTH
Fokko