Sorry to drag this up again, but this has changed now that
manager.getReference(...) requires a CreationalContext, about which I
know very little. I'll try reading the latest spec soon, but in the
meantime if anyone has any silver bullets please let me know.
I'm currently using this utility method:
public static <T> T getInstanceByType(BeanManager manager,
Class<T> type, Annotation... bindings) {
return (T)manager.getReference(
manager.getBeans(type).iterator().next(), type, null);
}
Obviously it's that null at the end (where CreationalContext should
be) that's causing the problem.
Cheers,
Pete.
On 29/05/2009, at 2:02 AM, David Allen wrote:
On Thu, 2009-05-28 at 10:52 -0500, Clint Popetz wrote:
>
>
> On Thu, May 28, 2009 at 10:51 AM, David Allen <drallendc(a)gmail.com>
> wrote:
> On Thu, 2009-05-28 at 11:43 -0400, Dan Allen wrote:
>> On Thu, May 28, 2009 at 11:14 AM, Pete Muir
> <pmuir(a)redhat.com> wrote:
>>
>> On 28 May 2009, at 16:04, Dan Allen wrote:
>>
>>> On Thu, May 28, 2009 at 6:35 AM, Pete Muir
>>> <pmuir(a)redhat.com> wrote:
>>> Yeah, this is used a lot in the TCK, and
> maybe a bit
>>> in addons which enable injection in types
> WB doesn't
>>> know about (?), but I don't think users
> will hit it.
>>>
>>> Correct, users really should hit this. It's used
> heavily in
>>> tests, for instance in AbstractWebBeans tests.
>>
>>
>> Hmm, yes you might well want to use this in a
> standalone, unit
>> test, environment as an entry point.
>>
>> It would be great if we can add a convenience method to
>> AbstractWebBeansTest. That would pretty much clear up any
> annoyances.
>
>
> Yes, that is the plan. Ditto for the TCK abstract test class.
>
>
>
> I got the TCK compiling locally with the new BeanManager interface,
> but rather than adding the bridge methods to the old SPI methods in
> the abstract test class, I added them to a separate utility class,
> because several things in the TCK that aren't test subclasses use
> this
> functionality as well.
>
> I can also add a method to the abstract test class to delegate to the
> utility class.
>
> Is that ok?
Yeah, that sounds good. Most of our tests do extend an abstract
class,
so I just thought that would be a little cleaner in the code to use a
member method.
>
> -Clint
>
>
>
>>
>>
>>
>>
>>> It is also used when you are entering from outside
> the WB
>>> environment. You get a handle to manager and
> lookup the type
>>> that gives you entry. For instance, you might look
> up the
>>> Identity component and then invoke some method on
> it which
>>> may trigger a chain of WB injections once
> "inside".
>>
>>
>> Yes, this is addon frameworks, not end users.
>>
>> Yep, agreed. I've found that injection is sufficient for all
> but those
>> "entry point" cases.
>>
>> -Dan
>>
>>
>> --
>> Dan Allen
>> Senior Software Engineer, Red Hat | Author of Seam in Action
>>
>>
http://mojavelinux.com
>>
http://mojavelinux.com/seaminaction
>>
http://in.relation.to/Bloggers/Dan
>>
>> NOTE: While I make a strong effort to keep up with my email
> on a daily
>> basis, personal or other work matters can sometimes keep me
> away
>> from my email. If you contact me, but don't hear back for
> more than a
>> week,
>> it is very likely that I am excessively backlogged or the
> message was
>> caught in the spam filters. Please don't hesitate to resend
> a message
>> if
>> you feel that it did not reach my attention.
>
>
>
> _______________________________________________
> webbeans-dev mailing list
> webbeans-dev(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/webbeans-dev
>
>
>
>
> --
> Clint Popetz
>
http://42lines.net
> Scalable Web Application Development
_______________________________________________
webbeans-dev mailing list
webbeans-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/webbeans-dev