Merged branch 'jetty-10.0.x' into 'jetty-10.0.x-3897-new_docs_2'.

This commit is contained in:
Simone Bordet 2020-03-28 18:31:05 +01:00
commit 4d612b077f
4201 changed files with 123389 additions and 90454 deletions

View File

@ -0,0 +1,18 @@
---
name: Issue
about: Reporting bugs and problems in Eclipse Jetty
title: ''
assignees: ''
---
**Jetty version**
**Java version**
**OS type/version**
**Description**

View File

@ -0,0 +1,16 @@
---
name: Question
about: Asking questions about Eclipse Jetty
title: ''
labels: Question
assignees: ''
---
**Jetty version**
**Java version**
**Question**

20
.github/stale.yml vendored Normal file
View File

@ -0,0 +1,20 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 365
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 30
# Issues with these labels will never be considered stale
exemptLabels:
- Pinned
- Security
- Specification
- TCK
# Label to use when marking an issue as stale
staleLabel: Stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has been a
full year without activity. It will be closed if no further activity occurs.
Thank you for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: >
This issue has been closed due to it having no activity.

View File

@ -53,10 +53,10 @@ Be sure to search for existing bugs before you create another one. Remember that
Reporting Security Issues Reporting Security Issues
----------------- -----------------
There are a number of avenues for reporting security issues to the Jetty project available. There are a number of avenues for reporting security issues to the Jetty project available.
If the issue is directly related to Jetty itself then reporting to the Jetty developers is encouraged. If the issue is directly related to Jetty itself then reporting to the Jetty developers is encouraged.
The most direct method is to mail [security@webtide.com](mailto:security@webtide.com). The most direct method is to mail [security@webtide.com](mailto:security@webtide.com).
Webtide is comprised of the active committers of the Jetty project is our preferred reporting method. Webtide is comprised of the active committers of the Jetty project is our preferred reporting method.
We are flexible in how we work with reporters of security issues but we reserve the right to act in the interests of the Jetty project in all circumstances. We are flexible in how we work with reporters of security issues but we reserve the right to act in the interests of the Jetty project in all circumstances.
If the issue is related to Eclipse or its Jetty integration then we encourage you to reach out to [security@eclipse.org](mailto:security@eclipse.org). If the issue is related to Eclipse or its Jetty integration then we encourage you to reach out to [security@eclipse.org](mailto:security@eclipse.org).

123
Jenkinsfile vendored
View File

