Design Pattern Front Controller Pattern - Design Patterns

What is Design Pattern Front Controller Pattern?

The front controller design pattern is use to provide a centralized request handling instrument so that all requirements will be handled by a single handler. This handler can do the verification/ authorization/ logging or tracking of application and then pass the requests to corresponding handlers. Follow are the entity of this type of design pattern.

  • Front Controller - Single handler for all kinds of requests coming to the application (either web based/ desktop based).
  • Dispatcher - Front Controller may use a dispatcher object which can dispatch the request to corresponding specific handler.
  • View - Views are the object for which the requests are made.

Implementation

We are going to produce a Front Controller and recipient to act as Front Controller and Dispatcher correspondingly. Home vision and StudentViewrepresent various views for which desires can come to front controller.

FrontControllerPatternDemo, our demo class, will use Front Controller to express Front Controller Design Pattern.
frontcontroller_pattern_uml_diagram

Step 1

Create Views.

HomeView.java

StudentView.java

Step 2

Create Dispatcher.

Dispatcher.java

Step 3

Create Front Controller

FrontController.java

Step 4

Use the Front Controller to show Front Controller Design Pattern.

FrontControllerPatternDemo.java

Step 5

Verify the output.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Design Patterns Topics