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.
Well, as I said - it's the same as if you're injecting a contextual
reference. And the user of BM.getReference() - probably extension author
or integrator - should be aware of this. In practice, this beanType
paramater is often ignored and the proxy implements all bean types (this
is what Weld does in most cases).
For a custom impl of Bean, I think it's ok to return the class of the
extension which registered the bean.
------------------------------------------------------------------------
*From:* cdi-dev-bounces(a)lists.jboss.org
<cdi-dev-bounces(a)lists.jboss.org> on behalf of Martin Kouba
<mkouba(a)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(a)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(a)lists.jboss.org
>>>
https://lists.jboss.org/mailman/listinfo/cdi-dev
cdi-dev Info Page - JBoss Developer
<
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.
Apache License, Version 2.0
<
http://www.apache.org/licenses/LICENSE-2.0.html>
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(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/cdi-dev
cdi-dev Info Page - JBoss Developer
<
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.
Apache License, Version 2.0
<
http://www.apache.org/licenses/LICENSE-2.0.html>
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(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/cdi-dev
cdi-dev Info Page - JBoss Developer
<
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.
Apache License, Version 2.0
<
http://www.apache.org/licenses/LICENSE-2.0.html>
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.