users@glassfish.java.net

Re: Best way to kick off thread from EJB singleton bean?

From: <glassfish_at_javadesktop.org>
Date: Fri, 18 Jun 2010 16:14:19 PDT

Thanks for the advice.

Your simple question made me think...because my first instinct was, well, see, it's this feature in Drools that lets Drools constantly monitor a directory for changes...and of course it must be doing so by manipulating the current thread--which, officially, is a no-no in EJB land (none of the standard Java EE 6 security permissions involve anything having to do with threads). So...I'm not sure. :-)

For the moment, let's say I just need to kick off the daemon and effectively have it run forever. And let's suppose I were to use the AsyncResult to accomplish this. This kickoff actually has to happen in my @PostConstruct, and only the bean itself would be calling this method. Does the asynchronous specification (sections 4.5 and following in the EJB 3.1 spec)...hmm...how would I call a bean method from within the bean in such a way that the container-interposed asynchronous machinery would be invoked? Is that ALL encapsulated in the AsyncResult class?

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

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