[cdi-dev] RequestScoped and Injection Points
struberg at yahoo.de
Thu Sep 8 03:28:44 EDT 2011
If I understand you correctly then the answer is: why the hack don't I get the InjectionPoint info for @RequestScoped bean producer methods, right?
This has to do that NormalScoped Contexts always will result in creating a proxy which will get injected. Which means that we could determine the injection point only for the proxy (which is of no use) but not for the contextual instance which gets created by the producer method.
You just have no way to determine where your contextual instance will gonna get used. In fact, they will always only be accessed via proxies and thus from n different other beans. In other words: there is not 1 InjectionPoint but multiple. And they are completely undetermined at the time the contextual instance gets created.
You currently can only use the InjectionPoint info in produer methods for @Dependent beans.
----- Original Message -----
> From: Jozef Hartinger <jharting at redhat.com>
> To: John D. Ament <john.d.ament at gmail.com>
> Cc: cdi-dev at lists.jboss.org
> Sent: Thursday, September 8, 2011 8:17 AM
> Subject: Re: [cdi-dev] RequestScoped and Injection Points
> On 09/07/2011 02:10 AM, John D. Ament wrote:
>> CDI Experts
>> Was wondering if you could help me understand rationale. In request
>> scoped objects, when you create a producer method that creates request
>> scoped instances, why is there no access to the underlying injection
>> Let's say that you have a qualifier with a single String value
>> attribute that is nonbinding; let's say @JmsDestination. You have the
>> following injection points:
>> @Inject @JmsDestination("jms/MyQueue") MessageProducer
>> @Inject @JmsDestination("jms/MyTopic") MessageProducer
>> In this case, two distinct MessageProducers should be injected. The
>> CDI container should be able to differentiate the two, since they have
>> different values on the qualifier.
> The CDI container is be able to differentiate the two. By annotating the
> qualifier's member with @NonBinding, you explicitly asked the container
> it to ignore the difference.
>> However, CDI disallows this since the producer methods used to create
>> them would not have access to the injection point. If a second
>> injection point is found, CDI should return the same instance.
>> I hope it doesn't sound like I'm babbling, but I wanted to put the
>> question out there to see if it's something that could be addressed.
>> cdi-dev mailing list
>> cdi-dev at lists.jboss.org
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
More information about the cdi-dev