aspose file tools*
The moose likes Struts and the fly likes Dependency Injection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dependency Injection" Watch "Dependency Injection" New topic
Author

Dependency Injection

Bilal A. Siddiqui
Ranch Hand

Joined: Sep 14, 2008
Posts: 53

Hi All,

i am reading strutss 2 in action where they are integerating springs with struts. I am trying a lot but i am unable to understand what is dependency injection.

I am also not sure whether this question has to be post in springs forum or struts forum.

Regards
Bilal


Cheers!!! Bilal
Handsome Android||@bilal_speed||LinkedIn
kurt hanni
Ranch Hand

Joined: Aug 11, 2007
Posts: 140

Dependency injection is done by the Spring framework.

Check this post about DI


SCJA, SCJP, SCJD, SCMAD, SCWCD, SCBCD, SCDJWS, SCEA, SOA, Spring Certified, OCP MySQL 5 Developer, PMP
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The nutshell version is that instead of an S2 action instantiating and using an implementation, like this:actions will instead allow the implementation to be instantiated and injected by Spring. This is generally defined in a configuration file, but there are other ways. So the code would look more like this:Amongst other things, this means that the action can now be tested with various user service implementations--like one that always fails login, one that always succeeds, or one that succeeds/fails based on user information, whatever.

It's a simple concept, but very, very helpful.
Bilal A. Siddiqui
Ranch Hand

Joined: Sep 14, 2008
Posts: 53

Thanks David & kurt

I think i need to study more. I am still not very comfortable with the concept.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dependency Injection