@ -11,65 +11,53 @@ pipeline {
agent { node { label 'linux' } } agent { node { label 'linux' } }
options { timeout(time: 120, unit: 'MINUTES') } options { timeout(time: 120, unit: 'MINUTES') }
steps { steps {
mavenBuild("jdk11", "-Pmongodb install", "maven3", true) // -Pautobahn mavenBuild("jdk11", "-T3 -Pmongodb clean install", "maven3", true) // -Pautobahn
// Collect up the jacoco execution results (only on main build) // Collect up the jacoco execution results (only on main build)
jacoco inclusionPattern: '**/org/eclipse/jetty/**/*.class', jacoco inclusionPattern: '**/org/eclipse/jetty/**/*.class',
exclusionPattern: '' + exclusionPattern: '' +
// build tools // build tools
'**/org/eclipse/jetty/ant/**' + '**/org/eclipse/jetty/ant/**' +
',**/org/eclipse/jetty/maven/**' + ',**/org/eclipse/jetty/maven/**' +
',**/org/eclipse/jetty/jspc/**' + ',**/org/eclipse/jetty/jspc/**' +
// example code / documentation // example code / documentation
',**/org/eclipse/jetty/embedded/**' + ',**/org/eclipse/jetty/embedded/**' +
',**/org/eclipse/jetty/asyncrest/**' + ',**/org/eclipse/jetty/asyncrest/**' +
',**/org/eclipse/jetty/demo/**' + ',**/org/eclipse/jetty/demo/**' +
// special environments / late integrations // special environments / late integrations
',**/org/eclipse/jetty/gcloud/**' + ',**/org/eclipse/jetty/gcloud/**' +
',**/org/eclipse/jetty/infinispan/**' + ',**/org/eclipse/jetty/infinispan/**' +
',**/org/eclipse/jetty/osgi/**' + ',**/org/eclipse/jetty/osgi/**' +
',**/org/eclipse/jetty/spring/**' + ',**/org/eclipse/jetty/spring/**' +
',**/org/eclipse/jetty/http/spi/**' + ',**/org/eclipse/jetty/http/spi/**' +
// test classes // test classes
',**/org/eclipse/jetty/tests/**' + ',**/org/eclipse/jetty/tests/**' +
',**/org/eclipse/jetty/test/**', ',**/org/eclipse/jetty/test/**',
execPattern: '**/target/jacoco.exec', execPattern: '**/target/jacoco.exec',
classPattern: '**/target/classes', classPattern: '**/target/classes',
sourcePattern: '**/src/main/java' sourcePattern: '**/src/main/java'
warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'Java']] warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'Java']]
junit testResults: '**/target/surefire-reports/*.xml,**/target/invoker-reports/TEST*.xml,**/target/autobahntestsuite-reports/*.xml' junit testResults: '**/target/surefire-reports/*.xml,**/target/invoker-reports/TEST*.xml,**/target/autobahntestsuite-reports/*.xml'
} }
} }
stage("Build / Test - JDK12") { stage("Build / Test - JDK13") {
agent { node { label 'linux' } } agent { node { label 'linux' } }
options { timeout(time: 120, unit: 'MINUTES') }
steps { steps {
mavenBuild("jdk12", "-Pmongodb install", "maven3", true) timeout(time: 120, unit: 'MINUTES') {
warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'Java']] mavenBuild("jdk13", "-T3 -Pmongodb clean install", "maven3", true)
junit testResults: '**/target/surefire-reports/*.xml,**/target/invoker-reports/TEST*.xml' warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'Java']]
junit testResults: '**/target/surefire-reports/*.xml,**/target/invoker-reports/TEST*.xml'
}
} }
} }
stage("Build Javadoc") { stage("Build Javadoc") {
agent { node { label 'linux' } } agent { node { label 'linux' } }
options { timeout(time: 30, unit: 'MINUTES') }
steps { steps {
mavenBuild("jdk11", "install javadoc:javadoc -DskipTests", "maven3", true) timeout(time: 30, unit: 'MINUTES') {
warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'JavaDoc'], [parserName: 'Java']] mavenBuild("jdk11", "package source:jar javadoc:jar javadoc:aggregate-jar -Peclipse-release -DskipTests -Dpmd.skip=true -Dcheckstyle.skip=true", "maven3", true)
} warnings consoleParsers: [[parserName: 'Maven'], [parserName: 'JavaDoc'], [parserName: 'Java']]
} }
stage("Checkstyle ") {
agent { node { label 'linux' } }
options { timeout(time: 30, unit: 'MINUTES') }
steps {
mavenBuild("jdk11", "install -DskipTests", "maven3", true)
mavenBuild("jdk11", "install -f build-resources", "maven3", true)
mavenBuild("jdk11", "install checkstyle:check -DskipTests", "maven3", true)
recordIssues(
enabledForFailure: true, aggregatingResults: true,
tools: [java(), checkStyle(pattern: '**/target/checkstyle-result.xml', reportEncoding: 'UTF-8')]
)
} }
} }
} }
@ -88,28 +76,24 @@ pipeline {
} }
} }
def slackNotif() { def slackNotif() {
script { script {
try try {
{ if (env.BRANCH_NAME == 'jetty-10.0.x' || env.BRANCH_NAME == 'jetty-9.4.x') {
if ( env.BRANCH_NAME == 'jetty-10.0.x' || env.BRANCH_NAME == 'jetty-9.4.x' ) //BUILD_USER = currentBuild.rawBuild.getCause(Cause.UserIdCause).getUserId()
{ // by ${BUILD_USER}
//BUILD_USER = currentBuild.rawBuild.getCause(Cause.UserIdCause).getUserId() COLOR_MAP = ['SUCCESS': 'good', 'FAILURE': 'danger', 'UNSTABLE': 'danger', 'ABORTED': 'danger']
// by ${BUILD_USER} slackSend channel: '#jenkins',
COLOR_MAP = ['SUCCESS': 'good', 'FAILURE': 'danger', 'UNSTABLE': 'danger', 'ABORTED': 'danger'] color: COLOR_MAP[currentBuild.currentResult],
slackSend channel: '#jenkins', message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} - ${env.BUILD_URL}"
color: COLOR_MAP[currentBuild.currentResult],
message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} - ${env.BUILD_URL}"
}
} catch (Exception e) {
e.printStackTrace()
echo "skip failure slack notification: " + e.getMessage()
} }
} catch (Exception e) {
e.printStackTrace()
echo "skip failure slack notification: " + e.getMessage()
} }
}
} }
/** /**
* To other developers, if you are using this method above, please use the following syntax. * To other developers, if you are using this method above, please use the following syntax.
* *
@ -125,15 +109,16 @@ def mavenBuild(jdk, cmdline, mvnName, junitPublishDisabled) {
def mavenOpts = '-Xms1g -Xmx4g -Djava.awt.headless=true' def mavenOpts = '-Xms1g -Xmx4g -Djava.awt.headless=true'
withMaven( withMaven(
maven: mvnName, maven: mvnName,
jdk: "$jdk", jdk: "$jdk",
publisherStrategy: 'EXPLICIT', publisherStrategy: 'EXPLICIT',
options: [junitPublisher(disabled: junitPublishDisabled),mavenLinkerPublisher(disabled: false),pipelineGraphPublisher(disabled: false)], options: [junitPublisher(disabled: junitPublishDisabled), mavenLinkerPublisher(disabled: false), pipelineGraphPublisher(disabled: false)],
mavenOpts: mavenOpts, mavenOpts: mavenOpts,
mavenLocalRepo: localRepo) { mavenLocalRepo: localRepo) {
// Some common Maven command line + provided command line // Some common Maven command line + provided command line
sh "mvn -Pci -V -B -T3 -e -fae -Dmaven.test.failure.ignore=true -Djetty.testtracker.log=true $cmdline -Dunix.socket.tmp=" + env.JENKINS_HOME sh "mvn -Pci -V -B -e -fae -Dmaven.test.failure.ignore=true -Djetty.testtracker.log=true $cmdline -Dunix.socket.tmp=" + env.JENKINS_HOME
} }
} }
// vim: et:ts=2:sw=2:ft=groovy // vim: et:ts=2:sw=2:ft=groovy

View File

@ -2,6 +2,6 @@
Jan Bartel <janb@mortbay.com> AED5 EE6C 45D0 FE8D 5D1B 164F 27DE D4BF 6216 DB8F Jan Bartel <janb@mortbay.com> AED5 EE6C 45D0 FE8D 5D1B 164F 27DE D4BF 6216 DB8F
Jesse McConnell <jesse.mcconnell@gmail.com> 2A68 4B57 436A 81FA 8706 B53C 61C3 351A 438A 3B7D Jesse McConnell <jesse.mcconnell@gmail.com> 2A68 4B57 436A 81FA 8706 B53C 61C3 351A 438A 3B7D
Joakim Erdfelt <joakim.erdfelt@gmail.com> 5989 BAF7 6217 B843 D66B E55B 2D0E 1FB8 FE4B 68B4 Joakim Erdfelt <joakim.erdfelt@gmail.com> 5989 BAF7 6217 B843 D66B E55B 2D0E 1FB8 FE4B 68B4
Joakim Erdfelt <joakim@apache.org> B59B 67FD 7904 9843 67F9 3180 0818 D9D6 8FB6 7BAC Joakim Erdfelt <joakime@apache.org> B59B 67FD 7904 9843 67F9 3180 0818 D9D6 8FB6 7BAC
Joakim Erdfelt <joakim@erdfelt.com> BFBB 21C2 46D7 7768 3628 7A48 A04E 0C74 ABB3 5FEA Joakim Erdfelt <joakim@erdfelt.com> BFBB 21C2 46D7 7768 3628 7A48 A04E 0C74 ABB3 5FEA
Simone Bordet <simone.bordet@gmail.com> 8B09 6546 B1A8 F026 56B1 5D3B 1677 D141 BCF3 584D Simone Bordet <simone.bordet@gmail.com> 8B09 6546 B1A8 F026 56B1 5D3B 1677 D141 BCF3 584D

413
LICENSE
View File

@ -1,215 +1,290 @@
This program and the accompanying materials are made available under the This program and the accompanying materials are made available under
terms of the Eclipse Public License 1.0 which is available at the terms of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/org/documents/epl-1.0/EPL-1.0.txt https://www.eclipse.org/legal/epl-2.0
or the Apache Software License 2.0 which is available at This Source Code may also be made available under the following
Secondary Licenses when the conditions for such availability set
forth in the Eclipse Public License, v. 2.0 are satisfied:
the Apache License v2.0 which is available at
https://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Eclipse Public License - v 2.0
Eclipse Public License - v 1.0 THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION
THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
1. DEFINITIONS 1. DEFINITIONS
"Contribution" means: "Contribution" means:
a) in the case of the initial Contributor, the initial code and documentation a) in the case of the initial Contributor, the initial content
distributed under this Agreement, and Distributed under this Agreement, and
b) in the case of each subsequent Contributor:
i) changes to the Program, and
ii) additions to the Program;
where such changes and/or additions to the Program originate from and are b) in the case of each subsequent Contributor:
distributed by that particular Contributor. A Contribution 'originates' i) changes to the Program, and
from a Contributor if it was added to the Program by such Contributor ii) additions to the Program;
itself or anyone acting on such Contributor's behalf. Contributions do not where such changes and/or additions to the Program originate from
include additions to the Program which: (i) are separate modules of and are Distributed by that particular Contributor. A Contribution
software distributed in conjunction with the Program under their own "originates" from a Contributor if it was added to the Program by
license agreement, and (ii) are not derivative works of the Program. such Contributor itself or anyone acting on such Contributor's behalf.
Contributions do not include changes or additions to the Program that
are not Modified Works.
"Contributor" means any person or entity that distributes the Program. "Contributor" means any person or entity that Distributes the Program.
"Licensed Patents" mean patent claims licensable by a Contributor which are "Licensed Patents" mean patent claims licensable by a Contributor which
necessarily infringed by the use or sale of its Contribution alone or when are necessarily infringed by the use or sale of its Contribution alone
combined with the Program. or when combined with the Program.
"Program" means the Contributions distributed in accordance with this "Program" means the Contributions Distributed in accordance with this
Agreement. Agreement.
"Recipient" means anyone who receives the Program under this Agreement, "Recipient" means anyone who receives the Program under this Agreement
including all Contributors. or any Secondary License (as applicable), including Contributors.
"Derivative Works" shall mean any work, whether in Source Code or other
form, that is based on (or derived from) the Program and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship.
"Modified Works" shall mean any work in Source Code or other form that
results from an addition to, deletion from, or modification of the
contents of the Program, including, for purposes of clarity any new file
in Source Code form that contains any contents of the Program. Modified
Works shall not include works that contain only declarations,
interfaces, types, classes, structures, or files of the Program solely
in each case in order to link to, bind by name, or subclass the Program
or Modified Works thereof.
"Distribute" means the acts of a) distributing or b) making available
in any manner that enables the transfer of a copy.
"Source Code" means the form of a Program preferred for making
modifications, including but not limited to software source code,
documentation source, and configuration files.
"Secondary License" means either the GNU General Public License,
Version 2.0, or any later versions of that license, including any
exceptions or additional permissions as identified by the initial
Contributor.
2. GRANT OF RIGHTS 2. GRANT OF RIGHTS
a) Subject to the terms of this Agreement, each Contributor hereby grants
Recipient a non-exclusive, worldwide, royalty-free copyright license to a) Subject to the terms of this Agreement, each Contributor hereby
reproduce, prepare derivative works of, publicly display, publicly grants Recipient a non-exclusive, worldwide, royalty-free copyright
perform, distribute and sublicense the Contribution of such Contributor, license to reproduce, prepare Derivative Works of, publicly display,
if any, and such derivative works, in source code and object code form. publicly perform, Distribute and sublicense the Contribution of such
b) Subject to the terms of this Agreement, each Contributor hereby grants Contributor, if any, and such Derivative Works.
Recipient a non-exclusive, worldwide, royalty-free patent license under
Licensed Patents to make, use, sell, offer to sell, import and otherwise b) Subject to the terms of this Agreement, each Contributor hereby
transfer the Contribution of such Contributor, if any, in source code and grants Recipient a non-exclusive, worldwide, royalty-free patent
object code form. This patent license shall apply to the combination of license under Licensed Patents to make, use, sell, offer to sell,
the Contribution and the Program if, at the time the Contribution is import and otherwise transfer the Contribution of such Contributor,
added by the Contributor, such addition of the Contribution causes such if any, in Source Code or other form. This patent license shall
combination to be covered by the Licensed Patents. The patent license apply to the combination of the Contribution and the Program if, at
shall not apply to any other combinations which include the Contribution. the time the Contribution is added by the Contributor, such addition
No hardware per se is licensed hereunder. of the Contribution causes such combination to be covered by the
c) Recipient understands that although each Contributor grants the licenses Licensed Patents. The patent license shall not apply to any other
to its Contributions set forth herein, no assurances are provided by any combinations which include the Contribution. No hardware per se is
Contributor that the Program does not infringe the patent or other licensed hereunder.
intellectual property rights of any other entity. Each Contributor
disclaims any liability to Recipient for claims brought by any other c) Recipient understands that although each Contributor grants the
entity based on infringement of intellectual property rights or licenses to its Contributions set forth herein, no assurances are
otherwise. As a condition to exercising the rights and licenses granted provided by any Contributor that the Program does not infringe the
hereunder, each Recipient hereby assumes sole responsibility to secure patent or other intellectual property rights of any other entity.
any other intellectual property rights needed, if any. For example, if a Each Contributor disclaims any liability to Recipient for claims
third party patent license is required to allow Recipient to distribute brought by any other entity based on infringement of intellectual
the Program, it is Recipient's responsibility to acquire that license property rights or otherwise. As a condition to exercising the
before distributing the Program. rights and licenses granted hereunder, each Recipient hereby
d) Each Contributor represents that to its knowledge it has sufficient assumes sole responsibility to secure any other intellectual
copyright rights in its Contribution, if any, to grant the copyright property rights needed, if any. For example, if a third party
license set forth in this Agreement. patent license is required to allow Recipient to Distribute the
Program, it is Recipient's responsibility to acquire that license
before distributing the Program.
d) Each Contributor represents that to its knowledge it has
sufficient copyright rights in its Contribution, if any, to grant
the copyright license set forth in this Agreement.
e) Notwithstanding the terms of any Secondary License, no
Contributor makes additional grants to any Recipient (other than
those set forth in this Agreement) as a result of such Recipient's
receipt of the Program under the terms of a Secondary License
(if permitted under the terms of Section 3).
3. REQUIREMENTS 3. REQUIREMENTS
A Contributor may choose to distribute the Program in object code form under 3.1 If a Contributor Distributes the Program in any form, then:
its own license agreement, provided that:
a) it complies with the terms and conditions of this Agreement; and a) the Program must also be made available as Source Code, in
b) its license agreement: accordance with section 3.2, and the Contributor must accompany
i) effectively disclaims on behalf of all Contributors all warranties the Program with a statement that the Source Code for the Program
and conditions, express and implied, including warranties or is available under this Agreement, and informs Recipients how to
conditions of title and non-infringement, and implied warranties or obtain it in a reasonable manner on or through a medium customarily
conditions of merchantability and fitness for a particular purpose; used for software exchange; and
ii) effectively excludes on behalf of all Contributors all liability for
damages, including direct, indirect, special, incidental and
consequential damages, such as lost profits;
iii) states that any provisions which differ from this Agreement are
offered by that Contributor alone and not by any other party; and
iv) states that source code for the Program is available from such
Contributor, and informs licensees how to obtain it in a reasonable
manner on or through a medium customarily used for software exchange.
When the Program is made available in source code form: b) the Contributor may Distribute the Program under a license
different than this Agreement, provided that such license:
i) effectively disclaims on behalf of all other Contributors all
warranties and conditions, express and implied, including
warranties or conditions of title and non-infringement, and
implied warranties or conditions of merchantability and fitness
for a particular purpose;
a) it must be made available under this Agreement; and ii) effectively excludes on behalf of all other Contributors all
b) a copy of this Agreement must be included with each copy of the Program. liability for damages, including direct, indirect, special,
Contributors may not remove or alter any copyright notices contained incidental and consequential damages, such as lost profits;
within the Program.
Each Contributor must identify itself as the originator of its Contribution, iii) does not attempt to limit or alter the recipients' rights
if in the Source Code under section 3.2; and
any, in a manner that reasonably allows subsequent Recipients to identify the
originator of the Contribution. iv) requires any subsequent distribution of the Program by any
party to be under a license that satisfies the requirements
of this section 3.
3.2 When the Program is Distributed as Source Code:
a) it must be made available under this Agreement, or if the
Program (i) is combined with other material in a separate file or
files made available under a Secondary License, and (ii) the initial
Contributor attached to the Source Code the notice described in
Exhibit A of this Agreement, then the Program may be made available
under the terms of such Secondary Licenses, and
b) a copy of this Agreement must be included with each copy of
the Program.
3.3 Contributors may not remove or alter any copyright, patent,
trademark, attribution notices, disclaimers of warranty, or limitations
of liability ("notices") contained within the Program from any copy of
the Program which they Distribute, provided that Contributors may add
their own appropriate notices.
4. COMMERCIAL DISTRIBUTION 4. COMMERCIAL DISTRIBUTION
Commercial distributors of software may accept certain responsibilities with Commercial distributors of software may accept certain responsibilities
respect to end users, business partners and the like. While this license is with respect to end users, business partners and the like. While this
intended to facilitate the commercial use of the Program, the Contributor who license is intended to facilitate the commercial use of the Program,
includes the Program in a commercial product offering should do so in a manner the Contributor who includes the Program in a commercial product
which does not create potential liability for other Contributors. Therefore, offering should do so in a manner which does not create potential
if a Contributor includes the Program in a commercial product offering, such liability for other Contributors. Therefore, if a Contributor includes
Contributor ("Commercial Contributor") hereby agrees to defend and indemnify the Program in a commercial product offering, such Contributor
every other Contributor ("Indemnified Contributor") against any losses, ("Commercial Contributor") hereby agrees to defend and indemnify every
damages and costs (collectively "Losses") arising from claims, lawsuits and other Contributor ("Indemnified Contributor") against any losses,
other legal actions brought by a third party against the Indemnified damages and costs (collectively "Losses") arising from claims, lawsuits
Contributor to the extent caused by the acts or omissions of such Commercial and other legal actions brought by a third party against the Indemnified
Contributor in connection with its distribution of the Program in a commercial Contributor to the extent caused by the acts or omissions of such
product offering. The obligations in this section do not apply to any claims Commercial Contributor in connection with its distribution of the Program
or Losses relating to any actual or alleged intellectual property in a commercial product offering. The obligations in this section do not
infringement. In order to qualify, an Indemnified Contributor must: apply to any claims or Losses relating to any actual or alleged
a) promptly notify the Commercial Contributor in writing of such claim, and intellectual property infringement. In order to qualify, an Indemnified
b) allow the Commercial Contributor to control, and cooperate with the Contributor must: a) promptly notify the Commercial Contributor in
Commercial Contributor in, the defense and any related settlement writing of such claim, and b) allow the Commercial Contributor to control,
negotiations. The Indemnified Contributor may participate in any such claim at and cooperate with the Commercial Contributor in, the defense and any
its own expense. related settlement negotiations. The Indemnified Contributor may
participate in any such claim at its own expense.
For example, a Contributor might include the Program in a commercial product For example, a Contributor might include the Program in a commercial
offering, Product X. That Contributor is then a Commercial Contributor. If product offering, Product X. That Contributor is then a Commercial
that Commercial Contributor then makes performance claims, or offers Contributor. If that Commercial Contributor then makes performance
warranties related to Product X, those performance claims and warranties are claims, or offers warranties related to Product X, those performance
such Commercial Contributor's responsibility alone. Under this section, the claims and warranties are such Commercial Contributor's responsibility
Commercial Contributor would have to defend claims against the other alone. Under this section, the Commercial Contributor would have to
Contributors related to those performance claims and warranties, and if a defend claims against the other Contributors related to those performance
court requires any other Contributor to pay any damages as a result, the claims and warranties, and if a court requires any other Contributor to
Commercial Contributor must pay those damages. pay any damages as a result, the Commercial Contributor must pay
those damages.
5. NO WARRANTY 5. NO WARRANTY
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS"
IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR
NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF
Recipient is solely responsible for determining the appropriateness of using TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
and distributing the Program and assumes all risks associated with its PURPOSE. Each Recipient is solely responsible for determining the
exercise of rights under this Agreement , including but not limited to the appropriateness of using and distributing the Program and assumes all
risks and costs of program errors, compliance with applicable laws, damage to risks associated with its exercise of rights under this Agreement,
or loss of data, programs or equipment, and unavailability or interruption of including but not limited to the risks and costs of program errors,
operations. compliance with applicable laws, damage to or loss of data, programs
or equipment, and unavailability or interruption of operations.
6. DISCLAIMER OF LIABILITY 6. DISCLAIMER OF LIABILITY
EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT
CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
OF SUCH DAMAGES. POSSIBILITY OF SUCH DAMAGES.
7. GENERAL 7. GENERAL
If any provision of this Agreement is invalid or unenforceable under If any provision of this Agreement is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of the applicable law, it shall not affect the validity or enforceability of
remainder of the terms of this Agreement, and without further action by the the remainder of the terms of this Agreement, and without further
parties hereto, such provision shall be reformed to the minimum extent action by the parties hereto, such provision shall be reformed to the
necessary to make such provision valid and enforceable. minimum extent necessary to make such provision valid and enforceable.
If Recipient institutes patent litigation against any entity (including a If Recipient institutes patent litigation against any entity
cross-claim or counterclaim in a lawsuit) alleging that the Program itself (including a cross-claim or counterclaim in a lawsuit) alleging that the
(excluding combinations of the Program with other software or hardware) Program itself (excluding combinations of the Program with other software
infringes such Recipient's patent(s), then such Recipient's rights granted or hardware) infringes such Recipient's patent(s), then such Recipient's
under Section 2(b) shall terminate as of the date such litigation is filed. rights granted under Section 2(b) shall terminate as of the date such
litigation is filed.
All Recipient's rights under this Agreement shall terminate if it fails to All Recipient's rights under this Agreement shall terminate if it
comply with any of the material terms or conditions of this Agreement and does fails to comply with any of the material terms or conditions of this
not cure such failure in a reasonable period of time after becoming aware of Agreement and does not cure such failure in a reasonable period of
such noncompliance. If all Recipient's rights under this Agreement terminate, time after becoming aware of such noncompliance. If all Recipient's
Recipient agrees to cease use and distribution of the Program as soon as rights under this Agreement terminate, Recipient agrees to cease use
reasonably practicable. However, Recipient's obligations under this Agreement and distribution of the Program as soon as reasonably practicable.
and any licenses granted by Recipient relating to the Program shall continue However, Recipient's obligations under this Agreement and any licenses
and survive. granted by Recipient relating to the Program shall continue and survive.
Everyone is permitted to copy and distribute copies of this Agreement, but in Everyone is permitted to copy and distribute copies of this Agreement,
order to avoid inconsistency the Agreement is copyrighted and may only be but in order to avoid inconsistency the Agreement is copyrighted and
modified in the following manner. The Agreement Steward reserves the right to may only be modified in the following manner. The Agreement Steward
publish new versions (including revisions) of this Agreement from time to reserves the right to publish new versions (including revisions) of
time. No one other than the Agreement Steward has the right to modify this this Agreement from time to time. No one other than the Agreement
Agreement. The Eclipse Foundation is the initial Agreement Steward. The Steward has the right to modify this Agreement. The Eclipse Foundation
Eclipse Foundation may assign the responsibility to serve as the Agreement is the initial Agreement Steward. The Eclipse Foundation may assign the
Steward to a suitable separate entity. Each new version of the Agreement will responsibility to serve as the Agreement Steward to a suitable separate
be given a distinguishing version number. The Program (including entity. Each new version of the Agreement will be given a distinguishing
Contributions) may always be distributed subject to the version of the version number. The Program (including Contributions) may always be
Agreement under which it was received. In addition, after a new version of the Distributed subject to the version of the Agreement under which it was
Agreement is published, Contributor may elect to distribute the Program received. In addition, after a new version of the Agreement is published,
(including its Contributions) under the new version. Except as expressly Contributor may elect to Distribute the Program (including its
stated in Sections 2(a) and 2(b) above, Recipient receives no rights or Contributions) under the new version.
licenses to the intellectual property of any Contributor under this Agreement,
whether expressly, by implication, estoppel or otherwise. All rights in the
Program not expressly granted under this Agreement are reserved.
This Agreement is governed by the laws of the State of New York and the Except as expressly stated in Sections 2(a) and 2(b) above, Recipient
intellectual property laws of the United States of America. No party to this receives no rights or licenses to the intellectual property of any
Agreement will bring a legal action under this Agreement more than one year Contributor under this Agreement, whether expressly, by implication,
after the cause of action arose. Each party waives its rights to a jury trial in estoppel or otherwise. All rights in the Program not expressly granted
any resulting litigation. under this Agreement are reserved. Nothing in this Agreement is intended
to be enforceable by any entity that is not a Contributor or Recipient.
No third-party beneficiary rights are created under this Agreement.
Exhibit A - Form of Secondary Licenses Notice
"This Source Code may also be made available under the following
Secondary Licenses when the conditions for such availability set forth
in the Eclipse Public License, v. 2.0 are satisfied: {name license(s),
version(s), and exceptions or additional permissions here}."
Simply including a copy of this Agreement, including this Exhibit A
is not sufficient to license the Source Code under Secondary Licenses.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to
look for such a notice.
You may add additional accurate notices of copyright ownership.
Apache License Apache License
@ -413,3 +488,7 @@ any resulting litigation.
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
SPDX-License-Identifier: EPL-2.0
SPDX-License-Identifier: Apache-2.0

View File

@ -1,41 +1,42 @@
============================================================== Notices for Eclipse Jetty
Jetty Web Container =========================
Copyright 1995-2019 Mort Bay Consulting Pty Ltd. This content is produced and maintained by the Eclipse Jetty project.
==============================================================
The Jetty Web Container is Copyright Mort Bay Consulting Pty Ltd Project home: https://www.eclipse.org/jetty/
unless otherwise noted.
Jetty is dual licensed under both Trademarks
----------
Eclipse Jetty, and Jetty are trademarks of the Eclipse Foundation.
* The Apache 2.0 License Copyright
http://www.apache.org/licenses/LICENSE-2.0.html ---------
All contributions are the property of the respective authors or of
entities to which copyright has been assigned by the authors (eg. employer).
and Declared Project Licenses
-------------------------
This artifacts of this project are made available under the terms of:
* The Eclipse Public 1.0 License * the Eclipse Public License v2.0
http://www.eclipse.org/legal/epl-v10.html https://www.eclipse.org/legal/epl-2.0
SPDX-License-Identifier: EPL-2.0
Jetty may be distributed under either license. or
------ * the Apache License, Version 2.0
Eclipse https://www.apache.org/licenses/LICENSE-2.0
SPDX-License-Identifier: Apache-2.0
The following artifacts are EPL. The following dependencies are EPL.
* org.eclipse.jetty.orbit:org.eclipse.jdt.core * org.eclipse.jetty.orbit:org.eclipse.jdt.core
The following artifacts are EPL and ASL2. The following dependencies are EPL and ASL2.
* org.eclipse.jetty.orbit:javax.security.auth.message * org.eclipse.jetty.orbit:javax.security.auth.message
The following dependencies are EPL and CDDL 1.0.
The following artifacts are EPL and CDDL 1.0.
* org.eclipse.jetty.orbit:javax.mail.glassfish * org.eclipse.jetty.orbit:javax.mail.glassfish
The following dependencies are CDDL + GPLv2 with classpath exception.
------
Oracle
The following artifacts are CDDL + GPLv2 with classpath exception.
https://glassfish.dev.java.net/nonav/public/CDDL+GPL.html https://glassfish.dev.java.net/nonav/public/CDDL+GPL.html
* javax.servlet:javax.servlet-api * javax.servlet:javax.servlet-api
@ -43,72 +44,46 @@ https://glassfish.dev.java.net/nonav/public/CDDL+GPL.html
* javax.transaction:javax.transaction-api * javax.transaction:javax.transaction-api
* javax.websocket:javax.websocket-api * javax.websocket:javax.websocket-api
------ The following dependencies are licensed by the OW2 Foundation according to the
Oracle OpenJDK
If ALPN is used to negotiate HTTP/2 connections, then the following
artifacts may be included in the distribution or downloaded when ALPN
module is selected.
* java.sun.security.ssl
These artifacts replace/modify OpenJDK classes. The modififications
are hosted at github and both modified and original are under GPL v2 with
classpath exceptions.
http://openjdk.java.net/legal/gplv2+ce.html
------
OW2
The following artifacts are licensed by the OW2 Foundation according to the
terms of http://asm.ow2.org/license.html terms of http://asm.ow2.org/license.html
org.ow2.asm:asm-commons * org.ow2.asm:asm-commons
org.ow2.asm:asm * org.ow2.asm:asm
The following dependencies are ASL2 licensed.
------ * org.apache.taglibs:taglibs-standard-spec
Apache * org.apache.taglibs:taglibs-standard-impl
The following artifacts are ASL2 licensed. The following dependencies are ASL2 licensed. Based on selected classes from
org.apache.taglibs:taglibs-standard-spec
org.apache.taglibs:taglibs-standard-impl
------
MortBay
The following artifacts are ASL2 licensed. Based on selected classes from
following Apache Tomcat jars, all ASL2 licensed. following Apache Tomcat jars, all ASL2 licensed.
org.mortbay.jasper:apache-jsp * org.mortbay.jasper:apache-jsp
org.apache.tomcat:tomcat-jasper * org.apache.tomcat:tomcat-jasper
org.apache.tomcat:tomcat-juli * org.apache.tomcat:tomcat-juli
org.apache.tomcat:tomcat-jsp-api * org.apache.tomcat:tomcat-jsp-api
org.apache.tomcat:tomcat-el-api * org.apache.tomcat:tomcat-el-api
org.apache.tomcat:tomcat-jasper-el * org.apache.tomcat:tomcat-jasper-el
org.apache.tomcat:tomcat-api * org.apache.tomcat:tomcat-api
org.apache.tomcat:tomcat-util-scan * org.apache.tomcat:tomcat-util-scan
org.apache.tomcat:tomcat-util * org.apache.tomcat:tomcat-util
* org.mortbay.jasper:apache-el
org.mortbay.jasper:apache-el * org.apache.tomcat:tomcat-jasper-el
org.apache.tomcat:tomcat-jasper-el * org.apache.tomcat:tomcat-el-api
org.apache.tomcat:tomcat-el-api
------
Mortbay
The following artifacts are CDDL + GPLv2 with classpath exception. The following artifacts are CDDL + GPLv2 with classpath exception.
https://glassfish.dev.java.net/nonav/public/CDDL+GPL.html https://glassfish.dev.java.net/nonav/public/CDDL+GPL.html
org.eclipse.jetty.toolchain:jetty-servlet-api * org.eclipse.jetty.toolchain:jetty-schemas
------ Cryptography
Assorted ------------
Content may contain encryption software. The country in which you are currently
may have restrictions on the import, possession, and use, and/or re-export to
another country, of encryption software. BEFORE using any encryption software,
please check the country's laws, regulations and policies concerning the import,
possession, or use, and re-export of encryption software, to see if this is
permitted.
The UnixCrypt.java code implements the one way cryptography used by The UnixCrypt.java code implements the one way cryptography used by
Unix systems for simple password protection. Copyright 1996 Aki Yoshida, Unix systems for simple password protection. Copyright 1996 Aki Yoshida,

View File

@ -23,7 +23,7 @@ Documentation
Project documentation is available on the Jetty Eclipse website. Project documentation is available on the Jetty Eclipse website.
- [http://www.eclipse.org/jetty/documentation](http://www.eclipse.org/jetty/documentation) - [https://www.eclipse.org/jetty/documentation](https://www.eclipse.org/jetty/documentation)
Building Building
======== ========
@ -40,9 +40,9 @@ The first build may take a longer than expected as Maven downloads all the depen
The build tests do a lot of stress testing, and on some machines it is necessary to set the file descriptor limit to greater than 2048 for the tests to all pass successfully. The build tests do a lot of stress testing, and on some machines it is necessary to set the file descriptor limit to greater than 2048 for the tests to all pass successfully.
It is possible to bypass tests by building with `mvn -Dmaven.test.skip=true install` but note that this will not produce some of the test jars that are leveraged in other places in the build. It is possible to bypass tests by building with `mvn clean install -DskipTests`.
Professional Services Professional Services
--------------------- ---------------------
Expert advice and production support are available through [Webtide.com](http://webtide.com). Expert advice and production support are available through [Webtide.com](https://webtide.com).

View File

@ -1,5 +1,168 @@
jetty-10.0.0-SNAPSHOT jetty-10.0.0-SNAPSHOT
jetty-10.0.0.alpha1 - 26 November 2019
+ 97 Permanent UnavailableException thrown during servlet request handling
should cause servlet destroy
+ 137 Support OAuth
+ 155 No way to set keystore for JSR 356 websocket clients, needed for SSL
client authentication
+ 250 Implement HTTP CONNECT for HTTP/2
+ 995 UrlEncoded.encodeString should skip more characters
+ 1036 Allow easy configuration of Scheduler-Threads and name them more
appropriate
+ 1485 Add systemd service file
+ 1743 Refactor jetty maven plugin goals to be more orthogonal
+ 2266 Jetty maven plugin reload is triggered each time the
`scanIntervalSeconds` pass
+ 2340 Remove raw ServletHandler usage examples from documentation
+ 2429 Review HttpClient backpressure semantic
+ 2578 Use addEventListener(EventListener listener)
+ 2709 current default for headerCacheSize is not large enough for many
requests
+ 2815 hpack fields are opaque octets
+ 3040 Allow RFC6265 Cookies to include optional SameSite attribute.
+ 3083 The ini-template for jetty.console-capture.dir does not match the
default value
+ 3106 Websocket connection stats and request stats
+ 3558 Error notifications can be received after a successful websocket close
+ 3601 HTTP2 stall on reset streams
+ 3705 Review ClientUpgradeRequest exception handling
+ 3734 websocket suspend when input closed
+ 3747 Make Jetty Demo work with JPMS
+ 3787 Jetty client sometimes returns EOFException instead of
SSLHandshakeException on certificate errors.
+ 3804 Weld/CDI XML backwards compat?
+ 3806 Error Page handling Async race with ProxyServlet
+ 3822 trustAll will not work on some servers
+ 3829 Avoid sending empty trailer frames for http/2 responses
+ 3840 Byte-range request performance problems with large files
+ 3856 Different behaviour with maxFormContentSize=0 if Content-Length header
is present/missing
+ 3863 Enforce use of SNI
+ 3869 Update to ASM 7.2 for jdk 13
+ 3872 Review exposure of JavaxWebSocketServletContainerInitializer
+ 3876 WebSocketPartialListener is only called for initial frames, not for
continuation frames
+ 3884 @WebSocket without @OnWebSocketMessage handler fails when receiving a
continuation frame
+ 3888 BufferUtil.toBuffer(Resource resource,boolean direct) does not like
large (4G+) Resources
+ 3906 Fix for #3840 breaks Path encapsulation in PathResource
+ 3913 Clustered HttpSession IllegalStateException: Invalid for read
+ 3929 Deadlock between new HTTP2Connection() and Server.stop()
+ 3936 Race condition when modifying session + sendRedirect()
+ 3940 Double initialization of Log
+ 3951 Consider adding demand API to HTTP/2
+ 3952 Server configuration for direct/heap ByteBuffers
+ 3956 Remove and warn on use of illegal HTTP/2 response headers
+ 3957 CustomRequestLog bad usage of MethodHandles.lookup()
+ 3960 Fix HttpConfiguration copy constructor
+ 3964 Improve efficiency of listeners
+ 3968 WebSocket sporadic ReadPendingException using suspend/resume
+ 3969 X-Forwarded-Port header customization isn't possible
+ 3978 HTTP/2 fixes for robustly handling abnormal traffic and resource
exhaustion
+ 3983 JarFileResource incorrectly lists the contents of directories with
spaces
+ 3985 Improve lenient Cookie parsing
+ 3989 Inform custom ManagedSelector of dead selector via optional
onFailedSelect()
+ 4000 Add SameFileAliasChecker to help with FileSystem static file access
normalization on Mac and Windows
+ 4003 Quickstart broken in jetty-10
+ 4007 Getting NullPointerException while trying to run jetty start.run on
Windows
+ 4009 ServletContextHandler setSecurityHandler broke handler chain
+ 4020 Revert WebSocket ExtensionFactory change to interface
+ 4022 Servlet which is added by ServletRegistration can't be started
+ 4025 Provide more write-through behaviours for DefaultSessionCache
+ 4027 Ensure AbstractSessionDataStore cannot be used unless it is started
+ 4033 Ignore bad percent encodings in paths during
URIUtil.equalsIgnoreEncodings()
+ 4047 Gracefully stopped Jetty not flushing all response data
+ 4048 Multiple values in X-Forwarded-Port throw NumberFormatException
+ 4057 NullPointerException in o.e.j.h.HttpFields
+ 4058 Review Locker
+ 4064 java.lang.NullPointerException initializing embedded servlet
+ 4075 Do not fail on servlet-mapping with url-pattern /On*
+ 4076 Restarting quickstarted webapp throws IllegalStateException:
ServletContainerInitializersStarter already exists
+ 4082 Debug logging causes NullPointerException in client
+ 4084 Use of HttpConfiguration.setBlockingTimeout(long) in jetty.xml produces
warning on jetty-home startup
+ 4096 Thread in ReservedThreadExecutor does not exit when stopped
+ 4104 Frames are sent through ExtensionStack even if WebSocket Session is
closed
+ 4105 QueuedThreadPool increased thread usage and no idle thread decay
+ 4113 HttpClient fails with JDK 13 and TLS 1.3
+ 4115 Drop HTTP/2 pseudo headers
+ 4121 QueuedThreadPool should support ThreadFactory behaviors
+ 4122 QueuedThreadPool should reset thread interrupted on failed run
+ 4124 Run websocket autobahn tests with jetty and javax apis instead of just
with core.
+ 4128 OpenIdCredentials can't decode JWT ID token
+ 4132 Should be possible to use OIDC without metadata
+ 4138 OpenID module should use HttpClient instead of HttpURLConnection
+ 4141 ClassCastException with non-async Servlet + async Filter +
HttpServletRequestWrapper
+ 4142 Configurable HTTP/2 RateControl
+ 4144 Naked cast to Request should be avoided
+ 4150 Module org.eclipse.jetty.alpn.client not found, required by
org.eclipse.jetty.proxy
+ 4152 WebSocket autoFragment does not fragment based on maxFrameSize
+ 4156 IllegalStateException when forwarding to jsp with new session
+ 4161 Regression: EofException: request lifecycle violation
+ 4170 Client-side alias selection based on SSLEngine
+ 4173 NullPointerException warning in log from WebInfConfiguration after
upgrade
+ 4174 ConcurrentModificationException when stopping jetty:run-war
+ 4176 Should not set header if sendError has been called
+ 4177 Configure HTTP proxy with SslContextFactory
+ 4179 Improve HttpChannel$SendCallback references for GC
+ 4183 Jetty considers bootstrap injected class to be a "server class"
+ 4188 Spin in HttpOutput.close
+ 4190 Jetty hangs after thread blocked in SharedBlockingCallback.block()
called by HttpOutput.close
+ 4191 Increase GzipHandler minGzipSize default value
+ 4193 InetAccessHandler - new includeConnectors/excludeConnectors not quite
correct anymore
+ 4201 Throw SSLHandshakeException in case of TLS handshake failures
+ 4203 Some Transfer-Encoding and Content-Length combinations do not result in
expected 400 Bad Request
+ 4204 Transfer-Encoding behavior does not follow RFC7230
+ 4208 304 response with Content-Length fails, not conform to RFC7230
+ 4209 Unused TLS connection is not closed in Java 11
+ 4217 SslConnection.DecryptedEnpoint.flush eternal busy loop
+ 4222 Major/Minor Version wrong (jetty 10 is servlet 4)
+ 4227 First authorization request produced by OIDC module fails due to
inclusion of sessionid
+ 4236 clean up redirect code calculation for OpenIdAuthenticator
+ 4237 simplify openid module configuration
+ 4240 CGI form post results in 500 response if no character encoding
+ 4243 ErrorHandler produces invalid json error response
+ 4247 Cookie security attributes are going to mandated by Google Chrome
+ 4248 Websocket client UpgradeListener never reports success
+ 4251 Http 2.0 clients cannot upgrade protocol
+ 4258 RateControl should be per-connection
+ 4264 Spring Boot BasicErrorController no longer invoked
+ 4265 HttpChannel SEND_ERROR should use ErrorHandler.doError()
+ 4277 Reading streamed gzipped body never terminates
+ 4279 Regression: ResponseWriter#close blocks indefinitely
+ 4282 Review HttpParser handling in case of no content
+ 4283 Wrong package for OpenJDK8ClientALPNProcessor
+ 4284 Possible NullPointerException in Main.java when stopped from command
line
+ 4287 Move getUriLastPathSegment(URI uri) to URIUtil
+ 4296 Unable to create WebSocket connect if the query string of the URL has %
symbol.
+ 4301 Demand beforeContent is not forwarded
+ 4305 Jetty server ALPN shall alert fatal no_application_protocol if no
client application protocol is supported
+ 4325 Deprecate SniX509ExtendedKeyManager constructor without
SslContextFactory$Server
+ 4334 Better test ErrorHandler changes
+ 4342 OpenID module cannot create HttpClient in Jetty 10
jetty-10.0.0-alpha0 - 11 July 2019 jetty-10.0.0-alpha0 - 11 July 2019
+ 113 Add support for NCSA Extended Log File Format + 113 Add support for NCSA Extended Log File Format
+ 114 Bring back overlay deployer + 114 Bring back overlay deployer
@ -7,7 +170,7 @@ jetty-10.0.0-alpha0 - 11 July 2019
+ 207 Support javax.websocket version 1.1 + 207 Support javax.websocket version 1.1
+ 215 Add Conscrypt for native ALPN/TLS/SSL + 215 Add Conscrypt for native ALPN/TLS/SSL
+ 300 Implement Deflater / Inflater Object Pool + 300 Implement Deflater / Inflater Object Pool
+ 482 [jetty-osgi] The CCL while parsing the xml files should be set to a + 482 jetty-osgi] The CCL while parsing the xml files should be set to a
combination of Jetty and Bundle-Classloader combination of Jetty and Bundle-Classloader
+ 592 Support no-value Host header in HttpParser + 592 Support no-value Host header in HttpParser
+ 632 JMX tests rely on fixed port + 632 JMX tests rely on fixed port
@ -77,8 +240,9 @@ jetty-10.0.0-alpha0 - 11 July 2019
+ 2061 WebSocket hangs in blockingWrite + 2061 WebSocket hangs in blockingWrite
+ 2075 Deprecating MultiException + 2075 Deprecating MultiException
+ 2095 Remove FastCGI multiplexing + 2095 Remove FastCGI multiplexing
+ 2103 Server should open connectors early in start sequence + 2103 Server should open connectors early in start sequence
+ 2108 Update licence headers and plugin for 2018 + 2108 Update licence headers and plugin for 2018
+ 2140 Infinispan and hazelcast changes to scavenge zombie expired sessions
+ 2172 Support javax.websocket 1.1 + 2172 Support javax.websocket 1.1
+ 2175 Refactor WebSocket close handling + 2175 Refactor WebSocket close handling
+ 2191 JPMS Support + 2191 JPMS Support
@ -91,13 +255,12 @@ jetty-10.0.0-alpha0 - 11 July 2019
+ 2978 Add module-info.java to relevant Jetty modules + 2978 Add module-info.java to relevant Jetty modules
+ 2983 Jetty 10 Configuration abstraction + 2983 Jetty 10 Configuration abstraction
+ 2985 Jetty 10 Configuration replacement algorithm incorrect + 2985 Jetty 10 Configuration replacement algorithm incorrect
+ 2996 ContextHandler.setDefaultContextPath() not implemented for quickstart. + 2996 ContextHandler.setDefaultContextPath() not implemented for quickstart
+ 3009 Update Jetty 10 to use non-LEGACY Compliance Modes + 3009 Update Jetty 10 to use non-LEGACY Compliance Modes
+ 3010 Move old MultiPart parsing implementation to jetty-http + 3010 Move old MultiPart parsing implementation to jetty-http
+ 3011 Move HttpCompliance to HttpConfiguration + 3011 Move HttpCompliance to HttpConfiguration
+ 3012 Refactor HttpCompliance and HttpComplianceSection to be friendlier to + 3012 Refactor HttpCompliance and HttpComplianceSection to be friendlier to
customization customization
+ 3106 Websocket connection stats and request stats
+ 3129 javax-websocket-common pom.xml is wrong + 3129 javax-websocket-common pom.xml is wrong
+ 3139 NPE on + 3139 NPE on
WebSocketServerContainerInitializer.configureContext(ServletContextHandler) WebSocketServerContainerInitializer.configureContext(ServletContextHandler)
@ -114,7 +277,7 @@ jetty-10.0.0-alpha0 - 11 July 2019
+ 3197 Use jetty specific websocket API jar + 3197 Use jetty specific websocket API jar
+ 3213 MetaInfConfigurationTest tests disabled in jetty-10.0.x + 3213 MetaInfConfigurationTest tests disabled in jetty-10.0.x
+ 3216 Autobahn WebSocketServer failures in jetty 10 + 3216 Autobahn WebSocketServer failures in jetty 10
+ 3225 Response.sendError should not set reason. + 3225 Response.sendError should not set reason
+ 3246 javax-websocket-tests exception stacktraces + 3246 javax-websocket-tests exception stacktraces
+ 3249 Update to apache jasper 9.0.14 for jetty-10 + 3249 Update to apache jasper 9.0.14 for jetty-10
+ 3274 OSGi versions of java.base classes in + 3274 OSGi versions of java.base classes in
@ -122,7 +285,7 @@ jetty-10.0.0-alpha0 - 11 July 2019
+ 3279 WebSocket write may hang forever + 3279 WebSocket write may hang forever
+ 3288 Correct websocket artifactIds on jetty-10.0.x + 3288 Correct websocket artifactIds on jetty-10.0.x
+ 3290 async websocket onOpen, onError and onClose in 10.0.x + 3290 async websocket onOpen, onError and onClose in 10.0.x
+ 3298 Review jetty-10 websocket CompletableFuture usage. + 3298 Review jetty-10 websocket CompletableFuture usage
+ 3303 Update to jakarta ee javax artifacts for jetty-10 + 3303 Update to jakarta ee javax artifacts for jetty-10
+ 3308 Remove deprecated methods from sessions + 3308 Remove deprecated methods from sessions
+ 3320 Review Jetty 10 module-info.java + 3320 Review Jetty 10 module-info.java
@ -156,7 +319,7 @@ jetty-10.0.0-alpha0 - 11 July 2019
+ 3648 javax.websocket client container incorrectly creates Server + 3648 javax.websocket client container incorrectly creates Server
SslContextFactory SslContextFactory
+ 3661 JettyWebSocketServerContainer exposes websocket common classes + 3661 JettyWebSocketServerContainer exposes websocket common classes
+ 3666 WebSocket - Handling sent 1009 close frame. + 3666 WebSocket - Handling sent 1009 close frame
+ 3696 Unwrap JavaxWebSocketClientContainer.connectToServer() exceptions + 3696 Unwrap JavaxWebSocketClientContainer.connectToServer() exceptions
+ 3698 Missing WebSocket ServerContainer after server restart + 3698 Missing WebSocket ServerContainer after server restart
+ 3700 stackoverflow in WebAppClassLoaderUrlStreamTest + 3700 stackoverflow in WebAppClassLoaderUrlStreamTest
@ -191,8 +354,256 @@ jetty-10.0.0-alpha0 - 11 July 2019
+ 3840 Byte-range request performance problems with large files + 3840 Byte-range request performance problems with large files
+ 3849 ClosedChannelException from jetty-test-webapp javax websocket chat + 3849 ClosedChannelException from jetty-test-webapp javax websocket chat
example example
+ 467246 null
+ jetty-10 null jetty-9.4.27.v20200227 - 27 February 2020
+ 3247 Generate jetty-maven-plugin website
+ 4247 Cookie security attributes are going to mandated by Google Chrome
+ 4360 Upgrade to Apache Jasper 8.5.49
+ 4475 WebSocket JSR356 implementation not honoring javadoc of MessageHandler
on Whole<Reader>
+ 4495 Review ReservedThreadExecutor's concurrency model
+ 4504 X-Forwarded-Server header overwrites X-Forwarded-Host
+ 4520 Jetty jdbc session manager causing exceptions for violating primary key
in inserting session in the table
+ 4529 ErrorHandler showing servlet info, can not be disabled unless
overriding most of its functionality
+ 4533 Reinstate hard close in dispatcher
+ 4537 High CPU on Jetty Websocket thread
+ 4541 Jetty server always allocates maximum response header size
+ 4550 XmlConfiguration constructor selection based on number of arguments
+ 4567 Jetty logging supporting Throwable as last argument
+ 4573 Order dependency of X-Forwarded-Host and X-Forwarded-Port
+ 4575 Stopping ReservedThreadExecutor may hang
+ 4577 request getPathInfo returns null
+ 4594 ServletContextListeners added to destroyServletContextListeners in
ContextHandler::startContext() are not removed by
ContextHandler::removeEventListener()
+ 4606 DateCache.formatNow(long now) does not honor the passed in long
+ 4612 ReservedThreadExecutor hangs when the last reserved thread idles out
jetty-9.4.26.v20200117 - 17 January 2020
+ 2620 Exception from user endpoint onClose results in unclosed
WebSocketSession
+ 4383 Errors deleting multipart tmp files java.lang.NullPointerException
under heavy load
+ 4444 TLS Connection Timeout Intermittently
+ 4461 IllegalStateException in HttpOutput with Jersey
jetty-9.4.25.v20191220 - 20 December 2019
+ 995 UrlEncoded.encodeString should skip more characters
+ 2195 Add parameter expansion to start.jar --exec parameters
+ 3512 File descriptor is not released after zip file uploaded via
jetty-client
+ 3730 WebSocketClient constructor cleanup (and deprecations)
+ 4269 ResponseWriter should not throw RuntimeIOExceptions
+ 4323 QOS Filter does not handle IllegalStateException and never releases
passes
+ 4329 rewrite prevents URL session tracking.
+ 4331 Improve handling of HttpOutput.close() for pending writes
+ 4350 Deprecated MultiPartInputStreamParser still used in jetty-server
(MultiPartsUtilParser) but OSGi ExportPackage suppressed
+ 4351 Servlet.service called before Servlet.init is finished when servlet is
lazily initialized
+ 4363 jetty-maven-plugin no longer processes supplied context.xml-file.
+ 4366 HTTP client uses SOCKS4 proxy hostname for SSL hostname verification
+ 4374 Jetty client: Response.AsyncContentListener.onContent is not called
+ 4376 Async Content Complete bug results in
org.eclipse.jetty.io.EofException: Async closed
+ 4385 Limit new UnsupportedOperationException to direct base class
SslContextFactory usage
+ 4392 Suppress logging of QuietException in HttpChannelState.asyncError()
+ 4402 NPE in JettyRunWarExplodedMojo
+ 4411 Jetty server spins on incomplete request due to delayed dispatch
until content
+ 4415 GzipHandler invalid input zip size on large
(over 2,147,483,647 bytes) request body content
+ 4421 HttpClient support for PROXY protocol
+ 4427 Retried HttpClient Requests can result in duplicates cookies
jetty-9.4.24.v20191120 - 20 November 2019
+ 3083 The ini-template for jetty.console-capture.dir does not match the
default value
+ 4128 OpenIdCredetials can't decode JWT ID token
+ 4334 Better test ErrorHandler changes
jetty-9.4.23.v20191118 - 18 November 2019
+ 1485 Add systemd service file
+ 2266 Jetty maven plugin reload is triggered each time the
`scanIntervalSeconds` pass
+ 2340 Remove raw ServletHandler usage examples from documentation
+ 2709 current default for headerCacheSize is not large enough for many
requests
+ 3863 Enforce use of SNI
+ 3869 Update to ASM 7.2 for jdk 13
+ 4033 Ignore bad percent encodings in paths during
URIUtil.equalsIgnoreEncodings()
+ 4138 OpenID module should use HttpClient instead of HttpURLConnection
+ 4156 IllegalStateException when forwarding to jsp with new session
+ 4161 Regression: EofException: request lifecycle violation
+ 4173 NullPointerException warning in log from WebInfConfiguration after
upgrade
+ 4217 SslConnection.DecryptedEnpoint.flush eternal busy loop
+ 4236 clean up redirect code calculation for OpenIdAuthenticator
+ 4237 simplify openid module configuration
+ 4240 CGI form post results in 500 response if no character encoding
+ 4243 ErrorHandler produces invalid json error response
+ 4247 Cookie security attributes are going to mandated by Google Chrome
+ 4248 Websocket client UpgradeListener never reports success
+ 4251 Http 2.0 clients cannot upgrade protocol
+ 4258 RateControl should be per-connection
+ 4264 Spring Boot BasicErrorController no longer invoked
+ 4265 HttpChannel SEND_ERROR should use ErrorHandler.doError()
+ 4277 Reading streamed gzipped body never terminates
+ 4279 Regression: ResponseWriter#close blocks indefinitely
+ 4282 Review HttpParser handling in case of no content
+ 4283 Wrong package for OpenJDK8ClientALPNProcessor
+ 4284 Possible NullPointerException in Main.java when stopped from command
line
+ 4287 Move getUriLastPathSegment(URI uri) to URIUtil
+ 4296 Unable to create WebSocket connect if the query string of the URL has %
symbol.
+ 4301 Demand beforeContent is not forwarded
+ 4305 Jetty server ALPN shall alert fatal no_application_protocol if no
client application protocol is supported
+ 4325 Deprecate SniX509ExtendedKeyManager constructor without
SslContextFactory$Server
jetty-9.4.22.v20191022 - 22 October 2019
+ 2429 HttpClient backpressure improved
+ 3558 Error notifications can be received after a successful websocket
+ 3787 Jetty client sometimes returns EOFException instead of
SSLHandshakeException on certificate errors.
+ 3913 Clustered HttpSession IllegalStateException: Invalid for read
+ 3989 Inform custom ManagedSelector of dead selector via optional
onFailedSelect()
+ 4096 Thread in ReservedThreadExecutor does not exit when stopped
+ 4104 Frames are sent through ExtensionStack even if WebSocket Session is
closed
+ 4105 QueuedThreadPool increased thread usage and no idle thread decay
+ 4115 Drop HTTP/2 pseudo headers
+ 4121 QueuedThreadPool should support ThreadFactory behaviors
+ 4122 QueuedThreadPool should reset thread interrupted on failed run
+ 4128 OpenIdCredetials can't decode JWT ID token
+ 4132 Should be possible to use OIDC without metadata
+ 4141 ClassCastException with non-async Servlet + async Filter +
HttpServletRequestWrapper
+ 4142 Configurable HTTP/2 RateControl
+ 4144 Naked cast to Request should be avoided
+ 4156 IllegalStateException when forwarding to jsp with new session
+ 4158 Behaviour change in session handling in 9.4.21.v20190926
+ 4170 Client-side alias selection based on SSLEngine
+ 4174 ConcurrentModificationException when stopping jetty:run-war
+ 4176 Should not set header if sendError has been called
+ 4177 Configure HTTP proxy with SslContextFactory
+ 4179 Improve HttpChannel$SendCallback references for GC
+ 4183 Jetty considers bootstrap injected class to be a "server class"
+ 4188 Spin in HttpOutput.close
+ 4190 Jetty hangs after thread blocked in SharedBlockingCallback.block()
called by HttpOutput.close
+ 4191 Increase GzipHandler minGzipSize default size
+ 4193 InetAccessHandler - new includeConnectors/excludeConnectors not quite
correct anymore
+ 4201 Throw SSLHandshakeException in case of TLS handshake failures
+ 4203 Some Transfer-Encoding and Content-Length combinations do not result in
expected 400 Bad Request
+ 4204 Transfer-Encoding behavior does not follow RFC7230
+ 4208 Regression in Jetty 9.4.21: 304 response with Content-Length fails
+ 4209 Unused TLS connection is not closed in Java 11
+ 4217 SslConnection.DecryptedEnpoint.flush eternal busy loop
+ 4227 First authorization request produced by OIDC module fails due to
inclusion of sessionid
jetty-9.4.21.v20190926 - 26 September 2019
+ 97 Permanent UnavailableException thrown during servlet request handling
should cause servlet destroy
+ 137 Support OAuth
+ 155 No way to set keystore for JSR 356 websocket clients, needed for SSL
client authentication
+ 1036 Allow easy configuration of Scheduler-Threads and name them more
appropriate
+ 2815 HPack fields are opaque octets
+ 3040 Allow RFC6265 Cookies to include optional SameSite attribute
+ 3106 WebSocket connection stats and request stats
+ 3734 WebSocket suspend when input closed
+ 3747 Make Jetty Demo work with JPMS
+ 3806 Error Page handling Async race with ProxyServlet
+ 3913 Clustered HttpSession IllegalStateException: Invalid for read
+ 3936 Race condition when modifying session + sendRedirect()
+ 3956 Remove and warn on use of illegal HTTP/2 response headers
+ 3964 Improve efficiency of listeners
+ 3968 WebSocket sporadic ReadPendingException using suspend/resume
+ 3978 HTTP/2 fixes for robustly handling abnormal traffic and resource
exhaustion
+ 3983 JarFileResource incorrectly lists the contents of directories with
spaces
+ 3985 Improve lenient Cookie parsing
+ 3989 Inform custom ManagedSelector of dead selector via optional
onFailedSelect()
+ 4000 Add SameFileAliasChecker to help with FileSystem static file access
normalization on Mac and Windows
+ 4007 NullPointerException while trying to run jetty start.run on Windows
+ 4009 ServletContextHandler setSecurityHandler broke handler chain
+ 4020 Revert WebSocket ExtensionFactory change to interface
+ 4022 Servlet which is added by ServletRegistration can't be started
+ 4025 Provide more write-through behaviours for DefaultSessionCache
+ 4027 Ensure AbstractSessionDataStore cannot be used unless it is started
+ 4033 Ignore bad percent encodings in paths during
URIUtil.equalsIgnoreEncodings()
+ 4047 Gracefully stopped Jetty not flushing all response data
+ 4048 Multiple values in X-Forwarded-Port throw NumberFormatException
+ 4057 NullPointerException in o.e.j.h.HttpFields
+ 4064 NullPointerException initializing embedded servlet
+ 4075 Do not fail on servlet-mapping with url-pattern /On*
+ 4082 NullPointerExceptoin while Debug logging in client
+ 4084 Use of HttpConfiguration.setBlockingTimeout(long) in jetty.xml produces
warning on jetty-home startup
+ 4105 Cleanup of Idle thread count in QueuedThreadPool
+ 4113 HttpClient fails with JDK 13 and TLS 1.3
jetty-9.4.20.v20190813 - 13 August 2019
+ 300 Implement Deflater / Inflater Object Pool
+ 2061 WebSocket hangs in blockingWrite
+ 3601 HTTP2 stall on reset streams
+ 3648 javax.websocket client container incorrectly creates Server
SslContextFactory
+ 3698 Missing WebSocket ServerContainer after server restart
+ 3700 stackoverflow in WebAppClassLoaderUrlStreamTest
+ 3708 Swap various java.lang.String replace() methods for better performant
ones
+ 3731 Add testing of CDI behaviors
+ 3736 NPE from WebAppClassLoader during CDI
+ 3746 ClassCastException in WriteFlusher.java - IdleState cannot be cast to
FailedState
+ 3749 Memory leak while processing AsyncListener annotations
+ 3755 ServerWithAnnotations doesn't do anything
+ 3758 Avoid sending empty trailer frames for http/2 requests
+ 3782 X-Forwarded-Port overrides X-Forwarded-For
+ 3786 ALPN support for Java 14
+ 3798 ClasspathPattern match method throws NPE. URI can be null
+ 3799 Programmatically added listeners from
ServletContextListener.contextInitialzed() are not called
+ 3804 Weld/CDI XML backwards compat
+ 3805 XmlConfiguration odd behavior for numbers
+ 3806 The error page handler didn't process correctly in proxy
+ 3815 PropertyFileLoginModule adds user principle as a role
+ 3822 trustAll will not work on some servers
+ 3829 Avoid sending empty trailer frames for http/2 responses
+ 3835 WebSocketSession are not being stopped properly
+ 3840 Byte-range request performance problems with large files
+ 3856 Different behaviour with maxFormContentSize=0 if Content-Length header
is present/missing
+ 3876 WebSocketPartialListener is only called for initial frames, not for
continuation frames
+ 3884 @WebSocket without @OnWebSocketMessage handler fails when receiving a
continuation frame
+ 3888 BufferUtil.toBuffer(Resource resource,boolean direct) does not like
large (4G+) Resources
+ 3906 Fix for #3840 breaks Path encapsulation in PathResource
+ 3929 Deadlock between new HTTP2Connection() and Server.stop()
+ 3940 Double initialization of Log
+ 3957 CustomRequestLog bad usage of MethodHandles.lookup()
+ 3960 Fix HttpConfiguration copy constructor
+ 3969 X-Forwarded-Port header customization isn't possible
jetty-9.4.19.v20190610 - 10 June 2019 jetty-9.4.19.v20190610 - 10 June 2019
+ 2909 Remove B64Code + 2909 Remove B64Code
@ -246,6 +657,7 @@ jetty-9.4.18.v20190429 - 29 April 2019
+ 3609 Fix infinispan start module dependencies + 3609 Fix infinispan start module dependencies
jetty-9.4.17.v20190418 - 18 April 2019 jetty-9.4.17.v20190418 - 18 April 2019
+ 2140 Infinispan and hazelcast changes to scavenge zombie expired sessions
+ 3464 Split SslContextFactory into Client and Server + 3464 Split SslContextFactory into Client and Server
+ 3549 Directory Listing on Windows reveals Resource Base path + 3549 Directory Listing on Windows reveals Resource Base path
+ 3555 DefaultHandler Reveals Base Resource Path of each Context + 3555 DefaultHandler Reveals Base Resource Path of each Context
@ -323,6 +735,11 @@ jetty-9.4.15.v20190215 - 15 February 2019
+ 3350 Do not expect to be able to connect to https URLs with the HttpClient + 3350 Do not expect to be able to connect to https URLs with the HttpClient
created from a parameterless constructor created from a parameterless constructor
jetty-9.3.28.v20191105 - 05 November 2019
+ 3989 Inform custom ManagedSelector of dead selector via optional
onFailedSelect()
+ 4217 SslConnection.DecryptedEnpoint.flush eternal busy loop
jetty-9.3.27.v20190418 - 18 April 2019 jetty-9.3.27.v20190418 - 18 April 2019
+ 3549 Directory Listing on Windows reveals Resource Base path + 3549 Directory Listing on Windows reveals Resource Base path
+ 3555 DefaultHandler Reveals Base Resource Path of each Context + 3555 DefaultHandler Reveals Base Resource Path of each Context
@ -335,6 +752,9 @@ jetty-9.3.26.v20190403 - 03 April 2019
ForwardedRequestCustomizer ForwardedRequestCustomizer
+ 3319 Allow reverse sort for directory listed files + 3319 Allow reverse sort for directory listed files
jetty-9.2.29.v20191105 - 05 November 2019
+ 4217 SslConnection.DecryptedEnpoint.flush eternal busy loop
jetty-9.2.28.v20190418 - 18 April 2019 jetty-9.2.28.v20190418 - 18 April 2019
+ 3549 Directory Listing on Windows reveals Resource Base path + 3549 Directory Listing on Windows reveals Resource Base path
+ 3555 DefaultHandler Reveals Base Resource Path of each Context + 3555 DefaultHandler Reveals Base Resource Path of each Context

View File

@ -183,12 +183,12 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty.websocket</groupId> <groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server</artifactId> <artifactId>websocket-javax-server</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty.websocket</groupId> <groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-client</artifactId> <artifactId>websocket-jetty-client</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<!-- http/2 support --> <!-- http/2 support -->

View File

@ -113,7 +113,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty.websocket</groupId> <groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server</artifactId> <artifactId>websocket-javax-server</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -63,6 +63,10 @@
</build> </build>
<dependencies> <dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId> <artifactId>jetty-util</artifactId>
@ -101,6 +105,11 @@
<version>${project.version}</version> <version>${project.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty.toolchain</groupId> <groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId> <artifactId>jetty-test-helper</artifactId>

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
import javax.servlet.ServletContainerInitializer; import javax.servlet.ServletContainerInitializer;
@ -31,6 +31,7 @@ module org.eclipse.jetty.apache.jsp
requires jetty.servlet.api; requires jetty.servlet.api;
requires org.eclipse.jetty.util; requires org.eclipse.jetty.util;
requires org.mortbay.apache.jasper; requires org.mortbay.apache.jasper;
requires org.slf4j;
provides Log with JuliLog; provides Log with JuliLog;
provides ServletContainerInitializer with JettyJasperInitializer; provides ServletContainerInitializer with JettyJasperInitializer;

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.apache.jsp; package org.eclipse.jetty.apache.jsp;
@ -54,27 +54,18 @@ public class JettyJasperInitializer extends JasperInitializer
super(context, namespaceAware, validation, blockExternal); super(context, namespaceAware, validation, blockExternal);
} }
/**
* @see org.apache.jasper.servlet.TldScanner#scan()
*/
@Override @Override
public void scan() throws IOException, SAXException public void scan() throws IOException, SAXException
{ {
return; //do nothing return; //do nothing
} }
/**
* @see org.apache.jasper.servlet.TldScanner#getListeners()
*/
@Override @Override
public List<String> getListeners() public List<String> getListeners()
{ {
return Collections.emptyList(); return Collections.emptyList();
} }
/**
* @see org.apache.jasper.servlet.TldScanner#scanJars()
*/
@Override @Override
public void scanJars() public void scanJars()
{ {

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.apache.jsp; package org.eclipse.jetty.apache.jsp;
@ -48,9 +48,6 @@ public class JettyTldPreScanned extends TldPreScanned
_jettyPreScannedURLs = preScannedTlds; _jettyPreScannedURLs = preScannedTlds;
} }
/**
* @see org.apache.jasper.servlet.TldPreScanned#scanJars()
*/
@Override @Override
public void scanJars() public void scanJars()
{ {

View File

@ -1,23 +1,25 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.apache.jsp; package org.eclipse.jetty.apache.jsp;
import org.slf4j.LoggerFactory;
public class JuliLog implements org.apache.juli.logging.Log public class JuliLog implements org.apache.juli.logging.Log
{ {
public static org.apache.juli.logging.Log getInstance(String name) public static org.apache.juli.logging.Log getInstance(String name)
@ -25,19 +27,16 @@ public class JuliLog implements org.apache.juli.logging.Log
return new JuliLog(name); return new JuliLog(name);
} }
private final org.eclipse.jetty.util.log.Logger _logger; private final org.slf4j.Logger _logger;
private final org.eclipse.jetty.util.log.StdErrLog _stdErrLog;
public JuliLog() public JuliLog()
{ {
_logger = org.eclipse.jetty.util.log.Log.getRootLogger(); _logger = LoggerFactory.getLogger("");
_stdErrLog = (_logger instanceof org.eclipse.jetty.util.log.StdErrLog) ? (org.eclipse.jetty.util.log.StdErrLog)_logger : null;
} }
public JuliLog(String name) public JuliLog(String name)
{ {
_logger = org.eclipse.jetty.util.log.Log.getLogger(name); _logger = LoggerFactory.getLogger(name);
_stdErrLog = (_logger instanceof org.eclipse.jetty.util.log.StdErrLog) ? (org.eclipse.jetty.util.log.StdErrLog)_logger : null;
} }
@Override @Override
@ -49,31 +48,31 @@ public class JuliLog implements org.apache.juli.logging.Log
@Override @Override
public boolean isErrorEnabled() public boolean isErrorEnabled()
{ {
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_WARN; return _logger.isErrorEnabled();
} }
@Override @Override
public boolean isFatalEnabled() public boolean isFatalEnabled()
{ {
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_WARN; return _logger.isErrorEnabled();
} }
@Override @Override
public boolean isInfoEnabled() public boolean isInfoEnabled()
{ {
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_INFO; return _logger.isInfoEnabled();
} }
@Override @Override
public boolean isTraceEnabled() public boolean isTraceEnabled()
{ {
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_DEBUG; return _logger.isTraceEnabled();
} }
@Override @Override
public boolean isWarnEnabled() public boolean isWarnEnabled()
{ {
return _stdErrLog == null ? true : _stdErrLog.getLevel() <= org.eclipse.jetty.util.log.StdErrLog.LEVEL_WARN; return _logger.isWarnEnabled();
} }
@Override @Override

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.jsp; package org.eclipse.jetty.jsp;

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.jsp; package org.eclipse.jetty.jsp;
@ -62,9 +62,6 @@ public class TestJettyJspServlet
super(); super();
} }
/**
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override @Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
{ {

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.jsp; package org.eclipse.jetty.jsp;

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.jsp; package org.eclipse.jetty.jsp;

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.jstl; package org.eclipse.jetty.jstl;

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.jstl; package org.eclipse.jetty.jstl;

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.jstl; package org.eclipse.jetty.jstl;

View File

@ -1,3 +1,3 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog # Jetty Logging using jetty-slf4j-impl
# org.eclipse.jetty.LEVEL=INFO # org.eclipse.jetty.LEVEL=INFO
# org.eclipse.jetty.util.LEVEL=DEBUG # org.eclipse.jetty.util.LEVEL=DEBUG

View File

@ -347,7 +347,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="false"/> <setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="128"/> <setting id="org.eclipse.jdt.core.formatter.lineSplit" value="512"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
</profile> </profile>

View File

@ -1,4 +1,4 @@
<code_scheme name="Jetty-StyleChecked" version="173"> <code_scheme name="Jetty" version="173">
<option name="AUTODETECT_INDENTS" value="false" /> <option name="AUTODETECT_INDENTS" value="false" />
<option name="LINE_SEPARATOR" value="&#xA;" /> <option name="LINE_SEPARATOR" value="&#xA;" />
<option name="RIGHT_MARGIN" value="128" /> <option name="RIGHT_MARGIN" value="128" />
@ -9,7 +9,6 @@
<option name="HTML_ATTRIBUTE_WRAP" value="0" /> <option name="HTML_ATTRIBUTE_WRAP" value="0" />
</HTMLCodeStyleSettings> </HTMLCodeStyleSettings>
<JavaCodeStyleSettings> <JavaCodeStyleSettings>
<option name="FIELD_NAME_PREFIX" value="_" />
<option name="USE_EXTERNAL_ANNOTATIONS" value="true" /> <option name="USE_EXTERNAL_ANNOTATIONS" value="true" />
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" /> <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
<option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" /> <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="999" />
@ -67,9 +66,11 @@
<option name="WHILE_ON_NEW_LINE" value="true" /> <option name="WHILE_ON_NEW_LINE" value="true" />
<option name="CATCH_ON_NEW_LINE" value="true" /> <option name="CATCH_ON_NEW_LINE" value="true" />
<option name="FINALLY_ON_NEW_LINE" value="true" /> <option name="FINALLY_ON_NEW_LINE" value="true" />
<option name="ALIGN_MULTILINE_PARAMETERS" value="true" />
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" /> <option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
<option name="SPACE_AFTER_TYPE_CAST" value="false" /> <option name="SPACE_AFTER_TYPE_CAST" value="false" />
<option name="RESOURCE_LIST_WRAP" value="2" /> <option name="RESOURCE_LIST_WRAP" value="2" />
<option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="false" />
<option name="KEEP_SIMPLE_LAMBDAS_IN_ONE_LINE" value="true" /> <option name="KEEP_SIMPLE_LAMBDAS_IN_ONE_LINE" value="true" />
<option name="KEEP_SIMPLE_CLASSES_IN_ONE_LINE" value="true" /> <option name="KEEP_SIMPLE_CLASSES_IN_ONE_LINE" value="true" />
<option name="ARRAY_INITIALIZER_WRAP" value="1" /> <option name="ARRAY_INITIALIZER_WRAP" value="1" />
@ -80,6 +81,7 @@
<option name="FOR_BRACE_FORCE" value="3" /> <option name="FOR_BRACE_FORCE" value="3" />
<indentOptions> <indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" /> <option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="USE_RELATIVE_INDENTS" value="false" />
</indentOptions> </indentOptions>
<arrangement> <arrangement>
<rules> <rules>

View File

@ -4,18 +4,70 @@
<artifactId>build-resources</artifactId> <artifactId>build-resources</artifactId>
<version>10.0.0-SNAPSHOT</version> <version>10.0.0-SNAPSHOT</version>
<name>Jetty :: Build Resources</name> <name>Jetty :: Build Resources</name>
<packaging>jar</packaging>
<build> <build>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
</resource>
<resource>
<directory>${project.basedir}/../</directory>
<includes>
<include>LICENSE</include>
<include>NOTICE.txt</include>
</includes>
<targetPath>META-INF</targetPath>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<!-- No point building javadoc for this project -->
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-remote-resources-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>create-shared-resources</id>
<phase>process-resources</phase>
<goals>
<goal>bundle</goal>
</goals>
<configuration>
<resourcesDirectory>${project.build.outputDirectory}</resourcesDirectory>
<includes>
<include>META-INF/LICENSE</include>
<include>META-INF/NOTICE.txt</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId> <artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version> <version>2.8.2</version>
<configuration> <configuration>
<!-- we would prefer not deploy it but we need as it's not discovered as part of reactor
as it's a dependency of a plugin
<skip>true</skip> <skip>true</skip>
-->
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

View File

@ -14,12 +14,6 @@
<property name="fileExtensions" value="java"/> <property name="fileExtensions" value="java"/>
<!-- reference to suppressions filter for both eclipse and intellij checkstyle plugins -->
<module name="SuppressionFilter">
<property name="file" value="${checkstyle.suppressions.file}"/>
<property name="optional" value="true"/>
</module>
<!-- Excludes all 'module-info.java' files --> <!-- Excludes all 'module-info.java' files -->
<!-- See https://checkstyle.org/config_filefilters.html --> <!-- See https://checkstyle.org/config_filefilters.html -->
<module name="BeforeExecutionExclusionFileFilter"> <module name="BeforeExecutionExclusionFileFilter">
@ -33,22 +27,16 @@
</module> </module>
<module name="TreeWalker"> <module name="TreeWalker">
<!--
Eclipse Jetty Specific.
===========================================================================================
-->
<module name="SuppressionCommentFilter"> <module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="@checkstyle-disable-check : ([\w\|]+)"/> <property name="offCommentFormat" value="@checkstyle-disable-check : ([\w\|]+)"/>
<property name="onCommentFormat" value="@checkstyle-enable-check : ([\w\|]+)"/> <property name="onCommentFormat" value="@checkstyle-enable-check : ([\w\|]+)"/>
<property name="checkFormat" value="$1"/> <property name="checkFormat" value="$1"/>
</module> </module>
<!-- Check abbreviations(consecutive capital letters) length in identifier name --> <!--
<module name="AbbreviationAsWordInName"> Eclipse Jetty Specific.
<property name="ignoreFinal" value="true"/> ===========================================================================================
<property name="allowedAbbreviations" value="ALPN, ASCII, AWT, CRLDP, CRLF, FCGI, GZIP, HTTP, HTTPS, ID, IP, ISO8859, JAAS, JDBC, JMXRMI, JNDI, JPMS, JSON, JSTL, LDAP, PROXY, RFC, SPNEGO, URI, URL, UTF8, XML"/> -->
</module>
<!-- Location of Annotations --> <!-- Location of Annotations -->
<module name="AnnotationLocation"> <module name="AnnotationLocation">
@ -90,7 +78,7 @@
<!-- Indentation Rules --> <!-- Indentation Rules -->
<module name="Indentation"> <module name="Indentation">
<property name="throwsIndent" value="0"/> <property name="arrayInitIndent" value="8"/>
</module> </module>
<!-- Interface Type Parameter Name --> <!-- Interface Type Parameter Name -->
@ -215,7 +203,9 @@
</module> </module>
<!-- all switch statements should have "default" label declared --> <!-- all switch statements should have "default" label declared -->
<!-- Disabled: Is super noisy
<module name="MissingSwitchDefault"/> <module name="MissingSwitchDefault"/>
-->
<!-- prevent line wrapping of import / package statements --> <!-- prevent line wrapping of import / package statements -->
<module name="NoLineWrap"/> <module name="NoLineWrap"/>
@ -226,9 +216,6 @@
<!-- Filename and Classname match --> <!-- Filename and Classname match -->
<module name="OuterTypeFilename"/> <module name="OuterTypeFilename"/>
<!-- Checks that overload methods are grouped together -->
<module name="OverloadMethodsDeclarationOrder"/>
<!-- <!--
Checks based on the Java Language Specification recommendations. Checks based on the Java Language Specification recommendations.
https://docs.oracle.com/javase/specs/jls/se8/html/index.html https://docs.oracle.com/javase/specs/jls/se8/html/index.html
@ -284,8 +271,5 @@
<module name="UpperEll"/> <module name="UpperEll"/>
<!-- TODO: look for float / double version of above --> <!-- TODO: look for float / double version of above -->
<!-- Checks the distance between declaration of variable and its first usage -->
<module name="VariableDeclarationUsageDistance"/>
</module> </module>
</module> </module>

View File

@ -1,35 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<!-- all /target/ directories -->
<suppress checks=".*" files="[/\\]target[/\\]generated-sources[/\\]" />
<!-- General JUnit Test Cases -->
<suppress checks="AbbreviationAsWordInNameCheck"
files="[/\\]src[/\\]test[/\\]java[/\\]" />
<suppress checks="AvoidEscapedUnicodeCharactersCheck"
files="[/\\]src[/\\]test[/\\]java[/\\]" />
<suppress checks="LocalVariableNameCheck"
files="[/\\]src[/\\]test[/\\]java[/\\]" />
<suppress checks="MethodNameCheck"
files="[/\\]src[/\\]test[/\\]java[/\\]" />
<suppress checks="TypeNameCheck"
files="[/\\]src[/\\]test[/\\]java[/\\]" />
<!-- jetty-jmh specific -->
<suppress checks="AbbreviationAsWordInNameCheck"
files="[/\\]jetty-jmh[/\\]src[/\\]main[/\\]java[/\\]" />
<suppress checks="AvoidEscapedUnicodeCharactersCheck"
files="[/\\]jetty-jmh[/\\]src[/\\]main[/\\]java[/\\]" />
<suppress checks="LocalVariableNameCheck"
files="[/\\]jetty-jmh[/\\]src[/\\]main[/\\]java[/\\]" />
<suppress checks="MethodNameCheck"
files="[/\\]jetty-jmh[/\\]src[/\\]main[/\\]java[/\\]" />
<suppress checks="TypeNameCheck"
files="[/\\]jetty-jmh[/\\]src[/\\]main[/\\]java[/\\]" />
</suppressions>

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.example.asyncrest; package org.eclipse.jetty.example.asyncrest;
@ -101,19 +101,19 @@ public class AbstractRestServlet extends HttpServlet
} }
} }
protected String generateThumbs(Queue<Map<String, String>> results) protected String generateThumbs(Queue<Map<String, Object>> results)
{ {
StringBuilder thumbs = new StringBuilder(); StringBuilder thumbs = new StringBuilder();
for (Map<String, String> m : results) for (Map<String, Object> m : results)
{ {
if (!m.containsKey("GalleryURL")) if (!m.containsKey("GalleryURL"))
continue; continue;
thumbs.append("<a href=\"" + m.get("ViewItemURLForNaturalSearch") + "\">"); thumbs.append("<a href=\"").append(m.get("ViewItemURLForNaturalSearch")).append("\">");
thumbs.append("<img class='thumb' border='1px' height='25px'" + thumbs.append("<img class='thumb' border='1px' height='25px' src='")
" src='" + m.get("GalleryURL") + "'" + .append(m.get("GalleryURL")).append("'")
" title='" + m.get("Title") + "'" + .append(" title='").append(m.get("Title")).append("'")
"/>"); .append("/>");
thumbs.append("</a>&nbsp;"); thumbs.append("</a>&nbsp;");
} }
return thumbs.toString(); return thumbs.toString();

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.example.asyncrest; package org.eclipse.jetty.example.asyncrest;
@ -77,17 +77,18 @@ public class AsyncRestServlet extends AbstractRestServlet
@Override @Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{ {
Long start = System.nanoTime(); long start = System.nanoTime();
// Do we have results yet? // Do we have results yet?
Queue<Map<String, String>> results = (Queue<Map<String, String>>)request.getAttribute(RESULTS_ATTR); @SuppressWarnings("unchecked")
Queue<Map<String, Object>> results = (Queue<Map<String, Object>>)request.getAttribute(RESULTS_ATTR);
// If no results, this must be the first dispatch, so send the REST request(s) // If no results, this must be the first dispatch, so send the REST request(s)
if (results == null) if (results == null)
{ {
// define results data structures // define results data structures
final Queue<Map<String, String>> resultsQueue = new ConcurrentLinkedQueue<>(); results = new ConcurrentLinkedQueue<>();
request.setAttribute(RESULTS_ATTR, results = resultsQueue); request.setAttribute(RESULTS_ATTR, results);
// suspend the request // suspend the request
// This is done before scheduling async handling to avoid race of // This is done before scheduling async handling to avoid race of
@ -100,13 +101,14 @@ public class AsyncRestServlet extends AbstractRestServlet
final AtomicInteger outstanding = new AtomicInteger(keywords.length); final AtomicInteger outstanding = new AtomicInteger(keywords.length);
// Send request each keyword // Send request each keyword
Queue<Map<String, Object>> resultsQueue = results;
for (final String item : keywords) for (final String item : keywords)
{ {
_client.newRequest(restURL(item)).method(HttpMethod.GET).send( _client.newRequest(restURL(item)).method(HttpMethod.GET).send(
new AsyncRestRequest() new AsyncRestRequest()
{ {
@Override @Override
void onAuctionFound(Map<String, String> auction) void onAuctionFound(Map<String, Object> auction)
{ {
resultsQueue.add(auction); resultsQueue.add(auction);
} }
@ -163,9 +165,9 @@ public class AsyncRestServlet extends AbstractRestServlet
out.close(); out.close();
} }
private abstract class AsyncRestRequest extends Response.Listener.Adapter private abstract static class AsyncRestRequest extends Response.Listener.Adapter
{ {
final Utf8StringBuilder _content = new Utf8StringBuilder(); private final Utf8StringBuilder _content = new Utf8StringBuilder();
AsyncRestRequest() AsyncRestRequest()
{ {
@ -182,13 +184,16 @@ public class AsyncRestServlet extends AbstractRestServlet
public void onComplete(Result result) public void onComplete(Result result)
{ {
// extract auctions from the results // extract auctions from the results
Map<String, ?> query = (Map<String, ?>)JSON.parse(_content.toString()); @SuppressWarnings("unchecked")
Map<String, Object> query = (Map<String, Object>)new JSON().fromJSON(_content.toString());
Object[] auctions = (Object[])query.get("Item"); Object[] auctions = (Object[])query.get("Item");
if (auctions != null) if (auctions != null)
{ {
for (Object o : auctions) for (Object o : auctions)
{ {
onAuctionFound((Map<String, String>)o); @SuppressWarnings("unchecked")
Map<String, Object> auction = (Map<String, Object>)o;
onAuctionFound(auction);
} }
} }
onComplete(); onComplete();
@ -196,8 +201,7 @@ public class AsyncRestServlet extends AbstractRestServlet
abstract void onComplete(); abstract void onComplete();
abstract void onAuctionFound(Map<String, String> details); abstract void onAuctionFound(Map<String, Object> details);
} }
@Override @Override

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.example.asyncrest; package org.eclipse.jetty.example.asyncrest;
@ -28,7 +28,6 @@ import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.Queue; import java.util.Queue;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -45,7 +44,7 @@ public class SerialRestServlet extends AbstractRestServlet
final long start = System.nanoTime(); final long start = System.nanoTime();
String[] keywords = sanitize(request.getParameter(ITEMS_PARAM)).split(","); String[] keywords = sanitize(request.getParameter(ITEMS_PARAM)).split(",");
Queue<Map<String, String>> results = new LinkedList<Map<String, String>>(); Queue<Map<String, Object>> results = new LinkedList<>();
// make all requests serially // make all requests serially
for (String itemName : keywords) for (String itemName : keywords)
@ -55,13 +54,16 @@ public class SerialRestServlet extends AbstractRestServlet
HttpURLConnection connection = (HttpURLConnection)url.openConnection(); HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestMethod("GET"); connection.setRequestMethod("GET");
Map query = (Map)JSON.parse(new BufferedReader(new InputStreamReader(connection.getInputStream()))); @SuppressWarnings("unchecked")
Map<String, Object> query = (Map<String, Object>)new JSON().fromJSON(new BufferedReader(new InputStreamReader(connection.getInputStream())));
Object[] auctions = (Object[])query.get("Item"); Object[] auctions = (Object[])query.get("Item");
if (auctions != null) if (auctions != null)
{ {
for (Object o : auctions) for (Object o : auctions)
{ {
results.add((Map)o); @SuppressWarnings("unchecked")
Map<String, Object> auction = (Map<String, Object>)o;
results.add(auction);
} }
} }
} }
@ -91,10 +93,6 @@ public class SerialRestServlet extends AbstractRestServlet
out.close(); out.close();
} }
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
@Override @Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{ {

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.example.asyncrest; package org.eclipse.jetty.example.asyncrest;

View File

@ -16,6 +16,15 @@
</build> </build>
<dependencies> <dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-slf4j-impl</artifactId>
<scope>compile</scope>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty.example-async-rest</groupId> <groupId>org.eclipse.jetty.example-async-rest</groupId>
<artifactId>example-async-rest-jar</artifactId> <artifactId>example-async-rest-jar</artifactId>

View File

@ -15,6 +15,15 @@
<bundle-symbolic-name>${project.groupId}.embedded</bundle-symbolic-name> <bundle-symbolic-name>${project.groupId}.embedded</bundle-symbolic-name>
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util-ajax</artifactId> <artifactId>jetty-util-ajax</artifactId>
@ -52,7 +61,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty.websocket</groupId> <groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server</artifactId> <artifactId>websocket-javax-server</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
@ -62,7 +71,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty.websocket</groupId> <groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>jetty-websocket-server</artifactId> <artifactId>websocket-jetty-server</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency> <dependency>
@ -132,7 +141,32 @@
<dependency> <dependency>
<groupId>org.eclipse.jetty.toolchain</groupId> <groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId> <artifactId>jetty-test-helper</artifactId>
<!-- scope>test</scope--> <scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-jetty-client</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-distribution</artifactId>
<version>${project.version}</version>
<type>tar.gz</type>
<scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useManifestOnlyJar>false</useManifestOnlyJar>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
@ -22,7 +22,6 @@ import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import javax.servlet.AsyncContext; import javax.servlet.AsyncContext;
import javax.servlet.ReadListener; import javax.servlet.ReadListener;
import javax.servlet.ServletException;
import javax.servlet.ServletInputStream; import javax.servlet.ServletInputStream;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.WriteListener; import javax.servlet.WriteListener;
@ -35,7 +34,7 @@ public class AsyncEchoServlet extends HttpServlet
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Override @Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException protected void service(HttpServletRequest request, HttpServletResponse response) throws IOException
{ {
AsyncContext asyncContext = request.startAsync(request, response); AsyncContext asyncContext = request.startAsync(request, response);
asyncContext.setTimeout(0); asyncContext.setTimeout(0);

View File

@ -1,25 +1,27 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.Collections;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -45,12 +47,28 @@ public class DumpServlet extends HttpServlet
out.println("pathInfo=" + request.getPathInfo()); out.println("pathInfo=" + request.getPathInfo());
out.println("session=" + request.getSession(true).getId()); out.println("session=" + request.getSession(true).getId());
ServletContext servletContext = getServletContext();
String r = request.getParameter("resource"); String r = request.getParameter("resource");
if (r != null) if (r != null)
{ {
out.println("resource(" + r + ")=" + getServletContext().getResource(r)); out.println("resource(" + r + ")=" + servletContext.getResource(r));
} }
Collections.list(request.getAttributeNames())
.stream()
.filter((name) -> name.startsWith("X-"))
.sorted()
.forEach((name) ->
out.println("request.attribute[" + name + "]=" + request.getAttribute(name)));
Collections.list(servletContext.getAttributeNames())
.stream()
.filter((name) -> name.startsWith("X-"))
.sorted()
.forEach((name) ->
out.println("servletContext.attribute[" + name + "]=" + servletContext.getAttribute(name)));
out.println("</pre>"); out.println("</pre>");
} }
} }

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
@ -28,12 +28,12 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
public class ExampleServer public class ExampleServer
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port)
{ {
Server server = new Server(); Server server = new Server();
ServerConnector connector = new ServerConnector(server); ServerConnector connector = new ServerConnector(server);
connector.setPort(8080); connector.setPort(port);
server.setConnectors(new Connector[]{connector}); server.setConnectors(new Connector[]{connector});
ServletContextHandler context = new ServletContextHandler(); ServletContextHandler context = new ServletContextHandler();
@ -45,6 +45,13 @@ public class ExampleServer
handlers.setHandlers(new Handler[]{context, new DefaultHandler()}); handlers.setHandlers(new Handler[]{context, new DefaultHandler()});
server.setHandler(handlers); server.setHandler(handlers);
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
server.start(); server.start();
server.join(); server.join();
} }

View File

@ -1,38 +1,48 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.xml.XmlConfiguration; import org.eclipse.jetty.xml.XmlConfiguration;
/** /**
* Configures and Starts a Jetty server from an XML declaration. * Configures and Starts a Jetty server from an XML declaration.
* <p>
* See <a href="https://raw.githubusercontent.com/eclipse/jetty.project/master/examples/embedded/src/main/resources/exampleserver.xml">exampleserver.xml</a>
* </p>
*/ */
public class ExampleServerXml public class ExampleServerXml
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port) throws Exception
{ {
// Find Jetty XML (in classpath) that configures and starts Server. // Find Jetty XML (in classpath) that configures and starts Server.
// See src/main/resources/exampleserver.xml
Resource serverXml = Resource.newSystemResource("exampleserver.xml"); Resource serverXml = Resource.newSystemResource("exampleserver.xml");
XmlConfiguration.main(serverXml.getFile().getAbsolutePath()); XmlConfiguration xml = new XmlConfiguration(serverXml);
xml.getProperties().put("http.port", Integer.toString(port));
Server server = (Server)xml.configure();
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
server.start();
server.join();
} }
} }

