[cdi-dev] [JBoss JIRA] (CDI-610) Add API to obtain current injection point from Bean#create

Arjan t (JIRA) issues at jboss.org
Tue May 31 06:10:00 EDT 2016

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

Arjan t commented on CDI-610:

{quote}Maybe we could add getInjectionPoint() method to the CreationalContext?{quote}

For the {{Bean<T>}} case this would surely work as well. Maybe for some code deeper down {{BeanManager}} would still be more convenient, but principally {{CreationalContext}} should work too.

{quote}Also it should return null for beans which are not @Dependent.{quote}

Naturally, or perhaps even an exception. It should be as much aligned with injecting the {{InjectionPoint}} in a producer method. (I don't know from the top of my head, but does it throw an exception during startup if it concerns a  non {{@Dependent}} bean?)

> Add API to obtain current injection point from Bean#create
> ----------------------------------------------------------
>                 Key: CDI-610
>                 URL: https://issues.jboss.org/browse/CDI-610
>             Project: CDI Specification Issues
>          Issue Type: Feature Request
>          Components: Portable Extensions
>            Reporter: arjan tijms
> There's currently not a clear way on how to obtain the *current* injection point (if any) from {{Bean<T>#create}}.
> A previously somewhat accepted way (though not specified) was:
> {code}
>   Bean<? extends Object> bean = beanManager.resolve(beanManager.getBeans(InjectionPoint.class));
>   InjectionPoint injectionPoint = (InjectionPoint) beanManager.getReference(bean, InjectionPoint.class, creationalContext);
> {code}
> This however broke in some version of Weld.
> Since getting the injection point is an often used feature in producers, I'd like to propose to introduce an easy API for this, so {{Bean<T>}} implementations can use this just as easily. E.g. something like: {{BeanManager#getCurrentInjectionPoint()}}.
> Also see: http://cdi-development-mailing-list.1064426.n5.nabble.com/Getting-injection-point-from-Bean-create-td5710505i20.html

This message was sent by Atlassian JIRA

More information about the cdi-dev mailing list