Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design pattern used in Struts Framework ?

 
jose chiramal
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What design pattern does Struts framework follow ?

Is it Inversion of Control ???

If yes, how does inversion of control happen in struts ?

I have heard that this concept is used in Spring but not sure if it is in struts.

Thanks.
 
Bhagat Singh Rawat
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jose chiramal wrote:What design pattern does Struts framework follow ?


Struts controller uses the Command design pattern and the action classes use the Adapter design pattern. The process() method of the RequestProcessor uses the Template method design pattern. Struts also implement the following J2EE design patterns.

* Service to Worker
* Dispatcher View
* Composite View (Struts Tiles)
* Front Controller
* View Helper
* Synchronizer Token


Is it Inversion of Control ???

If yes, how does inversion of control happen in struts ?

I have heard that this concept is used in Spring but not sure if it is in struts.


Struts2 is based on WebWork which has IoC. Struts2 supports interface injection (IOC).
 
Venkata Kumar
Ranch Hand
Posts: 110
Firefox Browser Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What design pattern does Struts framework follow ?

Struts follows MVC architecture and uses Front Controller design pattern.
Which version of Struts are you using?
Struts 2 uses Inversion of Control (IoC) pattern also known as dependency injection.
If yes, how does inversion of control happen in struts ?

In Struts 2 action class the HTTPServletRequest object can be obtained using IoC pattern

I have heard that this concept is used in Spring but not sure if it is in struts.

Yes Spring uses IoC pattern. Strus2 also uses Ioc pattern. I am not sure about Struts 1.x
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For Struts 1 it depends on which version, but the concept is relatively limited (as it was with most Java code back in those days). Struts 1 did integrate with Spring, however, allowing some injection, and it was possible to identify which implementation classes to use for various things (like custom request processors) in the Struts configuration file (again depending on version). So I'd say yes, Struts 1 supported IoC, but in a limited way.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic