Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dependency Injection

 
Bilal A. Siddiqui
Ranch Hand
Posts: 53
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
kurt hanni
Ranch Hand
Posts: 140
Eclipse IDE Java Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dependency injection is done by the Spring framework.

Check this post about DI
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 53
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks David & kurt

I think i need to study more. I am still not very comfortable with the concept.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic