I checked it out. Ok... I am finally starting to realize what Seam Solder is. :)<div><br></div><div>This is good. I like the order bit for the provider / serviceLoader.</div><div>...</div><div><br></div><div>CDISource has some overlap with Seam Solder so I will start really looking into what Seam Solder does more fully. (Get ideas, share ideas, etc.)</div>
<div><br></div><div>I wrote a Spring CDI integration (on top of CDISource which works with Weld, Candi and OpenWebBeans) piece that needs to hold onto an application context, but I wanted to do this in a generic way as possible.</div>
<div><br></div><div>See... </div><div><a href="https://github.com/CDISource/cdisource/tree/master/spring/src/main/java/org/cdisource/springintegration/springsupport">https://github.com/CDISource/cdisource/tree/master/spring/src/main/java/org/cdisource/springintegration/springsupport</a></div>
<div><br></div><div>Imagine if instead of locating a Spring application context, it was locating a bean container. (In other words look at the design and style instead of what it is doing)</div><div><br></div><div>(The actual bean container lookup, I shared earlier needs a bit of refactoring)</div>
<div><br></div><div>The ApplicationContextLocator.java has one method that returns an Application Context</div><meta charset="utf-8"><div><br></div><div><a href="https://github.com/CDISource/cdisource/blob/master/spring/src/main/java/org/cdisource/springintegration/springsupport/ApplicationContextLocator.java">https://github.com/CDISource/cdisource/blob/master/spring/src/main/java/org/cdisource/springintegration/springsupport/ApplicationContextLocator.java</a></div>
<div><br></div><div><br></div><div>(again imagine the words were BeanContainer)</div><div><br></div><div>The <span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; ">ApplicationContextLocatorManager </span></div>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1038.35">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco}
</style>


<div><br></div><div>Locates an instance of <span class="Apple-style-span" style="font-family: Monaco; font-size: 11px; ">ApplicationContextLocator then stores it in a &quot;singleton&quot; that is web application friendly.</span></div>
<meta charset="utf-8"><div>...</div><div><br></div><div><br></div><div>From the JavaDocs:</div><div><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1038.35">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 11.0px 0.0px; font: 11.0px 'Lucida Grande'}
</style>


<p class="p1">ApplicationContextLocatorManager, this is used to find an ApplicationContextLocator. An ApplicationContextLocator locates an application context. This does not use a normal singleton. It uses a singleton that will not prevent a web application from reloading. It does this by using WeakHashMap with WeakReference keyed on the current classloader. To load the ApplicationContextLocator it first checks to see if a property or system property has been set called org.cdisource.springintegration.springsupport.ApplicationContextLocator. If this has not been set, then it checks the ServiceLoader. If more than one item is loaded form the ServiceLoader, it throws an exception. If one ApplicationContextLocator is found with the ServiceLoader then it uses this ApplicationContextLocator. Lastly, it instantiates a ApplicationContextLocatorImpl which is the default implementation.</p>
<p class="p1"><br></p><p class="p1">(Again imagine it was doing this for BeanManager instead).</p><p class="p1"><br></p><p class="p1"><a href="https://github.com/CDISource/cdisource/blob/master/spring/src/main/java/org/cdisource/springintegration/springsupport/ApplicationContextLocatorManager.java">https://github.com/CDISource/cdisource/blob/master/spring/src/main/java/org/cdisource/springintegration/springsupport/ApplicationContextLocatorManager.java</a></p>
<p class="p1"><br></p><p class="p1">I am going to refactor our BeanContainer pieces to adopt a similar philosophy. (Currently, it has some ugly singleton bits).</p><p class="p1"><br></p><p class="p1"><br></p></div><div><br>
<div class="gmail_quote">On Mon, Apr 25, 2011 at 2:37 PM, Dan Allen <span dir="ltr">&lt;<a href="mailto:dan.j.allen@gmail.com">dan.j.allen@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;">
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" target="_blank">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" target="_blank">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<div><div></div><div class="h5"><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" target="_blank">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><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" 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>
<br></blockquote></div><br><br clear="all"><br>-- <br></div></div><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>
</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>