File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Caching Java Properties" Watch "Caching Java Properties" New topic

Caching Java Properties

Chad Wessel

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

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

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

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

I agree. Here's the link:
subject: Caching Java Properties
It's not a secret anymore!