-
Dec 6th, 2011, 05:55 PM
#1
using a <jee:jndi-lookup string inside an instance of PropertyPlaceholderConfigurer
Environment: Windows server 2003, Spring 3.0, Tomcat 6
How can I use a JNDI property inside a PropertyPlaceholderConfigurer?
Specifically, I'm using JNDI to look up a java.lang.String that represents a path to a property file needed by my webapp
<jee:jndi-lookup id="mypropsfile1" jndi-name="myPropsFile1" resource-ref="true"/>
<jee:jndi-lookup id="mypropsfile2" jndi-name="myPropsFile2" resource-ref="true"/>
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="locations">
<array>
<value>how to use mypropsfile1 here ??</value>
<value>how to use mypropsfile2 here ??</value>
</array>
</property>
</bean>
My "jee:jndi-lookup"s are working AFAIK. My problem seems to be how to reference JNDI resources inside the tag pair
Thanks in advance!
Mark
-
Dec 7th, 2011, 02:18 PM
#2
I've never tried this. but why not just use <ref> tags instead of your <value> tags. <ref bean="mypropsfile1"/>
Mark
-
Dec 7th, 2011, 06:14 PM
#3
I had stumbled upon the following and it works:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="locations">
<list>
<bean class="org.springframework.core.io.FileSystemResou rce">
<constructor-arg>
<jee:jndi-lookup id="props1" jndi-name="properties-1" resource-ref="true" />
</constructor-arg>
</bean>
<bean class="org.springframework.core.io.FileSystemResou rce">
<constructor-arg>
<jee:jndi-lookup id="props2" jndi-name="properties-2" resource-ref="true" />
</constructor-arg>
</bean>
</list>
</property>
</bean>
Regarding your suggestion, I assume you mean I could do this?
<jee:jndi-lookup id="props1" jndi-name="properties-1" resource-ref="true" />
<jee:jndi-lookup id="props2" jndi-name="properties-2" resource-ref="true" />
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="locations">
<list>
<ref bean="props1"/>
<ref bean="props2"/>
</list>
</property>
</bean>
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules