Results 1 to 2 of 2

Thread: Problem in reading Property files.

  1. #1
    Join Date
    Jan 2005
    Posts
    1

    Default Problem in reading Property files.

    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!

  2. #2
    Join Date
    Aug 2007
    Posts
    1

    Default Decrypt password from Property File

    Hi,

    I need to decrypt the password in properties file. I have overridden the convertPropertyValue(String) method and able to retrieve the password from the properties file. But my requirement is, i want to retrieve the property value in the form of key value pair.

    oracle.password=XXXXXX123

    Is there any way to pass ("oracle.password") as a key and retrieve value in spring?

    Regards,
    Saravana

Similar Threads

  1. ERROR: Context initialization failed
    By makhlo in forum Architecture
    Replies: 8
    Last Post: Jul 11th, 2008, 01:41 AM
  2. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. Replies: 4
    Last Post: Aug 17th, 2005, 04:42 AM
  5. Replies: 2
    Last Post: May 13th, 2005, 05:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •