users@glassfish.java.net

Best way to kick off thread from EJB singleton bean?

From: <glassfish_at_javadesktop.org>
Date: Fri, 18 Jun 2010 13:51:16 PDT

I have a singleton session bean.

In it, I need to ask the container to--in a spec-compliant way--kick off what amounts to a daemon thread.

I know that I have several options ranging from creating a single-use Timer to somehow invoking an asynchronous method on the same bean (where the return type is essentially Future<void>, however one would write that.

I'm leaning towards the Timer.

I have experience writing resource adapters, and there there is a very convenient item called a WorkManager. You get a handle to it and give it a Work instance, and it runs it for you in the background, taking care of cleanup at shutdown. I'm looking for the equivalent from the EJB 3.1 side.

Thanks,
Laird
[Message sent by forum member 'ljnelson']

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