[weld-dev] Java SE extension

Gavin King gavin.king at gmail.com
Sun Nov 29 19:25:58 EST 2009


It looks as if event() is returning
javax.enterprise.inject.Instance<javax.enterprise.event.Event>
instead of javax.enterprise.event.Event.

On Sun, Nov 29, 2009 at 6:12 PM, Peter Royle
<howardmoon at screamingcoder.com> wrote:
> Hi,
> I've done the first iteration of this (checked in - r5173). It doesn't yet
> separate out the initialisation, I'll do that next.
> One problem is that I can't get the following line to compile:
> weld.event().select(CustomEvent.class).fire(new CustomEvent());
> I get:
> Compilation failure
> org/jboss/weld/environment/se/test/WeldMainTest.java:[70,18] cannot find
> symbol
> symbol  : method
> select(java.lang.Class<org.jboss.weld.environment.se.test.beans.CustomEvent>)
> location: interface
> javax.enterprise.inject.Instance<javax.enterprise.event.Event>
> I think the problem is that my CustomEvent doesn't implement or extend
> Event. I don't think it has to though (am I mistaken?). Anyone know what I'm
> missing?
> Cheers,
>
>
> On 24/11/2009, at 11:11 PM, Dan Allen wrote:
>
>>
>> > WeldContainer weld = new Weld().initialize();
>> > weld.instance().select(Foo.class).get();
>>
>> Yes, this seems sensible to me, as it will allow us to provide flexibility
>> with the configuration in the future.
>
> Emmanuel, master of fluent APIs, has made an important point that we should
> keep in mind when designing a sequential call chain. Think twice before
> returning "this" and think if there is a more specific type that you can
> return that narrows the options based on where you are in the sequence. That
> way, you prevent being able to invoke methods out of sequence.
>
> You can now prevent:
>
> new Weld().event()
>
> Returning a more specific type is also self documenting.
>
> -Dan
> --
> Dan Allen
> Senior Software Engineer, Red Hat | Author of Seam in Action
> Registered Linux User #231597
>
> http://mojavelinux.com
> http://mojavelinux.com/seaminaction
> http://www.google.com/profiles/dan.j.allen
> _______________________________________________
> weld-dev mailing list
> weld-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/weld-dev
>
> _______________________________________________
> weld-dev mailing list
> weld-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/weld-dev
>



-- 
Gavin King
gavin.king at gmail.com
http://in.relation.to/Bloggers/Gavin
http://hibernate.org
http://seamframework.org



More information about the weld-dev mailing list