• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

J2EE Pattern for Configuration Management ?

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I'm looking for a good pattern for the management of my configuration.

My configuration resides in the database.
The configurable elements all have a dateSince and a dateUpTo field.

I want to transparently (for the developer) manage those dateSince and dateUpTo.

Any idea ?

Benoît
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are the current problems you are having with the management of your configuration?
 
Benoît de Chateauvieux
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi James,

I have 2 doubts:

1/ I don't want the developers to have to think of those dates every time they program a query to the database.
I'm looking for a generic way of managing this.
I'm using JPA (Hibernate) with only NamedQueries.

2/ In my presentation tiers (JSF), I have a cache (Bean with scope application) with the catalogs (all the combobox of my application, like cities, countries, etc.).
As the elements have dateSince and dateUpTo, the catalogs can change every day.
how can I refresh my cache ?

Thank you for your time and ideas

Benoît
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to enable developers to query the database without those dates, then create a generic query that does not use these date fields. And have them use this query instead of the one that uses the dates.

When you created the cache, how long did you set the expiration time to? Change the setting to refresh every twelve hours.

 
Benoît de Chateauvieux
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi James,

Thanks for your answers.

1/ OK.

2/ Why is it better to refresh the cache every 12 hours ?
For example, if I start my server at 23:00, I will have in cache the elements of the day D.
Does-it mean that I must wait until 11:00 of the day D+1 in order to see the elements that have a dateSince = D+1 ?

3/ Another question...
Imagine I have a catalog (a combobox of code/value) composed of:
A - "label A" - dateUpTo = null
B - "label B" - dateUpTo = D
C - "label C" - dateUpTo = null
If, during the day D+1, I refresh my cache, then the element B will desapear from the cache.
My combobox now contains only A and C.
How can I then display an old form-data, captured when this elements was in the configuration ?
It can potentially reference a B code and this code isn't in the combo anymore...

Thank you for your help.

Benoît
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My suggestion to refresh cache every twelve hours was based on your information that the catalog information changes every "day." You need to figure out what the best time period is, you should have already covered this when you decided to create a cache. How about every twelve minutes?

If refreshing the cache every twelve minutes doesn't work, then maybe you should try every two minutes or remove the cache period.
 
Benoît de Chateauvieux
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're right, I just need a short delay !
Thanks.

Benoît
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Refreshing the cache at a fixed interval, starting at a random time - when in fact you know exactly the point of time when the cache content will become invalid - sounds like a suboptimal solution to me. Sounds to me like you should simply refresh the cache exactly at midnight, shouldn't you?

Regarding old and now invalid form data - what do your users need? Do they need to see that B was choosen but is now invalid? Or would it suffice for them to see that currently no valid option is choosen? Or...
 
Benoît de Chateauvieux
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ijla,

I completly agree with you.

I've just read an interesant introduction to OSCache.

OSCache 2.0 now gives you the ability to expire content at specific dates and/or times based on a cron expression.


from http://www.opensymphony.com/oscache/wiki/Cron Expressions.html
I think I will give it a try.

Thanks for all the answers !

Benoît
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic