[cdi-dev] [JBoss JIRA] (CDI-78) Clarify how isDelegate() behaves on InjectionPoint, and what happens when an InjectionPoint is injected into a Decorator

Antoine Sabot-Durand (JIRA) issues at jboss.org
Tue May 30 04:21:00 EDT 2017


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

Antoine Sabot-Durand edited comment on CDI-78 at 5/30/17 4:20 AM:
------------------------------------------------------------------

2 scenarios here.

h2. InjectionPoint relates to the decorator bean itself

As a decorator can't be injected directly since it's not available for injection as stated in 5.1.4, so {{InjectionPoint}} of a decorator should always return null.

h2. InjectionPoint relates to the decorated bean

It could be nice to have information about {{InjectionPoint}} of the decorated bean in the decorator, but it can be confusing to deal with it: decorator can decorate dependent and non-dependent beans at the same time. So, if we don't want to break the spec, we should forbid it if at least one decorated bean is not dependent.

h2. My proposal

{{InjectionPoint}} with @Default qualifier injected in decorator (or interceptor BTW), should be considered as scenario 1 and always return null.

To support injection of decorated bean's {{InjectionPoint}} we should use the {{@Decorated}} qualifier ({{@Inject @Decorated  InjectionPoint}}) allowing to have the IP instance if decorated bean is dependent or null if it is not. It won't violate the spec and be less confusing for users (we can assume that a user adding such a qualifier probably knows what he's doing).

Again this proposal is also interesting for Interceptors.

WDYT ?


was (Author: antoinesabot-durand):
2 scenarios here.

h2. InjectionPoint relates to the decorator bean itself

As a decorator can't be injected directly since it's not available for injection as stated in 5.1.4, so {{InjectionPoint}} of a decorator should always return null.

h2. InjectionPoint relates to the decorated bean

It could be nice to have information about {{InjectionPoint}} of the decorated bean in the decorator, but it can be confusing to deal with it: decorator can decorate dependent and non-dependent beans at the same time. So, if we don't want to break the spec, we should forbid it if at leat one decorated bean is not dependent.

h2. My proposal

{{InjectionPoint}} with @Default qualifier injected in decorator (or interceptor BTW), should be considered as scenario 1 and always return null.

To support injection of decorated bean's {{InjectionPoint}} we should use the {{@Decorated}} qualifier ({{@Inject @Decorated  InjectionPoint}}) allowing to have the IP instance if decorated bean is dependent or null if it is not. It won't violate the spec and be less confusing for users (we can assume that a user adding such a qualifier probably knows what he's doing).

Again this proposal is also interesting for Interceptors.

WDYT ?

> Clarify how isDelegate() behaves on InjectionPoint, and what happens when an InjectionPoint is injected into a Decorator
> ------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CDI-78
>                 URL: https://issues.jboss.org/browse/CDI-78
>             Project: CDI Specification Issues
>          Issue Type: Clarification
>          Components: Decorators
>    Affects Versions: 1.0
>            Reporter: Pete Muir
>              Labels: F2F2016
>
> The InjectionPoint should be that of the injection into the consumer, and isDelegate() should return false.



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the cdi-dev mailing list