-
1. Re: CDI Qualifiers Question & Seam Security
lightguard Oct 28, 2011 2:04 AM (in response to zeeman)I'd actually use alternatives for this. In development I doubt you'll be testing both kinds of authentication simultaneously so an alternative which you switch on and off in beans.xml would probably be a cleaner solution. You read more about alternatives in the Weld docs, or the spec.
-
2. Re: CDI Qualifiers Question & Seam Security
zeeman Oct 28, 2011 11:56 AM (in response to zeeman)I thought about using alternatives. Does that change how I inject LoggedInUser? Do I still use @Any or use my own @Authenticated annotation?
-
3. Re: CDI Qualifiers Question & Seam Security
lightguard Oct 28, 2011 1:49 PM (in response to zeeman)You could use @Any but you won't have to. In fact you could use the same qualifier. Because of the alternatives, there will only be one bean that will satisfy that injection point.
-
4. Re: CDI Qualifiers Question & Seam Security
zeeman Oct 30, 2011 10:37 PM (in response to zeeman)I have to use @any, if I don't get dependency unsatisfied error when starting AS7. Any ideas? I would rather not to have put @Any when injecting the LoggedInUser.
-
5. Re: CDI Qualifiers Question & Seam Security
lightguard Nov 1, 2011 12:19 AM (in response to zeeman)Please post the code bits you're working with (the inject points, producers, and the beans.xml), or gist or something.
-
6. Re: CDI Qualifiers Question & Seam Security
zeeman Nov 1, 2011 12:15 PM (in response to zeeman)Hi Jason,
I figured it out. As you can see from my code above. I used @Any on @Produces. So to get that member injected I had to use @Any. After I removed @Any from outjection point I can inject LoggedInMemberInfo without having to use @Any. Thanks for your help.
But that does not make sense, CDI should not error out on @Any. It seems like CDI does a literal match for injection points regardless of their functional meaning. In other words using @Any at outjection code should work for fields injected without using @Any.
My code is exactly what I posted above.
-
7. Re: CDI Qualifiers Question & Seam Security
lightguard Nov 1, 2011 5:14 PM (in response to zeeman)@Any should be used at injection, not production. You can read the API description at http://docs.jboss.org/cdi/api/1.0/javax/enterprise/inject/Any.html. When you use it with a producer, you're going to force any injection point to also have it. When it's used at injection it's becomes a wildcard match essentially.
Does that help at all?
-
8. Re: CDI Qualifiers Question & Seam Security
zeeman Nov 1, 2011 9:42 PM (in response to zeeman)yes, this clarifies it for me. Thanks!