1.jetty Server的主要结构如下:
The Jetty Server is the plumbing between a collection of Connectors that accept HTTP connections, and a collection of Handlers that service requests from the connections and produce responses, with the work being done by threads taken from a thread pool.
server主要就是吧connector,handler和ThreadPool结合起来.,这里主要针对SelectChannelConnector分析:
其中connector又有两个角色:
- 一个是负责socket.accept()的线程,所做的工作就是accept,然后把socketChannel放入队列,等待别的模块处理,类似与tomcat或者其他容器的bio的方式:
_manager.dispatch(new Runnable()
{
public void run()
{
final ServerSocketChannel server=_acceptChannel;
while (isRunning() && _acceptChannel==server && server.isOpen())
{
try
{
SocketChannel channel = server.accept();
channel.configureBlocking(false);
Socket socket = channel.socket();
configure(socket);