Skip to content

Commit

Permalink
Upgrade to Jetty 12
Browse files Browse the repository at this point in the history
Signed-off-by: Steffen Nießing <[email protected]>
  • Loading branch information
zUniQueX authored Sep 7, 2023
1 parent 7aa69fa commit 521015e
Show file tree
Hide file tree
Showing 157 changed files with 5,995 additions and 545 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
</dependency> -->

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-servlet</artifactId>
<version>\${jetty.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-webapp</artifactId>
<version>\${jetty.version}</version>
<scope>provided</scope>
</dependency>
Expand Down Expand Up @@ -89,8 +89,8 @@
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-maven-plugin</artifactId>
<version>\${jetty.version}</version>
<configuration>
<contextPath>/</contextPath>
Expand All @@ -117,7 +117,7 @@

<properties>
<jersey.version>${project.version}</jersey.version>
<jetty.version>11.0.15</jetty.version>
<jetty.version>12.0.0</jetty.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<surefire.mvn.plugin.version>3.1.2</surefire.mvn.plugin.version>
<war.mvn.plugin.version>3.4.0</war.mvn.plugin.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ${package}.heroku;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.ee10.webapp.WebAppContext;

/**
* This class launches the web application in an embedded Jetty container. This is the entry point to your application. The Java
Expand Down Expand Up @@ -30,7 +30,7 @@ public static void main(String[] args) throws Exception{

final String webappDirLocation = "src/main/webapp/";
root.setDescriptor(webappDirLocation + "/WEB-INF/web.xml");
root.setResourceBase(webappDirLocation);
root.setBaseResourceAsString(webappDirLocation);

server.setHandler(root);

Expand Down
5 changes: 5 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
<artifactId>jersey-jetty-connector</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-jetty11-connector</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-jdk-connector</artifactId>
Expand Down
154 changes: 144 additions & 10 deletions connectors/jetty-connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java11.build.outputDirectory>${project.basedir}/target</java11.build.outputDirectory>
<java11.sourceDirectory>${project.basedir}/src/main/java11</java11.sourceDirectory>
<java17.build.outputDirectory>${project.basedir}/target17</java17.build.outputDirectory>
<java17.sourceDirectory>${project.basedir}/src/main/java17</java17.sourceDirectory>
</properties>

<dependencies>
Expand All @@ -47,16 +51,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.media</groupId>
Expand Down Expand Up @@ -125,4 +119,144 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>JettyExclude</id>
<activation>
<jdk>[11,17)</jdk>
</activation>
<properties>
<jetty.version>${jetty11.version}</jetty.version>
</properties>
<build>
<directory>${java11.build.outputDirectory}</directory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${java11.sourceDirectory}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<testExcludes>
<testExclude>org/glassfish/jersey/jetty/connector/*.java</testExclude>
</testExcludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>JettyInclude</id>
<activation>
<jdk>[17,)</jdk>
</activation>
<build>
<directory>${java17.build.outputDirectory}</directory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${java17.sourceDirectory}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>copyJDK17FilesToMultiReleaseJar</id>
<activation>
<file>
<!-- ${java17.build.outputDirectory} does not work here -->
<exists>target17/classes/org/glassfish/jersey/jetty/connector/JettyConnector.class</exists>
</file>
<jdk>[11,17)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<inherited>true</inherited>
<extensions>true</extensions>
<configuration>
<instructions>
<Multi-Release>true</Multi-Release>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<inherited>true</inherited>
<executions>
<execution>
<id>copy-jdk17-classes</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${java11.build.outputDirectory}/classes/META-INF/versions/17</outputDirectory>
<resources>
<resource>
<directory>${java17.build.outputDirectory}/classes</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copy-jdk17-sources</id>
<phase>package</phase>
<configuration>
<target>
<property name="sources-jar" value="${java11.build.outputDirectory}/${project.artifactId}-${project.version}-sources.jar"/>
<echo>sources-jar: ${sources-jar}</echo>
<zip destfile="${sources-jar}" update="true">
<zipfileset dir="${java17.sourceDirectory}" prefix="META-INF/versions/17"/>
</zip>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright (c) 2013, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://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: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.jersey.jetty.connector;

import jakarta.ws.rs.ProcessingException;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.core.Configuration;
import org.glassfish.jersey.client.spi.Connector;
import org.glassfish.jersey.client.spi.ConnectorProvider;

/**
* A {@link ConnectorProvider} for Jersey {@link Connector connector}
* instances that utilize the Jetty HTTP Client to send and receive
* HTTP request and responses.
* <p>
* The following connector configuration properties are supported:
* <ul>
* <li>{@link org.glassfish.jersey.client.ClientProperties#ASYNC_THREADPOOL_SIZE}</li>
* <li>{@link org.glassfish.jersey.client.ClientProperties#CONNECT_TIMEOUT}</li>
* <li>{@link org.glassfish.jersey.client.ClientProperties#FOLLOW_REDIRECTS}</li>
* <li>{@link org.glassfish.jersey.client.ClientProperties#PROXY_URI}</li>
* <li>{@link org.glassfish.jersey.client.ClientProperties#PROXY_USERNAME}</li>
* <li>{@link org.glassfish.jersey.client.ClientProperties#PROXY_PASSWORD}</li>
* <li>{@link org.glassfish.jersey.client.ClientProperties#PROXY_PASSWORD}</li>
* <li>{@link JettyClientProperties#DISABLE_COOKIES}</li>*
* <li>{@link JettyClientProperties#ENABLE_SSL_HOSTNAME_VERIFICATION}</li>
* <li>{@link JettyClientProperties#PREEMPTIVE_BASIC_AUTHENTICATION}</li>
* <li>{@link JettyClientProperties#SYNC_LISTENER_RESPONSE_MAX_SIZE}</li>
* </ul>
* </p>
* <p>
* This transport supports both synchronous and asynchronous processing of client requests.
* The following methods are supported: GET, POST, PUT, DELETE, HEAD, OPTIONS, TRACE, CONNECT and MOVE.
* </p>
* <p>
* Typical usage:
* </p>
* <pre>
* {@code
* ClientConfig config = new ClientConfig();
* config.connectorProvider(new JettyConnectorProvider());
* Client client = ClientBuilder.newClient(config);
*
* // async request
* WebTarget target = client.target("http://localhost:8080");
* Future<Response> future = target.path("resource").request().async().get();
*
* // wait for 3 seconds
* Response response = future.get(3, TimeUnit.SECONDS);
* String entity = response.readEntity(String.class);
* client.close();
* }
* </pre>
* <p>
* Connector instances created via Jetty HTTP Client-based connector provider support only
* {@link org.glassfish.jersey.client.RequestEntityProcessing#BUFFERED entity buffering}.
* Defining the property {@link org.glassfish.jersey.client.ClientProperties#REQUEST_ENTITY_PROCESSING} has no
* effect on Jetty HTTP Client-based connectors.
* </p>
*
* @author Arul Dhesiaseelan (aruld at acm.org)
* @author Marek Potociar
* @since 2.5
*/
public class JettyConnectorProvider implements ConnectorProvider {

@Override
public Connector getConnector(Client client, Configuration runtimeConfig) {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2021 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2023 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down
Loading

0 comments on commit 521015e

Please sign in to comment.