[
https://issues.jboss.org/browse/CDI-610?page=com.atlassian.jira.plugin.sy...
]
Arjan t commented on CDI-610:
-----------------------------
{quote}Which other cases do you have in mind?{quote}
Not really so much a wildly different usecase, just something like
{code}
public Object create(CreationalContext<T> creationalContext) {
someclass.somemethod();
}
[...]
public void somemethod() {
InjectionPoint point = beanManager.getCurrentInjectionPoint();
}
{code}
Utility code would often already have access to the bean manager (or it can pull it out of
thin air), and the actual need for the injection point could be some levels deep and via
utility code. Passing the {{CreationalContext}} around may be less convenient. Also, the
existing (semi-official) methods to get the injection point used the {{BeanManager}} as
well.
That all said, {{CreationalContext}} would be fine with me ;)
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-injecti...
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)