We have explored a similar ServiceLoader approach in Solder, for reference. (Pardon the reminder if I already cited it).<div><br></div><div><a href="https://github.com/seam/solder/tree/master/api/src/main/java/org/jboss/seam/solder/beanManager">https://github.com/seam/solder/tree/master/api/src/main/java/org/jboss/seam/solder/beanManager</a></div>

<div><br></div><div>Here&#39;s the implementation that puts the BeanManager in the ServletContext.</div><div><br></div><div><a href="https://github.com/seam/servlet/blob/master/impl/src/main/java/org/jboss/seam/servlet/beanManager/ServletContextAttributeProvider.java">https://github.com/seam/servlet/blob/master/impl/src/main/java/org/jboss/seam/servlet/beanManager/ServletContextAttributeProvider.java</a></div>

<div><br></div><div>It&#39;s easy for the spec to say &quot;you should never have to lookup the BeanManager as you should always be able to use dependency injection.&quot; However, the reality is, we have to adopt to the world around us. Thus, standardizing this API would be fantastic.<br>

<div><br></div><div>-Dan<br><br><div class="gmail_quote">On Mon, Apr 25, 2011 at 15:23, Rick Hightower <span dir="ltr">&lt;<a href="mailto:richardhightower@gmail.com">richardhightower@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

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 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-wrap">java.util.ServiceLoader.</span></div>


<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" target="_blank">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" target="_blank">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" target="_blank">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><div><div><div></div><div class="h5"><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" target="_blank">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><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" target="_blank">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></div></div>-- <br><b>Rick Hightower</b><br><a href="tel:%28415%29%20968-9037" value="+14159689037" target="_blank">(415) 968-9037</a> <br><a href="http://www.google.com/profiles/RichardHightower" target="_blank">Profile</a> <br>

<br>
</div>
<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>
<br></blockquote></div><br><br clear="all"><br>-- <br><div>Dan Allen</div>Principal Software Engineer, Red Hat | Author of Seam in Action<br>Registered Linux User #231597<br><br><div><a href="http://www.google.com/profiles/dan.j.allen#about" target="_blank">http://www.google.com/profiles/dan.j.allen#about</a><br>

<a href="http://mojavelinux.com" target="_blank">http://mojavelinux.com</a><br><a href="http://mojavelinux.com/seaminaction" target="_blank">http://mojavelinux.com/seaminaction</a><br></div><br>
</div></div>