View File

@ -0,0 +1,86 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import org.eclipse.jetty.util.StringUtil;
public class ExampleUtil
{
/**
* Get a port, possibly configured from Command line or System property.
*
* @param args the command line arguments
* @param propertyName the property name
* @param defValue the default value
* @return the configured port
*/
public static int getPort(String[] args, String propertyName, int defValue)
{
for (String arg : args)
{
if (arg.startsWith(propertyName + "="))
{
String value = arg.substring(propertyName.length() + 2);
int port = toInt(value);
if (isValidPort(port))
return port;
}
}
String value = System.getProperty(propertyName);
int port = toInt(value);
if (isValidPort(port))
return port;
return defValue;
}
/**
* Test if port is in the valid range to be used.
*
* @param port the port to test
* @return true if valid
*/
private static boolean isValidPort(int port)
{
return (port >= 0) && (port <= 65535);
}
/**
* Parse an int, ignoring any {@link NumberFormatException}
*
* @param value the string value to parse
* @return the int (if parsed), or -1 if not parsed.
*/
private static int toInt(String value)
{
if (StringUtil.isBlank(value))
return -1;
try
{
return Integer.parseInt(value);
}
catch (NumberFormatException ignored)
{
// ignored
return -1;
}
}
}

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
@ -58,17 +58,24 @@ import org.eclipse.jetty.util.resource.Resource;
*/ */
public class FastFileServer public class FastFileServer
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port, File resourceBase)
{ {
Server server = new Server(8080); Server server = new Server(port);
HandlerList handlers = new HandlerList(); HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{ handlers.setHandlers(new Handler[]{
new FastFileHandler(new File(System.getProperty("user.dir"))), new FastFileHandler(resourceBase),
new DefaultHandler() new DefaultHandler()
}); });
server.setHandler(handlers); server.setHandler(handlers);
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
File directory = new File(System.getProperty("user.dir"));
Server server = createServer(port, directory);
server.start(); server.start();
server.join(); server.join();
} }

