[cdi-dev] Clarification for manually resolving 'Instance'
Mark Struberg
struberg at yahoo.de
Sun Sep 25 16:06:49 EDT 2011
>The parameterized type resolution rules are correct, it's just there
> is no raw type of Instance to resolve.
Yes, I think too, but was not sure if everyone do see it that way.
> Should there be? Not sure if it would just be more confusing?
I already saw the usage of Instance.class without the TypeLiteral (which is pretty well hidden in the specs).
And people wondered why that doesn't work ...
LieGrue,
strub
----- Original Message -----
> From: Pete Muir <pmuir at redhat.com>
> To: Mark Struberg <struberg at yahoo.de>
> Cc: "cdi-dev at lists.jboss.org" <cdi-dev at lists.jboss.org>
> Sent: Sunday, September 25, 2011 9:44 PM
> Subject: Re: [cdi-dev] Clarification for manually resolving 'Instance'
>
> See section 5.6.2. The built-in Instance - the spec only requires a bean of type
> Instance<X> not of raw type Instance<>
>
> I'm not sure there is a generalization here (or I don't understand
> yours). The parameterized type resolution rules are correct, it's just there
> is no raw type of Instance to resolve.
>
> Should there be? Not sure if it would just be more confusing?
>
> On 24 Sep 2011, at 11:41, Mark Struberg wrote:
>
>> Hi!
>>
>> Currently both Weld and OWB blow up if I resolve an unparameterized
> 'Instance' object.
>>
>> beanManager.getBeans(Instance.class);
>>
>> will return zero beans, so there is no way to call beanManager.getReference
> ...
>>
>>
>> Of course with a little trick I was able to get it working in OWB:
>> Type instanceType = new
> TypeLiteral<Instance<Object>>(){}.getType();
>> Set<Bean<?>> beans = beanManager.getBeans(instanceType);
>>
>> (did not test it on Weld yet)
>
> This should work on Weld to.
>
>>
>>
>> My question is which behaviour is expected.
>> This question could maybe be generalized to: how do beans for parameterized
> types need to get handled?
>>
>>
>> LieGrue,
>> strub
>>
>> _______________________________________________
>> cdi-dev mailing list
>> cdi-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>
More information about the cdi-dev
mailing list