[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
Tue Aug 8 08:53:00 EDT 2017
[ https://issues.jboss.org/browse/CDI-712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13445647#comment-13445647 ]
Martin Kouba commented on CDI-712:
----------------------------------
AFAIK the only requirement of MP Config 1.0 is to satisfy a similar injection point:
{code:java}
@Inject
@ConfigProperty(name="myprj.some.dynamic.timeout", defaultValue="100")
private javax.inject.Provider<Long> timeout;
{code}
For this you don't need to override the built-in Provider but provide a bean with type {{Long}} and qualifier {{ConfigProperty}}. I don't know details but a simple @Dependent producer method injecting {{Config}} and inspecting the injection point metadata could do the trick.
> 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)
More information about the cdi-dev
mailing list