This is a software design pattern which provides a centralized entry point for handling requests. Front controller pattern enforces channeling all requests through a single controller.
Front Controller provides one of the best ways to structure the controller for very complex Web applications so that developer can achieve reuse and flexibility while avoiding code duplication
Front Controller provides one of the best ways to structure the controller for very complex Web applications so that developer can achieve reuse and flexibility while avoiding code duplication
This design pattern suggests use of a single controller as the initial point of contact for handling a request. The controller manages the handling of the request, including invoking security services such as authentication and authorization, delegating business processing, managing the choice of an appropriate view, handling errors, and managing the selection of content creation strategies.
The controller itself is usually implemented in two parts: a handler and a hierarchy of commands.
The responsibilities of handler include receiving the HTTP GET or POST request from the client and retrieving relevant parameters from the request and then use the retrieved parameters to select the correct command and transfer control to that command for processing.
The command themselves are part of controller.
The command themselves are part of controller.
Benifits of using front controller pattern:
Centralized control: Front controller pattern enforces channeling all requests through a single controller. This single controller is in the perfect location to enforce application-wide policies, such as security and usage tracking.
Configurability: Configuration of web server is highly simplified since only one front controller needs to be configured into the Web server; the handler does the rest of the dispatching.
Configurability: Configuration of web server is highly simplified since only one front controller needs to be configured into the Web server; the handler does the rest of the dispatching.
Liabilities associated with the use of front controller pattern:
There are also some liabilities that are associated with front controllers which include:
Performance considerations: Front Controller is a single controller that handles all requests for the Web application. As the handler receives all the requests and then chooses the appropriate controller for processing of the requests, therefore in situations in which the handler must perform a database query or a query of an XML document to make the decision, performance could be very slow as a result.
Performance considerations: Front Controller is a single controller that handles all requests for the Web application. As the handler receives all the requests and then chooses the appropriate controller for processing of the requests, therefore in situations in which the handler must perform a database query or a query of an XML document to make the decision, performance could be very slow as a result.