Basic architecture of Jetty
Jetty is now a more optimistic servlet engine, its architecture is relatively simple, is also a scalable and very flexible application server, it has a basic data model, this data model is Handler, all can be extended components can be used as a Handler, Added to the Server, Jetty is helping you manage these Handler.
Basic architecture of Jetty
is the basic architecture diagram of Jetty, the core components of the entire Jetty are composed of server and Connector two components, the entire server component is based on the Handler container, it resembles the Container container of Tomcat, Jetty and to The comparison of MCAT is described in detail later. The other component in Jetty is connector, which is responsible for accepting the client's connection request and assigning the request to a processing queue to execute.
Figure 1. Basic architecture of Jetty
There are also some optional components in jetty that we can expand on. such as JMX, we can define some Mbean to add it to the server, and when the server starts, the beans will work together.
Figure 2. Class diagram of the main components of the Jetty
It can be seen that the core of the entire jetty is built around the server class, and the server class inherits the Handler, associating Connector and Container. Container is a container for managing Mbean. The Jetty server extension is primarily implemented by Handler and adding Handler to the server, which provides access rules for invoking these Handler.
The lifecycle management of all components of the entire jetty is based on the observer template design, which is similar to Tomcat management. Here is the class diagram for LifeCycle
each component holds an observer (here is the Listener class, which usually corresponds to the observer role commonly used in the observer pattern, These Listener will be called when events such as Start, fail, or stop are triggered, which is the simplest way to design, much simpler than Tomcat's LifeCycle.
Architecture of the Handler
The Jetty described above is mainly based on Handler, and the Handler architecture affects all aspects of the Jetty. The following summarizes the types and effects of Handler:
Figure 3. Architecture of the Handler
Jetty mainly provides two types of Handler, one is handlerwrapper, it can delegate a Handler to another class to execute, if we want to add a Handler to Jetty, then we must delegate this Handler to Serv ER to call. With the Scopehandler class we can intercept Handler execution, before or after calling Handler, and can do something else, similar to Valve in Tomcat, and the other Handler type is handlercollection, which The Handler class can assemble multiple Handler together to form a Handler chain that allows us to expand.
Reference: http://www.ibm.com/developerworks/cn/java/j-lo-jetty/
Basic architecture of Jetty