Yes. But cache 1 InitialContext per 1 EJB. Don't share the
InitialContext among different EJB instances:

setEntityContext(...) {
        if (ic==null)
                ic = new InitialContext();
}

Good:

private transient InitialContext ic=null;

Bad:

private static transient InitialContext ic = null;

HTH,


Juan Pablo Lorandi
Chief Software Architect
Code Foundry Ltd.
[EMAIL PROTECTED]

Barberstown, Straffan, Co. Kildare, Ireland.
Tel: +353-1-6012050  Fax: +353-1-6012051
Mobile: +353-86-2157900
www.codefoundry.com


> -----Original Message-----
> From: A mailing list for Enterprise JavaBeans development
> [mailto:EJB-INTEREST@;JAVA.SUN.COM] On Behalf Of Anamitra Bhattacharyya
> Sent: Tuesday, November 12, 2002 3:56 PM
> To: [EMAIL PROTECTED]
> Subject: InitialContext caching
>
>
> Hi All
> I was going tthrough the EJB best practices doc in
> http://www-106.ibm.com/developerworks/java/library/j-ejb0924.html
> by Brett. He suggests caching the InitalContext object
> instances to boost performance. However if I fo to the
> javadoc for Context - they clearly say that this : "A Context
> instance is not guaranteed to be synchronized against
> concurrent access by multiple threads. Threads that need to
> access a single Context instance concurrently should
> synchronize amongst themselves and provide the necessary
> locking." I am confused as to how caching will work if this
> is true!. OR is it that if the only use of Context is to
> lookup objects and not to bind objects - then only I can use
> caching? My application uses the Context objects to lookup
> other objects on the JNDI tree and not to bind objects - can
> I use the caching?
>
> thanks
> Anamitra
>
> __________________________________________________
> Do you Yahoo!?
> U2 on LAUNCH - Exclusive greatest hits videos
> http://launch.yahoo.com/u2
>
>
> ==============================================================
> =============
> To unsubscribe, send email to [EMAIL PROTECTED] and
> include in the body of the message "signoff EJB-INTEREST".
> For general help, send email to [EMAIL PROTECTED] and
> include in the body of the message "help".
>
>

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to