Norman, I figure you should give this a try since you&#39;ll be focusing on the initial Seam 2 integration.<br><br>-Dan<br><br><div class="gmail_quote">On Fri, Nov 20, 2009 at 9:10 AM, Gavin King <span dir="ltr">&lt;<a href="mailto:gavin.king@gmail.com">gavin.king@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Folks, would someone please try out the following portable extension<br>
for me. It should be enough to let you typesafe-inject a Seam2<br>
component using Weld, e.g.<br>
<br>
   @Inject @Qualifier MySeamComponent msc;<br>
<br>
It&#39;s not enough to allow the use of typesafe injection in the seam<br>
component itself, however.<br>
<br>
Please test this for me, thanks!<br>
<br>
++++<br>
package org.seamframework;<br>
<br>
import java.util.Collections;<br>
import java.util.Set;<br>
<br>
import javax.enterprise.context.RequestScoped;<br>
import javax.enterprise.context.spi.CreationalContext;<br>
import javax.enterprise.event.Observes;<br>
import javax.enterprise.inject.spi.AnnotatedType;<br>
import javax.enterprise.inject.spi.BeforeBeanDiscovery;<br>
import javax.enterprise.inject.spi.Extension;<br>
import javax.enterprise.inject.spi.InjectionPoint;<br>
import javax.enterprise.inject.spi.InjectionTarget;<br>
import javax.enterprise.inject.spi.ProcessInjectionTarget;<br>
import javax.enterprise.util.AnnotationLiteral;<br>
<br>
import org.jboss.seam.Component;<br>
import <a href="http://org.jboss.seam.annotations.Name" target="_blank">org.jboss.seam.annotations.Name</a>;<br>
<br>
public class SeamComponentExtension implements Extension {<br>
<br>
        void beforeBeanDiscovery(@Observes BeforeBeanDiscovery bbd) {<br>
                bbd.addStereotype(Name.class, new AnnotationLiteral&lt;RequestScoped&gt;()<br>
{}); //TODO: put it in a @StatelessScope!<br>
        }<br>
<br>
        &lt;X&gt; void processInjectionTarget(@Observes final<br>
ProcessInjectionTarget&lt;X&gt; pit) {<br>
                final AnnotatedType&lt;X&gt; at = pit.getAnnotatedType();<br>
                if ( at.isAnnotationPresent(Name.class) ) {<br>
                        if ( !pit.getInjectionTarget().getInjectionPoints().isEmpty() ) {<br>
                                throw new RuntimeException(&quot;CDI injection points not supported for<br>
Seam2 components&quot;);<br>
                        }<br>
                        InjectionTarget&lt;X&gt; it = new InjectionTarget&lt;X&gt;() {<br>
                                @Override<br>
                                public void inject(X instance, CreationalContext&lt;X&gt; ctx) {<br>
                                        //TODO figure out a way to inject into the Seam component<br>
                                }<br>
                                @Override<br>
                                public void postConstruct(X instance) {}<br>
                                @Override<br>
                                public void preDestroy(X instance) {}<br>
                                @Override<br>
                                public void dispose(X instance) {}<br>
                                @Override<br>
                                public Set&lt;InjectionPoint&gt; getInjectionPoints() {<br>
                                        return Collections.EMPTY_SET;<br>
                                }<br>
                                @Override<br>
                                public X produce(CreationalContext&lt;X&gt; ctx) {<br>
                                        //TODO: it would be better to override<br>
Component.instantiateJavaBean() to call<br>
                                        //      it.produce(), in order to get injection, etc, but then we<br>
would have<br>
                                        //      to figure out a way to replace the Seam Component object<br>
                                        return (X) Component.getInstance( at.getJavaClass(), true );<br>
                                }<br>
                        };<br>
                        pit.setInjectionTarget(it);<br>
                }<br>
        }<br>
<br>
}<br>
<br>
<br>
--<br>
Gavin King<br>
<font color="#888888"><a href="mailto:gavin.king@gmail.com">gavin.king@gmail.com</a><br>
<a href="http://in.relation.to/Bloggers/Gavin" target="_blank">http://in.relation.to/Bloggers/Gavin</a><br>
<a href="http://hibernate.org" target="_blank">http://hibernate.org</a><br>
<a href="http://seamframework.org" target="_blank">http://seamframework.org</a><br>
_______________________________________________<br>
weld-dev mailing list<br>
<a href="mailto:weld-dev@lists.jboss.org">weld-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/weld-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/weld-dev</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Dan Allen<br>Senior Software Engineer, Red Hat | Author of Seam in Action<br>Registered Linux User #231597<br><br><a href="http://mojavelinux.com">http://mojavelinux.com</a><br>
<a href="http://mojavelinux.com/seaminaction">http://mojavelinux.com/seaminaction</a><br><a href="http://www.google.com/profiles/dan.j.allen">http://www.google.com/profiles/dan.j.allen</a><br>