[cdi-dev] [JBoss JIRA] (CDI-683) BeanConfigurator#produceWith(Function) does not allow access to InjectionPoint

Laird Nelson (JIRA) issues at jboss.org
Thu Feb 9 14:03:00 EST 2017

Laird Nelson created CDI-683:

             Summary: BeanConfigurator#produceWith(Function) does not allow access to InjectionPoint
                 Key: CDI-683
                 URL: https://issues.jboss.org/browse/CDI-683
             Project: CDI Specification Issues
          Issue Type: Bug
          Components: Beans
    Affects Versions: 2.0 .Final
            Reporter: Laird Nelson

The {{BeanConfigurator#produceWith(Function)}} method is intended to simulate a producer method, and is quite convenient.

The {{Function}} that it takes accepts one parameter which is of type {{Instance<Object>}}.  This is supposed to allow "faking" parameter injection in a producer method.

One of the parameters that you commonly want in a producer method is the {{InjectionPoint}} for which the return value of the producer method is destined.

If you try to "get" this {{InjectionPoint}} like this:
final Instance<InjectionPoint> injectionPointInstance = instance.select(InjectionPoint.class);
final InjectionPoint injectionPoint = injectionPointInstance.get();
...the {{InjectionPoint}} returned is _not_ the one you want, but instead a strange {{InjectionPoint}} that seems to represent something in the {{Instance}} class itself.

The [{{InjectionPoint}} javadocs|http://docs.jboss.org/cdi/api/2.0.Beta1/javax/enterprise/inject/spi/InjectionPoint.html] say this about the matter:

bq. If the injection point is a dynamically selected reference obtained [sic] then the metadata obtain [sic] reflects the injection point of the Instance, with the required type and any additional required qualifers [sic] defined by Instance.select().

I observe that Weld's behavior in this case matches the javadocs (if I'm understanding them right), but surely I should be able to get the {{InjectionPoint}} that is being serviced by my simulated producer method.

This message was sent by Atlassian JIRA

More information about the cdi-dev mailing list