#107 Front Controller example JavaDoc
This commit is contained in:
parent
de784cfdc1
commit
c5c4a68c6f
@ -4,22 +4,26 @@ package com.iluwatar.front.controller;
|
|||||||
*
|
*
|
||||||
* The Front Controller is a presentation tier pattern. Essentially it defines a
|
* The Front Controller is a presentation tier pattern. Essentially it defines a
|
||||||
* controller that handles all requests for a web site.
|
* controller that handles all requests for a web site.
|
||||||
*
|
* <p>
|
||||||
* The Front Controller pattern consolidates request handling through a single handler
|
* The Front Controller pattern consolidates request handling through a single handler
|
||||||
* object (FrontController). This object can carry out the common the behavior such as
|
* object ({@link FrontController}). This object can carry out the common the behavior such as
|
||||||
* authorization, request logging and routing requests to corresponding views.
|
* authorization, request logging and routing requests to corresponding views.
|
||||||
*
|
* <p>
|
||||||
* Typically the requests are mapped to command objects (Command) which then display
|
* Typically the requests are mapped to command objects ({@link Command}) which then display
|
||||||
* the correct view (View).
|
* the correct view ({@link View}).
|
||||||
*
|
* <p>
|
||||||
* In this example we have implemented two views: ArcherView and CatapultView. These
|
* In this example we have implemented two views: {@link ArcherView} and {@link CatapultView}. These
|
||||||
* are displayed by sending correct request to the FrontController object. For example,
|
* are displayed by sending correct request to the {@link FrontController} object. For example,
|
||||||
* the ArcherView gets displayed when FrontController receives request "Archer". When
|
* the {@link ArcherView} gets displayed when {@link FrontController} receives request "Archer". When
|
||||||
* the request is unknown, we display the error view (ErrorView).
|
* the request is unknown, we display the error view ({@link ErrorView}).
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Program entry point
|
||||||
|
* @param args command line args
|
||||||
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
FrontController controller = new FrontController();
|
FrontController controller = new FrontController();
|
||||||
controller.handleRequest("Archer");
|
controller.handleRequest("Archer");
|
||||||
|
@ -1,8 +1,15 @@
|
|||||||
package com.iluwatar.front.controller;
|
package com.iluwatar.front.controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Custom exception type
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class ApplicationException extends RuntimeException {
|
public class ApplicationException extends RuntimeException {
|
||||||
|
|
||||||
public ApplicationException(Throwable cause) {
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public ApplicationException(Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,11 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import com.iluwatar.front.controller.App;
|
import com.iluwatar.front.controller.App;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Application test
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class AppTest {
|
public class AppTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user