[cdi-dev] [JBoss JIRA] Commented: (CDI-6) Clarify InjectionTarget method parameters

Pete Muir (JIRA) jira-events at lists.jboss.org
Sun Sep 18 08:38:26 EDT 2011


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

Pete Muir commented on CDI-6:
-----------------------------

Update the spec to indicate that the instance passed must be capable of having reflection performed on it, in order to allow additional injections to occur. Effectively this requires an impl to use subclassing for interception and decoration.

> Clarify InjectionTarget method parameters
> -----------------------------------------
>
>                 Key: CDI-6
>                 URL: https://issues.jboss.org/browse/CDI-6
>             Project: CDI Specification Issues
>          Issue Type: Clarification
>          Components: Portable Extensions
>    Affects Versions: 1.0
>            Reporter: Jozef Hartinger
>            Assignee: Marius Bogoevici
>            Priority: Minor
>             Fix For: 1.1 (Proposed)
>
>
> For the inject() method, the spec says: "inject() performs dependency injection upon the given object". It is not clear to me what does the "given object" refer two. if the CDI implementation uses proxies to implement interceptors and decorators, I can see two candidates for "the given object":
> - the product of the produce() method including interceptors and decorators -> a proxy
> - the target instance -> the object created by calling a constructor (no interception/decoration)
> Arguments for the first option
> - Let's have and extension that adds additional dependency injection capabilities by providing a custom InjectionTarget implementation and wrapping default InjectionTarget instances with custom ones. The custom InjectionTarget implementation does the additional DI in the inject() method and delegates to the default InjectionTarget instance to finish the injection. This implementation needs a direct access to the target instance (it cannot access field values through a proxy)
> - Interceptor-like behavior - similarity to interceptors, where the InvocationContext.getTarget() returns the (non-intercepted) target instance
> Arguments for the second option
> - the contract of the produce() method says: "produce() calls the constructor annotated @Inject if it exists, or the constructor with no parameters otherwise, as defined in Section 5.5.1, "Injection using the bean constructor", and returns the resulting instance. If the class has inter- ceptors, produce() is responsible for building the interceptors and decorators of the instance." which means it returns an intercepted/decorated instance.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the cdi-dev mailing list