users@glassfish.java.net

Re: GFv1b14 Transaction problems

From: <glassfish_at_javadesktop.org>
Date: Thu, 14 Jun 2007 13:00:56 PDT

>
> Now, regarding the ServiceContext technique.
>
> Does this run afoul of the "Session Beans aren't
> rentrant" mantra?

Good question. No, it's perfectly safe.
The second invocation will be serviced by a different bean instance,
just as it would be for an invocation made from a different client
component.

>
> Is there any reason to use the ServiceContext method
> over just injecting it, or can a Session Bean not
> inject itself?

Technically it would be fine to inject a stateless @EJB reference to yourself,
since the lifecycle of the stateless bean instance is decoupled from the
reference. However, doing that for a SFSB reference would result in an
infinite loop since a new SFSB instance is created as a side effect of each
SFSB injection.
[Message sent by forum member 'ksak' (ksak)]

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