[cdi-dev] Easy way to get 'original' type from alternative producers
Martin Kouba
mkouba at redhat.com
Fri Feb 16 05:28:10 EST 2018
Dne 15.2.2018 v 18:15 arjan tijms napsal(a):
> Hi,
>
> On Thu, Feb 15, 2018 at 10:57 AM, Martin Kouba <mkouba at redhat.com
> <mailto:mkouba at redhat.com>> wrote:
>
>
> I think it could be a nice feature. Pls file a JIRA issue.
>
>
> Allright, I'll do that. Thx!
>
>
>
> In order to get that bean, a bunch of quite verbose code is
> needed. I.e I came up with:
>
> HttpAuthenticationMechanism mechanism =
> createRef(
> beanManager.resolve(
>
>
> This wouldn't work because BeanManager.resolve() attempts to resolve
> the ambiguities thus eliminate all non-alternative beans.
>
>
> It actually does seem to work, and I've been using it for a while now.
You're right - you're actually filtering the alternative bean
(ApplicationInit producer) and so there is only one bean left.
>
>
>
> This would not work - you would need to distinguish the original
> injection point.
>
> return ...
> }
> }
>
> Or reuse the @Delegate (perhaps with the @Alternative annotation)
>
>
> -1 This might be confusing.
>
>
> Agreed with both, it was just a bit of brain storming. Not sure what
> would be a better name though. @Original? @NonAlternative?
>
> Kind regards,
> Arjan Tijms
>
>
--
Martin Kouba
Senior Software Engineer
Red Hat, Czech Republic
More information about the cdi-dev
mailing list