On Sat, 05 Apr 2014 18:51:44 -0300, Sanket Sharma <sanketsha...@gmail.com>
wrote:
Okay, so following your advice, I gave it another try.
Created a new project using tapestry jumpstart and experimented with
case 1 type injection again. And guess what...it works!
Yay! :)
As I analysed the code again, I am wondering at what point does injection
really take place? It is not really an issue when using constructor based
injection, but what about instance variables?
Another argument for constructor-based injection. :) When using field
injection, the actual injection is done just after the constructor is
called by Tapestry-IoC and the call finishes (supposing it doesn't throw
an exception).
I think that's what I was doing wrong (assuming in this case injection
does not happen until after the object has come into existence e.g.
constructor has returned?)
Exactly. And that's a limitation of Java itself, maybe even
object-orientation as a whole, not Tapestry-IoC. That's just how objects
work: you cannot do anything with them until the constructor call finishes.
Summary: constructor dependency injection rules! :D
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org