-
1. Re: CDI General Question
lightguard Nov 15, 2011 6:39 PM (in response to aarnold)There may be other Users such as one which has not logged in, this further qualifies which instance you want to inject.
The @Produces creates the @LoggedIn User so you can @Inject it.
-
2. Re: CDI General Question
aarnold Nov 16, 2011 11:37 AM (in response to aarnold)Jason,
Thanks for the response! I think I get what you are saying, but I still am a little shakey on the concept of injection in general I guess. So the @Produces creates the @LoggedIn User so you can @Inject it. I guess now I have a more fundemental question... Why inject? Isn't injecting simply invoking the getCurrentUser() method on the instantiation of the Login class? Why can't this be done with some call in a constructor? Or even using @PostConstruct? Is this all needed because beans can not have parameterized constructors?
Thanks for you time.
--Drew
-
3. Re: CDI General Question
aarnold Nov 16, 2011 11:43 AM (in response to aarnold)Ok, hold on... I think I need to re-phrase. Fields/Methods with @Inject get invoked on instation of the class. I guess @Produces is for a user of the class? Who can use this implemetation of @LoggedIn? What if another class has a different @Produces @LoggedIn implementation?
-
4. Re: CDI General Question
aarnold Nov 16, 2011 12:25 PM (in response to aarnold)Jason,
I realize the previous questions reeked of ignorance. I am in the process of digging into CDI for the first time. I am reading the Weld - JSR-299 Reference Implementation now. I didn't realize there was good literature out there on this topic.... http://docs.jboss.org/weld/reference/latest/en-US/html/index.html.
I'm sure the guide will clear things up for me.
Thanks so much for your response.
--Drew