File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes OO, Patterns, UML and Refactoring and the fly likes DI Queries Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "DI Queries" Watch "DI Queries" New topic

DI Queries

Soniya Ahuja
Ranch Hand

Joined: Jul 20, 2008
Posts: 83
In my current project we are using a lot of Dependency Injection. I need to know

1. When should setter injection be used and when should we go for constructor injection?
2. Should Programming to Interfaces be used always for DI?
3. How can we program to ask our container to inject dependencies for us (kike in Spring)?

Any help appreciated

Thanks in advance.

SCJP 1.5 | SCWCD 5 | SCJP 6.0
[url][/url] - Online training for Java/JSPs and Servlets/SCJP/SCWCD
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33106

#1 is covered in this thread

#2 - Very few things are "always" true in programming.

#3 - Use Spring?

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: DI Queries
It's not a secret anymore!