[JBoss JIRA] (CDI-712) Clarify whether is should be possible to "override" built-in Instance/Provider
by Mark Struberg (JIRA)
[ https://issues.jboss.org/browse/CDI-712?page=com.atlassian.jira.plugin.sy... ]
Mark Struberg commented on CDI-712:
-----------------------------------
> Not a big deal.
Well, that entirely depends on your performance needs. Do a benchmark. A full bean resolving is about 10.000 more expensive than a simple get on a cache Map.
> In other words, the built-in bean must be treated in a special way.
No, not at all. It must just be *provided* in a special way. That's all.
I mentioned the JSR-330 reference because Provider is not a CDI class at all. It's from atinject. So the CDI spec must not prevent any other usages.
> Also note that built-in beans must be passivation capable dependencies.
Yes, of course. But I have no clue what this changes regarding to the current topic?
> 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)
7 years, 4 months
[JBoss JIRA] (CDI-712) Clarify whether is should be possible to "override" built-in Instance/Provider
by Martin Kouba (JIRA)
[ https://issues.jboss.org/browse/CDI-712?page=com.atlassian.jira.plugin.sy... ]
Martin Kouba commented on CDI-712:
----------------------------------
Also note that built-in beans must be passivation capable dependencies.
> 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)
7 years, 4 months
[JBoss JIRA] (CDI-712) Clarify whether is should be possible to "override" built-in Instance/Provider
by Martin Kouba (JIRA)
[ https://issues.jboss.org/browse/CDI-712?page=com.atlassian.jira.plugin.sy... ]
Martin Kouba commented on CDI-712:
----------------------------------
bq. A Long Bean would also work but then it would go through the whole CDI stack for EACH and every invocation!
Not a big deal.
bq. Also the spec does NOT state that one cannot provide an Alternative for built-in beans.
Agreed.
bq. 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.
I don't understand even a little.
bq. This is just a standard bean...
It's not standard in the way that it must satisfy all {{Instance<X>}} or {{Provider<X>}} for any legal bean type {{X}} and qualifiers are also handled specially. In other words, the built-in bean must be treated in a special way.
> 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)
7 years, 4 months
[JBoss JIRA] (CDI-712) Clarify whether is should be possible to "override" built-in Instance/Provider
by Mark Struberg (JIRA)
[ https://issues.jboss.org/browse/CDI-712?page=com.atlassian.jira.plugin.sy... ]
Mark Struberg commented on CDI-712:
-----------------------------------
See also the following spec paragraph (1.0)
{noformat}
5.6.2. The built-in Instance
The container must provide a built-in bean...:
{noformat}
This is just a standard bean otherwise and no special rules apply. So why should one not be able to implement an Alternative for it? This is a perfectly legit use case!
> 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)
7 years, 4 months
[JBoss JIRA] (CDI-712) Clarify whether is should be possible to "override" built-in Instance/Provider
by Mark Struberg (JIRA)
[ https://issues.jboss.org/browse/CDI-712?page=com.atlassian.jira.plugin.sy... ]
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)
7 years, 4 months
[JBoss JIRA] (CDI-712) Clarify whether is should be possible to "override" built-in Instance/Provider
by Martin Kouba (JIRA)
[ https://issues.jboss.org/browse/CDI-712?page=com.atlassian.jira.plugin.sy... ]
Martin Kouba commented on CDI-712:
----------------------------------
Hm, why is it preferable?
> 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)
7 years, 4 months
[JBoss JIRA] (CDI-712) Clarify whether is should be possible to "override" built-in Instance/Provider
by John Ament (JIRA)
[ https://issues.jboss.org/browse/CDI-712?page=com.atlassian.jira.plugin.sy... ]
John Ament commented on CDI-712:
--------------------------------
Agreed, we can provide a bean of type Long to satisfy this requirement as well. Though its preferable to just provide a Provider.
> 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)
7 years, 4 months
[JBoss JIRA] (CDI-712) Clarify whether is should be possible to "override" built-in Instance/Provider
by Martin Kouba (JIRA)
[ https://issues.jboss.org/browse/CDI-712?page=com.atlassian.jira.plugin.sy... ]
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)
7 years, 4 months
[JBoss JIRA] (CDI-712) Clarify whether is should be possible to "override" built-in Instance/Provider
by John Ament (JIRA)
[ https://issues.jboss.org/browse/CDI-712?page=com.atlassian.jira.plugin.sy... ]
John Ament commented on CDI-712:
--------------------------------
BTW, this is a requirement of MP Config 1.0.
> 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)
7 years, 4 months
[JBoss JIRA] (CDI-712) Clarify whether is should be possible to "override" built-in Instance/Provider
by Martin Kouba (JIRA)
Martin Kouba created CDI-712:
--------------------------------
Summary: 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)
7 years, 4 months