It's not a secret anymore!*
The moose likes Struts and the fly likes Dependency Injection in struts 2.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Dependency Injection in struts 2.0" Watch "Dependency Injection in struts 2.0" New topic
Author

Dependency Injection in struts 2.0

Vineela Devi
Ranch Hand

Joined: Dec 20, 2003
Posts: 191
Can anyone tell me where exactly the dependency injection comes into picture in struts 2.0?

Thanks.
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 515
Hello,
Dependency injection in Struts action classes can be used to inject dependencies such as business delegates and other helper classes.
Even you can inject some configuration properties as well in the Struts action classes.
There three ways to achieve this
1) Using Spring Action Support classes.
2) Using DelegatingRequestProcessor
3) Using DelegatingActionProxy = I have used this one earlier in one of the projects. This is the best way suggested to use DI in struts. In this approach you declare map the type attribute in action-mappings to the spring class DelegatingActionProxy and declare the action class as spring beans in spring configuration file.
Thnx
amit


Regards,
Amit
Vineela Devi
Ranch Hand

Joined: Dec 20, 2003
Posts: 191
I am a bit confused with the explanations of the Dependency Injection. Can anyone please explain the IOC or dependency Injection concept with an example or point me to some good links where I can get a clear picture of the same and how it's used in the struts 2.0 framework(probably with some live examples).

Thanks Much!
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you don't understand the concept of IOC very well, my advice would be to forget about Struts 2 for a while and concentrate on learning IOC in the context of Spring. Then once you have a good handle on that, work on how to integrate with Struts 2.
[ June 21, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dependency Injection in struts 2.0