> this has nothing to do with java 5, you can just as easily inject fields as
> setters in java 1.4
True. You can technically inject fields just as well. I guess I was
thinking that I'd like to have a public setter rather than expose the
field as public. What I meant by the whole 1.4/5.0 thing was simply
not needing annotations.
why would you expose the field as public? That is not needed with reflection
Reflection can by pass all scopes. And set private fields just as easy.
setting it through fields is the way to go because we already do stuff
that is more or less a bit dangerous (calling/settings stuff on a not already completely
constructed object). But as long as you just use fields and don't declare the fields a
default value ( xxxx = null; but just xxxx;) then it will be alright.
in setter methods beaware don;'t do ANYTHING else in that method then just setting
that field. Because you are working in a not fully constructed object.
Why would the constructor need those dependencies? Isn't this
dependent on how you implement your component?
because pretty much everybody is doing the initializing of the component in the constructor.
So it is very handy to have all the injected objects there.
johan