Research on the jetty server

Source: Internet
Author: User

The following document is an analysis of the jetty7.6.x


1) http://benni82.iteye.com/blog/844922----Analysis of the use of Start.ini

Run the Java-jar start.jar,jetty program at the command line first to see if your system has configured the JETTY_HOME system variable if it is configured, it will look under the Start.ini file, if not

will be in the current execution directory to find Start.ini file, found will be based on the configuration of this file to load the specific content, in fact Start.ini content can be directly written in the command line, written in this file

Easy to manage calls in unified


2) How to disable Jetty HTTP protocol, only open HTTPS protocol

Modify Start.ini

Comment out the etc/jetty.xml, and open etc/jetty-ssl.xml

But only open Jetty-ssl.xml is unable to start the jetty, you need to copy some of the contents of Jetty.xml to Jetty-ssl.xml, the content is as follows:

<set name= "Handler" >

<new id= "Handlers" class= "Org.eclipse.jetty.server.handler.HandlerCollection" >

<set name= "Handlers" >

<array type= "Org.eclipse.jetty.server.Handler" >

<Item>

<new id= "Contexts" class= "org.eclipse.jetty.server.handler.ContextHandlerCollection"/>

</Item>

<Item>

<new id= "DefaultHandler" class= "Org.eclipse.jetty.server.handler.DefaultHandler"/>

</Item>

</Array>

</Set>

</New>

</Set>


<!--===========================================================--

<!--extra Options--

<!--===========================================================--

<set name= "Stopatshutdown" >true</Set>

<set name= "Sendserverversion" >true</Set>

<set name= "Senddateheader" >true</Set>

<set name= "Gracefulshutdown" >1000</Set>

<set name= "Dumpafterstart" >false</Set>

<set name= "Dumpbeforestop" >false</Set>

is actually to remove the HTTP protocol corresponding to the connection group, it is necessary to add the content, which is related to the jetty architecture

A jetty contains a server,server under which there must be handler, and contexts

3) principle and architecture of jetty

http://www.ibm.com/developerworks/cn/java/j-lo-jetty/

.) The core components of the entire jetty are comprised of server and connector two components, and the entire server component is based on the handler container

Work, another indispensable component in Jetty is connector, which is responsible for receiving client connection requests and

The request is assigned to a processing queue to execute.

.) The jetty Group provides two types of Handler, one is Handlerwrapper, which can delegate one Handler to another class to execute,

If we were to add a Handler to the Jetty, we would have to delegate this Handler to the Server to invoke. With Scopehandler

Class We can intercept the execution of Handler, before or after calling Handler, can do something else, similar to the Valve in Tomcat;

Another Handler type is handlercollection, a Handler class that can assemble multiple Handler together to form a Handler chain that allows us to expand.


4) Jetty Start-up process

The jetty portal is the server class, and the server class is started, which means that jetty can provide you with services. What services it can provide depends on when the Server class starts

The Start method of the other component is used. From the Jetty configuration file we can see that the process of configuring Jetty is the process of configuring those classes to the Server.

Because all components in Jetty inherit LifeCycle, the Start method call of the server invokes all components that are already registered with the server, and the order in which the server launches the other components is:

First start the setup to Server Handler, usually this Handler will have a lot of Handler, these Handler will form a Handler chain. The Server starts all Handler on the chain in turn.

The Mbean that is registered on the Server is then started, and the Mbean is also working together, finally starting the Connector, opening the port, accepting the client request, and starting the logic very simple


5) receive the request:

.) Jetty Create a queue thread pool to handle each task that creates a connection

.) Create a serversocket that prepares a socket request for a client to be accepted

.) Create one or more listener threads to listen for connections to the access port

When the connected environment is ready, the HTTP request can be accepted, and when the acceptor accepts the socket connection, it will be transferred to the corresponding server for processing.


6) Many functions of jetty can be added in the Start.ini of the corresponding configuration file started, such as the function of opening jetty-fileserver file server

This can be achieved by loading different handler.


Research on the jetty server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.