aspose file tools*
The moose likes Struts and the fly likes Design pattern used in Struts Framework ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Design pattern used in Struts Framework ?" Watch "Design pattern used in Struts Framework ?" New topic
Author

Design pattern used in Struts Framework ?

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
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

Joined: Apr 04, 2009
Posts: 93
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).


Brainbench Java 2.0 Fundamentals, J2EE 1.4
http://www.brainbench.com/transcript.jsp?pid=8192792
Venkata Kumar
Ranch Hand

Joined: Apr 16, 2008
Posts: 110

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


SCJP 5.0, SCWCD 5, preparing for SCDJWS
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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.
 
 
subject: Design pattern used in Struts Framework ?