I think what the original poster asked is, given the following code sequence

public class X implements SessionBean {

   public void someMethod() {
       Context c1 = new InitialContext();
   }

   // ...

}

public class Y {

    public void anotherMethod() {
        Context c2 = new InitialContext();
    }

}

are c1 and c2 logically identical? This is a vendor-independent question,
and the vendor-independent answer is no, c1 is not equivalent to c2, because
of the java:comp/env namespace. This has nothing to do with vendor
optimizations AFAICT.

- Avi
--
This signature intentionally left blank.

> -----Original Message-----
> From: Krishnan Subramanian [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 12, 2001 16:56
> To: ejb-interest; Avi Kivity
> Subject: RE: IntialContext
>
>
> Avi,
>
> The context implementation is up to the vendor.
> Some vendors (like us) have chosen to optimize
> the initialization of the context (which is
> potentially an expensive operation).
>
> With our product, the first initialization
> (if I may use the term) is a heavyweight call.
> Further calls to initialize the context will be
> light weight calls (even within your jsps
> and java apps).
>
> You are right if you meant the "local" environment
> naming context of an enterprise bean. This is
> illustrated with the pseudo code below:
>
> Context jndiContext = new InitialContext();
> // Above can be used pretty much everywhere
> // in that application (or VM) without needing
> // to be reinitialized every time
>
> Context aSpecificBeanContext =
>      (Context)jndiContext.lookup("java:comp/env");
> // Above can be used only in and by a
> // particular enterprise bean
>
> So if you have something defined in an EJB
> (say) - "java:comp/env/MyValue" which is of type
> "Integer", then you can look it up either from
> the "jndiContext" object instance via a call to
> jndiContext.lookup("java:comp/env/MyValue");
> or from the "aSpecificBeanContext" directly
> via a call to aSpecificBeanContext.lookup("MyValue");
> (skips the java:comp/env prefix)
>
> -krish
>
> > -----Original Message-----
> > From: A mailing list for Enterprise JavaBeans development
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Avi Kivity
> > Sent: Wednesday, September 12, 2001 2:48 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: IntialContext
> >
> >
> > > When I do:
> > >
> > > Context initCtx=new InitialContext()
> > >
> > > within my EJB, my initCtx is related to my ejb or is global?
> > > I think that
> > > is related to my EJB because the "java:comp/env" is for my
> > > EJB and before
> > > I can lookup "java:comp/env" I have to get a new InitialContext.
> >
> > Yes, you are right - it is a local context.
> >
> >
> > - Avi
>

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