So, after a few hous of not thinking about this problem, here is the (possible) 
answer:

The Spec only mentions the JNDI because _they_ need it in _their_ scenario!
And what is their scenario? 
The WebBeans RI is designed to be an integral part of the JBoss J2EE Server, so 
the webbeans-ri.jar will reside in the app servers jar classpath and NOT be 
packaged in any EAR or WAR file.
So the webbeans-ri classes will be loaded through the app-servers parent 
classloader, which is the same for _all_ webapps running in this server. In 
this scenario one has to make sure that each webapp gets its own 
javax.inject.Manager singleton, and the easiest way is to use a JNDI 
java:comp/env environment (because a singleton using static would simply not 
work)!

But all this magic is completely futile if our openwebbeans-impl.jar is 
packaged inside the EAR or WAR, because in this case we are already in the 
correct per-webapp-classloader.

So we either always lookup the Manager from java:comp/env/Manager or our 
ManagerObjectFactory or even the WebBeansFinder has to be a SPI with a JNDI 
implementation for running on a server level and an implementation using 
statics if being packaged with the app.

I can imagine that that there is standard answer to our problem, because using 
JNDI for each and every Manager access is not the fastest solution. So come on 
EE guys, enlighten us :)
 
Any thoughts on this?

LieGrü,
strub

--- Mark Struberg <[email protected]> schrieb am Mi, 4.2.2009:

> Von: Mark Struberg <[email protected]>
> Betreff: JNDI usage question
> An: [email protected]
> Datum: Mittwoch, 4. Februar 2009, 14:53
> Hi!
> 
> 
> The JNDI context set by OpenWebBean is
> 
> WebBeansConstants.WEB_BEANS_MANAGER_JNDI_NAME
> 
> But although I see where is gets bound and und bound, I
> cannot see where it is actually being used?
> 
> So maybe I'm blind, but what for do we currently use
> the JNDI context? Is this work in progress, or did I miss
> something?
> 
> Just to make sure we have the same undersanding: how should
> @ApplicationScoped work in 
> a) a WAR in a ServletEngine like tomcat
> b) a EAR in a J2EE Server like Geronimo
> c) a WAR (solo, without EAR) in a J2EE Server like Geronimo
> 
> LieGrue,
> strub



Reply via email to