Handling requests with the front-controller pattern
The goal of the pattern is to create a common service for most of the client requirements. The pattern defines a procedure that allows common functions such as authentication, security, custom manipulation, and logging to be encapsulated at a single location.
Motivation
This pattern is commonly seen within web applications. It implements and defines the standard handler used by the controller. It is the handler’s responsibility to evaluate the validity of all incoming requests, although the handler itself may be available in many incarnations at runtime. The code is encapsulated in one place and referenced by the clients.
Finding it in the JDK
Usage of the front-controller pattern can be found in the jdk.httpserver
module, the sun.net.httpserver
package, and the HttpServer
abstract class. The class implements the createContext
abstract method, which accepts the HttpHander
interface. Handler instances participate...