[cdi-dev] Clarification of BeanManager.getReference

Martin Kouba mkouba at redhat.com
Mon Dec 12 03:19:44 EST 2016


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 at 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 at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>>>
>>> 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.
>>>
>>
>> --
>> Martin Kouba
>> Software Engineer
>> Red Hat, Czech Republic
>> _______________________________________________
>> cdi-dev mailing list
>> cdi-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>>
>> 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.
>

-- 
Martin Kouba
Software Engineer
Red Hat, Czech Republic


More information about the cdi-dev mailing list