Article:
  Stateful Session EJBs: Beasts of Burden
Subject:   What about nearly static data?
Date:   2001-12-21 04:45:29
From:   jonathan.oconnor
I have a table containing information about the world's currencies (name, ISO code, decimal places, etc...) This information changes maybe once or twice a year. Most of my business logic needs to access this data often, so naturally I want to cache it. The $64 question is, how?


My natuarl inclination is to create a singleton class (probably static methods) which reads teh DB table at initialization or first use.


Then I just use this anywhere I need it. But what happens if I want to refresh the data? Can I use EJBs for a better solution? It should give fast access to the data.


From reading your article, it seems that I shouldn't use a SFSB to do this.


Very interested to hear your advice,
Jonathan O'Connor

Main Topics Newest First

Showing messages 1 through 1 of 1.

  • What about nearly static data?
    2005-08-10 11:44:25  palaniappan.rajaram [View]

    Hello Jonathan,

    Three and half years later I'm faced with the same design issue. I too have some static data which change once in a few days, in the middle of the regular hours of operation. Obviously, restarting when many users are logged in, is not an option.

    Have you found a better solution than a singleton? That was my original approach but refresh became a hassle. Now, I'm debating if I should use a "stateless" session bean (just one instance of it) which should have the following:

    - hashtable for the objects from the database
    - public getter method to retrieve an object
    - refresh method which when called should block access to the getter method until refresh is completed

    I would appreciate any feedback that you can provide.

    Thanks

    Raj
    prajaran@mindspring.com