2015-07-24 11:32:22 +03:00
|
|
|
package com.iluwatar.front.controller;
|
2015-07-19 11:44:39 +03:00
|
|
|
|
2015-07-19 13:54:07 +03:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* The Front Controller is a presentation tier pattern. Essentially it defines a
|
|
|
|
* controller that handles all requests for a web site.
|
2015-08-18 22:54:15 +03:00
|
|
|
* <p>
|
2015-07-19 13:54:07 +03:00
|
|
|
* The Front Controller pattern consolidates request handling through a single handler
|
2015-08-18 22:54:15 +03:00
|
|
|
* object ({@link FrontController}). This object can carry out the common the behavior such as
|
2015-07-19 13:54:07 +03:00
|
|
|
* authorization, request logging and routing requests to corresponding views.
|
2015-08-18 22:54:15 +03:00
|
|
|
* <p>
|
|
|
|
* Typically the requests are mapped to command objects ({@link Command}) which then display
|
|
|
|
* the correct view ({@link View}).
|
|
|
|
* <p>
|
|
|
|
* In this example we have implemented two views: {@link ArcherView} and {@link CatapultView}. These
|
|
|
|
* are displayed by sending correct request to the {@link FrontController} object. For example,
|
|
|
|
* the {@link ArcherView} gets displayed when {@link FrontController} receives request "Archer". When
|
|
|
|
* the request is unknown, we display the error view ({@link ErrorView}).
|
2015-07-19 13:54:07 +03:00
|
|
|
*
|
|
|
|
*/
|
2015-07-19 11:44:39 +03:00
|
|
|
public class App {
|
2015-07-19 12:44:51 +03:00
|
|
|
|
2015-08-18 22:54:15 +03:00
|
|
|
/**
|
|
|
|
* Program entry point
|
|
|
|
* @param args command line args
|
|
|
|
*/
|
2015-07-19 11:44:39 +03:00
|
|
|
public static void main(String[] args) {
|
2015-07-19 12:44:51 +03:00
|
|
|
FrontController controller = new FrontController();
|
|
|
|
controller.handleRequest("Archer");
|
|
|
|
controller.handleRequest("Catapult");
|
|
|
|
controller.handleRequest("foobar");
|
2015-07-19 11:44:39 +03:00
|
|
|
}
|
|
|
|
}
|