tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: RV: Session & Context variables architecture problem
Date Mon, 01 Nov 2010 15:00:39 GMT
Hash: SHA1


On 10/28/2010 5:36 PM, Pid wrote:
> I would suggest that you created a class which periodically updated all
> the values by selecting the data in the DB and storing the result in the
> Context.
> Implementing a ServletContextListener will give you access to the
> ServletContext and two methods, for app startup & shutdown, which you
> can use to start the periodic process, and properly stop it (very
> important).
> You may consider using a Timer, or something from the
> java.util.concurrent package.

I would be even lazier (pun intended): record the last-accessed-time of
the data in the Context as well, and perform a re-fetch whenever that
time is too old (or missing entirely). That avoids the headache of
managing another thread on the server (how many questions do we get
about still-running threads on app shutdown?) and does not refresh the
values from the database unless they are actually requested by code (and
therefore doesn't do speculative fetches that might not be required at all).

- -chris
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message