This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Property files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Property files" Watch "Property files" New topic
Author

Property files

Nijeesh Balan
Ranch Hand

Joined: Oct 09, 2000
Posts: 116
Hi All,
We are having some property files in our project.
I don't want to do File I/O operation during each method call nor do I want to load the session with these values. So the property file loading was specified in the static block of the class and the values were retrieved.
But the problem here is if the property file is modified we have to restart the application server.
Is there any work-around for this or is there any other method of implementation?
TIA,
Nijeesh.


Thanks & Regards,<br />Nijeesh.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Don't store the properties values but go through the Properties object every time the value is needed. The lookup is quite quick.
If you have access to the Properties object go through a static method, you can have that method check the datestamp on the file and reload if necessary.
Bill
Nijeesh Balan
Ranch Hand

Joined: Oct 09, 2000
Posts: 116
Hi William,
Thanks for the response.
Is it not heavy to check the lastModified time of the file every time(as it is also a File I/O operation) when you try to read from the Property object.
Can we have a thread which runs during regular intervals and does this operation
Please Clarify
Thanks in Advance,
Nijeesh.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Checking the last modified date is certainly an IO operation but I don't think it is a particularly heavy one. Generally the operating system will have a cache of recently accessed disk data so it may not involve any real disk operation.
As you suggest, if your traffic is heavy enough that this might make a differenc, then a separate Thread that looks every X seconds is easy enough to do.
If your properties data is complex, consider using an XML DOM instead of a long properties file.
Bill
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Property files
 
Similar Threads
Get Property Values from Properties.Load()
Reading from two property files using a relative path
Property File Reload problem
EJB 3.0 Question
NX: when to use values from suncertify.properties