Andy Gibson, Rob Williams and I, implemented something like this for CDISource.<div>It works with Weld, OpenWebBeans and Candi.</div><div><br></div><div>We have a BeanContainerManager that uses <span class="Apple-style-span" style="color: rgb(85, 85, 85); font-family: &#39;Bitstream Vera Sans Mono&#39;, Courier, monospace; font-size: 12px; line-height: 17px; white-space: pre; ">java.util.ServiceLoader.</span></div>
<meta charset="utf-8"><div><br></div><div>see</div><div><br></div><div><a href="https://github.com/CDISource/cdisource/blob/master/beancontainer/api/src/main/java/org/cdisource/beancontainer/BeanContainerManager.java">https://github.com/CDISource/cdisource/blob/master/beancontainer/api/src/main/java/org/cdisource/beancontainer/BeanContainerManager.java</a></div>
<div><br>I think in addition to the ability to easily load a BeanManager, we need a simplified interface for dealing with beans. BeanManager is a bit at the SPI level. It needs a Facade to make it easier to use.</div><div>
<br></div><div>Compare the BeanManager to the Spring&#39;s Application Context. I think the BeanManager should be more like the Spring Application Context.</div><div><br></div><div>for some ideas see:</div><div><br></div>
<div><a href="https://github.com/CDISource/cdisource/blob/master/beancontainer/api/src/main/java/org/cdisource/beancontainer/BeanContainer.java">https://github.com/CDISource/cdisource/blob/master/beancontainer/api/src/main/java/org/cdisource/beancontainer/BeanContainer.java</a></div>
<div><br></div><div>The Spring integration piece that I wrote tries to find the BeanManager in JNDI and then uses the Service Locator if it does not find it in JNDI.</div><div><br></div><div>I think it would be nice if there was a BeanManagerFactory that looks up first using JNDI, then uses a Service Locator if it can&#39;t find it in JNDI.</div>
<div><br></div><div>Ok it is not the exact behavior, but I know what you are taking about:</div><div><br></div><div><a href="https://github.com/CDISource/cdisource/blob/master/spring/src/main/java/org/cdisource/springintegration/BeanManagerLocationUtil.java">https://github.com/CDISource/cdisource/blob/master/spring/src/main/java/org/cdisource/springintegration/BeanManagerLocationUtil.java</a></div>
<div><br></div><div><br></div><div><br></div><meta charset="utf-8"><div><br><div class="gmail_quote">On Mon, Apr 25, 2011 at 12:38 AM, Pete Muir (JIRA) <span dir="ltr">&lt;<a href="mailto:jira-events@lists.jboss.org">jira-events@lists.jboss.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
    [ <a href="https://issues.jboss.org/browse/CDI-117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=12597724#comment-12597724" target="_blank">https://issues.jboss.org/browse/CDI-117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=12597724#comment-12597724</a> ]<br>

<br>
Pete Muir commented on CDI-117:<br>
-------------------------------<br>
<br>
Cloves please file an issue for your approach.<br>
<div><div></div><div class="h5"><br>
&gt; Add BeanManager to a ServletContext attribute<br>
&gt; ---------------------------------------------<br>
&gt;<br>
&gt;                 Key: CDI-117<br>
&gt;                 URL: <a href="https://issues.jboss.org/browse/CDI-117" target="_blank">https://issues.jboss.org/browse/CDI-117</a><br>
&gt;             Project: CDI Specification Issues<br>
&gt;          Issue Type: Feature Request<br>
&gt;          Components: Java EE integration<br>
&gt;    Affects Versions: 1.0<br>
&gt;            Reporter: Christian Kaltepoth<br>
&gt;            Priority: Minor<br>
&gt;<br>
&gt; CDI 1.0 defines a JNDI lookup as the standard way to obtain the BeanManager for resources not managed by the CDI environment. However in a servlet environment it would be much easier to get the BeanManager from a standardized servlet context attribute. This would be also a major simplification in environments that don&#39;t support JNDI (for example GAE) or that don&#39;t allow to use the standard JNDI name for the BeanManager (for example Apache Tomcat).<br>

&gt; This topic was already discussed on weld-dev about a year ago [1]. Weld 1.0 already supports this [2] and OpenWebBeans also added this feature [3]. Unfortunately Weld 1.1 changed the attribute to a Weld-specific name in [4] which currently leads to much confusion [5].<br>

&gt; As both of the major CDI implementations support this feature I think it should finally be put into the spec.<br>
&gt; [1] <a href="http://lists.jboss.org/pipermail/weld-dev/2010-March/002359.html" target="_blank">http://lists.jboss.org/pipermail/weld-dev/2010-March/002359.html</a><br>
&gt; [2] <a href="https://issues.jboss.org/browse/WELD-202" target="_blank">https://issues.jboss.org/browse/WELD-202</a><br>
&gt; [3] <a href="https://issues.apache.org/jira/browse/OWB-360" target="_blank">https://issues.apache.org/jira/browse/OWB-360</a><br>
&gt; [4] <a href="https://jira.jboss.org/browse/WELD-679" target="_blank">https://jira.jboss.org/browse/WELD-679</a><br>
&gt; [5] <a href="http://seamframework.org/Community/GettingBeanManagerFromServletContextWithWeld11" target="_blank">http://seamframework.org/Community/GettingBeanManagerFromServletContextWithWeld11</a><br>
<br>
--<br>
This message is automatically generated by JIRA.<br>
For more information on JIRA, see: <a href="http://www.atlassian.com/software/jira" target="_blank">http://www.atlassian.com/software/jira</a><br>
_______________________________________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><b>Rick Hightower</b><br>(415) 968-9037 <br><a href="http://www.google.com/profiles/RichardHightower" target="_blank">Profile</a> <br><br>
</div>