Erik,
I'm not an offical Sun source but ...
Erik Voldal wrote:
> I have a couple questions about the scope of JNDI lookup of ejb-refs.
> 1. Is non-EJB code running within the scope of a method called on an EJB object
> able to look up ejb-refs? Suppose I have an entity bean Foo, implemented in the
> FooBean class, whose deployment descriptor defines some ejb-ref. Should JNDI
> lookups of that ejb-ref only work in the code that is directly in the FooBean
> class' method implementations, or should they also work from other Java code
> that I call from FooBean method implementations (such as a Java class I might
> implement to factor out some common implementation between several entity
> beans)? Would it make a difference whether that other Java code is included in
> the same jar file with Foo?
This works. I know because I've done it in the J2EE RI and more importantly it makes
sense because classes that are accessed by the bean but are not remote references
are considered to be part of the bean's deployment. This answers your second
question: You must JAR any application code used by the bean with the bean when its
packaged for deployment.
> 2. When there are nested invocations of EJB objects, are ejb-refs defined in an
> outer scope visible to a lookup performed in the inner scope? Suppose session
> bean Foo (which defines some ejb-ref) calls a method on entity bean Bar. If the
> BarBean implementation does a lookup of that ejb-ref name, and that ejb-ref is
> not defined in Bar's deployment descriptor but is defined in Foo's deployment
> descriptor, would it be not found, or would it find the ejb-ref defined by Foo?
> Would it make a difference whether Bar is included in the same jar file with
> Foo? Although I described a scenario of a session bean calling an entity bean, I
> assume the answer would be the same if they were both entities.
No. Bean bar would not have access to Foo's JNDI environment name space because the
environment name space is specific to the bean type accessing it. In this case,
unlike the above scenario, bar bean is considered to be a separate deployment. In
other words, bean bar is not part of the bean foo.
>
>
> As far as I can tell the EJB1.1 or J2EE1.2 specs don't specifically address
> these scenarios, which would mean the results in either of these scenarios are
> undefined and might work one way in one server and another in a different one.
> But I wondered if I were missing something, or if was the intent of the spec to
> define the behavior for these scenarios.
Really excellent questions. I would like the J2EE team to comment on this also
since I'm just voicing my own opinions.
--
Richard Monson-Haefel
EJB Expert for jGuru.com
( http://www.jguru.com )
Author of Enterprise JavaBeans
Published by O'Reilly & Associates
( http://www.ejbnow.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".