Skip to content

Commit 111af66

Browse files
committedOct 14, 2020
Jetty modules handled for JDK less than 11
Signed-off-by: Maxim Nesen <maxim.nesen@oracle.com>
1 parent 01ff902 commit 111af66

File tree

21 files changed

+621
-64
lines changed

21 files changed

+621
-64
lines changed
 

‎bom/pom.xml

+20-28
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@
7373
<artifactId>jersey-grizzly-connector</artifactId>
7474
<version>${project.version}</version>
7575
</dependency>
76+
<dependency>
77+
<groupId>org.glassfish.jersey.connectors</groupId>
78+
<artifactId>jersey-jetty-connector</artifactId>
79+
<version>${project.version}</version>
80+
</dependency>
7681
<dependency>
7782
<groupId>org.glassfish.jersey.connectors</groupId>
7883
<artifactId>jersey-jdk-connector</artifactId>
@@ -83,6 +88,11 @@
8388
<artifactId>jersey-netty-connector</artifactId>
8489
<version>${project.version}</version>
8590
</dependency>
91+
<dependency>
92+
<groupId>org.glassfish.jersey.containers</groupId>
93+
<artifactId>jersey-container-jetty-http</artifactId>
94+
<version>${project.version}</version>
95+
</dependency>
8696
<dependency>
8797
<groupId>org.glassfish.jersey.containers</groupId>
8898
<artifactId>jersey-container-grizzly2-http</artifactId>
@@ -93,6 +103,11 @@
93103
<artifactId>jersey-container-grizzly2-servlet</artifactId>
94104
<version>${project.version}</version>
95105
</dependency>
106+
<dependency>
107+
<groupId>org.glassfish.jersey.containers</groupId>
108+
<artifactId>jersey-container-jetty-servlet</artifactId>
109+
<version>${project.version}</version>
110+
</dependency>
96111
<dependency>
97112
<groupId>org.glassfish.jersey.containers</groupId>
98113
<artifactId>jersey-container-jdk-http</artifactId>
@@ -354,6 +369,11 @@
354369
<artifactId>jersey-test-framework-provider-simple</artifactId>
355370
<version>${project.version}</version>
356371
</dependency>
372+
<dependency>
373+
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
374+
<artifactId>jersey-test-framework-provider-jetty</artifactId>
375+
<version>${project.version}</version>
376+
</dependency>
357377
<dependency>
358378
<groupId>org.glassfish.jersey.test-framework</groupId>
359379
<artifactId>jersey-test-framework-util</artifactId>
@@ -393,33 +413,5 @@
393413
</site>
394414
</distributionManagement>
395415
</profile>
396-
<profile>
397-
<id>Jetty11</id>
398-
<activation>
399-
<jdk>[11,)</jdk>
400-
</activation>
401-
<dependencies>
402-
<dependency>
403-
<groupId>org.glassfish.jersey.connectors</groupId>
404-
<artifactId>jersey-jetty-connector</artifactId>
405-
<version>${project.version}</version>
406-
</dependency>
407-
<dependency>
408-
<groupId>org.glassfish.jersey.containers</groupId>
409-
<artifactId>jersey-container-jetty-http</artifactId>
410-
<version>${project.version}</version>
411-
</dependency>
412-
<dependency>
413-
<groupId>org.glassfish.jersey.containers</groupId>
414-
<artifactId>jersey-container-jetty-servlet</artifactId>
415-
<version>${project.version}</version>
416-
</dependency>
417-
<dependency>
418-
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
419-
<artifactId>jersey-test-framework-provider-jetty</artifactId>
420-
<version>${project.version}</version>
421-
</dependency>
422-
</dependencies>
423-
</profile>
424416
</profiles>
425417
</project>

‎connectors/jetty-connector/pom.xml

+138
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434

3535
<properties>
3636
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37+
<java8.build.outputDirectory>${project.basedir}/target</java8.build.outputDirectory>
38+
<java8.sourceDirectory>${project.basedir}/src/main/java8</java8.sourceDirectory>
39+
<java11.build.outputDirectory>${project.basedir}/target11</java11.build.outputDirectory>
40+
<java11.sourceDirectory>${project.basedir}/src/main/java11</java11.sourceDirectory>
3741
</properties>
3842

