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

Enable jetty servlet/web container factory #4620

Merged
merged 1 commit into from
Oct 26, 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
199 changes: 187 additions & 12 deletions containers/jetty-servlet/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@
<artifactId>jersey-container-servlet-core</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.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
</dependency>
<!-- TODO jakartify this -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
Expand Down Expand Up @@ -86,4 +74,191 @@
</plugin>
</plugins>
</build>

<properties>
<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>
<jetty.javax.version>9.4.28.v20200408</jetty.javax.version>
</properties>

<profiles>
<profile>
<id>JettyExclude</id>
<activation>
<jdk>1.8</jdk>
</activation>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.javax.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.javax.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jetty-http</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<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/*.java</testExclude>
</testExcludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>Jetty11</id>
<activation>
<jdk>[11,)</jdk>
</activation>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jetty-http</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<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/JettyHttpContainer.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
@@ -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 Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* 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.servlet;

import java.net.URI;
import java.util.Map;

import jakarta.servlet.Servlet;

import jakarta.ws.rs.ProcessingException;
import org.eclipse.jetty.server.Server;
import org.glassfish.jersey.jetty.internal.LocalizationMessages;

/**
* Jersey {@code Server} stub based on Jetty {@link org.eclipse.jetty.server.Server}.
* <p>
* For JDK 1.8 only since Jetty 11 does not support JDKs below 11
*/
public final class JettyWebContainerFactory {

private JettyWebContainerFactory() {
}


public static Server create(String u)
throws Exception {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}

public static Server create(String u, Map<String, String> initParams)
throws Exception {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}

public static Server create(URI u)
throws Exception {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}

public static Server create(URI u, Map<String, String> initParams)
throws Exception {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}

public static Server create(String u, Class<? extends Servlet> c)
throws Exception {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}

public static Server create(String u, Class<? extends Servlet> c,
Map<String, String> initParams)
throws Exception {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}

public static Server create(URI u, Class<? extends Servlet> c)
throws Exception {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}

public static Server create(URI u, Class<? extends Servlet> c, Map<String, String> initParams)
throws Exception {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}

private static Server create(URI u, Class<? extends Servlet> c, Servlet servlet,
Map<String, String> initParams, Map<String, String> contextInitParams)
throws Exception {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}

public static Server create(URI u, Servlet servlet, Map<String, String> initParams, Map<String, String> contextInitParams)
throws Exception {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# 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
#

# {0} - status code; {1} - status reason message
not.supported=Jetty container is not supported on JDK version less than 11.
3 changes: 1 addition & 2 deletions containers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
<module>jersey-servlet-core</module>
<module>jersey-servlet</module>
<module>jetty-http</module>
<!-- TODO jakartify this -->
<!-- <module>jetty-servlet</module>-->
<module>jetty-servlet</module>
<module>netty-http</module>
<module>simple-http</module>
</modules>
Expand Down