Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Properties or Resource Bundle

 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 162
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Water! People swim in water! Even tiny ads swim in water:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic