From: Laird Nelson <ljnelson_at_gmail.com>
Date: Mon, 20 Aug 2012 11:22:42 -0700
Section 16.15.2 of the EJB 3.1 specification states in its entirety:
The Container Provider is responsible for providing an appropriate
> EJBContext object to the referencing component. The object returned must
> be of the appropriate specific type for the bean requesting injection or
> performing the lookup—that is, the container provider must return an
> instance of the SessionContext interface to referencing session beans and
> an instance of the MessageDrivenContext interface to message-driven beans.
Must this EJBContext object be safe for use by multiple threads?
In a stateless session bean that injects a SessionContext, the object
*must*obviously be thread safe, since a stateless session bean is
prohibited from
using synchronization primitives, and hence would be unable to use the
synchronized keyword to control access to this object.
But what about in a singleton session bean with bean-managed concurrency?
Suppose such a bean has a SessionContext injected into it. Must that bean
synchronize access to the SessionContext? Or is the
SessionContextguaranteed by some other part of the specification to be
thread safe?