View File

@ -1,28 +1,33 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.util.resource.PathResource;
import org.eclipse.jetty.util.resource.Resource;
/** /**
* Simple Jetty FileServer. * Simple Jetty FileServer.
@ -30,12 +35,12 @@ import org.eclipse.jetty.server.handler.ResourceHandler;
*/ */
public class FileServer public class FileServer
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port, Resource baseResource) throws Exception
{ {
// Create a basic Jetty server object that will listen on port 8080. Note that if you set this to port 0 // Create a basic Jetty server object that will listen on port 8080. Note that if you set this to port 0
// then a randomly available port will be assigned that you can either look in the logs for the port, // then a randomly available port will be assigned that you can either look in the logs for the port,
// or programmatically obtain it for use in test cases. // or programmatically obtain it for use in test cases.
final Server server = new Server(8080); Server server = new Server(port);
// Create the ResourceHandler. It is the object that will actually handle the request for a given file. It is // Create the ResourceHandler. It is the object that will actually handle the request for a given file. It is
// a Jetty Handler object so it is suitable for chaining with other handlers as you will see in other examples. // a Jetty Handler object so it is suitable for chaining with other handlers as you will see in other examples.
@ -45,13 +50,24 @@ public class FileServer
// In this example it is the current directory but it can be configured to anything that the jvm has access to. // In this example it is the current directory but it can be configured to anything that the jvm has access to.
resourceHandler.setDirectoriesListed(true); resourceHandler.setDirectoriesListed(true);
resourceHandler.setWelcomeFiles(new String[]{"index.html"}); resourceHandler.setWelcomeFiles(new String[]{"index.html"});
resourceHandler.setResourceBase("."); resourceHandler.setBaseResource(baseResource);
// Add the ResourceHandler to the server. // Add the ResourceHandler to the server.
HandlerList handlers = new HandlerList(); HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{resourceHandler, new DefaultHandler()}); handlers.setHandlers(new Handler[]{resourceHandler, new DefaultHandler()});
server.setHandler(handlers); server.setHandler(handlers);
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Path userDir = Paths.get(System.getProperty("user.dir"));
PathResource pathResource = new PathResource(userDir);
Server server = createServer(port, pathResource);
// Start things up! By using the server.join() the server thread will join with the current thread. // Start things up! By using the server.join() the server thread will join with the current thread.
// See "http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.html#join()" for more details. // See "http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.html#join()" for more details.
server.start(); server.start();

View File

@ -1,23 +1,26 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.xml.XmlConfiguration; import org.eclipse.jetty.xml.XmlConfiguration;
@ -28,17 +31,25 @@ import org.eclipse.jetty.xml.XmlConfiguration;
* This server is identical to {@link FileServer}, except that it is configured * This server is identical to {@link FileServer}, except that it is configured
* via an {@link XmlConfiguration} config file that does the identical work. * via an {@link XmlConfiguration} config file that does the identical work.
* </p> * </p>
* <p>
* See <a href="https://raw.githubusercontent.com/eclipse/jetty.project/master/examples/embedded/src/main/resources/fileserver.xml">fileserver.xml</a>
* </p>
*/ */
public class FileServerXml public class FileServerXml
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port, Path baseResource) throws Exception
{ {
// Find Jetty XML (in classpath) that configures and starts Server.
// See src/main/resources/fileserver.xml
Resource fileServerXml = Resource.newSystemResource("fileserver.xml"); Resource fileServerXml = Resource.newSystemResource("fileserver.xml");
XmlConfiguration configuration = new XmlConfiguration(fileServerXml); XmlConfiguration configuration = new XmlConfiguration(fileServerXml);
Server server = (Server)configuration.configure(); configuration.getProperties().put("http.port", Integer.toString(port));
configuration.getProperties().put("fileserver.baseresource", baseResource.toAbsolutePath().toString());
return (Server)configuration.configure();
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Path userDir = Paths.get(System.getProperty("user.dir"));
Server server = createServer(port, userDir);
server.start(); server.start();
server.join(); server.join();
} }

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
@ -51,7 +51,8 @@ public class HelloWorld extends AbstractHandler
public static void main(String[] args) throws Exception public static void main(String[] args) throws Exception
{ {
Server server = new Server(8080); int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = new Server(port);
server.setHandler(new HelloWorld()); server.setHandler(new HelloWorld());
server.start(); server.start();

View File

@ -1,26 +1,29 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.io.File; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.EnumSet; import java.util.EnumSet;
@ -56,12 +59,15 @@ import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.servlets.PushCacheFilter; import org.eclipse.jetty.servlets.PushCacheFilter;
import org.eclipse.jetty.util.resource.PathResource;
import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.ssl.SslContextFactory;
public class Http2Server public class Http2Server
{ {
public static void main(String... args) throws Exception public static void main(String... args) throws Exception
{ {
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
int securePort = ExampleUtil.getPort(args, "jetty.https.port", 8443);
Server server = new Server(); Server server = new Server();
MBeanContainer mbContainer = new MBeanContainer( MBeanContainer mbContainer = new MBeanContainer(
@ -69,10 +75,11 @@ public class Http2Server
server.addBean(mbContainer); server.addBean(mbContainer);
ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
String docroot = "src/main/resources/docroot"; Path docroot = Paths.get("src/main/resources/docroot");
if (!new File(docroot).exists()) if (!Files.exists(docroot))
docroot = "examples/embedded/src/main/resources/docroot"; throw new FileNotFoundException(docroot.toString());
context.setResourceBase(docroot);
context.setBaseResource(new PathResource(docroot));
context.addFilter(PushCacheFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); context.addFilter(PushCacheFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
// context.addFilter(PushSessionCacheFilter.class,"/*",EnumSet.of(DispatcherType.REQUEST)); // context.addFilter(PushSessionCacheFilter.class,"/*",EnumSet.of(DispatcherType.REQUEST));
context.addFilter(PushedTilesFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); context.addFilter(PushedTilesFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
@ -83,23 +90,22 @@ public class Http2Server
// HTTP Configuration // HTTP Configuration
HttpConfiguration httpConfig = new HttpConfiguration(); HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSecureScheme("https"); httpConfig.setSecureScheme("https");
httpConfig.setSecurePort(8443); httpConfig.setSecurePort(securePort);
httpConfig.setSendXPoweredBy(true); httpConfig.setSendXPoweredBy(true);
httpConfig.setSendServerVersion(true); httpConfig.setSendServerVersion(true);
// HTTP Connector // HTTP Connector
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig), new HTTP2CServerConnectionFactory(httpConfig)); ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig), new HTTP2CServerConnectionFactory(httpConfig));
http.setPort(8080); http.setPort(port);
server.addConnector(http); server.addConnector(http);
// SSL Context Factory for HTTPS and HTTP/2 // SSL Context Factory for HTTPS and HTTP/2
String jettyDistro = System.getProperty("jetty.distro", "../../jetty-distribution/target/distribution"); Path keystorePath = Paths.get("src/main/resources/etc/keystore.p12").toAbsolutePath();
if (!new File(jettyDistro).exists()) if (!Files.exists(keystorePath))
jettyDistro = "jetty-distribution/target/distribution"; throw new FileNotFoundException(keystorePath.toString());
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server(); SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
sslContextFactory.setKeyStorePath(jettyDistro + "/demo-base/etc/keystore"); sslContextFactory.setKeyStorePath(keystorePath.toString());
sslContextFactory.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"); sslContextFactory.setKeyStorePassword("storepwd");
sslContextFactory.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR); sslContextFactory.setCipherComparator(HTTP2Cipher.COMPARATOR);
// sslContextFactory.setProvider("Conscrypt"); // sslContextFactory.setProvider("Conscrypt");
@ -119,7 +125,7 @@ public class Http2Server
// HTTP/2 Connector // HTTP/2 Connector
ServerConnector http2Connector = ServerConnector http2Connector =
new ServerConnector(server, ssl, alpn, h2, new HttpConnectionFactory(httpsConfig)); new ServerConnector(server, ssl, alpn, h2, new HttpConnectionFactory(httpsConfig));
http2Connector.setPort(8443); http2Connector.setPort(securePort);
server.addConnector(http2Connector); server.addConnector(http2Connector);
server.start(); server.start();

View File

@ -1,24 +1,28 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import org.eclipse.jetty.server.Handler; import java.io.FileNotFoundException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.HandlerList;
@ -28,24 +32,36 @@ import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
/** /**
* * Example of serving content from a JAR file.
* The JAR file in this example does not belong to any Classpath.
*/ */
public class JarServer public class JarServer
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port) throws Exception
{ {
final Server server = new Server(8080); Server server = new Server(port);
Path jarFile = Paths.get("src/main/other/content.jar");
if (!Files.exists(jarFile))
throw new FileNotFoundException(jarFile.toString());
ServletContextHandler context = new ServletContextHandler(); ServletContextHandler context = new ServletContextHandler();
Resource.setDefaultUseCaches(true); Resource.setDefaultUseCaches(true);
Resource base = Resource.newResource("jar:file:src/main/resources/content.jar!/"); Resource base = Resource.newResource("jar:" + jarFile.toAbsolutePath().toUri().toASCIIString() + "!/");
context.setBaseResource(base); context.setBaseResource(base);
context.addServlet(new ServletHolder(new DefaultServlet()), "/"); context.addServlet(new ServletHolder(new DefaultServlet()), "/");
HandlerList handlers = new HandlerList(); HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[]{context, new DefaultHandler()}); handlers.addHandler(context);
handlers.addHandler(new DefaultHandler());
server.setHandler(handlers); server.setHandler(handlers);
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
server.start(); server.start();
server.join(); server.join();
} }

View File

@ -1,29 +1,30 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.io.File; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.Log; import org.slf4j.Logger;
import org.eclipse.jetty.util.log.Logger; import org.slf4j.LoggerFactory;
/** /**
* A utility test class to locate a Jetty Distribution for testing purposes by searching: * A utility test class to locate a Jetty Distribution for testing purposes by searching:
@ -35,71 +36,104 @@ import org.eclipse.jetty.util.log.Logger;
*/ */
public class JettyDistribution public class JettyDistribution
{ {
private static final Logger LOG = Log.getLogger(JettyDistribution.class); private static final Logger LOG = LoggerFactory.getLogger(JettyDistribution.class);
public static final Path DISTRIBUTION; public static final Path DISTRIBUTION;
static static
{ {
Path distro = asJettyDistribution(System.getProperty("jetty.home")); Path distro = asJettyDistribution(System.getProperty("jetty.home"));
LOG.debug("JettyDistribution(prop(jetty.home)) = " + distro);
if (distro == null) if (distro == null)
{
distro = asJettyDistribution(System.getenv().get("JETTY_HOME")); distro = asJettyDistribution(System.getenv().get("JETTY_HOME"));
LOG.debug("JettyDistribution(env(JETTY_HOME)) = " + distro);
}
if (distro == null) if (distro == null)
{ {
try try
{ {
Path working = new File(".").getAbsoluteFile().getCanonicalFile().toPath(); Path working = Paths.get(System.getProperty("user.dir"));
LOG.debug("JettyDistribution(prop(user.dir)) = " + working);
while (distro == null && working != null) while (distro == null && working != null)
{ {
distro = asJettyDistribution(working.resolve("jetty-distribution/target/distribution").toString()); distro = asJettyDistribution(working.resolve("jetty-distribution/target/distribution").toString());
working = working.getParent(); working = working.getParent();
} }
LOG.debug("JettyDistribution(working.resolve(...)) = " + distro);
} }
catch (Throwable th) catch (Throwable th)
{ {
LOG.warn(th); LOG.warn("Unable to resolve Jetty Distribution location", th);
} }
} }
if (distro == null)
{
LOG.info("JettyDistribution() FAILURE: NOT FOUND");
}
else
{
LOG.debug("JettyDistribution() FOUND = " + distro);
}
DISTRIBUTION = distro; DISTRIBUTION = distro;
} }
private static Path asJettyDistribution(String test) private static Path asJettyDistribution(String jettyHome)
{ {
try try
{ {
if (StringUtil.isBlank(test)) if (jettyHome == null)
{ {
LOG.info("asJettyDistribution {} is blank", test);
return null; return null;
} }
File dir = new File(test); if (StringUtil.isBlank(jettyHome))
if (!dir.exists() || !dir.isDirectory())
{ {
LOG.info("asJettyDistribution {} is not a directory", test); LOG.debug("asJettyDistribution {} is blank", jettyHome);
return null; return null;
} }
File demoBase = new File(dir, "demo-base"); Path dir = Paths.get(jettyHome);
if (!demoBase.exists() || !demoBase.isDirectory()) if (!Files.exists(dir))
{ {
LOG.info("asJettyDistribution {} has no demo-base", test); LOG.debug("asJettyDistribution {} does not exist", jettyHome);
return null; return null;
} }
LOG.info("asJettyDistribution {}", dir); if (!Files.isDirectory(dir))
return dir.getAbsoluteFile().getCanonicalFile().toPath(); {
LOG.debug("asJettyDistribution {} is not a directory", jettyHome);
return null;
}
Path demoBase = dir.resolve("demo-base");
if (!Files.exists(demoBase) || !Files.isDirectory(demoBase))
{
LOG.debug("asJettyDistribution {} has no demo-base", jettyHome);
return null;
}
LOG.debug("asJettyDistribution {}", dir);
return dir.toAbsolutePath();
} }
catch (Exception e) catch (Exception e)
{ {
LOG.ignore(e); LOG.trace("IGNORED", e);
} }
return null; return null;
} }
public static Path get()
{
if (DISTRIBUTION == null)
throw new RuntimeException("jetty-distribution not found");
return DISTRIBUTION;
}
public static Path resolve(String path) public static Path resolve(String path)
{ {
return DISTRIBUTION.resolve(path); return get().resolve(path);
} }
public static void main(String... arg) public static void main(String... arg)

View File

@ -1,29 +1,33 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.io.File; import java.io.FileNotFoundException;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.eclipse.jetty.annotations.AnnotationConfiguration; import org.eclipse.jetty.annotations.AnnotationConfiguration;
import org.eclipse.jetty.deploy.DeploymentManager; import org.eclipse.jetty.deploy.DeploymentManager;
import org.eclipse.jetty.deploy.PropertiesConfigurationManager; import org.eclipse.jetty.deploy.PropertiesConfigurationManager;
import org.eclipse.jetty.deploy.bindings.DebugListenerBinding;
import org.eclipse.jetty.deploy.providers.WebAppProvider; import org.eclipse.jetty.deploy.providers.WebAppProvider;
import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.jmx.MBeanContainer; import org.eclipse.jetty.jmx.MBeanContainer;
@ -35,6 +39,7 @@ import org.eclipse.jetty.rewrite.handler.ValidUrlRule;
import org.eclipse.jetty.security.HashLoginService; import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.AsyncRequestLogWriter; import org.eclipse.jetty.server.AsyncRequestLogWriter;
import org.eclipse.jetty.server.CustomRequestLog; import org.eclipse.jetty.server.CustomRequestLog;
import org.eclipse.jetty.server.DebugListener;
import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.HttpConnectionFactory;
@ -59,21 +64,21 @@ import org.eclipse.jetty.webapp.Configurations;
*/ */
public class LikeJettyXml public class LikeJettyXml
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port, int securePort, boolean addDebugListener) throws Exception
{ {
// Path to as-built jetty-distribution directory // Path to as-built jetty-distribution directory
String jettyHomeBuild = JettyDistribution.DISTRIBUTION.toString(); Path jettyHomeBuild = JettyDistribution.get();
// Find jetty home and base directories // Find jetty home and base directories
String homePath = System.getProperty("jetty.home", jettyHomeBuild); String homePath = System.getProperty("jetty.home", jettyHomeBuild.toString());
File homeDir = new File(homePath); Path homeDir = Paths.get(homePath);
String basePath = System.getProperty("jetty.base", homeDir + "/demo-base"); String basePath = System.getProperty("jetty.base", homeDir.resolve("demo-base").toString());
File baseDir = new File(basePath); Path baseDir = Paths.get(basePath);
// Configure jetty.home and jetty.base system properties // Configure jetty.home and jetty.base system properties
String jettyHome = homeDir.getAbsolutePath(); String jettyHome = homeDir.toAbsolutePath().toString();
String jettyBase = baseDir.getAbsolutePath(); String jettyBase = baseDir.toAbsolutePath().toString();
System.setProperty("jetty.home", jettyHome); System.setProperty("jetty.home", jettyHome);
System.setProperty("jetty.base", jettyBase); System.setProperty("jetty.base", jettyBase);
@ -91,7 +96,7 @@ public class LikeJettyXml
// HTTP Configuration // HTTP Configuration
HttpConfiguration httpConfig = new HttpConfiguration(); HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSecureScheme("https"); httpConfig.setSecureScheme("https");
httpConfig.setSecurePort(8443); httpConfig.setSecurePort(securePort);
httpConfig.setOutputBufferSize(32768); httpConfig.setOutputBufferSize(32768);
httpConfig.setRequestHeaderSize(8192); httpConfig.setRequestHeaderSize(8192);
httpConfig.setResponseHeaderSize(8192); httpConfig.setResponseHeaderSize(8192);
@ -105,11 +110,6 @@ public class LikeJettyXml
handlers.setHandlers(new Handler[]{contexts, new DefaultHandler()}); handlers.setHandlers(new Handler[]{contexts, new DefaultHandler()});
server.setHandler(handlers); server.setHandler(handlers);
// Extra options
server.setDumpAfterStart(true);
server.setDumpBeforeStop(false);
server.setStopAtShutdown(true);
// === jetty-jmx.xml === // === jetty-jmx.xml ===
MBeanContainer mbContainer = new MBeanContainer( MBeanContainer mbContainer = new MBeanContainer(
ManagementFactory.getPlatformMBeanServer()); ManagementFactory.getPlatformMBeanServer());
@ -118,24 +118,20 @@ public class LikeJettyXml
// === jetty-http.xml === // === jetty-http.xml ===
ServerConnector http = new ServerConnector(server, ServerConnector http = new ServerConnector(server,
new HttpConnectionFactory(httpConfig)); new HttpConnectionFactory(httpConfig));
http.setPort(8080); http.setPort(port);
http.setIdleTimeout(30000); http.setIdleTimeout(30000);
server.addConnector(http); server.addConnector(http);
// === jetty-https.xml === // === jetty-https.xml ===
// SSL Context Factory // SSL Context Factory
Path keystorePath = Paths.get("src/main/resources/etc/keystore.p12").toAbsolutePath();
if (!Files.exists(keystorePath))
throw new FileNotFoundException(keystorePath.toString());
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server(); SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
sslContextFactory.setKeyStorePath(jettyHome + "/../../../jetty-server/src/test/config/etc/keystore"); sslContextFactory.setKeyStorePath(keystorePath.toString());
sslContextFactory.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"); sslContextFactory.setKeyStorePassword("storepwd");
sslContextFactory.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g"); sslContextFactory.setTrustStorePath(keystorePath.toString());
sslContextFactory.setTrustStorePath(jettyHome + "/../../../jetty-server/src/test/config/etc/keystore"); sslContextFactory.setTrustStorePassword("storepwd");
sslContextFactory.setTrustStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4");
sslContextFactory.setExcludeCipherSuites("SSL_RSA_WITH_DES_CBC_SHA",
"SSL_DHE_RSA_WITH_DES_CBC_SHA", "SSL_DHE_DSS_WITH_DES_CBC_SHA",
"SSL_RSA_EXPORT_WITH_RC4_40_MD5",
"SSL_RSA_EXPORT_WITH_DES40_CBC_SHA",
"SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
"SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA");
// SSL HTTP Configuration // SSL HTTP Configuration
HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig); HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
@ -145,14 +141,17 @@ public class LikeJettyXml
ServerConnector sslConnector = new ServerConnector(server, ServerConnector sslConnector = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(httpsConfig)); new HttpConnectionFactory(httpsConfig));
sslConnector.setPort(8443); sslConnector.setPort(securePort);
server.addConnector(sslConnector); server.addConnector(sslConnector);
// === jetty-deploy.xml === // === jetty-deploy.xml ===
DeploymentManager deployer = new DeploymentManager(); DeploymentManager deployer = new DeploymentManager();
//DebugListener debug = new DebugListener(System.out,true,true,true); if (addDebugListener)
// server.addBean(debug); {
// deployer.addLifeCycleBinding(new DebugListenerBinding(debug)); DebugListener debug = new DebugListener(System.err, true, true, true);
server.addBean(debug);
deployer.addLifeCycleBinding(new DebugListenerBinding(debug));
}
deployer.setContexts(contexts); deployer.setContexts(contexts);
deployer.setContextAttribute( deployer.setContextAttribute(
"org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", "org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
@ -208,6 +207,20 @@ public class LikeJettyXml
login.setHotReload(false); login.setHotReload(false);
server.addBean(login); server.addBean(login);
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
int securePort = ExampleUtil.getPort(args, "jetty.https.port", 8443);
Server server = createServer(port, securePort, true);
// Extra options
server.setDumpAfterStart(true);
server.setDumpBeforeStop(false);
server.setStopAtShutdown(true);
// Start the server // Start the server
server.start(); server.start();
server.join(); server.join();

View File

@ -1,25 +1,27 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.eclipse.jetty.http.HttpVersion; import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Connector;
@ -36,23 +38,13 @@ import org.eclipse.jetty.util.ssl.SslContextFactory;
*/ */
public class ManyConnectors public class ManyConnectors
{ {
public static void main(String[] args) throws Exception public static Server createServer(int plainPort, int securePort) throws Exception
{ {
// Since this example shows off SSL configuration, we need a keystore // Since this example shows off SSL configuration, we need a keystore
// with the appropriate key. These lookup of jetty.home is purely a hack // with the appropriate key.
// to get access to a keystore that we use in many unit tests and should Path keystorePath = Paths.get("src/main/resources/etc/keystore.p12").toAbsolutePath();
// probably be a direct path to your own keystore. if (!Files.exists(keystorePath))
throw new FileNotFoundException(keystorePath.toString());
String jettyDistKeystore = "../../jetty-distribution/target/distribution/demo-base/etc/test-keystore";
String keystorePath = System.getProperty("example.keystore", jettyDistKeystore);
File keystoreFile = new File(keystorePath);
if (!keystoreFile.exists())
{
keystorePath = "jetty-distribution/target/distribution/demo-base/etc/keystore";
keystoreFile = new File(keystorePath);
if (!keystoreFile.exists())
throw new FileNotFoundException(keystoreFile.getAbsolutePath());
}
// Create a basic jetty server object without declaring the port. Since // Create a basic jetty server object without declaring the port. Since
// we are configuring connectors directly we'll be setting ports on // we are configuring connectors directly we'll be setting ports on
@ -67,7 +59,7 @@ public class ManyConnectors
// done. The port for secured communication is also set here. // done. The port for secured communication is also set here.
HttpConfiguration httpConfig = new HttpConfiguration(); HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSecureScheme("https"); httpConfig.setSecureScheme("https");
httpConfig.setSecurePort(8443); httpConfig.setSecurePort(securePort);
httpConfig.setOutputBufferSize(32768); httpConfig.setOutputBufferSize(32768);
// HTTP connector // HTTP connector
@ -77,7 +69,7 @@ public class ManyConnectors
// configure an idle timeout. // configure an idle timeout.
ServerConnector http = new ServerConnector(server, ServerConnector http = new ServerConnector(server,
new HttpConnectionFactory(httpConfig)); new HttpConnectionFactory(httpConfig));
http.setPort(8080); http.setPort(plainPort);
http.setIdleTimeout(30000); http.setIdleTimeout(30000);
// SSL Context Factory for HTTPS // SSL Context Factory for HTTPS
@ -88,9 +80,8 @@ public class ManyConnectors
// keystore to be used. // keystore to be used.
SslContextFactory.Server sslContextFactory = new SslContextFactory.Server(); SslContextFactory.Server sslContextFactory = new SslContextFactory.Server();
sslContextFactory.setKeyStorePath(keystoreFile.getAbsolutePath()); sslContextFactory.setKeyStorePath(keystorePath.toString());
sslContextFactory.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"); sslContextFactory.setKeyStorePassword("storepwd");
sslContextFactory.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g");
// OPTIONAL: Un-comment the following to use Conscrypt for SSL instead of // OPTIONAL: Un-comment the following to use Conscrypt for SSL instead of
// the native JSSE implementation. // the native JSSE implementation.
@ -118,7 +109,7 @@ public class ManyConnectors
ServerConnector https = new ServerConnector(server, ServerConnector https = new ServerConnector(server,
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
new HttpConnectionFactory(httpsConfig)); new HttpConnectionFactory(httpsConfig));
https.setPort(8443); https.setPort(securePort);
https.setIdleTimeout(500000); https.setIdleTimeout(500000);
// Here you see the server having multiple connectors registered with // Here you see the server having multiple connectors registered with
@ -132,7 +123,14 @@ public class ManyConnectors
// Set a handler // Set a handler
server.setHandler(new HelloHandler()); server.setHandler(new HelloHandler());
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
int securePort = ExampleUtil.getPort(args, "jetty.https.port", 8443);
Server server = createServer(port, securePort);
// Start the server // Start the server
server.start(); server.start();
server.dumpStdErr(); server.dumpStdErr();

View File

@ -1,56 +1,59 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.server.handler.ContextHandlerCollection;
public class ManyContexts public class ManyContexts
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port)
{ {
final Server server = new Server(8080); Server server = new Server(port);
ContextHandler context = new ContextHandler("/"); ContextHandler context = new ContextHandler("/");
context.setContextPath("/"); context.setContextPath("/");
context.setHandler(new HelloHandler("Root Hello")); context.setHandler(new HelloHandler("Root Hello"));
ContextHandler contextFR = new ContextHandler("/fr"); ContextHandler contextFR = new ContextHandler("/fr");
contextFR.setHandler(new HelloHandler("Bonjoir")); contextFR.setHandler(new HelloHandler("Bonjour"));
ContextHandler contextIT = new ContextHandler("/it"); ContextHandler contextIT = new ContextHandler("/it");
contextIT.setHandler(new HelloHandler("Bongiorno")); contextIT.setHandler(new HelloHandler("Buongiorno"));
ContextHandler contextV = new ContextHandler("/"); ContextHandler contextV = new ContextHandler("/");
contextV.setVirtualHosts(new String[]{"127.0.0.2"}); contextV.setVirtualHosts(new String[]{"127.0.0.2"});
contextV.setHandler(new HelloHandler("Virtual Hello")); contextV.setHandler(new HelloHandler("Virtual Hello"));
ContextHandlerCollection contexts = new ContextHandlerCollection(); ContextHandlerCollection contexts = new ContextHandlerCollection(
contexts.setHandlers(new Handler[]{ context, contextFR, contextIT, contextV
context, contextFR, contextIT, );
contextV
});
server.setHandler(contexts); server.setHandler(contexts);
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
server.start(); server.start();
server.dumpStdErr(); server.dumpStdErr();
server.join(); server.join();

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
@ -30,6 +30,8 @@ import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerCollection; import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.HandlerList;
@ -81,7 +83,7 @@ public class ManyHandlers
if (!params.isEmpty()) if (!params.isEmpty())
{ {
response.setContentType("text/plain"); response.setContentType("text/plain");
response.getWriter().println(JSON.toString(params)); response.getWriter().println(new JSON().toJSON(params));
baseRequest.setHandled(true); baseRequest.setHandled(true);
} }
} }
@ -99,20 +101,23 @@ public class ManyHandlers
HttpServletResponse response) throws IOException, HttpServletResponse response) throws IOException,
ServletException ServletException
{ {
request.setAttribute("welcome", "Hello"); response.setHeader("X-Welcome", "Greetings from WelcomeWrapHandler");
super.handle(target, baseRequest, request, response); super.handle(target, baseRequest, request, response);
} }
} }
public static void main(String[] args) throws Exception public static Server createServer(int port) throws IOException
{ {
final Server server = new Server(8080); Server server = new Server(port);
// create the handlers // create the handlers
final Handler param = new ParamHandler(); Handler param = new ParamHandler();
final HandlerWrapper wrapper = new WelcomeWrapHandler(); HandlerWrapper wrapper = new WelcomeWrapHandler();
final Handler hello = new HelloHandler(); Handler hello = new HelloHandler();
final Handler dft = new DefaultHandler(); GzipHandler gzipHandler = new GzipHandler();
gzipHandler.setMinGzipSize(10);
gzipHandler.addIncludedMimeTypes("text/plain");
gzipHandler.addIncludedMimeTypes("text/html");
// configure request logging // configure request logging
File requestLogFile = File.createTempFile("demo", "log"); File requestLogFile = File.createTempFile("demo", "log");
@ -120,16 +125,47 @@ public class ManyHandlers
server.setRequestLog(ncsaLog); server.setRequestLog(ncsaLog);
// create the handler collections // create the handler collections
HandlerCollection handlers = new HandlerCollection(); HandlerList handlers = new HandlerList();
HandlerList list = new HandlerList();
// link them all together // wrap contexts around specific handlers
wrapper.setHandler(hello); wrapper.setHandler(hello);
list.setHandlers(new Handler[]{param, new GzipHandler()}); ContextHandler helloContext = new ContextHandler("/hello");
handlers.setHandlers(new Handler[]{list, dft}); helloContext.setHandler(wrapper);
ContextHandler paramContext = new ContextHandler("/params");
paramContext.setHandler(param);
ContextHandlerCollection contexts = new ContextHandlerCollection(helloContext, paramContext);
// Wrap Contexts with GZIP
gzipHandler.setHandler(contexts);
// Set the top level Handler List
handlers.addHandler(gzipHandler);
handlers.addHandler(new DefaultHandler());
server.setHandler(handlers); server.setHandler(handlers);
/* At this point you have the following handler hierarchy.
*
* Server.handler:
* HandlerList
* \- GzipHandler
* | \- ContextHandlerCollection
* | \- ContextHandler ("/hello")
* | | \- WelcomeWrapHandler
* | | \- HelloHandler
* | \- ContextHandler ("/params")
* | \- ParamHandler
* \- DefaultHandler
*/
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
server.start(); server.start();
server.join(); server.join();
} }

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
@ -29,9 +29,9 @@ import org.eclipse.jetty.servlet.ServletHolder;
public class ManyServletContexts public class ManyServletContexts
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port)
{ {
Server server = new Server(8080); Server server = new Server(port);
// Setup JMX // Setup JMX
MBeanContainer mbContainer = new MBeanContainer( MBeanContainer mbContainer = new MBeanContainer(
@ -48,7 +48,7 @@ public class ManyServletContexts
// Add servlets to root context // Add servlets to root context
root.addServlet(new ServletHolder(new HelloServlet("Hello")), "/"); root.addServlet(new ServletHolder(new HelloServlet("Hello")), "/");
root.addServlet(new ServletHolder(new HelloServlet("Ciao")), "/it/*"); root.addServlet(new ServletHolder(new HelloServlet("Ciao")), "/it/*");
root.addServlet(new ServletHolder(new HelloServlet("Bonjoir")), "/fr/*"); root.addServlet(new ServletHolder(new HelloServlet("Bonjour")), "/fr/*");
// Configure context "/other" for servlets // Configure context "/other" for servlets
ServletContextHandler other = new ServletContextHandler(contexts, ServletContextHandler other = new ServletContextHandler(contexts,
@ -57,6 +57,13 @@ public class ManyServletContexts
other.addServlet(DefaultServlet.class.getCanonicalName(), "/"); other.addServlet(DefaultServlet.class.getCanonicalName(), "/");
other.addServlet(new ServletHolder(new HelloServlet("YO!")), "*.yo"); other.addServlet(new ServletHolder(new HelloServlet("YO!")), "*.yo");
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
server.start(); server.start();
server.dumpStdErr(); server.dumpStdErr();
server.join(); server.join();

View File

@ -1,25 +1,24 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.io.IOException; import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -29,13 +28,13 @@ import org.eclipse.jetty.servlet.ServletHandler;
public class MinimalServlets public class MinimalServlets
{ {
public static void main(String[] args) throws Exception
public static Server createServer(int port)
{ {
// Create a basic jetty server object that will listen on port 8080.
// Note that if you set this to port 0 then a randomly available port // Note that if you set this to port 0 then a randomly available port
// will be assigned that you can either look in the logs for the port, // will be assigned that you can either look in the logs for the port,
// or programmatically obtain it for use in test cases. // or programmatically obtain it for use in test cases.
Server server = new Server(8080); Server server = new Server(port);
// The ServletHandler is a dead simple way to create a context handler // The ServletHandler is a dead simple way to create a context handler
// that is backed by an instance of a Servlet. // that is backed by an instance of a Servlet.
@ -51,13 +50,20 @@ public class MinimalServlets
// through a web.xml @WebServlet annotation, or anything similar. // through a web.xml @WebServlet annotation, or anything similar.
handler.addServletWithMapping(HelloServlet.class, "/*"); handler.addServletWithMapping(HelloServlet.class, "/*");
return server;
}
public static void main(String[] args) throws Exception
{
// Create a basic jetty server object that will listen on port 8080.
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
// Start things up! // Start things up!
server.start(); server.start();
// The use of server.join() the will make the current thread join and // The use of server.join() the will make the current thread join and
// wait until the server is done executing. // wait until the server thread is done executing.
// See
// http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#join()
server.join(); server.join();
} }
@ -66,11 +72,11 @@ public class MinimalServlets
{ {
@Override @Override
protected void doGet(HttpServletRequest request, protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, HttpServletResponse response) throws IOException
IOException
{ {
response.setContentType("text/html");
response.setStatus(HttpServletResponse.SC_OK); response.setStatus(HttpServletResponse.SC_OK);
response.setContentType("text/html");
response.setCharacterEncoding("utf-8");
response.getWriter().println("<h1>Hello from HelloServlet</h1>"); response.getWriter().println("<h1>Hello from HelloServlet</h1>");
} }
} }

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
@ -26,7 +26,7 @@ import org.eclipse.jetty.server.ServerConnector;
*/ */
public class OneConnector public class OneConnector
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port) throws Exception
{ {
// The Server // The Server
Server server = new Server(); Server server = new Server();
@ -34,7 +34,7 @@ public class OneConnector
// HTTP connector // HTTP connector
ServerConnector http = new ServerConnector(server); ServerConnector http = new ServerConnector(server);
http.setHost("localhost"); http.setHost("localhost");
http.setPort(8080); http.setPort(port);
http.setIdleTimeout(30000); http.setIdleTimeout(30000);
// Set the connector // Set the connector
@ -42,6 +42,13 @@ public class OneConnector
// Set a handler // Set a handler
server.setHandler(new HelloHandler()); server.setHandler(new HelloHandler());
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
// Start the server // Start the server
server.start(); server.start();

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
@ -23,9 +23,9 @@ import org.eclipse.jetty.server.handler.ContextHandler;
public class OneContext public class OneContext
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port)
{ {
Server server = new Server(8080); Server server = new Server(port);
// Add a single handler on context "/hello" // Add a single handler on context "/hello"
ContextHandler context = new ContextHandler(); ContextHandler context = new ContextHandler();
@ -35,6 +35,13 @@ public class OneContext
// Can be accessed using http://localhost:8080/hello // Can be accessed using http://localhost:8080/hello
server.setHandler(context); server.setHandler(context);
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
// Start the server // Start the server
server.start(); server.start();

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
@ -22,11 +22,17 @@ import org.eclipse.jetty.server.Server;
public class OneHandler public class OneHandler
{ {
public static Server createServer(int port)
{
Server server = new Server(port);
server.setHandler(new HelloHandler());
return server;
}
public static void main(String[] args) throws Exception public static void main(String[] args) throws Exception
{ {
Server server = new Server(8080); int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
server.setHandler(new HelloHandler()); Server server = createServer(port);
server.start(); server.start();
server.join(); server.join();
} }

View File

@ -1,26 +1,27 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.EnumSet; import java.util.EnumSet;
import javax.servlet.DispatcherType;
import javax.servlet.Filter; import javax.servlet.Filter;
import javax.servlet.FilterChain; import javax.servlet.FilterChain;
import javax.servlet.FilterConfig; import javax.servlet.FilterConfig;
@ -31,38 +32,59 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestEvent; import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener; import javax.servlet.ServletRequestListener;
import javax.servlet.ServletResponse; import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.DefaultServlet; import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ListenerHolder; import org.eclipse.jetty.servlet.ListenerHolder;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.resource.PathResource;
import org.eclipse.jetty.util.resource.Resource;
import static javax.servlet.DispatcherType.ASYNC;
import static javax.servlet.DispatcherType.REQUEST;
public class OneServletContext public class OneServletContext
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port, Resource baseResource)
{ {
Server server = new Server(8080); Server server = new Server(port);
ServletContextHandler context = new ServletContextHandler( ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
ServletContextHandler.SESSIONS);
context.setContextPath("/"); context.setContextPath("/");
context.setResourceBase(System.getProperty("java.io.tmpdir")); context.setBaseResource(baseResource);
server.setHandler(context); server.setHandler(context);
// Add dump servlet // add hello servlet
context.addServlet(
context.addServlet(DumpServlet.class, "/dump/*"),
"*.dump");
context.addServlet(HelloServlet.class, "/hello/*"); context.addServlet(HelloServlet.class, "/hello/*");
// Add dump servlet on multiple url-patterns
ServletHolder debugHolder = new ServletHolder("debug", DumpServlet.class);
context.addServlet(debugHolder, "/dump/*");
context.addServlet(debugHolder, "*.dump");
// add default servlet (for error handling and static resources)
context.addServlet(DefaultServlet.class, "/"); context.addServlet(DefaultServlet.class, "/");
context.addFilter(TestFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); // sprinkle in a few filters to demonstrate behaviors
context.addFilter(TestFilter.class, "/test", EnumSet.of(DispatcherType.REQUEST, DispatcherType.ASYNC)); context.addFilter(TestFilter.class, "/test/*", EnumSet.of(REQUEST));
context.addFilter(TestFilter.class, "*.test", EnumSet.of(DispatcherType.REQUEST, DispatcherType.INCLUDE, DispatcherType.FORWARD)); context.addFilter(TestFilter.class, "*.test", EnumSet.of(REQUEST, ASYNC));
// and a few listeners to show other ways of working with servlets
context.getServletHandler().addListener(new ListenerHolder(InitListener.class)); context.getServletHandler().addListener(new ListenerHolder(InitListener.class));
context.getServletHandler().addListener(new ListenerHolder(RequestListener.class)); context.getServletHandler().addListener(new ListenerHolder(RequestListener.class));
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Path tempDir = Paths.get(System.getProperty("java.io.tmpdir"));
Server server = createServer(port, new PathResource(tempDir));
server.start(); server.start();
server.dumpStdErr(); server.dumpStdErr();
server.join(); server.join();
@ -71,14 +93,18 @@ public class OneServletContext
public static class TestFilter implements Filter public static class TestFilter implements Filter
{ {
@Override @Override
public void init(FilterConfig filterConfig) throws ServletException public void init(FilterConfig filterConfig)
{ {
} }
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{ {
if (response instanceof HttpServletResponse)
{
HttpServletResponse httpServletResponse = (HttpServletResponse)response;
httpServletResponse.setHeader("X-TestFilter", "true");
}
chain.doFilter(request, response); chain.doFilter(request, response);
} }
@ -94,6 +120,7 @@ public class OneServletContext
@Override @Override
public void contextInitialized(ServletContextEvent sce) public void contextInitialized(ServletContextEvent sce)
{ {
sce.getServletContext().setAttribute("X-Init", "true");
} }
@Override @Override
@ -105,15 +132,14 @@ public class OneServletContext
public static class RequestListener implements ServletRequestListener public static class RequestListener implements ServletRequestListener
{ {
@Override @Override
public void requestDestroyed(ServletRequestEvent sre) public void requestInitialized(ServletRequestEvent sre)
{ {
sre.getServletRequest().setAttribute("X-ReqListener", "true");
} }
@Override @Override
public void requestInitialized(ServletRequestEvent sre) public void requestDestroyed(ServletRequestEvent sre)
{ {
} }
} }
} }

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
@ -28,9 +28,10 @@ import org.eclipse.jetty.servlet.ServletContextHandler;
public class OneServletContextJmxStats public class OneServletContextJmxStats
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port)
{ {
Server server = new Server(8080); Server server = new Server(port);
// Add JMX tracking to Server // Add JMX tracking to Server
server.addBean(new MBeanContainer(ManagementFactory server.addBean(new MBeanContainer(ManagementFactory
.getPlatformMBeanServer())); .getPlatformMBeanServer()));
@ -45,6 +46,13 @@ public class OneServletContextJmxStats
// Add Connector Statistics tracking to all connectors // Add Connector Statistics tracking to all connectors
ServerConnectionStatistics.addToAllConnectors(server); ServerConnectionStatistics.addToAllConnectors(server);
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
server.start(); server.start();
server.join(); server.join();

View File

@ -1,41 +1,46 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.session.DefaultSessionCache; import org.eclipse.jetty.server.session.DefaultSessionCache;
import org.eclipse.jetty.server.session.NullSessionDataStore; import org.eclipse.jetty.server.session.NullSessionDataStore;
import org.eclipse.jetty.server.session.SessionCache; import org.eclipse.jetty.server.session.SessionCache;
import org.eclipse.jetty.server.session.SessionHandler; import org.eclipse.jetty.server.session.SessionHandler;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.resource.PathResource;
import org.eclipse.jetty.util.resource.Resource;
public class OneServletContextWithSession public class OneServletContextWithSession
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port, Resource baseResource)
{ {
Server server = new Server(8080); Server server = new Server(port);
// Create a ServletContext, with a session handler enabled. // Create a ServletContext, with a session handler enabled.
ServletContextHandler context = new ServletContextHandler( ServletContextHandler context = new ServletContextHandler(
ServletContextHandler.SESSIONS); ServletContextHandler.SESSIONS);
context.setContextPath("/"); context.setContextPath("/");
context.setResourceBase(System.getProperty("java.io.tmpdir")); context.setBaseResource(baseResource);
server.setHandler(context); server.setHandler(context);
// Access the SessionHandler from the context. // Access the SessionHandler from the context.
@ -55,6 +60,15 @@ public class OneServletContextWithSession
// Servlet to read/set the greeting stored in the session. // Servlet to read/set the greeting stored in the session.
// Can be accessed using http://localhost:8080/hello // Can be accessed using http://localhost:8080/hello
context.addServlet(HelloSessionServlet.class, "/"); context.addServlet(HelloSessionServlet.class, "/");
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Path dir = Paths.get(System.getProperty("user.dir"));
PathResource baseResource = new PathResource(dir);
Server server = createServer(port, baseResource);
server.start(); server.start();
server.dumpStdErr(); server.dumpStdErr();

View File

@ -1,45 +1,38 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.io.File; import java.io.File;
import java.lang.management.ManagementFactory;
import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.Configurations; import org.eclipse.jetty.webapp.Configurations;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
public class OneWebApp public class OneWebApp
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port)
{ {
// Create a basic jetty server object that will listen on port 8080. // Create a basic jetty server object that will listen on port 8080.
// Note that if you set this to port 0 then a randomly available port // Note that if you set this to port 0 then a randomly available port
// will be assigned that you can either look in the logs for the port, // will be assigned that you can either look in the logs for the port,
// or programmatically obtain it for use in test cases. // or programmatically obtain it for use in test cases.
Server server = new Server(8080); Server server = new Server(port);
// Setup JMX
MBeanContainer mbContainer = new MBeanContainer(
ManagementFactory.getPlatformMBeanServer());
server.addBean(mbContainer);
// The WebAppContext is the entity that controls the environment in // The WebAppContext is the entity that controls the environment in
// which a web application lives and breathes. In this example the // which a web application lives and breathes. In this example the
@ -56,6 +49,13 @@ public class OneWebApp
// A WebAppContext is a ContextHandler as well so it needs to be set to // A WebAppContext is a ContextHandler as well so it needs to be set to
// the server so it is aware of where to send the appropriate requests. // the server so it is aware of where to send the appropriate requests.
server.setHandler(webapp); server.setHandler(webapp);
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
Configurations.setServerDefault(server); Configurations.setServerDefault(server);
@ -66,7 +66,6 @@ public class OneWebApp
// The use of server.join() the will make the current thread join and // The use of server.join() the will make the current thread join and
// wait until the server is done executing. // wait until the server is done executing.
// See http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#join()
server.join(); server.join();
} }
} }

View File

@ -1,66 +1,62 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.io.File; import java.io.FileNotFoundException;
import java.lang.management.ManagementFactory; import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import org.eclipse.jetty.annotations.AnnotationConfiguration; import org.eclipse.jetty.annotations.AnnotationConfiguration;
import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.security.HashLoginService; import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.resource.PathResource;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
public class OneWebAppWithJsp public class OneWebAppWithJsp
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port) throws FileNotFoundException
{ {
// Create a basic jetty server object that will listen on port 8080. // Create a basic jetty server object that will listen on port 8080.
// Note that if you set this to port 0 then // Note that if you set this to port 0 then
// a randomly available port will be assigned that you can either look // a randomly available port will be assigned that you can either look
// in the logs for the port, // in the logs for the port,
// or programmatically obtain it for use in test cases. // or programmatically obtain it for use in test cases.
Server server = new Server(8080); Server server = new Server(port);
// Setup JMX
MBeanContainer mbContainer = new MBeanContainer(
ManagementFactory.getPlatformMBeanServer());
server.addBean(mbContainer);
// The WebAppContext is the entity that controls the environment in // The WebAppContext is the entity that controls the environment in
// which a web application lives and // which a web application lives and breathes.
// breathes. In this example the context path is being set to "/" so it // In this example the context path is being set to "/" so it
// is suitable for serving root context // is suitable for serving root context
// requests and then we see it setting the location of the war. A whole // requests and then we see it setting the location of the war.
// host of other configurations are // A whole host of other configurations are
// available, ranging from configuring to support annotation scanning in // available, ranging from configuring to support annotation scanning in
// the webapp (through // the webapp (through PlusConfiguration), to choosing where
// PlusConfiguration) to choosing where the webapp will unpack itself. // the webapp will unpack itself.
WebAppContext webapp = new WebAppContext(); WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/"); webapp.setContextPath("/");
File warFile = new File( Path warFile = JettyDistribution.resolve("demo-base/webapps/test.war");
"jetty-distribution/target/distribution/demo-base/webapps/test.war"); if (!Files.exists(warFile))
if (!warFile.exists())
{ {
throw new RuntimeException("Unable to find WAR File: " + warFile.getAbsolutePath()); throw new FileNotFoundException(warFile.toString());
} }
webapp.setWar(warFile.getAbsolutePath()); webapp.setWarResource(new PathResource(warFile));
webapp.setExtractWAR(true); webapp.setExtractWAR(true);
// This webapp will use jsps and jstl. We need to enable the // This webapp will use jsps and jstl. We need to enable the
@ -89,19 +85,32 @@ public class OneWebAppWithJsp
// its own we register it as a bean with the Jetty server object so it // its own we register it as a bean with the Jetty server object so it
// can be started and stopped according to the lifecycle of the server // can be started and stopped according to the lifecycle of the server
// itself. // itself.
String realmResourceName = "etc/realm.properties";
ClassLoader classLoader = OneWebAppWithJsp.class.getClassLoader();
URL realmProps = classLoader.getResource(realmResourceName);
if (realmProps == null)
throw new FileNotFoundException("Unable to find " + realmResourceName);
HashLoginService loginService = new HashLoginService(); HashLoginService loginService = new HashLoginService();
loginService.setName("Test Realm"); loginService.setName("Test Realm");
loginService.setConfig("examples/embedded/src/test/resources/realm.properties"); loginService.setConfig(realmProps.toExternalForm());
server.addBean(loginService); server.addBean(loginService);
// Start things up! return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
// Start things up!
server.start(); server.start();
server.dumpStdErr(); server.dumpStdErr();
// The use of server.join() the will make the current thread join and // The use of server.join() the will make the current thread join and
// wait until the server is done executing. // wait until the server is done executing.
// See http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#join()
server.join(); server.join();
} }
} }

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
@ -27,11 +27,13 @@ import org.eclipse.jetty.servlet.ServletHolder;
public class ProxyServer public class ProxyServer
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port)
{ {
Server server = new Server(); Server server = new Server();
// Establish listening connector
ServerConnector connector = new ServerConnector(server); ServerConnector connector = new ServerConnector(server);
connector.setPort(8888); connector.setPort(port);
server.addConnector(connector); server.addConnector(connector);
// Setup proxy handler to handle CONNECT methods // Setup proxy handler to handle CONNECT methods
@ -45,6 +47,15 @@ public class ProxyServer
proxyServlet.setInitParameter("blackList", "www.eclipse.org"); proxyServlet.setInitParameter("blackList", "www.eclipse.org");
context.addServlet(proxyServlet, "/*"); context.addServlet(proxyServlet, "/*");
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
server.start(); server.start();
server.join();
} }
} }

View File

@ -1,44 +1,46 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.util.Arrays;
import org.eclipse.jetty.rewrite.RewriteCustomizer; import org.eclipse.jetty.rewrite.RewriteCustomizer;
import org.eclipse.jetty.rewrite.handler.CompactPathRule; import org.eclipse.jetty.rewrite.handler.CompactPathRule;
import org.eclipse.jetty.rewrite.handler.RewriteRegexRule; import org.eclipse.jetty.rewrite.handler.RewriteRegexRule;
import org.eclipse.jetty.server.HttpConfiguration;
import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.HttpConnectionFactory;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
public class RewriteServer public class RewriteServer
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port)
{ {
Server server = new Server(8080); Server server = new Server(port);
HttpConfiguration config = server.getConnectors()[0].getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration();
RewriteCustomizer rewrite = new RewriteCustomizer(); RewriteCustomizer rewrite = new RewriteCustomizer();
config.addCustomizer(rewrite);
rewrite.addRule(new CompactPathRule()); rewrite.addRule(new CompactPathRule());
rewrite.addRule(new RewriteRegexRule("(.*)foo(.*)", "$1FOO$2")); rewrite.addRule(new RewriteRegexRule("(.*)foo(.*)", "$1FOO$2"));
Arrays.stream(server.getConnectors())
.forEach((connector) -> connector.getConnectionFactory(HttpConnectionFactory.class)
.getHttpConfiguration().addCustomizer(rewrite));
ServletContextHandler context = new ServletContextHandler( ServletContextHandler context = new ServletContextHandler(
ServletContextHandler.SESSIONS); ServletContextHandler.SESSIONS);
context.setContextPath("/"); context.setContextPath("/");
@ -46,6 +48,14 @@ public class RewriteServer
context.addServlet(DumpServlet.class, "/*"); context.addServlet(DumpServlet.class, "/*");
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
server.start(); server.start();
server.join(); server.join();
} }

View File

@ -1,23 +1,25 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.io.FileNotFoundException;
import java.net.URL;
import java.util.Collections; import java.util.Collections;
import org.eclipse.jetty.security.ConstraintMapping; import org.eclipse.jetty.security.ConstraintMapping;
@ -30,13 +32,13 @@ import org.eclipse.jetty.util.security.Constraint;
public class SecuredHelloHandler public class SecuredHelloHandler
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port) throws FileNotFoundException
{ {
// Create a basic jetty server object that will listen on port 8080. // Create a basic jetty server object that will listen on port 8080.
// Note that if you set this to port 0 then a randomly available port // Note that if you set this to port 0 then a randomly available port
// will be assigned that you can either look in the logs for the port, // will be assigned that you can either look in the logs for the port,
// or programmatically obtain it for use in test cases. // or programmatically obtain it for use in test cases.
Server server = new Server(8080); Server server = new Server(port);
// Since this example is for our test webapp, we need to setup a // Since this example is for our test webapp, we need to setup a
// LoginService so this shows how to create a very simple hashmap based // LoginService so this shows how to create a very simple hashmap based
@ -46,8 +48,14 @@ public class SecuredHelloHandler
// started and stopped according to the lifecycle of the server itself. // started and stopped according to the lifecycle of the server itself.
// In this example the name can be whatever you like since we are not // In this example the name can be whatever you like since we are not
// dealing with webapp realms. // dealing with webapp realms.
String realmResourceName = "etc/realm.properties";
ClassLoader classLoader = SecuredHelloHandler.class.getClassLoader();
URL realmProps = classLoader.getResource(realmResourceName);
if (realmProps == null)
throw new FileNotFoundException("Unable to find " + realmResourceName);
LoginService loginService = new HashLoginService("MyRealm", LoginService loginService = new HashLoginService("MyRealm",
"src/test/resources/realm.properties"); realmProps.toExternalForm());
server.addBean(loginService); server.addBean(loginService);
// A security handler is a jetty handler that secures content behind a // A security handler is a jetty handler that secures content behind a
@ -68,7 +76,7 @@ public class SecuredHelloHandler
constraint.setRoles(new String[]{"user", "admin"}); constraint.setRoles(new String[]{"user", "admin"});
// Binds a url pattern with the previously created constraint. The roles // Binds a url pattern with the previously created constraint. The roles
// for this constraing mapping are mined from the Constraint itself // for this constraint mapping are mined from the Constraint itself
// although methods exist to declare and bind roles separately as well. // although methods exist to declare and bind roles separately as well.
ConstraintMapping mapping = new ConstraintMapping(); ConstraintMapping mapping = new ConstraintMapping();
mapping.setPathSpec("/*"); mapping.setPathSpec("/*");
@ -92,13 +100,19 @@ public class SecuredHelloHandler
// chain the hello handler into the security handler // chain the hello handler into the security handler
security.setHandler(hh); security.setHandler(hh);
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
// Start things up! // Start things up!
server.start(); server.start();
// The use of server.join() the will make the current thread join and // The use of server.join() the will make the current thread join and
// wait until the server is done executing. // wait until the server is done executing.
// See
// http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#join()
server.join(); server.join();
} }
} }

View File

@ -1,24 +1,27 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.net.URL;
import javax.naming.NamingException;
import org.eclipse.jetty.annotations.AnnotationConfiguration; import org.eclipse.jetty.annotations.AnnotationConfiguration;
import org.eclipse.jetty.plus.jndi.EnvEntry; import org.eclipse.jetty.plus.jndi.EnvEntry;
@ -36,10 +39,10 @@ import org.eclipse.jetty.webapp.WebAppContext;
*/ */
public class ServerWithAnnotations public class ServerWithAnnotations
{ {
public static final void main(String[] args) throws Exception public static Server createServer(int port) throws NamingException, FileNotFoundException
{ {
// Create the server // Create the server
final Server server = new Server(8080); Server server = new Server(port);
// Create a WebApp // Create a WebApp
WebAppContext webapp = new WebAppContext(); WebAppContext webapp = new WebAppContext();
@ -60,7 +63,7 @@ public class ServerWithAnnotations
new Transaction(new com.acme.MockUserTransaction()); new Transaction(new com.acme.MockUserTransaction());
// Define an env entry with webapp scope. // Define an env entry with webapp scope.
// THIS ENTRY IS OVERRIDEN BY THE ENTRY IN jetty-env.xml // THIS ENTRY IS OVERRIDDEN BY THE ENTRY IN jetty-env.xml
new EnvEntry(webapp, "maxAmount", 100d, true); new EnvEntry(webapp, "maxAmount", 100d, true);
// Register a mock DataSource scoped to the webapp // Register a mock DataSource scoped to the webapp
@ -70,10 +73,23 @@ public class ServerWithAnnotations
server.addBean(new NamingDump()); server.addBean(new NamingDump());
// Configure a LoginService // Configure a LoginService
String realmResourceName = "etc/realm.properties";
ClassLoader classLoader = ServerWithAnnotations.class.getClassLoader();
URL realmProps = classLoader.getResource(realmResourceName);
if (realmProps == null)
throw new FileNotFoundException("Unable to find " + realmResourceName);
HashLoginService loginService = new HashLoginService(); HashLoginService loginService = new HashLoginService();
loginService.setName("Test Realm"); loginService.setName("Test Realm");
loginService.setConfig("examples/embedded/src/test/resources/realm.properties"); loginService.setConfig(realmProps.toExternalForm());
server.addBean(loginService); server.addBean(loginService);
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
server.start(); server.start();
server.dumpStdErr(); server.dumpStdErr();

View File

@ -1,24 +1,25 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.net.MalformedURLException;
import javax.management.remote.JMXServiceURL; import javax.management.remote.JMXServiceURL;
import org.eclipse.jetty.jmx.ConnectorServer; import org.eclipse.jetty.jmx.ConnectorServer;
@ -26,17 +27,16 @@ import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
/** /**
* The simplest possible Jetty server. * A Jetty Server with JMX enabled for remote connections
*/ */
public class ServerWithJMX public class ServerWithJMX
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port) throws MalformedURLException
{ {
// === jetty-jmx.xml === Server server = new Server(port);
MBeanContainer mbContainer = new MBeanContainer( MBeanContainer mbContainer = new MBeanContainer(
ManagementFactory.getPlatformMBeanServer()); ManagementFactory.getPlatformMBeanServer());
Server server = new Server(8080);
server.addBean(mbContainer); server.addBean(mbContainer);
ConnectorServer jmx = new ConnectorServer( ConnectorServer jmx = new ConnectorServer(
@ -48,6 +48,14 @@ public class ServerWithJMX
"org.eclipse.jetty.jmx:name=rmiconnectorserver"); "org.eclipse.jetty.jmx:name=rmiconnectorserver");
server.addBean(jmx); server.addBean(jmx);
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
server.start(); server.start();
server.dumpStdErr(); server.dumpStdErr();
server.join(); server.join();

View File

@ -1,29 +1,31 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.io.File; import java.nio.file.Path;
import java.util.Properties; import java.util.Properties;
import javax.naming.NamingException;
import org.eclipse.jetty.plus.webapp.EnvConfiguration; import org.eclipse.jetty.plus.webapp.EnvConfiguration;
import org.eclipse.jetty.plus.webapp.PlusConfiguration; import org.eclipse.jetty.plus.webapp.PlusConfiguration;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.resource.PathResource;
import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebAppContext;
/** /**
@ -31,18 +33,16 @@ import org.eclipse.jetty.webapp.WebAppContext;
*/ */
public class ServerWithJNDI public class ServerWithJNDI
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port) throws NamingException
{ {
// Create the server // Create the server
Server server = new Server(8080); Server server = new Server(port);
// Create a WebApp // Create a WebApp
WebAppContext webapp = new WebAppContext(); WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/"); webapp.setContextPath("/");
File warFile = new File( Path testJndiWar = JettyDistribution.resolve("demo-base/webapps/test-jndi.war");
"../../jetty-distribution/target/distribution/demo-base/webapps/test-jndi.war"); webapp.setWarResource(new PathResource(testJndiWar));
webapp.setWar(warFile.getAbsolutePath());
server.setHandler(webapp); server.setHandler(webapp);
// Enable parsing of jndi-related parts of web.xml and jetty-env.xml // Enable parsing of jndi-related parts of web.xml and jetty-env.xml
@ -74,7 +74,7 @@ public class ServerWithJNDI
// Note that the last arg of "true" means that this definition for // Note that the last arg of "true" means that this definition for
// "wiggle" would override an entry of the // "wiggle" would override an entry of the
// same name in web.xml // same name in web.xml
new org.eclipse.jetty.plus.jndi.EnvEntry(webapp, "wiggle", 100D, true); new org.eclipse.jetty.plus.jndi.EnvEntry(webapp, "wiggle", 100d, true);
// Register a reference to a mail service scoped to the webapp. // Register a reference to a mail service scoped to the webapp.
// This must be linked to the webapp by an entry in web.xml: // This must be linked to the webapp by an entry in web.xml:
@ -84,7 +84,8 @@ public class ServerWithJNDI
// <res-auth>Container</res-auth> // <res-auth>Container</res-auth>
// </resource-ref> // </resource-ref>
// At runtime the webapp accesses this as java:comp/env/mail/Session // At runtime the webapp accesses this as java:comp/env/mail/Session
org.eclipse.jetty.jndi.factories.MailSessionReference mailref = new org.eclipse.jetty.jndi.factories.MailSessionReference(); org.eclipse.jetty.jndi.factories.MailSessionReference mailref =
new org.eclipse.jetty.jndi.factories.MailSessionReference();
mailref.setUser("CHANGE-ME"); mailref.setUser("CHANGE-ME");
mailref.setPassword("CHANGE-ME"); mailref.setPassword("CHANGE-ME");
Properties props = new Properties(); Properties props = new Properties();
@ -106,6 +107,13 @@ public class ServerWithJNDI
// java:comp/env/jdbc/mydatasource // java:comp/env/jdbc/mydatasource
new org.eclipse.jetty.plus.jndi.Resource( new org.eclipse.jetty.plus.jndi.Resource(
webapp, "jdbc/mydatasource", new com.acme.MockDataSource()); webapp, "jdbc/mydatasource", new com.acme.MockDataSource());
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
server.start(); server.start();
server.join(); server.join();

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
@ -25,11 +25,20 @@ import org.eclipse.jetty.server.Server;
*/ */
public class SimplestServer public class SimplestServer
{ {
public static Server createServer(int port)
{
Server server = new Server(port);
// This has a connector listening on port specified
// and no handlers, meaning all requests will result
// in a 404 response
return server;
}
public static void main(String[] args) throws Exception public static void main(String[] args) throws Exception
{ {
Server server = new Server(8080); int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
server.start(); server.start();
server.dumpStdErr();
server.join(); server.join();
} }
} }

View File

@ -1,33 +1,31 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import java.io.File; import java.nio.file.Paths;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandlerCollection; import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.util.resource.PathResource;
import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.resource.Resource;
/** /**
@ -37,59 +35,68 @@ import org.eclipse.jetty.util.resource.Resource;
*/ */
public class SplitFileServer public class SplitFileServer
{ {
public static void main(String[] args) throws Exception public static Server createServer(int port, Resource baseResource0, Resource baseResource1)
{ {
// Create the Server object and a corresponding ServerConnector and then // Create the Server object and a corresponding ServerConnector and then
// set the port for the connector. In this example the server will // set the port for the connector. In this example the server will
// listen on port 8090. If you set this to port 0 then when the server // listen on port 8080. If you set this to port 0 then when the server
// has been started you can called connector.getLocalPort() to // has been started you can called connector.getLocalPort() to
// programmatically get the port the server started on. // programmatically get the port the server started on.
Server server = new Server(); Server server = new Server();
ServerConnector connector = new ServerConnector(server); ServerConnector connector = new ServerConnector(server);
connector.setPort(8090); connector.setPort(port);
server.setConnectors(new Connector[]{connector}); server.addConnector(connector);
// Create a Context Handler and ResourceHandler. The ContextHandler is // Create a Context Handler and ResourceHandler. The ContextHandler is
// getting set to "/" path but this could be anything you like for // getting set to "/" path but this could be anything you like for
// builing out your url. Note how we are setting the ResourceBase using // building out your url. Note how we are setting the ResourceBase using
// our jetty maven testing utilities to get the proper resource // our jetty maven testing utilities to get the proper resource
// directory, you needn't use these, you simply need to supply the paths // directory, you needn't use these, you simply need to supply the paths
// you are looking to serve content from. // you are looking to serve content from.
ResourceHandler rh0 = new ResourceHandler(); ResourceHandler rh0 = new ResourceHandler();
rh0.setDirectoriesListed(false);
ContextHandler context0 = new ContextHandler(); ContextHandler context0 = new ContextHandler();
context0.setContextPath("/"); context0.setContextPath("/");
File dir0 = MavenTestingUtils.getTestResourceDir("dir0"); context0.setBaseResource(baseResource0);
context0.setBaseResource(Resource.newResource(dir0));
context0.setHandler(rh0); context0.setHandler(rh0);
// Rinse and repeat the previous item, only specifying a different // Rinse and repeat the previous item, only specifying a different
// resource base. // resource base.
ResourceHandler rh1 = new ResourceHandler(); ResourceHandler rh1 = new ResourceHandler();
rh1.setDirectoriesListed(false);
ContextHandler context1 = new ContextHandler(); ContextHandler context1 = new ContextHandler();
context1.setContextPath("/"); context1.setContextPath("/");
File dir1 = MavenTestingUtils.getTestResourceDir("dir1"); context1.setBaseResource(baseResource1);
context1.setBaseResource(Resource.newResource(dir1));
context1.setHandler(rh1); context1.setHandler(rh1);
// Create a ContextHandlerCollection and set the context handlers to it. // Create a ContextHandlerCollection and set the context handlers to it.
// This will let jetty process urls against the declared contexts in // This will let jetty process urls against the declared contexts in
// order to match up content. // order to match up content.
ContextHandlerCollection contexts = new ContextHandlerCollection(); ContextHandlerCollection contexts = new ContextHandlerCollection(
contexts.setHandlers(new Handler[]{context0, context1}); context0, context1
);
server.setHandler(contexts); server.setHandler(contexts);
return server;
}
// Start things up! public static void main(String[] args) throws Exception
server.start(); {
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Resource resource0 = new PathResource(Paths.get("src/test/resources/dir0"));
Resource resource1 = new PathResource(Paths.get("src/test/resources/dir1"));
Server server = createServer(port, resource0, resource1);
// Dump the server state // Dump the server state
System.out.println(server.dump()); server.setDumpAfterStart(true);
// Start things up!
server.start();
// The use of server.join() the will make the current thread join and // The use of server.join() the will make the current thread join and
// wait until the server is done executing. // wait until the server is done executing.
// See http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#join()
server.join(); server.join();
} }
} }

View File

@ -1,19 +1,19 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
@ -26,7 +26,7 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerList; import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.websocket.javax.server.JavaxWebSocketServletContainerInitializer; import org.eclipse.jetty.websocket.javax.server.config.JavaxWebSocketServletContainerInitializer;
/** /**
* Example of setting up a javax.websocket server with Jetty embedded * Example of setting up a javax.websocket server with Jetty embedded
@ -46,25 +46,37 @@ public class WebSocketJsrServer
} }
} }
public static void main(String[] args) throws Exception public static Server createServer(int port)
{ {
final Server server = new Server(8080); Server server = new Server(port);
HandlerList handlers = new HandlerList(); HandlerList handlers = new HandlerList();
ServletContextHandler contextHandler = new ServletContextHandler( ServletContextHandler context = new ServletContextHandler();
ServletContextHandler.SESSIONS); context.setContextPath("/");
contextHandler.setContextPath("/"); handlers.addHandler(context);
handlers.addHandler(contextHandler);
// Enable javax.websocket configuration for the context
JavaxWebSocketServletContainerInitializer.configure(context,
(servletContext, serverContainer) ->
{
// Add your websocket to the javax.websocket.server.ServerContainer
serverContainer.addEndpoint(EchoJsrSocket.class);
}
);
handlers.addHandler(new DefaultHandler()); handlers.addHandler(new DefaultHandler());
server.setHandler(handlers); server.setHandler(handlers);
// Enable javax.websocket configuration for the context return server;
JavaxWebSocketServletContainerInitializer.configure(contextHandler, (context, container) -> }
container.addEndpoint(EchoJsrSocket.class));
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
server.start(); server.start();
contextHandler.dumpStdErr();
server.join(); server.join();
} }
} }

View File

@ -1,32 +1,32 @@
// //
// ======================================================================== // ========================================================================
// Copyright (c) 1995-2019 Mort Bay Consulting Pty. Ltd. // Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
// //
// The Eclipse Public License is available at // This program and the accompanying materials are made available under
// http://www.eclipse.org/legal/epl-v10.html // the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
// //
// The Apache License v2.0 is available at // This Source Code may also be made available under the following
// http://www.opensource.org/licenses/apache2.0.php // Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
// //
// You may elect to redistribute this code under either of these licenses. // SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ======================================================================== // ========================================================================
// //
package org.eclipse.jetty.embedded; package org.eclipse.jetty.embedded;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.api.WriteCallback;
import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
import org.eclipse.jetty.websocket.api.annotations.WebSocket; import org.eclipse.jetty.websocket.api.annotations.WebSocket;
import org.eclipse.jetty.websocket.server.JettyWebSocketServlet; import org.eclipse.jetty.websocket.server.JettyWebSocketServlet;
import org.eclipse.jetty.websocket.server.JettyWebSocketServletFactory; import org.eclipse.jetty.websocket.server.JettyWebSocketServletFactory;
import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
/** /**
* Example of setting up a Jetty WebSocket server * Example of setting up a Jetty WebSocket server
@ -61,20 +61,29 @@ public class WebSocketServer
} }
} }
public static void main(String[] args) throws Exception public static Server createServer(int port)
{ {
Server server = new Server(8080); Server server = new Server(port);
ServletContextHandler context = new ServletContextHandler( ServletContextHandler context = new ServletContextHandler();
ServletContextHandler.SESSIONS);
context.setContextPath("/"); context.setContextPath("/");
server.setHandler(context); server.setHandler(context);
// Add the echo socket servlet to the /echo path map // Add the echo socket servlet to the /echo path map
context.addServlet(new ServletHolder(EchoServlet.class), "/echo"); context.addServlet(EchoServlet.class, "/echo");
// Configure context to support WebSocket
JettyWebSocketServletContainerInitializer.configure(context, null);
return server;
}
public static void main(String[] args) throws Exception
{
int port = ExampleUtil.getPort(args, "jetty.http.port", 8080);
Server server = createServer(port);
server.start(); server.start();
context.dumpStdErr();
server.join(); server.join();
} }
} }

Binary file not shown.

View File

@ -0,0 +1,20 @@
#
# This file defines users passwords and roles for a HashUserRealm
#
# The format is
# <username>: <password>[,<rolename> ...]
#
# Passwords may be clear text, obfuscated or checksummed. The class
# org.eclipse.jetty.util.security.Password should be used to generate obfuscated
# passwords or password checksums
#
# If DIGEST Authentication is used, the password must be in a recoverable
# format, either plain text or OBF:.
#
jetty:MD5:164c88b302622e17050af52c89945d44,user
admin:CRYPT:adpexzg3FUZAk,server-administrator,content-administrator,admin,user
other:OBF:1xmk1w261u9r1w1c1xmq,user
plain:plain,user
user:password,user
# This entry is for digest auth. The credential is a MD5 hash of username:realmname:password
digest:MD5:6e120743ad67abfbc385bc2bb754e297,user

View File

@ -8,7 +8,9 @@
<Item> <Item>
<New class="org.eclipse.jetty.server.ServerConnector"> <New class="org.eclipse.jetty.server.ServerConnector">
<Arg><Ref refid="ExampleServer"/></Arg> <Arg><Ref refid="ExampleServer"/></Arg>
<Set name="port">8080</Set> <Set name="port">
<Property name="http.port" default="8080" />
</Set>
</New> </New>
</Item> </Item>
</Array> </Array>

View File

@ -7,7 +7,9 @@
<Arg> <Arg>
<New class="org.eclipse.jetty.server.ServerConnector"> <New class="org.eclipse.jetty.server.ServerConnector">
<Arg><Ref refid="FileServer"/></Arg> <Arg><Ref refid="FileServer"/></Arg>
<Set name="port">8080</Set> <Set name="port">
<Property name="http.port" default="8080" />
</Set>
</New> </New>
</Arg> </Arg>
</Call> </Call>
@ -22,7 +24,9 @@
<Set name="welcomeFiles"> <Set name="welcomeFiles">
<Array type="String"><Item>index.html</Item></Array> <Array type="String"><Item>index.html</Item></Array>
</Set> </Set>
<Set name="resourceBase">.</Set> <Set name="resourceBase">
<Property name="fileserver.baseresource" default="." />
</Set>
</New> </New>
</Item> </Item>
<Item> <Item>

View File

@ -1,4 +1,4 @@
#org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.JavaUtilLog ## Jetty Logging using jetty-slf4j-impl
#org.eclipse.jetty.util.log.javautil.PROPERTIES=java-util-logging.properties #org.eclipse.jetty.util.log.javautil.PROPERTIES=java-util-logging.properties
#org.eclipse.jetty.util.log.SOURCE=true #org.eclipse.jetty.util.log.SOURCE=true
#org.eclipse.jetty.LEVEL=INFO #org.eclipse.jetty.LEVEL=INFO

View File

@ -0,0 +1,64 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.http.HttpClientTransportOverHTTP;
import org.eclipse.jetty.io.ClientConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
public abstract class AbstractEmbeddedTest
{
public HttpClient client;
@BeforeEach
public void startClient() throws Exception
{
SslContextFactory.Client sslContextFactory = new SslContextFactory.Client();
sslContextFactory.setTrustAll(true);
ClientConnector clientConnector = new ClientConnector();
clientConnector.setSelectors(1);
clientConnector.setSslContextFactory(sslContextFactory);
QueuedThreadPool clientThreads = new QueuedThreadPool();
clientThreads.setName("client");
clientConnector.setExecutor(clientThreads);
client = new HttpClient(new HttpClientTransportOverHTTP(clientConnector));
client.start();
}
@AfterEach
public void stopClient() throws Exception
{
client.stop();
}
protected void dumpResponseHeaders(ContentResponse response)
{
System.out.printf("%s %s %s%n", response.getVersion(), response.getStatus(), response.getReason());
System.out.println(response.getHeaders());
}
}

View File

@ -0,0 +1,90 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.net.URI;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.client.util.StringContentProvider;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
public class ExampleServerTest extends AbstractEmbeddedTest
{
private Server server;
@BeforeEach
public void startServer() throws Exception
{
server = ExampleServer.createServer(0);
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testGetHello() throws Exception
{
URI uri = server.getURI().resolve("/hello");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Hello"));
}
@Test
public void testGetEcho() throws Exception
{
URI uri = server.getURI().resolve("/echo/a/greeting");
String postBody = "Greetings from " + ExampleServerTest.class;
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.POST)
.content(new StringContentProvider(postBody))
.send();
// Check the response status code
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString(postBody));
}
}

View File

@ -0,0 +1,67 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.net.URI;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
public class ExampleServerXmlTest extends AbstractEmbeddedTest
{
private Server server;
@BeforeEach
public void startServer() throws Exception
{
server = ExampleServerXml.createServer(0);
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testGetHello() throws Exception
{
URI uri = server.getURI().resolve("/hello");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Hello"));
}
}

View File

@ -0,0 +1,92 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.io.BufferedWriter;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
@ExtendWith(WorkDirExtension.class)
public class FastFileServerTest extends AbstractEmbeddedTest
{
private static final String TEXT_CONTENT = "I am an old man and I have known a great " +
"many troubles, but most of them never happened. - Mark Twain";
public WorkDir workDir;
private Server server;
@BeforeEach
public void startServer() throws Exception
{
Path baseDir = workDir.getEmptyPathDir();
Path textFile = baseDir.resolve("simple.txt");
try (BufferedWriter writer = Files.newBufferedWriter(textFile, UTF_8))
{
writer.write(TEXT_CONTENT);
}
server = FastFileServer.createServer(0, baseDir.toFile());
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testGetSimpleText() throws Exception
{
URI uri = server.getURI().resolve("/simple.txt");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
HttpFields responseHeaders = response.getHeaders();
assertThat("Content-Type", responseHeaders.get("Content-Type"), is("text/plain"));
assertThat("Content-Length", responseHeaders.getLongField("Content-Length"),
is((long)TEXT_CONTENT.length()));
// test response content
String responseBody = response.getContentAsString();
assertThat("Response body", responseBody, is(TEXT_CONTENT));
}
}

View File

@ -0,0 +1,93 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.io.BufferedWriter;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
import org.eclipse.jetty.util.resource.PathResource;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
@ExtendWith(WorkDirExtension.class)
public class FileServerTest extends AbstractEmbeddedTest
{
private static final String TEXT_CONTENT = "I am an old man and I have known a great " +
"many troubles, but most of them never happened. - Mark Twain";
public WorkDir workDir;
private Server server;
@BeforeEach
public void startServer() throws Exception
{
Path baseDir = workDir.getEmptyPathDir();
Path textFile = baseDir.resolve("simple.txt");
try (BufferedWriter writer = Files.newBufferedWriter(textFile, UTF_8))
{
writer.write(TEXT_CONTENT);
}
server = FileServer.createServer(0, new PathResource(baseDir));
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testGetSimpleText() throws Exception
{
URI uri = server.getURI().resolve("/simple.txt");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
HttpFields responseHeaders = response.getHeaders();
assertThat("Content-Type", responseHeaders.get("Content-Type"), is("text/plain"));
assertThat("Content-Length", responseHeaders.getLongField("Content-Length"),
is((long)TEXT_CONTENT.length()));
// test response content
String responseBody = response.getContentAsString();
assertThat("Response body", responseBody, is(TEXT_CONTENT));
}
}

View File

@ -0,0 +1,92 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.io.BufferedWriter;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
@ExtendWith(WorkDirExtension.class)
public class FileServerXmlTest extends AbstractEmbeddedTest
{
private static final String TEXT_CONTENT = "I am an old man and I have known a great " +
"many troubles, but most of them never happened. - Mark Twain";
public WorkDir workDir;
private Server server;
@BeforeEach
public void startServer() throws Exception
{
Path baseDir = workDir.getEmptyPathDir();
Path textFile = baseDir.resolve("simple.txt");
try (BufferedWriter writer = Files.newBufferedWriter(textFile, UTF_8))
{
writer.write(TEXT_CONTENT);
}
server = FileServerXml.createServer(0, baseDir);
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testGetSimpleText() throws Exception
{
URI uri = server.getURI().resolve("/simple.txt");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
HttpFields responseHeaders = response.getHeaders();
assertThat("Content-Type", responseHeaders.get("Content-Type"), is("text/plain"));
assertThat("Content-Length", responseHeaders.getLongField("Content-Length"),
is((long)TEXT_CONTENT.length()));
// test response content
String responseBody = response.getContentAsString();
assertThat("Response body", responseBody, is(TEXT_CONTENT));
}
}

View File

@ -0,0 +1,83 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.net.URI;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
public class JarServerTest extends AbstractEmbeddedTest
{
private Server server;
@BeforeEach
public void startServer() throws Exception
{
server = JarServer.createServer(0);
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testGetDir0Test0() throws Exception
{
URI uri = server.getURI().resolve("/dir0/test0.txt");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("test0"));
}
@Test
public void testGetDir1Test1() throws Exception
{
URI uri = server.getURI().resolve("/dir1/test1.txt");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("test1"));
}
}

View File

@ -0,0 +1,97 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.net.URI;
import java.util.Map;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.component.LifeCycle;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
public class LikeJettyXmlTest extends AbstractEmbeddedTest
{
private Server server;
private URI serverPlainUri;
private URI serverSslUri;
@BeforeEach
public void startServer() throws Exception
{
assumeTrue(JettyDistribution.DISTRIBUTION != null, "jetty-distribution not found");
server = LikeJettyXml.createServer(0, 0, false);
server.start();
Map<String, Integer> ports = ServerUtil.fixDynamicPortConfigurations(server);
// Establish base URI's that use "localhost" to prevent tripping over
// the "REMOTE ACCESS" warnings in demo-base
serverPlainUri = URI.create("http://localhost:" + ports.get("plain") + "/");
serverSslUri = URI.create("https://localhost:" + ports.get("secure") + "/");
}
@AfterEach
public void stopServer() throws Exception
{
LifeCycle.stop(server);
}
@Test
public void testGetTest() throws Exception
{
URI uri = serverPlainUri.resolve("/test/");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Hello"));
}
@Test
public void testGetTestSsl() throws Exception
{
URI uri = serverSslUri.resolve("/test/");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Hello"));
}
}

View File

@ -0,0 +1,95 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.net.URI;
import java.util.Map;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
public class ManyConnectorsTest extends AbstractEmbeddedTest
{
private Server server;
private URI serverPlainUri;
private URI serverSslUri;
@BeforeEach
public void startServer() throws Exception
{
server = ManyConnectors.createServer(0, 0);
server.start();
Map<String, Integer> ports = ServerUtil.fixDynamicPortConfigurations(server);
// Establish base URI's that use "localhost" to prevent tripping over
// the "REMOTE ACCESS" warnings in demo-base
serverPlainUri = URI.create("http://localhost:" + ports.get("plain") + "/");
serverSslUri = URI.create("https://localhost:" + ports.get("secure") + "/");
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testPlainGetHello() throws Exception
{
URI uri = serverPlainUri.resolve("/hello");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Hello"));
}
@Test
public void testSecureGetHello() throws Exception
{
URI uri = serverSslUri.resolve("/hello");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Hello"));
}
}

View File

@ -0,0 +1,117 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.net.URI;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
public class ManyContextsTest extends AbstractEmbeddedTest
{
private Server server;
@BeforeEach
public void startServer() throws Exception
{
server = ManyContexts.createServer(0);
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testGetRootHello() throws Exception
{
URI uri = server.getURI().resolve("/");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Root Hello"));
}
@Test
public void testGetFrenchHello() throws Exception
{
URI uri = server.getURI().resolve("/fr");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Bonjour"));
}
@Test
public void testGetItalianGoodMorning() throws Exception
{
URI uri = server.getURI().resolve("/it");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Buongiorno"));
}
@Test
public void testGetVirtualHostHello() throws Exception
{
int port = server.getURI().getPort();
URI uri = URI.create("http://127.0.0.2:" + port + "/");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Virtual Hello"));
}
}

View File

@ -0,0 +1,106 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.net.URI;
import java.util.Map;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.ajax.JSON;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
public class ManyHandlersTest extends AbstractEmbeddedTest
{
private Server server;
@BeforeEach
public void startServer() throws Exception
{
server = ManyHandlers.createServer(0);
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testGetParams() throws Exception
{
URI uri = server.getURI().resolve("/params?a=b&foo=bar");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.header(HttpHeader.ACCEPT_ENCODING, "gzip")
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test gzip
// Test that Gzip was used to produce the response
String contentEncoding = response.getHeaders().get(HttpHeader.CONTENT_ENCODING);
assertThat("Content-Encoding", contentEncoding, containsString("gzip"));
// test response content
String responseBody = response.getContentAsString();
Object jsonObj = new JSON().fromJSON(responseBody);
@SuppressWarnings("unchecked")
Map<String, Object> jsonMap = (Map<String, Object>)jsonObj;
assertThat("Response JSON keys.size", jsonMap.keySet().size(), is(2));
}
@Test
public void testGetHello() throws Exception
{
URI uri = server.getURI().resolve("/hello");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.header(HttpHeader.ACCEPT_ENCODING, "gzip")
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test gzip
// Test that Gzip was used to produce the response
String contentEncoding = response.getHeaders().get(HttpHeader.CONTENT_ENCODING);
assertThat("Content-Encoding", contentEncoding, containsString("gzip"));
// test expected header from wrapper
String welcome = response.getHeaders().get("X-Welcome");
assertThat("X-Welcome header", welcome, containsString("Greetings from WelcomeWrapHandler"));
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Hello"));
}
}

View File

@ -0,0 +1,115 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.net.URI;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
public class ManyServletContextsTest extends AbstractEmbeddedTest
{
private Server server;
@BeforeEach
public void startServer() throws Exception
{
server = ManyServletContexts.createServer(0);
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testGetHello() throws Exception
{
URI uri = server.getURI().resolve("/hello");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Hello"));
}
@Test
public void testGetItalianHello() throws Exception
{
URI uri = server.getURI().resolve("/it/hello");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Ciao"));
}
@Test
public void testGetFrenchHello() throws Exception
{
URI uri = server.getURI().resolve("/fr/hello");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Bonjour"));
}
@Test
public void testGetOtherYo() throws Exception
{
URI uri = server.getURI().resolve("/other/hello.yo");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("YO!"));
}
}

View File

@ -0,0 +1,67 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.net.URI;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
public class MinimalServletsTest extends AbstractEmbeddedTest
{
private Server server;
@BeforeEach
public void startServer() throws Exception
{
server = MinimalServlets.createServer(0);
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testGetHello() throws Exception
{
URI uri = server.getURI().resolve("/hello");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Hello"));
}
}

View File

@ -0,0 +1,67 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.net.URI;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
public class OneConnectorTest extends AbstractEmbeddedTest
{
private Server server;
@BeforeEach
public void startServer() throws Exception
{
server = OneConnector.createServer(0);
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testGetHello() throws Exception
{
URI uri = server.getURI().resolve("/hello");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Hello"));
}
}

View File

@ -0,0 +1,67 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.net.URI;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
public class OneContextTest extends AbstractEmbeddedTest
{
private Server server;
@BeforeEach
public void startServer() throws Exception
{
server = OneContext.createServer(0);
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testGetHello() throws Exception
{
URI uri = server.getURI().resolve("/hello");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Hello"));
}
}

View File

@ -0,0 +1,67 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.net.URI;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
public class OneHandlerTest extends AbstractEmbeddedTest
{
private Server server;
@BeforeEach
public void startServer() throws Exception
{
server = OneHandler.createServer(0);
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testGetHello() throws Exception
{
URI uri = server.getURI().resolve("/hello");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Hello"));
}
}

View File

@ -0,0 +1,101 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.net.URI;
import java.util.Set;
import javax.management.MBeanServer;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.io.ConnectionStatistics;
import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.opentest4j.AssertionFailedError;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
@ExtendWith(WorkDirExtension.class)
public class OneServletContextJmxStatsTest extends AbstractEmbeddedTest
{
private Server server;
@BeforeEach
public void startServer() throws Exception
{
server = OneServletContextJmxStats.createServer(0);
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testGetDumpViaPathInfo() throws Exception
{
URI uri = server.getURI().resolve("/dump/something");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody,
allOf(
containsString("DumpServlet"),
containsString("servletPath=/dump"),
containsString("pathInfo=/something")
)
);
}
@Test
public void testJmxConnectStatsPresent() throws Exception
{
MBeanContainer mbeanContainer = server.getBean(MBeanContainer.class);
MBeanServer mbeanServer = mbeanContainer.getMBeanServer();
String domain = ConnectionStatistics.class.getPackage().getName();
Set<ObjectName> mbeanNames = mbeanServer.queryNames(ObjectName.getInstance(domain + ":type=connectionstatistics,*"), null);
ObjectName connStatsName = mbeanNames.stream().findFirst().orElseThrow(AssertionFailedError::new);
ObjectInstance mbeanConnStats = mbeanServer.getObjectInstance(connStatsName);
Number connections = (Number)mbeanServer.getAttribute(connStatsName, "connections");
assertThat("stats[connections]", connections, is(notNullValue()));
assertThat("stats[connections]", connections.longValue(), greaterThanOrEqualTo(0L));
}
}

View File

@ -0,0 +1,158 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.io.BufferedWriter;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
import org.eclipse.jetty.util.resource.PathResource;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
@ExtendWith(WorkDirExtension.class)
public class OneServletContextTest extends AbstractEmbeddedTest
{
private static final String TEXT_CONTENT = "The secret of getting ahead is getting started. - Mark Twain";
public WorkDir workDir;
private Server server;
@BeforeEach
public void startServer() throws Exception
{
Path baseDir = workDir.getEmptyPathDir();
Path textFile = baseDir.resolve("simple.txt");
try (BufferedWriter writer = Files.newBufferedWriter(textFile, UTF_8))
{
writer.write(TEXT_CONTENT);
}
server = OneServletContext.createServer(0, new PathResource(baseDir));
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testGetHello() throws Exception
{
URI uri = server.getURI().resolve("/hello/there");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody, containsString("Hello"));
}
@Test
public void testGetDumpViaPathInfo() throws Exception
{
URI uri = server.getURI().resolve("/dump/something");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody,
allOf(
containsString("DumpServlet"),
containsString("servletPath=/dump"),
containsString("pathInfo=/something")
)
);
}
@Test
public void testGetDumpSuffix() throws Exception
{
URI uri = server.getURI().resolve("/another.dump");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody,
allOf(
containsString("DumpServlet"),
containsString("servletPath=/another.dump"),
containsString("pathInfo=null")
)
);
}
@Test
public void testGetTestDumpSuffix() throws Exception
{
URI uri = server.getURI().resolve("/test/another.dump");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
String filterResponseHeader = response.getHeaders().get("X-TestFilter");
assertThat("X-TestFilter header", filterResponseHeader, is("true"));
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody,
allOf(
containsString("DumpServlet"),
containsString("servletPath=/test/another.dump"),
containsString("pathInfo=null"),
containsString("request.attribute[X-ReqListener]=true"),
containsString("servletContext.attribute[X-Init]=true")
)
);
}
}

View File

@ -0,0 +1,95 @@
//
// ========================================================================
// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under
// the terms of the Eclipse Public License 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0
//
// This Source Code may also be made available under the following
// Secondary Licenses when the conditions for such availability set
// forth in the Eclipse Public License, v. 2.0 are satisfied:
// the Apache License v2.0 which is available at
// https://www.apache.org/licenses/LICENSE-2.0
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.embedded;
import java.io.BufferedWriter;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
import org.eclipse.jetty.util.resource.PathResource;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
@ExtendWith(WorkDirExtension.class)
public class OneServletContextWithSessionTest extends AbstractEmbeddedTest
{
private static final String TEXT_CONTENT = "Do the right thing. It will gratify some people and astonish the rest. - Mark Twain";
public WorkDir workDir;
private Server server;
@BeforeEach
public void startServer() throws Exception
{
Path baseDir = workDir.getEmptyPathDir();
Path textFile = baseDir.resolve("simple.txt");
try (BufferedWriter writer = Files.newBufferedWriter(textFile, UTF_8))
{
writer.write(TEXT_CONTENT);
}
server = OneServletContextWithSession.createServer(0, new PathResource(baseDir));
server.start();
}
@AfterEach
public void stopServer() throws Exception
{
server.stop();
}
@Test
public void testGetHello() throws Exception
{
URI uri = server.getURI().resolve("/");
ContentResponse response = client.newRequest(uri)
.method(HttpMethod.GET)
.send();
assertThat("HTTP Response Status", response.getStatus(), is(HttpStatus.OK_200));
// dumpResponseHeaders(response);
String setCookieValue = response.getHeaders().get(HttpHeader.SET_COOKIE);
assertThat("Set-Cookie value", setCookieValue, containsString("JSESSIONID="));
// test response content
String responseBody = response.getContentAsString();
assertThat("Response Content", responseBody,
allOf(
containsString("session.getId() = "),
containsString("session.isNew() = true")
)
);
}
}

Some files were not shown because too many files have changed in this diff Show More