-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/11.0.x' into 12.0.x
- Loading branch information
Showing
16 changed files
with
582 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.eclipse.jetty.examples</groupId> | ||
<artifactId>jetty-standalone-examples</artifactId> | ||
<version>12.0.x</version> | ||
</parent> | ||
|
||
<artifactId>lowresource-access</artifactId> | ||
<packaging>war</packaging> | ||
<name>Jetty Examples :: Jetty 12.0.x :: Standalone :: LowResource Access</name> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>jakarta.servlet</groupId> | ||
<artifactId>jakarta.servlet-api</artifactId> | ||
<version>6.0.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<!-- used to reference LowResourceMonitor --> | ||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-server</artifactId> | ||
<version>${jetty.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-deploy</artifactId> | ||
<version>${jetty.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-slf4j-impl</artifactId> | ||
<version>${jetty.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.jetty.ee10</groupId> | ||
<artifactId>jetty-ee10-annotations</artifactId> | ||
<version>${jetty.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.eclipse.jetty.ee10</groupId> | ||
<artifactId>jetty-ee10-webapp</artifactId> | ||
<version>${jetty.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- test deps below --> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>5.10.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>demo</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-antrun-plugin</artifactId> | ||
<version>3.1.0</version> | ||
<executions> | ||
<execution> | ||
<id>copy-to-webapps</id> | ||
<goals> | ||
<goal>run</goal> | ||
</goals> | ||
<phase>install</phase> | ||
<configuration> | ||
<target> | ||
<copy file="${project.build.directory}/${project.build.finalName}.war" todir="${project.basedir}/webapps/" /> | ||
</target> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
48 changes: 48 additions & 0 deletions
48
standalone/lowresource-access/src/main/java/examples/AbstractLowResourceDumpServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
package examples; | ||
|
||
import java.io.IOException; | ||
import java.util.Set; | ||
import jakarta.servlet.ServletOutputStream; | ||
import jakarta.servlet.http.HttpServlet; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import org.eclipse.jetty.server.LowResourceMonitor; | ||
import org.eclipse.jetty.server.Request; | ||
import org.eclipse.jetty.server.Server; | ||
|
||
public class AbstractLowResourceDumpServlet extends HttpServlet | ||
{ | ||
protected LowResourceMonitor getLowResourceMonitor() | ||
{ | ||
return (LowResourceMonitor)getServletContext().getAttribute(LowResourceMonitor.class.getName()); | ||
} | ||
|
||
protected Server getServer(HttpServletRequest request) | ||
{ | ||
Request coreRequest = (Request)request.getAttribute(Request.class.getName()); | ||
return coreRequest.getConnectionMetaData().getConnector().getServer(); | ||
} | ||
|
||
protected void dump(ServletOutputStream out, LowResourceMonitor monitor) throws IOException | ||
{ | ||
Set<LowResourceMonitor.LowResourceCheck> checks = monitor.getLowResourceChecks(); | ||
out.println("LowResourceChecks: "); | ||
for (LowResourceMonitor.LowResourceCheck check : checks) | ||
{ | ||
out.println(String.format(" (%s) %s%n", check.getClass().getName(), check)); | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
standalone/lowresource-access/src/main/java/examples/FromBaseRequestServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
package examples; | ||
|
||
import java.io.IOException; | ||
import jakarta.servlet.ServletException; | ||
import jakarta.servlet.annotation.WebServlet; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
|
||
import org.eclipse.jetty.server.LowResourceMonitor; | ||
import org.eclipse.jetty.server.Request; | ||
import org.eclipse.jetty.server.Server; | ||
|
||
@WebServlet("/baserequest") | ||
public class FromBaseRequestServlet extends AbstractLowResourceDumpServlet | ||
{ | ||
@Override | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException | ||
{ | ||
LowResourceMonitor monitor = getLowResourceMonitor(); | ||
|
||
response.setCharacterEncoding("UTF-8"); | ||
response.setContentType("text/plain"); | ||
dump(response.getOutputStream(), monitor); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
standalone/lowresource-access/src/main/java/examples/FromRequestAttributeChannelServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
package examples; | ||
|
||
import java.io.IOException; | ||
import jakarta.servlet.ServletException; | ||
import jakarta.servlet.annotation.WebServlet; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
|
||
import org.eclipse.jetty.server.HttpChannel; | ||
import org.eclipse.jetty.server.LowResourceMonitor; | ||
import org.eclipse.jetty.server.Server; | ||
|
||
@WebServlet("/requestattribute/channel") | ||
public class FromRequestAttributeChannelServlet extends AbstractLowResourceDumpServlet | ||
{ | ||
@Override | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException | ||
{ | ||
LowResourceMonitor monitor = getLowResourceMonitor(); | ||
|
||
response.setCharacterEncoding("UTF-8"); | ||
response.setContentType("text/plain"); | ||
dump(response.getOutputStream(), monitor); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...lone/lowresource-access/src/main/java/examples/FromRequestAttributeConnectionServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
package examples; | ||
|
||
import java.io.IOException; | ||
import jakarta.servlet.annotation.WebServlet; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
|
||
import org.eclipse.jetty.server.LowResourceMonitor; | ||
|
||
@WebServlet("/requestattribute/connection") | ||
public class FromRequestAttributeConnectionServlet extends AbstractLowResourceDumpServlet | ||
{ | ||
@Override | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException | ||
{ | ||
LowResourceMonitor monitor = getLowResourceMonitor(); | ||
|
||
response.setCharacterEncoding("UTF-8"); | ||
response.setContentType("text/plain"); | ||
dump(response.getOutputStream(), monitor); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
standalone/lowresource-access/src/main/java/examples/FromServletContextServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// ======================================================================== | ||
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// ======================================================================== | ||
// | ||
|
||
package examples; | ||
|
||
import java.io.IOException; | ||
import jakarta.servlet.ServletException; | ||
import jakarta.servlet.annotation.WebServlet; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
|
||
import org.eclipse.jetty.server.LowResourceMonitor; | ||
|
||
@WebServlet("/servletcontext") | ||
public class FromServletContextServlet extends AbstractLowResourceDumpServlet | ||
{ | ||
@Override | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException | ||
{ | ||
LowResourceMonitor monitor = getLowResourceMonitor(); | ||
response.setCharacterEncoding("UTF-8"); | ||
response.setContentType("text/plain"); | ||
dump(response.getOutputStream(), monitor); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
standalone/lowresource-access/src/main/webapp/WEB-INF/web.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee | ||
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> | ||
<display-name>Accessing LowResourceMonitor from a Servlet</display-name> | ||
</web-app> |
Oops, something went wrong.