It's not a secret anymore!*
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
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Caching Java Properties
 
Similar Threads
Obtaining User/Password info for DB connections
regarding sample test qn 25 from ExamCram book
Sample Session Bean creation.. javax.naming.NamingException: Lookup failed
How to manage a text file is a List or something similar.
Image file Properties -> height and width