3943
<dependencies>
@@ -119,6 +123,140 @@
119123
<skip.tests>true</skip.tests>
120124
</properties>
121125
</profile>
126+
<profile>
127+
<id>JettyExclude</id>
128+
<activation>
129+
<jdk>1.8</jdk>
130+
</activation>
131+
<build>
132+
<directory>${java8.build.outputDirectory}</directory>
133+
<plugins>
134+
<plugin>
135+
<groupId>org.codehaus.mojo</groupId>
136+
<artifactId>build-helper-maven-plugin</artifactId>
137+
<executions>
138+
<execution>
139+
<phase>generate-sources</phase>
140+
<goals>
141+
<goal>add-source</goal>
142+
</goals>
143+
<configuration>
144+
<sources>
145+
<source>${java8.sourceDirectory}</source>
146+
</sources>
147+
</configuration>
148+
</execution>
149+
</executions>
150+
</plugin>
151+
<plugin>
152+
<groupId>org.apache.maven.plugins</groupId>
153+
<artifactId>maven-compiler-plugin</artifactId>
154+
<configuration>
155+
<testExcludes>
156+
<testExclude>org/glassfish/jersey/jetty/connector/*.java</testExclude>
157+
</testExcludes>
158+
</configuration>
159+
</plugin>
160+
</plugins>
161+
</build>
162+
</profile>
163+
<profile>
164+
<id>Jetty11</id>
165+
<activation>
166+
<jdk>[11,)</jdk>
167+
</activation>
168+
<build>
169+
<directory>${java11.build.outputDirectory}</directory>
170+
<plugins>
171+
<plugin>
172+
<groupId>org.codehaus.mojo</groupId>
173+
<artifactId>build-helper-maven-plugin</artifactId>
174+
<executions>
175+
<execution>
176+
<phase>generate-sources</phase>
177+
<goals>
178+
<goal>add-source</goal>
179+
</goals>
180+
<configuration>
181+
<sources>
182+
<source>${java11.sourceDirectory}</source>
183+
</sources>
184+
</configuration>
185+
</execution>
186+
</executions>
187+
</plugin>
188+
</plugins>
189+
</build>
190+
</profile>
191+
<profile>
192+
<id>copyJDK11FilesToMultiReleaseJar</id>
193+
<activation>
194+
<file>
195+
<!-- ${java11.build.outputDirectory} does not work here -->
196+
<exists>target11/classes/org/glassfish/jersey/jetty/connector/JettyConnectorProvider.class</exists>
197+
</file>
198+
<jdk>1.8</jdk>
199+
</activation>
200+
<build>
201+
<plugins>
202+
<plugin>
203+
<groupId>org.apache.felix</groupId>
204+
<artifactId>maven-bundle-plugin</artifactId>
205+
<inherited>true</inherited>
206+
<extensions>true</extensions>
207+
<configuration>
208+
<instructions>
209+
<Multi-Release>true</Multi-Release>
210+
</instructions>
211+
</configuration>
212+
</plugin>
213+
<plugin>
214+
<groupId>org.apache.maven.plugins</groupId>
215+
<artifactId>maven-resources-plugin</artifactId>
216+
<inherited>true</inherited>
217+
<executions>
218+
<execution>
219+
<id>copy-jdk11-classes</id>
220+
<phase>prepare-package</phase>
221+
<goals>
222+
<goal>copy-resources</goal>
223+
</goals>
224+
<configuration>
225+
<outputDirectory>${java8.build.outputDirectory}/classes/META-INF/versions/11</outputDirectory>
226+
<resources>
227+
<resource>
228+
<directory>${java11.build.outputDirectory}/classes</directory>
229+
</resource>
230+
</resources>
231+
</configuration>
232+
</execution>
233+
</executions>
234+
</plugin>
235+
<plugin>
236+
<groupId>org.apache.maven.plugins</groupId>
237+
<artifactId>maven-antrun-plugin</artifactId>
238+
<executions>
239+
<execution>
240+
<id>copy-jdk11-sources</id>
241+
<phase>package</phase>
242+
<configuration>
243+
<target>
244+
<property name="sources-jar" value="${java8.build.outputDirectory}/${project.artifactId}-${project.version}-sources.jar"/>
245+
<echo>sources-jar: ${sources-jar}</echo>
246+
<zip destfile="${sources-jar}" update="true">
247+
<zipfileset dir="${java11.sourceDirectory}" prefix="META-INF/versions/11"/>
248+
</zip>
249+
</target>
250+
</configuration>
251+
<goals>
252+
<goal>run</goal>
253+
</goals>
254+
</execution>
255+
</executions>
256+
</plugin>
257+
</plugins>
258+
</build>
259+
</profile>
122260
</profiles>
123261

124262
</project>

‎connectors/jetty-connector/src/main/java/org/glassfish/jersey/jetty/connector/JettyConnectorProvider.java ‎connectors/jetty-connector/src/main/java11/org/glassfish/jersey/jetty/connector/JettyConnectorProvider.java

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.glassfish.jersey.jetty.connector;
1818

19+
import jakarta.ws.rs.ProcessingException;
1920
import jakarta.ws.rs.client.Client;
2021
import jakarta.ws.rs.core.Configurable;
2122
import jakarta.ws.rs.core.Configuration;
@@ -25,6 +26,7 @@
2526
import org.glassfish.jersey.client.spi.ConnectorProvider;
2627

2728
import org.eclipse.jetty.client.HttpClient;
29+
import org.glassfish.jersey.internal.util.JdkVersion;
2830

2931
/**
3032
* A {@link ConnectorProvider} for Jersey {@link Connector connector}
@@ -82,6 +84,9 @@ public class JettyConnectorProvider implements ConnectorProvider {
8284

8385
@Override
8486
public Connector getConnector(Client client, Configuration runtimeConfig) {
87+
if (JdkVersion.getJdkVersion().getMajor() < 11) {
88+
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
89+
}
8590
return new JettyConnector(client, runtimeConfig);
8691
}
8792

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
17+
package org.glassfish.jersey.jetty.connector;
18+
19+
import jakarta.ws.rs.ProcessingException;
20+
import jakarta.ws.rs.client.Client;
21+
import jakarta.ws.rs.core.Configuration;
22+
23+
import org.glassfish.jersey.client.spi.Connector;
24+
import org.glassfish.jersey.client.spi.ConnectorProvider;
25+
26+
import org.glassfish.jersey.internal.util.JdkVersion;
27+
28+
/**
29+
* JDK 1.8 Jetty Connector stub which only throws exception when running on JDK 1.8
30+
* New Jetty (11+) does not support JDKs prior to 11
31+
*
32+
* @since 3.0.0
33+
*/
34+
public class JettyConnectorProvider implements ConnectorProvider {
35+
36+
@Override
37+
public Connector getConnector(Client client, Configuration runtimeConfig) {
38+
if (JdkVersion.getJdkVersion().getMajor() < 11) {
39+
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
40+
}
41+
return null; // does not work at JDK 1.8
42+
}
43+
44+
}

