Well it sounds almost like a user would have to find the outer most value of getTypes to figure out which is the right type.


This means that popular CDI enabled frameworks, including Camel and DeltaSpike, are potentially doing it wrong


https://github.com/apache/deltaspike/blob/master/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/bean/BeanBuilder.java#L115

https://github.com/apache/camel/blob/master/components/camel-cdi/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java#L365




From: cdi-dev-bounces@lists.jboss.org <cdi-dev-bounces@lists.jboss.org> on behalf of Martin Kouba <mkouba@redhat.com>
Sent: Monday, December 12, 2016 3:19 AM
To: Mark Struberg
Cc: cdi-dev
Subject: Re: [cdi-dev] Clarification of BeanManager.getReference
 
Sure thing, bean.getBeanClass() does not have to be in the set of bean
types (producers, custom beans, bean class with @Typed, ...).

M

Dne 12.12.2016 v 09:15 Mark Struberg napsal(a):
> The main point (as mentioned over at CXF) is that one must not use bean.getBeanClass() as type parameter for getReference.
>
> LieGrue,
> strub
>
>
>> Am 12.12.2016 um 09:10 schrieb Martin Kouba <mkouba@redhat.com>:
>>
>> Hi John,
>>
>> the "beanType" parameter is de facto the same as the required type of an
>> injection point. So yes, the param must be one of the bean types and for
>> normal scoped the returned client proxy must implement this type (+ all
>> interfaces). Also note that a contextual reference (client for normal
>> scoped) is not required to implement all bean types of the bean.
>>
>> Martin
>>
>> Dne 11.12.2016 v 18:40 John Ament napsal(a):
>>> All,
>>>
>>>
>>> A discussion popped up on a recent CXF vote.  As I understand it, per
>>> section 11.3.2 (from CDI 1.2), The Type parameter passed in to
>>> getReference is meant to be the class to proxy for the returned object,
>>> if the object requires a proxy (e.g. a normal scoped bean).  Is that
>>> accurate? Or is the underlying type the type of the returned bean, from
>>> Bean.create(CreationalContext) ?
>>>
>>>
>>> John
>>>
>>>
>>> ------------------------------------------------------------------------
>>> NOTICE: This e-mail message and any attachments may contain
>>> confidential, proprietary, and/or privileged information which should be
>>> treated accordingly. If you are not the intended recipient, please
>>> notify the sender immediately by return e-mail, delete this message, and
>>> destroy all physical and electronic copies. Thank you.
>>>
>>>
>>> _______________________________________________
>>> cdi-dev mailing list
>>> cdi-dev@lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/cdi-dev
lists.jboss.org
List to discuss the development of CDI (the specification) To see the collection of prior postings to the list, visit the cdi-dev Archives.


>>>
>>> Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.
www.apache.org
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION. 1. Definitions.


>>>
>>
>> --
>> Martin Kouba
>> Software Engineer
>> Red Hat, Czech Republic
>> _______________________________________________
>> cdi-dev mailing list
>> cdi-dev@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/cdi-dev
lists.jboss.org
List to discuss the development of CDI (the specification) To see the collection of prior postings to the list, visit the cdi-dev Archives.


>>
>> Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.
www.apache.org
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION. 1. Definitions.


>

--
Martin Kouba
Software Engineer
Red Hat, Czech Republic
_______________________________________________
cdi-dev mailing list
cdi-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/cdi-dev
lists.jboss.org
List to discuss the development of CDI (the specification) To see the collection of prior postings to the list, visit the cdi-dev Archives.



Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.
www.apache.org
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION. 1. Definitions.



NOTICE: This e-mail message and any attachments may contain confidential, proprietary, and/or privileged information which should be treated accordingly. If you are not the intended recipient, please notify the sender immediately by return e-mail, delete this message, and destroy all physical and electronic copies. Thank you.