[cdi-dev] Clarification for manually resolving 'Instance'

Pete Muir pmuir at redhat.com
Sun Sep 25 15:44:17 EDT 2011


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