From 1210be0936d092ec86b6889ca69dd8443b8878bc Mon Sep 17 00:00:00 2001 From: Maxim Nesen Date: Thu, 22 Oct 2020 16:50:05 +0200 Subject: [PATCH] Enable jetty servlet/web container factory Signed-off-by: Maxim Nesen --- containers/jetty-servlet/pom.xml | 199 ++++++++++++++++-- .../servlet/JettyWebContainerFactory.java | 2 +- .../servlet/JettyWebContainerFactory.java | 90 ++++++++ .../servlet/internal/localization.properties | 18 ++ containers/pom.xml | 3 +- 5 files changed, 297 insertions(+), 15 deletions(-) rename containers/jetty-servlet/src/main/{java => java11}/org/glassfish/jersey/jetty/servlet/JettyWebContainerFactory.java (99%) create mode 100644 containers/jetty-servlet/src/main/java8/org/glassfish/jersey/jetty/servlet/JettyWebContainerFactory.java create mode 100644 containers/jetty-servlet/src/main/resources/org/glassfish/jersey/jetty/servlet/internal/localization.properties diff --git a/containers/jetty-servlet/pom.xml b/containers/jetty-servlet/pom.xml index e887171c6e..40e0d3d4b0 100644 --- a/containers/jetty-servlet/pom.xml +++ b/containers/jetty-servlet/pom.xml @@ -43,18 +43,6 @@ jersey-container-servlet-core ${project.version} - - - org.glassfish.jersey.containers - jersey-container-jetty-http - ${project.version} - - - - org.eclipse.jetty - jetty-webapp - - jakarta.servlet jakarta.servlet-api @@ -86,4 +74,191 @@ + + + ${project.basedir}/target + ${project.basedir}/src/main/java8 + ${project.basedir}/target11 + ${project.basedir}/src/main/java11 + 9.4.28.v20200408 + + + + + JettyExclude + + 1.8 + + + + org.eclipse.jetty + jetty-server + ${jetty.javax.version} + provided + + + org.eclipse.jetty + jetty-webapp + ${jetty.javax.version} + provided + + + org.eclipse.jetty + jetty-server + + + + + org.glassfish.jersey.containers + jersey-container-jetty-http + ${project.version} + + + org.eclipse.jetty + jetty-server + + + + + + ${java8.build.outputDirectory} + + + org.codehaus.mojo + build-helper-maven-plugin + + + generate-sources + + add-source + + + + ${java8.sourceDirectory} + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + org/glassfish/jersey/jetty/*.java + + + + + + + + Jetty11 + + [11,) + + + + org.eclipse.jetty + jetty-webapp + + + org.glassfish.jersey.containers + jersey-container-jetty-http + ${project.version} + + + + ${java11.build.outputDirectory} + + + org.codehaus.mojo + build-helper-maven-plugin + + + generate-sources + + add-source + + + + ${java11.sourceDirectory} + + + + + + + + + + copyJDK11FilesToMultiReleaseJar + + + + target11/classes/org/glassfish/jersey/jetty/JettyHttpContainer.class + + 1.8 + + + + + org.apache.felix + maven-bundle-plugin + true + true + + + true + + + + + org.apache.maven.plugins + maven-resources-plugin + true + + + copy-jdk11-classes + prepare-package + + copy-resources + + + ${java8.build.outputDirectory}/classes/META-INF/versions/11 + + + ${java11.build.outputDirectory}/classes + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + copy-jdk11-sources + package + + + + sources-jar: ${sources-jar} + + + + + + + run + + + + + + + + diff --git a/containers/jetty-servlet/src/main/java/org/glassfish/jersey/jetty/servlet/JettyWebContainerFactory.java b/containers/jetty-servlet/src/main/java11/org/glassfish/jersey/jetty/servlet/JettyWebContainerFactory.java similarity index 99% rename from containers/jetty-servlet/src/main/java/org/glassfish/jersey/jetty/servlet/JettyWebContainerFactory.java rename to containers/jetty-servlet/src/main/java11/org/glassfish/jersey/jetty/servlet/JettyWebContainerFactory.java index 72a4547751..7f46e7b2f8 100644 --- a/containers/jetty-servlet/src/main/java/org/glassfish/jersey/jetty/servlet/JettyWebContainerFactory.java +++ b/containers/jetty-servlet/src/main/java11/org/glassfish/jersey/jetty/servlet/JettyWebContainerFactory.java @@ -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 diff --git a/containers/jetty-servlet/src/main/java8/org/glassfish/jersey/jetty/servlet/JettyWebContainerFactory.java b/containers/jetty-servlet/src/main/java8/org/glassfish/jersey/jetty/servlet/JettyWebContainerFactory.java new file mode 100644 index 0000000000..3d87ae8c70 --- /dev/null +++ b/containers/jetty-servlet/src/main/java8/org/glassfish/jersey/jetty/servlet/JettyWebContainerFactory.java @@ -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}. + *

+ * 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 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 initParams) + throws Exception { + throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED()); + } + + public static Server create(String u, Class c) + throws Exception { + throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED()); + } + + public static Server create(String u, Class c, + Map initParams) + throws Exception { + throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED()); + } + + public static Server create(URI u, Class c) + throws Exception { + throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED()); + } + + public static Server create(URI u, Class c, Map initParams) + throws Exception { + throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED()); + } + + private static Server create(URI u, Class c, Servlet servlet, + Map initParams, Map contextInitParams) + throws Exception { + throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED()); + } + + public static Server create(URI u, Servlet servlet, Map initParams, Map contextInitParams) + throws Exception { + throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED()); + } +} \ No newline at end of file diff --git a/containers/jetty-servlet/src/main/resources/org/glassfish/jersey/jetty/servlet/internal/localization.properties b/containers/jetty-servlet/src/main/resources/org/glassfish/jersey/jetty/servlet/internal/localization.properties new file mode 100644 index 0000000000..c362bf0957 --- /dev/null +++ b/containers/jetty-servlet/src/main/resources/org/glassfish/jersey/jetty/servlet/internal/localization.properties @@ -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. diff --git a/containers/pom.xml b/containers/pom.xml index a197f5cbb7..3861860c9a 100644 --- a/containers/pom.xml +++ b/containers/pom.xml @@ -41,8 +41,7 @@ jersey-servlet-core jersey-servlet jetty-http - - + jetty-servlet netty-http simple-http