users@glassfish.java.net

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

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Fri, 18 Jun 2010 16:09:57 -0700

glassfish_at_javadesktop.org wrote:
> 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?

It's the same as before: you get a reference from
SessionContext.getEJBObject() - otherwise it's an instance call, and the
container has no knowledge about it.

-marina
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>