users@glassfish.java.net

Re: EJBContext: thread safe?

From: <jmilkiewicz_at_gmail.com>
Date: Tue, 23 Aug 2011 10:35:28 +0200

Hi

Asfair from J2EE it was quite common to cache initial context for
performance gains. Unfortunately to cache properly you need to tackle
with synchronizing.
A few years ago i did (very basic) performance tests to find out if
caching initial context matters.The results were highly
application-server dependent, so i would suggest measuring instead of
guessing.

br Jakub



2011/8/19 Laird Nelson <ljnelson_at_gmail.com>:
> On Fri, Aug 19, 2011 at 11:01 AM, Cheng Fang <cheng.fang_at_oracle.com> wrote:
>>
>> 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?
>
> I'm probably working with outdated information, but the act of creating a
> new InitialContext() used to be regarded as really heavyweight.  You would
> do it when you had to, but you would cache it (and thereby of course
> introduce thread safety concerns) whenever you could.  Am I hearing you
> right that InitialContext creation is now cheap?
>
> Best,
> Laird
>
> --
> http://about.me/lairdnelson
>
>