File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "DI Queries" Watch "DI Queries" New topic
Author

DI Queries

Soniya Ahuja
Ranch Hand

Joined: Jul 20, 2008
Posts: 83
Hi,
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]http://a2zjava.webs.com[/url] - Online training for Java/JSPs and Servlets/SCJP/SCWCD
http://soniyaahuja.webs.com
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29219
    
134

#1 is covered in this thread

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

#3 - Use Spring?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DI Queries
 
Similar Threads
Dependency-Injection Implementation.
Whether or not to use method injection?
DI vs IoC
Is OSGI framework a Dependency Injection killer?
DI or BD using EJB 3