[cdi-dev] [JBoss JIRA] (CDI-712) Clarify whether is should be possible to "override" built-in Instance/Provider

Martin Kouba (JIRA) issues at jboss.org
Wed Aug 9 04:16:00 EDT 2017

    [ https://issues.jboss.org/browse/CDI-712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13446102#comment-13446102 ] 

Martin Kouba commented on CDI-712:

Ok, so I've created https://github.com/mkouba/alternative-builtin-beans to verify the current state of support for {{Instance}} and {{Event}}. As expected Weld does not support this feature. OWB seems to support this feature but does not work correctly - see also the readme.

Note that I did not even try to test alternative custom bean for {{BeanManager}} although there is a "standard" built-in bean. Also note that it's not possible to create a decorator for {{BeanManager}} (explicitly disallowed by spec).

Feel free to comment the test repo.

bq. Yes, of course. But I have no clue what this changes regarding to the current topic?
[~struberg] If you provide a custom bean that is not passivation capable you can easily break existing applications.

> Clarify whether is should be possible to "override" built-in Instance/Provider
> ------------------------------------------------------------------------------
>                 Key: CDI-712
>                 URL: https://issues.jboss.org/browse/CDI-712
>             Project: CDI Specification Issues
>          Issue Type: Clarification
>            Reporter: Martin Kouba
> In theory, an extension could register an alternative custom bean to override the built-in Instance/Provider bean for injection points such as {{@Inject Provider<String>}}. 
> It is not forbidden at the moment. The spec only states that there must be a built-in bean eligible for any injection point with Instance/Provider required type and any qualifier. See also https://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#builtin_instance.
> It seems to be a powerful feature. On the other hand, it might be a source of confusion. Take for example this injection point:
> {code:java}
> @Inject
> @MyQualifier
> Instance<String> instance;
> {code}
> The qualifier is now considered when calling {{instance.get()}} and NOT when resolving the injection point.
> Note that the spec already allows to decorate built-in beans.

This message was sent by Atlassian JIRA

More information about the cdi-dev mailing list