Jetty global
The server is displayed at the entrance of the previous article. The following describes the structure of the server.
Jetty has several main concepts:
- Connector: receive connections
- Handler: Process requests
- Threadpool: thread pool, unified thread management
Server associates these important concepts. From the inheritance structure, server itself is a handler that can contain other handler (that is, a container), including connenctor and threadpool, these parts are connected internally.
Server. dostart () method:
Step 1: Create a threadpool and add it to the iner for later use
setThreadPool(new QueuedThreadPool());
Step 2: Execute dostart () of handlers ();
super.doStart();
Step 3: Execute connector initialization, open the port, and receive the request
_connectors[i].start();
Connector
- Sslconnector: Secure Sockets Layer, which provides security control methods such as authentication.
- Blockingchannelconnector: this connector uses efficient NiO buffers with a traditional blocking thread model
- Selectchannelconnector: this connector uses efficient NiO buffers with a Non Blocking threading model.
- Ajp13socketconnector: used for AJP Protocol Communication
- Networktrafficselectchannelconnector: supports networktrafficlistener (networktrafficlistener: A listener for raw network traffic within Jetty .)
- Inheritedchannelconnector: first, obtain the channel that inherits a process from the self-starting Virtual Machine (VM ).
Handler
Handler in three main categories
- Simple handler: directly inherits from abstracthandler to implement the handler function.
- Handlerwrapper: Decorative mode. It acts as a proxy outside handler to do things outside handler.
- Handlercollection: Handler container
Lifecycle
All components in jetty implement the lifecycle interface. Each action of the component calls the method (start, stop, etc.) corresponding to the lifecycle, and the notification _ listeners executes the corresponding method.
Connector initialization process
Take socketconnect as an example to make it clearer.
Process for receiving requests
Finally, enter the connection handler.
I forgot to list the directory structure.
Directory Name |
Function |
Bin |
Startup and other scripts |
Contexts |
Hot deployment files |
Contexts-available |
Pre-Context |
Lib |
Jar package |
Etc |
Various configuration files |
Javadoc |
API documentation |
Logs |
Default log directory |
Resources |
Other resource directories |
Webapps |
Store Web Applications |
Start. Jar |
Classes required to start Jetty |