Hi,
I have 2 property files with lot of key value pairs. The sample content is given below.
file1:
method1(long in0,long in1)=user.*,user.view
method2(String in0)=user.*
..
..
..
file2:
data1=a1,a2,a3
data2=x1,x2
data3=y1,y2
Problem:
I am using org.springframework.beans.factory.config.PropertyP laceholderConfigurer class to load the property data by the following settings in the applicationcontext.xml.
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
<property name="location"><value>/WEB-INF/classes/SystemProperties.properties</value></property>
</bean>
Problem:
1. How do I retrieve values for a given property key, which is as per the format above?
2. In the code side, I have created one PropertyBean class which will have setter and getter methods for each key in the 2nd property file. Since I have lot of keys in my 1st property file, I have created a separate class that reads the file and populates a HashTable without using Spring implementation.
How do I configure Spring in application-Context.xml to populate the properties file, specifically the 1st property file?
3. I understand that I need to create that many number of setter and getter methods in my PropertyBean class. Instead can I use single getter and setter methods which will load all the key-value pairs in the form of any java collection?
My current code is like this
class PropertyBean
{
private String[] data1;
private String[] data2;
private String[] data3;
public void SetData1(String[] data1)
{
this.data1= data1;
}
public void SetData2(String[] data2)
{
this.data2= data2;
}
public void SetData1(String[] data3)
{
this.data3= data3;
}
public String[] getData1()
{
return data1;
}
public String[] getData2()
{
return data2;
}
public String[] getData3()
{
return data3;
}
}
This above class is instantiated in the application-context like this...
<bean id="propertyBean" class="src.propertyBean">
<property name="data1"><value>${data1}</value></property>
<property name="data2"><value>${data2}</value></property>
<property name="data3"><value>${data3}</value></property>
</bean>
<bean id="userManagerTarget" class="src.impl">
<property name="propertyBean"><ref local="propertyBean"/></property>
</bean>
Please help!


Reply With Quote