users@glassfish.java.net

Re: EJBContext: thread safe?

From: Cheng Fang <cheng.fang_at_oracle.com>
Date: Fri, 19 Aug 2011 11:01:58 -0400

On 8/19/11 10:51 AM, Laird Nelson wrote:
> On Fri, Aug 19, 2011 at 10:27 AM, Cheng Fang <cheng.fang_at_oracle.com
> <mailto:cheng.fang_at_oracle.com>> wrote:
>
> In EJB apps concurrency is managed by the container, and
> application developers don't need to worry about concurrency
> issues. Singleton sessioin bean in EJB 3.1 adds some flexibility
> in terms of bean-managed concurrency, but the concurrency model
> for application developers is still the same. I would consider
> EJBContext immutable and thread-safe.
>
>
> Excellent. InitialContext lookups, however, even within EJB
> applications, still need to be synchronized, yes?
> (http://download.oracle.com/javase/6/docs/api/javax/naming/InitialContext.html;
> last paragraph)
>
Within stateless, stateful, MDB, and Singleton session beans with
container-managed-concurrency and correctly specified locking metadata,
don't need to use synchronized. For bean-managed-concurrency Singleton
bean, yes, you will need to synchronize access to any shared resources,
including IntialContext. But wouldn't it be easier and cheaper to just
use a new InitialContext?

-cheng
> Best,
> Laird