Skip to content

Commit

Permalink
Jetty 11 container adopted for backwards compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Nesen <maxim.nesen@oracle.com>
  • Loading branch information
senivam committed Dec 12, 2023
1 parent be7d357 commit aada81b
Show file tree
Hide file tree
Showing 26 changed files with 86 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.jersey.jetty11;
package org.glassfish.jersey.jetty;

import java.io.IOException;
import java.io.OutputStream;
Expand Down Expand Up @@ -49,7 +49,7 @@
import org.glassfish.jersey.internal.inject.ReferencingFactory;
import org.glassfish.jersey.internal.util.ExtendedLogger;
import org.glassfish.jersey.internal.util.collection.Ref;
import org.glassfish.jersey.jetty11.internal.LocalizationMessages;
import org.glassfish.jersey.jetty.internal.LocalizationMessages;
import org.glassfish.jersey.process.internal.RequestScoped;
import org.glassfish.jersey.server.ApplicationHandler;
import org.glassfish.jersey.server.ContainerException;
Expand All @@ -73,10 +73,10 @@
* @author Libor Kramolis
* @author Marek Potociar
*/
public final class Jetty11HttpContainer extends AbstractHandler implements Container {
public final class JettyHttpContainer extends AbstractHandler implements Container {

private static final ExtendedLogger LOGGER =
new ExtendedLogger(Logger.getLogger(Jetty11HttpContainer.class.getName()), Level.FINEST);
new ExtendedLogger(Logger.getLogger(JettyHttpContainer.class.getName()), Level.FINEST);

private static final Type REQUEST_TYPE = (new GenericType<Ref<Request>>() {}).getType();
private static final Type RESPONSE_TYPE = (new GenericType<Ref<Response>>() {}).getType();
Expand Down Expand Up @@ -471,7 +471,7 @@ public void doStop() throws Exception {
* @param application JAX-RS / Jersey application to be deployed on Jetty HTTP container.
* @param parentContext DI provider specific context with application's registered bindings.
*/
Jetty11HttpContainer(final Application application, final Object parentContext) {
JettyHttpContainer(final Application application, final Object parentContext) {
this.appHandler = new ApplicationHandler(application, new JettyBinder(), parentContext);
}

Expand All @@ -480,7 +480,7 @@ public void doStop() throws Exception {
*
* @param application JAX-RS / Jersey application to be deployed on Jetty HTTP container.
*/
Jetty11HttpContainer(final Application application) {
JettyHttpContainer(final Application application) {
this.appHandler = new ApplicationHandler(application, new JettyBinder());

cacheConfigSetStatusOverSendError();
Expand All @@ -491,7 +491,7 @@ public void doStop() throws Exception {
*
* @param applicationClass JAX-RS / Jersey class of application to be deployed on Jetty HTTP container.
*/
Jetty11HttpContainer(final Class<? extends Application> applicationClass) {
JettyHttpContainer(final Class<? extends Application> applicationClass) {
this.appHandler = new ApplicationHandler(applicationClass, new JettyBinder());

cacheConfigSetStatusOverSendError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.jersey.jetty11;
package org.glassfish.jersey.jetty;

import java.net.URI;
import java.util.concurrent.ThreadFactory;

import jakarta.ws.rs.ProcessingException;

import org.glassfish.jersey.internal.guava.ThreadFactoryBuilder;
import org.glassfish.jersey.jetty11.internal.LocalizationMessages;
import org.glassfish.jersey.jetty.internal.LocalizationMessages;
import org.glassfish.jersey.process.JerseyProcessingUncaughtExceptionHandler;
import org.glassfish.jersey.server.ContainerFactory;
import org.glassfish.jersey.server.ResourceConfig;
Expand Down Expand Up @@ -50,9 +50,9 @@
* @author Arul Dhesiaseelan (aruld@acm.org)
* @author Marek Potociar
*/
public final class Jetty11HttpContainerFactory {
public final class JettyHttpContainerFactory {

private Jetty11HttpContainerFactory() {
private JettyHttpContainerFactory() {
}

/**
Expand Down Expand Up @@ -107,7 +107,7 @@ public static Server createServer(final URI uri, final boolean start) throws Pro
public static Server createServer(final URI uri, final ResourceConfig config)
throws ProcessingException {

final Jetty11HttpContainer container = ContainerFactory.createContainer(Jetty11HttpContainer.class, config);
final JettyHttpContainer container = ContainerFactory.createContainer(JettyHttpContainer.class, config);
return createServer(uri, null, container, true);
}

Expand All @@ -132,7 +132,7 @@ public static Server createServer(final URI uri, final ResourceConfig config)
*/
public static Server createServer(final URI uri, final ResourceConfig configuration, final boolean start)
throws ProcessingException {
return createServer(uri, null, ContainerFactory.createContainer(Jetty11HttpContainer.class, configuration), start);
return createServer(uri, null, ContainerFactory.createContainer(JettyHttpContainer.class, configuration), start);
}


Expand All @@ -153,12 +153,12 @@ public static Server createServer(final URI uri, final ResourceConfig configurat
*
* @throws ProcessingException in case of any failure when creating a new Jetty {@code Server} instance.
* @throws IllegalArgumentException if {@code uri} is {@code null}.
* @see Jetty11HttpContainer
* @see JettyHttpContainer
* @since 2.12
*/
public static Server createServer(final URI uri, final ResourceConfig config, final boolean start,
final Object parentContext) {
return createServer(uri, null, new Jetty11HttpContainer(config, parentContext), start);
return createServer(uri, null, new JettyHttpContainer(config, parentContext), start);
}


Expand All @@ -177,11 +177,11 @@ public static Server createServer(final URI uri, final ResourceConfig config, fi
*
* @throws ProcessingException in case of any failure when creating a new Jetty {@code Server} instance.
* @throws IllegalArgumentException if {@code uri} is {@code null}.
* @see Jetty11HttpContainer
* @see JettyHttpContainer
* @since 2.12
*/
public static Server createServer(final URI uri, final ResourceConfig config, final Object parentContext) {
return createServer(uri, null, new Jetty11HttpContainer(config, parentContext), true);
return createServer(uri, null, new JettyHttpContainer(config, parentContext), true);
}

/**
Expand All @@ -208,7 +208,7 @@ public static Server createServer(final URI uri, final ResourceConfig config, fi
public static Server createServer(final URI uri, final SslContextFactory.Server sslContextFactory,
final ResourceConfig config)
throws ProcessingException {
final Jetty11HttpContainer container = ContainerFactory.createContainer(Jetty11HttpContainer.class, config);
final JettyHttpContainer container = ContainerFactory.createContainer(JettyHttpContainer.class, config);
return createServer(uri, sslContextFactory, container, true);
}

Expand All @@ -230,11 +230,11 @@ public static Server createServer(final URI uri, final SslContextFactory.Server
*
* @throws ProcessingException in case of any failure when creating a new Jetty {@code Server} instance.
* @throws IllegalArgumentException if {@code uri} is {@code null}.
* @see Jetty11HttpContainer
* @see JettyHttpContainer
*/
public static Server createServer(final URI uri,
final SslContextFactory.Server sslContextFactory,
final Jetty11HttpContainer handler,
final JettyHttpContainer handler,
final boolean start) {
if (uri == null) {
throw new IllegalArgumentException(LocalizationMessages.URI_CANNOT_BE_NULL());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.jersey.jetty11;
package org.glassfish.jersey.jetty;

import jakarta.ws.rs.ProcessingException;
import jakarta.ws.rs.core.Application;

import org.glassfish.jersey.internal.util.JdkVersion;
import org.glassfish.jersey.jetty11.internal.LocalizationMessages;
import org.glassfish.jersey.jetty.internal.LocalizationMessages;
import org.glassfish.jersey.server.spi.ContainerProvider;

/**
Expand All @@ -29,16 +29,16 @@
* @author Arul Dhesiaseelan (aruld@acm.org)
* @author Marek Potociar
*/
public final class Jetty11HttpContainerProvider implements ContainerProvider {
public final class JettyHttpContainerProvider implements ContainerProvider {

public static final String HANDLER_NAME = "org.eclipse.jetty.server.Handler";
@Override
public <T> T createContainer(final Class<T> type, final Application application) throws ProcessingException {
if (JdkVersion.getJdkVersion().getMajor() < 11) {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}
if (type != null && (HANDLER_NAME.equalsIgnoreCase(type.getCanonicalName()) || Jetty11HttpContainer.class == type)) {
return type.cast(new Jetty11HttpContainer(application));
if (type != null && (HANDLER_NAME.equalsIgnoreCase(type.getCanonicalName()) || JettyHttpContainer.class == type)) {
return type.cast(new JettyHttpContainer(application));
}
return null;
}
Expand All @@ -48,8 +48,8 @@ public <T> T createContainer(final Class<T> type, final Application application,
if (JdkVersion.getJdkVersion().getMajor() < 11) {
throw new ProcessingException(LocalizationMessages.NOT_SUPPORTED());
}
if (type != null && (HANDLER_NAME.equalsIgnoreCase(type.getCanonicalName()) || Jetty11HttpContainer.class == type)) {
return type.cast(new Jetty11HttpContainer(application, parentContext));
if (type != null && (HANDLER_NAME.equalsIgnoreCase(type.getCanonicalName()) || JettyHttpContainer.class == type)) {
return type.cast(new JettyHttpContainer(application, parentContext));
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.jersey.jetty11;
package org.glassfish.jersey.jetty;

import static jakarta.ws.rs.SeBootstrap.Configuration.SSLClientAuthentication.MANDATORY;
import static jakarta.ws.rs.SeBootstrap.Configuration.SSLClientAuthentication.OPTIONAL;
Expand All @@ -39,22 +39,22 @@
* @author Markus KARG (markus@headcrashing.eu)
* @since 3.1.0
*/
final class Jetty11HttpServer implements WebServer {
final class JettyHttpServer implements WebServer {

private final Jetty11HttpContainer container;
private final JettyHttpContainer container;

private final org.eclipse.jetty.server.Server httpServer;

Jetty11HttpServer(final Application application, final JerseySeBootstrapConfiguration configuration) {
this(ContainerFactory.createContainer(Jetty11HttpContainer.class, application), configuration);
JettyHttpServer(final Application application, final JerseySeBootstrapConfiguration configuration) {
this(ContainerFactory.createContainer(JettyHttpContainer.class, application), configuration);
}

Jetty11HttpServer(final Class<? extends Application> applicationClass,
JettyHttpServer(final Class<? extends Application> applicationClass,
final JerseySeBootstrapConfiguration configuration) {
this(new Jetty11HttpContainer(applicationClass), configuration);
this(new JettyHttpContainer(applicationClass), configuration);
}

Jetty11HttpServer(final Jetty11HttpContainer container, final JerseySeBootstrapConfiguration configuration) {
JettyHttpServer(final JettyHttpContainer container, final JerseySeBootstrapConfiguration configuration) {
final SeBootstrap.Configuration.SSLClientAuthentication sslClientAuthentication = configuration
.sslClientAuthentication();
final SslContextFactory.Server sslContextFactory;
Expand All @@ -67,15 +67,15 @@ final class Jetty11HttpServer implements WebServer {
sslContextFactory = null;
}
this.container = container;
this.httpServer = Jetty11HttpContainerFactory.createServer(
this.httpServer = JettyHttpContainerFactory.createServer(
configuration.uri(true),
sslContextFactory,
this.container,
configuration.autoStart());
}

@Override
public final Jetty11HttpContainer container() {
public final JettyHttpContainer container() {
return this.container;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.jersey.jetty11;
package org.glassfish.jersey.jetty;

import jakarta.ws.rs.SeBootstrap;
import jakarta.ws.rs.core.Application;
Expand All @@ -31,21 +31,21 @@
* @author Markus KARG (markus@headcrashing.eu)
* @since 3.1.0
*/
public final class Jetty11HttpServerProvider implements WebServerProvider {
public final class JettyHttpServerProvider implements WebServerProvider {

@Override
public <T extends WebServer> T createServer(final Class<T> type, final Application application,
final SeBootstrap.Configuration configuration) {
return WebServerProvider.isSupportedWebServer(Jetty11HttpServer.class, type, configuration)
? type.cast(new Jetty11HttpServer(application, JerseySeBootstrapConfiguration.from(configuration)))
return WebServerProvider.isSupportedWebServer(JettyHttpServer.class, type, configuration)
? type.cast(new JettyHttpServer(application, JerseySeBootstrapConfiguration.from(configuration)))
: null;
}

@Override
public <T extends WebServer> T createServer(final Class<T> type, final Class<? extends Application> applicationClass,
final SeBootstrap.Configuration configuration) {
return WebServerProvider.isSupportedWebServer(Jetty11HttpServer.class, type, configuration)
? type.cast(new Jetty11HttpServer(applicationClass, JerseySeBootstrapConfiguration.from(configuration)))
return WebServerProvider.isSupportedWebServer(JettyHttpServer.class, type, configuration)
? type.cast(new JettyHttpServer(applicationClass, JerseySeBootstrapConfiguration.from(configuration)))
: null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
/**
* Jersey Jetty container classes.
*/
package org.glassfish.jersey.jetty11;
package org.glassfish.jersey.jetty;
Original file line number Diff line number Diff line change
@@ -1 +1 @@
org.glassfish.jersey.jetty11.Jetty11HttpContainerProvider
org.glassfish.jersey.jetty.JettyHttpContainerProvider
Original file line number Diff line number Diff line change
@@ -1 +1 @@
org.glassfish.jersey.jetty11.Jetty11HttpServerProvider
org.glassfish.jersey.jetty.JettyHttpServerProvider
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.jersey.jetty11;
package org.glassfish.jersey.jetty;

import java.net.URI;
import java.security.AccessController;
Expand All @@ -40,9 +40,9 @@
* @author Arul Dhesiaseelan (aruld at acm.org)
* @author Miroslav Fuksa
*/
public abstract class AbstractJetty11ServerTester {
public abstract class AbstractJettyServerTester {

private static final Logger LOGGER = Logger.getLogger(AbstractJetty11ServerTester.class.getName());
private static final Logger LOGGER = Logger.getLogger(AbstractJettyServerTester.class.getName());

public static final String CONTEXT = "";
private static final int DEFAULT_PORT = 0; // rather Jetty choose than 9998
Expand Down Expand Up @@ -103,7 +103,7 @@ public void startServer(Class<?>... resources) {

public void startServer(ResourceConfig config) {
final URI baseUri = getBaseUri();
server = Jetty11HttpContainerFactory.createServer(baseUri, config);
server = JettyHttpContainerFactory.createServer(baseUri, config);
LOGGER.log(Level.INFO, "Jetty-http server started on base uri: " + getBaseUri());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.jersey.jetty11;
package org.glassfish.jersey.jetty;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
Expand Down Expand Up @@ -42,7 +42,7 @@
* @author Arul Dhesiaseelan (aruld at acm.org)
* @author Michal Gajdos
*/
public class AsyncTest extends AbstractJetty11ServerTester {
public class AsyncTest extends AbstractJettyServerTester {

@Path("/async")
@SuppressWarnings("VoidMethodAnnotatedWithGET")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.jersey.jetty11;
package org.glassfish.jersey.jetty;

import org.apache.http.HttpHost;
import org.apache.http.client.methods.CloseableHttpResponse;
Expand All @@ -40,7 +40,7 @@
/**
* @author Paul Sandoz
*/
public class ExceptionTest extends AbstractJetty11ServerTester {
public class ExceptionTest extends AbstractJettyServerTester {
@Path("{status}")
public static class ExceptionResource {
@GET
Expand Down
Loading

0 comments on commit aada81b

Please sign in to comment.