‎connectors/jetty-connector/src/main/resources/org/glassfish/jersey/jetty/connector/localization.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved.
33
#
44
# This program and the accompanying materials are made available under the
55
# terms of the Eclipse Public License v. 2.0, which is available at
@@ -20,3 +20,4 @@ method.not.supported=Method {0} not supported.
2020
wrong.proxy.uri.type=The proxy URI ("{0}") property MUST be an instance of String or URI.
2121
invalid.configurable.component.type=The supplied component "{0}" is not assignable from JerseyClient or JerseyWebTarget.
2222
expected.connector.provider.not.used=The supplied component is not configured to use a JettyConnectorProvider.
23+
not.supported=Jetty connector is not supported on JDK version less than 11.

‎connectors/pom.xml

+1-9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<module>apache-connector</module>
3838
<module>grizzly-connector</module>
3939
<module>jdk-connector</module>
40+
<module>jetty-connector</module>
4041
<module>netty-connector</module>
4142
</modules>
4243

@@ -86,14 +87,5 @@
8687
<module>helidon-connector</module>
8788
</modules>
8889
</profile>
89-
<profile>
90-
<id>Jetty11</id>
91-
<activation>
92-
<jdk>[11,)</jdk>
93-
</activation>
94-
<modules>
95-
<module>jetty-connector</module>
96-
</modules>
97-
</profile>
9890
</profiles>
9991
</project>

0 commit comments

Comments
 (0)