Jetty Getting Started notes (from deployment to rationale)

Source: Internet
Author: User
Chapter I. Deployment

1.1 in WebApps directory deployment

Webappprovider timed scan $jetty_home/webapps directory automatic deployment


Note If you have the same name, WebApp will compromise and contexts deployment.

1.2 In Contexts directory deployment

Contextprovider scheduled scan $jetty_home/contexts directory for automatic configuration file deployment

1.3 Jety Specify the resource publishing directory and use/root directory Access

{Jettyhome}/contexts/test.xml changes are as follows:

Chapter II Introduction to the catalogue 2.1 VERSION.txt

Change attributes for each version 2.2 The ETC configuration file directory

Etc/jetty.xml Default configuration file

Etc/jetty-xxx.xml This file is intended to increase the profile of the extended application for jetty

Etc/webdefault.xml: This file is the default profile for Web applications that control common properties for all Web applications in the Jetty container.

Similar to Tomcat config directory 2.3 contexts for Contextdeployer deployment

This directory will be scanned by an instance of the Contextdeployer class, affected by $jetty_home/etc/jetty.xml configuration

An XML configuration file that contains multiple independent descriptive contexts.

This folder supports hot deployment, that is, adding and deleting changes will take effect immediately.

Contexts directory and WebApp directory two ways to deploy to avoid duplication of deployment

Javadoc.xml

Test.xml

A config/catalina/localhost directory similar to Tomcat

2.4 contexts-available example.

.. /contexts-available contains many examples of contexts configurations that can be used for deployment in the contexts directory.

Move-context.xml: Demonstrated redirection

Resourcesxml: Demonstrates how static HTML and image deploys 2.5 Javadoc Jetty API Description 2.6 Lib Jetty relies on 2.7 logs log loss Scan folder for deployment of 2.8 overlays 2.9 Resources 2.10 WebApp Webappprovider

Chapter III Initiation 3.1 Embedded servlet boot



JAVA-CP $JETTY _classpath xxx. HelloWorld

3.2 Custom Start WebApp


3.3 Starting with XML

JAVA-CP $JETTY _classpathorg.eclipse.jetty.xml.xmlconfiguration etc/jetty.xml 3.4 using Start.jar startup

The above methods need to configure the classpath more cumbersome.

Java–jar Start.jar//The behavior of this command is controlled by the Start.config configuration file, which is in the Start.jar package.

What exactly did 3.4.1 do?

You can view Start.jar what equivalent commands are executed by performing Java-jar Start.jar--dry-run.

3.4.2 Specify the loaded jar package

You can specify the jar package to be loaded into the classpath by using the options parameter instead of the default value

Java-jar Start.jaroptions=server,jmx,ajp,setuid

Java-jar start.jar–list-options can view all options, if you select more than one such as SERVER,SERVLET,WEBAPP,JMS, WebSocket The Interleaved jar package will retain only 1 3.4.3 in the final classpath the specified loaded XML package

Java-jar Start.jar options=server,jmx,ajpetc/jetty-jmx.xml etc/jetty.xml etc/jetty-ajp.xml

If you do not specify that the default is Etc/jetty.xml 3.4.4 use Start.ini to configure default parameters

and Start.jar in the same directory, you can configure JVM parameters, configuration files, options parameters, etc., as Java–jar start. The default parameter for the jar, note that if you let the value of the JVM take effect, you must open the-exec

3.4.5 Specify port boot

In Jetty.xml <set name= "Port" ><systempropertyname= "Jetty.port" default= "8080"/></set>

Start command: Java-djetty.port=8888-jar start.jar 3.4.6 shutdown Service


Fourth Chapter JETTY7 structure

Connector: connectors, accepting HTTP connections

Handler: Handler, service connection request and generate response

ThreadPool: Thread pool, providing a common group oh threads

Server: Servers, holding connector collections and handler collections

Attention:

Although Jetty's request/response are inherited from the standard Servlet API, the full attributes of the standard API are available only if the handler for the response is registered. For example, the session API in request is invalid unless the request is passed to a sessionhandler.

In jetty, the servlet concept itself is implemented by a servlet handler, and if the servlet is not necessary to reduce the overhead of Serlvet request response, you can create a jetty server, using only connectors and handlers, Rather than using a servlet.

4.1 Mode

Most jetty components implement lifecycle interface

Jetty provides IO buffering mechanism and NIO non-blocking mechanism

Interfaces are abstract classes.

4.2 Connectors

and Ajpconnector, no painting.

4.3 Handler

Handlercollection corresponding order use, handlerwapper corresponding nesting

Handler can be nested or used in turn: independent of each other in order, not strictly dependent on the call sequence

Handler is used to process requests, most of the time using a traditional servlet, but when you have special needs or prohibit the use of all SERVLETAPI, you can directly use handler to provide dynamic content directly.

4.3.1 is divided into 3 kinds

l Coordinate handlers-handlers, routing requests to other processing (handlercollection,contexthandlercollection)

L Filter Handler-handler, enhance request, and pass it to other processing (Handlerwrapper,contexthandler, Sessionhandler)

L Generate processor-handler generated content (Resourcehandler and Servlethandler)

public void handle (String target, requestbaserequest, httpservletrequest request, httpservletresponse response)

Throws IOException, Servletexception

4.4 Servlets

Servlethandler passes a request to any configured filter last passed to the URL-matching servlet 4.5 Context 4.6 Web applications

Fifth Chapter Working principle

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

Http://wiki.eclipse.org/Jetty/Feature/Continuations

Seventh Chapter FAQ 7.1 cannot edit save static file at run time

http://wiki.eclipse.org/Jetty/

Eighth Chapter Appendix 8.1 coment Server Push technology based on long connection

http://www.ibm.com/developerworks/cn/web/wa-lo-comet/

Implementation mode:

L Long polling method based on AJAX long polling;

L The flow mode based on IFRAME and Htmlfile.

L Flash based xmlsocket (need Flash, firewall may block)

L Html 5 WebSocket

L encapsulates the Socket.io frame above

L Pushlet is an open source Comet framework for encapsulating Ajax-polling and IFRAME

Limit:

The HTTP 1.1 specification stipulates that the client should not establish more than two HTTP connections with the server side

The HTTP 1.0 specification closes the socket connection after each Get/post request is processed by the server

http1.1 specification The server maintains this connection, which is idle during the two-request interval.

Java 1.4 introduces a Java.nio package that supports asynchronous IO. When the connection is idle, the thread resource assigned to the connection is returned to the thread pool for use by the new connection;

It will not feed back to you. Because the server side limits the long connections that each client hangs

Org.eclipse.jetty.webapp.WebAppContext

Org.eclipse.jetty.server.handler.ContextHandler

8.2 Books

Http://www.doc88.com/p-671405123636.html

8.3 Online API

http://download.eclipse.org/jetty/stable-7/apidocs/



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.