I have a servlet that on startup compiles a list of 700 people. It has become apparent that a more regular/frequent schedule needs to be established. So I'm looking into running it once an hour. How would I implement scheduleAtFixedRate in that type of situation.
[ March 25, 2005: Message edited by: Timy McTipperstan ]
You can achieve it in the following ways 1) subscribe to a timmer event which will notify your people compiling process every hours? 2) keep track of your last refesh time. If the currenttime - last refresh time > 1hr, recompile your people list. 3) create a thread and put it to sleep for an hour
Tomcat doesn't have any built in timers. Resin has one but it goes beyond the servlet spec (might not matter to you).
I also asked about the OS because the easiest way to implement this is with a cron job and wget. With one line of code, you can have the OS make a request to your servet every [i]n[/n] days, minutes, weeks, etc... There are probably equivalents in Windows but I'm not sure what they are.
Also, James Curwen (sp?) posted the code to a timer he wrote within the last month or so. I'm not sure if it was here or in the JSP forum.
Did you not like Bear's caching pattern?
Joined: Feb 17, 2005
Havent looked at that one yet, will be looking into that this morning.
subject: Adding a Timer to a ServletContext Attribute