I have a spring bean (let's call it MagicBean) which has a HashSet<String> as one of its properties.
I know how to init a set like this:
<bean id="mySet" class="org.springframework.beans.factory.config.SetFactoryBean">
<property name="targetSetClass" value="java.util.HashSet"/>
<property name="sourceSet">
<set>
<value>Value 1</value>
<value>Value 2</value>
<value>Value 3</value>
</set>
</property>
</bean>
<bean id="magicBean" class="MagicBean">
<property name="mySet" ref="mySet"/>
</bean>
Is there a way to set the values in the set using values from .properties file instead of hard-coding those value in the xml?
Update 1: Since I might have different numbers of values for this set in different environments, using the hard-coded set in the xml won't work. That's why I need to somehow fetch these values from a properties file.
Update 2:
I came up with a quick-and-dirty way to do this which is list all values as ONE single string in the .properties file and then set this value to the MagicBean. Then in Java code, parse this string.
Any better idea?