This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Caching Java Properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Caching Java Properties" Watch "Caching Java Properties" New topic
Author

Caching Java Properties

Chad Wessel
Greenhorn

Joined: Jul 13, 2001
Posts: 2
In my web app, I have various scenarios where I read from Properties files to obtain information, such as JDBC pooling configurations, etc. Does anyone know of a clever way to load these properties files once and cache them, so that I won't have to hit the hard drive each time to obtain the the properties when they are needed?
Thanks in advance!
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
I�ve never done this but I think you can create a class and populate it with final static fields representing your configurations and than you can acces its fields using NameOfClass.field this must be much faster than hiting the disk all the time.
I hope it helps.
Mike Burnham
Greenhorn

Joined: Jun 06, 2001
Posts: 24
I load these into a static class for reference. In the logic to restart/refresh my application, I refresh these properties.


SCJP 1.2
Chad Wessel
Greenhorn

Joined: Jul 13, 2001
Posts: 2
Thank you both for your replies... I'll give this a try and post my results. =)
Chad
spalaniv
Greenhorn

Joined: May 08, 2001
Posts: 5
Create a Singleton object and store the properties as class data members.


Sakthi
 
jQuery in Action, 2nd edition
 
subject: Caching Java Properties