Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Properties or Resource Bundle

 
Karthik Rajendiran
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,
I am developing one application, where we need to maintain some application configuration in a properties file. and some messages in another properties file

file1: config.properties
file2: appMesages.properties

This application consists of 2 war[1 webservices, 1 normal web UI] and 1 ear [mdb] going to be deployed in oc4j.

This is a mission criticalapplication, cannot be restarted many times.

q1)
I would like to know what are the ways we can reload a properties file once a change has been done.

q2) Since i have 2 war, 1 ear, where can i keep this resources files and make it use across the application in the domain. is there any way to specify the path

At Present,

I am using ResourceBundle


But if business or my deployer changes the properties file , how to make application recognise it and use it without restarting.

Can anyone help me out?
Regards
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I imagine this is easiest to achieve using a ResourceBundle.Control subclass that overrides the getTimeToLive method by either returning zero (validate* the resource every time it is retrieved), TTL_NO_CACHE (don't put the bundle in a cache - effectively reload bundle every time the factory method is called), or has some count-down that sets a reasonable amount of time between validations.

*Validate means it will use the needsReload method to check if the data in the ResourceBundle needs to be reloaded. Typically for .properties files that would mean checking if the modified time of the file is after a timestamp the resource bundle holds internally.

For example:


See: ResourceBundle.Control API
 
Karthik Rajendiran
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks steve sir, for the information.
One question.
If we use fileinputstream to load the resources to properties, it would be performance hit rite due to I/O operations. ?
 
Karthik Rajendiran
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding the second question,
If i have 2 wars, 1 ear sharing the properties and resources, which is the best way to keep and where to keep in server,

1. inside the jar and give classpath or put it in resources folder of server?
 
Kuladip Yadav
Ranch Hand
Posts: 162
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Karthik Rajendiran:
Regarding the second question,
If i have 2 wars, 1 ear sharing the properties and resources, which is the best way to keep and where to keep in server,

1. inside the jar and give classpath or put it in resources folder of server?



put it in resources folder will be good
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic