tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: RV: Session & Context variables architecture problem
Date Mon, 01 Nov 2010 15:00:39 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Pid,

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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkzO1hcACgkQ9CaO5/Lv0PBuKQCePhvYb/rpMHOdUbNRdnJXu6Ud
aWEAn0F8AZcBVBw7KtKkwtGzluualYS6
=ur/V
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message