What is the best practice for reading property files in J2EE


General J2EE: What is the best practice for reading property files in J2EE

  1. I tried looking through the discussions but couldn't find any conclusive answers. Currently we are reading property files in our J2EE app, using the ClassLoader approach. I am looking for an out of the box open source solution, some framework that can be used to read and cache property files (XML or regular .properties file). Also it should be able to dynamically pick up any changes made to the property file. I am also planning to change the property file to an XML, wrap it with a Java class with getters. Is there anything open source solution out there? If not, what is the industry best practice. Should we move the properties to the database and then cache them. Again any framework that can cache and pick up updates from the database? I have checked OSCache, it does not pick up updates from the database. Any guidance from gurus will be appreciated! Thanks.
  2. Take a look at Apache commons-configuration. This might be what you are looking for. http://jakarta.apache.org/commons/configuration/ IMHO, properties that are fine to go to database should be application catalog data, like a list of countries. And you can get an MBean to refresh those values when changes happen. For configuration properties, I would still stick to putting properties in text files.
  3. Is there anything open source solution out there?
    http://obix-framework.sourceforge.net/ Regards, Rakesh.
  4. Thanks Farzad and Rakesh, I appreciate your thoughts and comments. I reviewed both jakarta commons configuration and obix for 2 of my main requirements, type safety and dynamic updates. I am still not sure about caching, I am assuming values are being cached. Does Spring framework provide these features? And can either of these frameworks be integrated with Spring? Jakarta Commons Configuration: - Type safety can be achived by using beans - Dynamic updates can be picked up by registering Event listeners. Obix: - Type safety - I found a tag in the XML for type string. I am not sure if other types can be specified (Integer, Long...). Would you know more on this? - Dynamic updates - this is a kewl feature of this framework, provides it out of the box.