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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

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

JIRA issues@jboss.org

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

Martin Kouba commented on CDI-610:

Maybe we don't need to extend the API but instead clarify that for a {{@Dependent}} bean it should be possible to obtain {{InjectionPoint}} from within {{Contextual.create()}} (e.g. using {{BeanManager.createInstance().select(InjectionPoint.class).get()}}) and during invocation of a callback specified by {{BeanConfigurator.produceWith()}} (https://github.com/weld/core/blob/master/tests-arquillian/src/test/java/org/jboss/weld/tests/injectionPoint/beanConfigurator/BeanConfiguratorExtension.java#L40).

Note that {{CreationalContext}} is currently bound to a bean instance, not an injection point, e.g. an instance might be reused when resolving all injection points of a bean instance. (of course this is just an impl detail)

> 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
cdi-dev mailing list
[hidden email]

Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.