> Nic Ferrier wrote:
> >
> > Personally I think it's a bad idea.
> >
>
> Hi,
>
> The idea sounds good to me. :)  This servlet-cron service would simply
> run in its own thread, and wakes up periodically.  This could be
> configured depending on the site's design.  Maybe every 30 seconds
> would be a good start.  It would check if there's any tasks at that
> point in time to be done, and when through go back to sleep

I don't think a generic cron replacement servlet is a good idea,
Cron has lots of nice properties that are hard to do in the servlet
environment like :
        Persistence across reboots/crashes
        correct actions over DST changes (allegedly)
        reliable one-shot actions
        run as less (or more) privileged user

If however you have a bit of servlet (or webapp) related periodic
activity,
then it is fine to code up a thread to be spun off from a servlet,
but be very aware of the servlet lifecycle as it is implemented in your
web server/engine.

Here are a couple of things that might trip you up:
        1) In some engines servlets are not loaded until the first use,
so your cron-servlet may never be loaded unless you take special steps.
        2) Some engines will destroy a servlet that's been idle for a long
time, and then subsequently start a new instance. Your background thread
however may still have a reference to the old servlet, and update the
state
of the 'destroyed' one.
        3) Some engines have multiple VM's running, be sure that the cron
servlet is in the one you want, i.e. the JVM serving https: servlets may
not
be the same as the one serving http: servlets.

None of these issue are insurmountable, but they sure can slow you down,
as I've discovered.

T.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to