Avi,

They would be - if an instance of X "used" an
instance of Y i.e. if you called
instanceOfY.anotherMethod() from within your
session bean X's someMethod, then both
c1 and c2 will lookup the same definitions
under "java:comp/env" defined in X's descriptor.

In other words - for a particular process
(or VM), an initial context instance is
[re]usable by all beans (and normal java objects
in turn referenced by those beans).

You are right that a "java:comp/env" namespace
is 'private' to that bean - and not available
to other beans and I am not trying to debate that
point. See above for debatable point ;)

The point is moot if subsequent initializing of
the context is optimized by the vendor (lightweight).
Else, you might see performance improvements by caching
that one instance within the VM.

http://archives.java.sun.com/cgi-bin/wa?A2=ind0105&L=ejb-interest&P=R19960

-krish

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

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