I prefer openning an InitialContext, grab everything that an EJB may need
from it, then close it. At the bean level, hold the references to those
objects retrieved from the InitialContext.

3 reasons that I do this:

1, you may have problem serializing InitialContext when the bean gets
passivated;

2, InitialContext is expensive, close it after use.

3, I read this from somewhere: a thread who closes the InitialContext has to
be the same thread who created it...


>From: Srinivas Ganapur <[EMAIL PROTECTED]>
>
>Hello Dapeng,
>
>Its good idea to create the InitialContext only once than every time as and
>when required.   I feel it is best to create in  ejbCreate() function,
>rather than in setEntityContext() as the setEntityContext() is called on a
>bean instance every time the bean is moved in-out of a free pool.  Hence,
>best place will be ejbCreate(), which is called only once. Any comments
>from
>others !!  (This is true in Weblogic4.51 , check it for other server
>implementation!!)
>
>Thank you,
>Regards.
>
>Ganapur Srinivas.
>
>Cognizant Technology Solutions India Ltd.
>Ground Floor,
>Deepak Complex,
>National Games Road,
>Opp.Pune Golf Course,
>Yerwada.
>Pune 411006.India.
>Tel. :6691960.Extn-2277.
>[EMAIL PROTECTED]
>
>
>
>Hi,
>
>in many EJB samples I have seen that people create the InitialContext and
>do
>the lookup on each request. I just wonder whether it is necessary or can I
>just do it once at the bean level in ejbCreate or setEntityContext to
>improve the performance? If I can do it only once per bean, where shall I
>do
>the initilization for the different beans? session beans in ejbCreate and
>entity beans in setEntityContext?
>
>I appreciate your help.
>
>cheers
>Dapeng Wang
>
>===========================================================================
>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".
>

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

===========================================================================
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