File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes J2EE Pattern for Configuration Management ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "J2EE Pattern for Configuration Management ?" Watch "J2EE Pattern for Configuration Management ?" New topic
Author

J2EE Pattern for Configuration Management ?

Benoît de Chateauvieux
Ranch Hand

Joined: Aug 10, 2007
Posts: 183
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


SCJP5 | SCBCD5 | SCEA5 Part 1
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
What are the current problems you are having with the management of your configuration?
Benoît de Chateauvieux
Ranch Hand

Joined: Aug 10, 2007
Posts: 183
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

Joined: Apr 16, 2008
Posts: 2187
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

Joined: Aug 10, 2007
Posts: 183
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

Joined: Apr 16, 2008
Posts: 2187
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

Joined: Aug 10, 2007
Posts: 183
You're right, I just need a short delay !
Thanks.

Benoît
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Benoît de Chateauvieux
Ranch Hand

Joined: Aug 10, 2007
Posts: 183
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: J2EE Pattern for Configuration Management ?
 
Similar Threads
Shift from role of a unix administrator to developer
Software Config. Management
The Big Picture : Resource Management
Release It!: How much Design and Deploy
Front Controller and Application Controller