Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jetty modules handled for JDK 1.8 #4609

Merged
merged 1 commit into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 20 additions & 28 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
<artifactId>jersey-grizzly-connector</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-jetty-connector</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-jdk-connector</artifactId>
Expand All @@ -83,6 +88,11 @@
<artifactId>jersey-netty-connector</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jetty-http</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
Expand All @@ -93,6 +103,11 @@
<artifactId>jersey-container-grizzly2-servlet</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jetty-servlet</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jdk-http</artifactId>
Expand Down Expand Up @@ -354,6 +369,11 @@
<artifactId>jersey-test-framework-provider-simple</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-util</artifactId>
Expand Down Expand Up @@ -393,33 +413,5 @@
</site>
</distributionManagement>
</profile>
<profile>
<id>Jetty11</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-jetty-connector</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jetty-http</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jetty-servlet</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
<artifactId>jersey-test-framework-provider-jetty</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
138 changes: 138 additions & 0 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>
<java8.build.outputDirectory>${project.basedir}/target</java8.build.outputDirectory>
<java8.sourceDirectory>${project.basedir}/src/main/java8</java8.sourceDirectory>
<java11.build.outputDirectory>${project.basedir}/target11</java11.build.outputDirectory>
<java11.sourceDirectory>${project.basedir}/src/main/java11</java11.sourceDirectory>
</properties>

<dependencies>
Expand Down Expand Up @@ -119,6 +123,140 @@
<skip.tests>true</skip.tests>
</properties>
</profile>
<profile>
<id>JettyExclude</id>
<activation>
<jdk>1.8</jdk>
</activation>
<build>
<directory>${java8.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>${java8.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>Jetty11</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<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>
</plugins>
</build>
</profile>
<profile>
<id>copyJDK11FilesToMultiReleaseJar</id>
<activation>
<file>
<!-- ${java11.build.outputDirectory} does not work here -->
<exists>target11/classes/org/glassfish/jersey/jetty/connector/JettyConnectorProvider.class</exists>
</file>
<jdk>1.8</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-jdk11-classes</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${java8.build.outputDirectory}/classes/META-INF/versions/11</outputDirectory>
<resources>
<resource>
<directory>${java11.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-jdk11-sources</id>
<phase>package</phase>
<configuration>
<target>
<property name="sources-jar" value="${java8.build.outputDirectory}/${project.artifactId}-${project.version}-sources.jar"/>
<echo>sources-jar: ${sources-jar}</echo>
<zip destfile="${sources-jar}" update="true">
<zipfileset dir="${java11.sourceDirectory}" prefix="META-INF/versions/11"/>
</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
Expand Up @@ -16,6 +16,7 @@

package org.glassfish.jersey.jetty.connector;

import jakarta.ws.rs.ProcessingException;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.core.Configurable;
import jakarta.ws.rs.core.Configuration;
Expand All @@ -25,6 +26,7 @@
import org.glassfish.jersey.client.spi.ConnectorProvider;

import org.eclipse.jetty.client.HttpClient;
import org.glassfish.jersey.internal.util.JdkVersion;

/**
* A {@link ConnectorProvider} for Jersey {@link Connector connector}
Expand Down Expand Up @@ -82,6 +84,9 @@ public class JettyConnectorProvider implements ConnectorProvider {

@Override
public Connector getConnector(Client client, Configuration runtimeConfig) {
if (JdkVersion.getJdkVersion().getMajor() < 11) {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}
return new JettyConnector(client, runtimeConfig);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2020 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;

import org.glassfish.jersey.internal.util.JdkVersion;

/**
* JDK 1.8 Jetty Connector stub which only throws exception when running on JDK 1.8
* New Jetty (11+) does not support JDKs prior to 11
*
* @since 3.0.0
*/
public class JettyConnectorProvider implements ConnectorProvider {

@Override
public Connector getConnector(Client client, Configuration runtimeConfig) {
if (JdkVersion.getJdkVersion().getMajor() < 11) {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}
return null; // does not work at JDK 1.8
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2013, 2020 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 All @@ -20,3 +20,4 @@ method.not.supported=Method {0} not supported.
wrong.proxy.uri.type=The proxy URI ("{0}") property MUST be an instance of String or URI.
invalid.configurable.component.type=The supplied component "{0}" is not assignable from JerseyClient or JerseyWebTarget.
expected.connector.provider.not.used=The supplied component is not configured to use a JettyConnectorProvider.
not.supported=Jetty connector is not supported on JDK version less than 11.
10 changes: 1 addition & 9 deletions connectors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
<module>apache-connector</module>
<module>grizzly-connector</module>
<module>jdk-connector</module>
<module>jetty-connector</module>
<module>netty-connector</module>
</modules>

Expand Down Expand Up @@ -86,14 +87,5 @@
<module>helidon-connector</module>
</modules>
</profile>
<profile>
<id>Jetty11</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<modules>
<module>jetty-connector</module>
</modules>
</profile>
</profiles>
</project>
Loading