users@glassfish.java.net

Re: How could I implement and deploy a background process in Glassfish?

From: <glassfish_at_javadesktop.org>
Date: Mon, 14 Jan 2008 13:57:53 PST

I don't know if it's ok according to the spec, but you can also write a ServletContextInitialized that starts a thread in the init method and kills it in the destroy method. It worked for me at least. If portability is not critical you can also write a Glassfish lifecycle module that starts a thread. Note that the ServletContextInitializer (which is deployed as a web application) can be redeployed without restarting Glassfish, which is not possible with a lifecycle. Of course, if you have a clustered Glassfish, then these simple solutions may not work (each node will have its background thread)
[Message sent by forum member 'ewernli' (ewernli)]

http://forums.java.net/jive/thread.jspa?messageID=253860