aspose file tools*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes why do we need Application Controller? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "why do we need Application Controller?" Watch "why do we need Application Controller?" New topic
Author

why do we need Application Controller?

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
I am confused with the need to have a separate pattern called Application Controller. Whatever it does Front Controller also does - controls the flow of the application (rather views and actions).
[ October 01, 2007: Message edited by: ankur rathi ]
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Seems like the same pattern to me.

The front controller controlls the application flow and logic.

-Cameron McKenzie
eduardo ferreira
Greenhorn

Joined: Oct 01, 2007
Posts: 16
No they are not.

- Front controller : Struts SERVLET.
- Application Controller : The struts actions you code.
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
Originally posted by eduardo ferreira:
No they are not.

- Front controller : Struts SERVLET.
- Application Controller : The struts actions you code.


can you please explain it in detail like

when you say struts servlet, it is struts action class in struts framework, whihc we don't write but that operates on the basis of struts-config.xml

and when you say "application controller" what you mean ?
we code view and action class/ which we extends the dispact action where we logically send action forward object ? i think


Thanks and Regards, Amit Taneja
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1



eduardo ferreira

No they are not.

- Front controller : Struts SERVLET.
- Application Controller : The struts actions you code.




It would seem that this article sees the Struts action Servlet as implementing the Application Controller pattern, while the struts actions you code being an implementation of the command pattern.




n Struts terminology, this class is called an action although you'll also see this general pattern referred to as the command pattern. At runtime, the Struts controller (a Java servlet) maps the incoming request onto an action class and calls the execute() method, which contains the (business) logic required to service the request. In the example, this logic is responsible for locating the Blog instance and making it available (via the request) so that the recent list of blog entries can be presented back to the user. As with all of the others, this example uses JSP as the view technology, although you'll notice from the code above that we don't explicitly say, "please now show JSP page X". We'll cover this shortly but for now, here's the JSP page itself.


Struts Command Pattern


In object-oriented programming, the Command pattern is a design pattern in which objects are used to represent actions. A command object encapsulates an action and its parameters.


Command Pattern Description

-Cameron McKenzie
[ October 01, 2007: Message edited by: Cameron McKenzie ]
eduardo ferreira
Greenhorn

Joined: Oct 01, 2007
Posts: 16
Originally posted by amit taneja:


can you please explain it in detail like

when you say struts servlet, it is struts action class in struts framework, whihc we don't write but that operates on the basis of struts-config.xml

and when you say "application controller" what you mean ?
we code view and action class/ which we extends the dispact action where we logically send action forward object ? i think


Yes, I think the front controller is the strut's servlet you declare on web.xml file (org.apache.struts.action.ActionServlet), and I see every action you code on your application (extending org.apache.struts.action.Action) as an application controller coded using the command pattern.

I don't think it's really useful to discuss too much beyond this point as the patterns on j2ee book are very abstract. I had never read this book before, and I'm reading it for the architect exam. I'm really hating this book: the patterns are not well explained, it gives you a LOT of bad examples (like coding a front controller using a JSP and stuff like this) and contains blocks senseless texts, so you have to skim through pages and pages. The problem is that I don't think that we have any other source for this subject, so we will have to read this book anyway, but with some care.
[ October 02, 2007: Message edited by: eduardo ferreira ]
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Eduardo,

Don't you know you're not supposed to say anything except great things about that book! That's like saying bad things about The Quoran or The Torah or The Bible. It's just not wise!

Actually, I'm glad you said it. I too felt the book was an awful read. You should read a book like that, and for every pattern have one of two responses:

OMG! I've been doing that for years, but I never knew it was a pattern! Kewl!

or

OMG! I've been struggling with that for years, and I never realized how easy a problem it was to solve! Kewl!

Instead, the reaction to every page seems to be the same:

Zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz.......

I agree with you about the book. And it's the lack of clarity of those types of references that makes us wonder what someone is talking about when they say Front Controller, Application Controller or Command Pattern.

-Cameron McKenzie
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
which book you are talking about ?
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Pretty much every book that has the words "Design" and/or "Pattern" in the title.

-Cameron McKenzie
Frank Kuepper
Ranch Hand

Joined: Mar 16, 2007
Posts: 45
The distinction Martin Fowler gives may be mor helpful than corej2eepatterns. See

http://www.martinfowler.com/eaaCatalog/frontController.html
http://www.martinfowler.com/eaaCatalog/applicationController.html

Seeing it this way, the two patterns make sense.


SCEA (93%/93%)
 
Consider Paul's rocket mass heater.
 
subject: why do we need Application Controller?