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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

JIRA issues@jboss.org

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

Mark Struberg commented on CDI-712:
-----------------------------------

> Hm, why is it preferable?
A Long Bean would also work but then it would go through the whole CDI stack for EACH and every invocation!
With a custom Provider we can do any direct resolution.

Also the spec does NOT state that one cannot provide an Alternative for built-in beans.
It should also be very easy for Weld to provide exactly that.
Note that it is also important to allow custom implementations of javax.inject.Provider as the Container would otherwise not be able to implement JSR-330 afaict.

> 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
(v7.2.3#72005)
_______________________________________________
cdi-dev mailing list
[hidden email]
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.
Loading...