This content has been marked as final.
Show 2 replies
-
1. Re: Why injection through new does not work?
manovotn Apr 18, 2016 6:29 AM (in response to ctwx)Hi Christian
First of all, thanks for the code, it makes things much easier to grasp
Why is that? I thought it gets injected because the injection annotations will make sure that fooList will be injected.
Weld cannot help you here, because you manually created the object. If you let Weld take care of the creation process (e.g. use the objects via @Inject) it will also resolve the injection point for you. That is why your latter case works fine.
The magic behind the creation involves much more than just calling new Object(), along with injection point resolution there is proxy creation etc.
-
2. Re: Why injection through new does not work?
ctwx Apr 20, 2016 6:18 AM (in response to manovotn)Thank you for your Answer. I guess I just misunderstood the concept. I thought, when I start the injection in the main method then it would does it magic on "new" calls as well. But after rethinking it makes sense!