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

Issue #9396 - fixes to resolve WebSocket JPMS warnings #9915

Merged
merged 15 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from 14 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

module org.eclipse.jetty.websocket.server
{
requires org.eclipse.jetty.server;
requires org.eclipse.jetty.websocket.core.server;
requires org.eclipse.jetty.websocket.common;
requires org.slf4j;

requires transitive org.eclipse.jetty.server;
requires transitive org.eclipse.jetty.websocket.api;

exports org.eclipse.jetty.websocket.server;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.eclipse.jetty.websocket.api.WebSocketContainer;
import org.eclipse.jetty.websocket.api.WebSocketSessionListener;
import org.eclipse.jetty.websocket.common.SessionTracker;
import org.eclipse.jetty.websocket.core.WebSocketComponents;
import org.eclipse.jetty.websocket.core.exception.WebSocketException;
import org.eclipse.jetty.websocket.core.server.FrameHandlerFactory;
import org.eclipse.jetty.websocket.core.server.WebSocketMappings;
Expand All @@ -58,23 +57,18 @@ public class ServerWebSocketContainer extends ContainerLifeCycle implements WebS
private final FrameHandlerFactory factory;
private InvocationType invocationType = InvocationType.BLOCKING;

public ServerWebSocketContainer(WebSocketMappings mappings)
ServerWebSocketContainer(WebSocketMappings mappings)
{
this.mappings = mappings;
this.factory = new ServerFrameHandlerFactory(this, mappings.getWebSocketComponents());
addSessionListener(sessionTracker);
addBean(sessionTracker);
}

public WebSocketComponents getWebSocketComponents()
{
return mappings.getWebSocketComponents();
}

@Override
public Executor getExecutor()
{
return getWebSocketComponents().getExecutor();
return mappings.getWebSocketComponents().getExecutor();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,20 @@ public class WebSocketUpgradeHandler extends Handler.Wrapper
*/
public static WebSocketUpgradeHandler from(Server server, ContextHandler context)
{
WebSocketUpgradeHandler wsHandler = new WebSocketUpgradeHandler(WebSocketServerComponents.ensureWebSocketComponents(server, context));
context.getContext().setAttribute(WebSocketContainer.class.getName(), wsHandler.container);
WebSocketComponents components = WebSocketServerComponents.ensureWebSocketComponents(server, context);
WebSocketMappings mappings = new WebSocketMappings(components);
ServerWebSocketContainer container = new ServerWebSocketContainer(mappings);

WebSocketUpgradeHandler wsHandler = new WebSocketUpgradeHandler(container);
context.getContext().setAttribute(WebSocketContainer.class.getName(), wsHandler._container);
return wsHandler;
}

private final ServerWebSocketContainer container;
private final ServerWebSocketContainer _container;

private WebSocketUpgradeHandler(WebSocketComponents components)
private WebSocketUpgradeHandler(ServerWebSocketContainer container)
{
this.container = new ServerWebSocketContainer(new WebSocketMappings(components));
_container = container;
addBean(container);
}

Expand All @@ -106,14 +110,14 @@ private WebSocketUpgradeHandler(WebSocketComponents components)
*/
public WebSocketUpgradeHandler configure(Consumer<ServerWebSocketContainer> configurator)
{
configurator.accept(container);
configurator.accept(_container);
return this;
}

@Override
public boolean handle(Request request, Response response, Callback callback) throws Exception
{
if (container.handle(request, response, callback))
if (_container.handle(request, response, callback))
return true;
return super.handle(request, response, callback);
}
Expand All @@ -125,6 +129,6 @@ public InvocationType getInvocationType()
return InvocationType.BLOCKING;
Handler handler = getHandler();
InvocationType handlerInvocationType = handler == null ? InvocationType.NON_BLOCKING : handler.getInvocationType();
return Invocable.combine(handlerInvocationType, container.getInvocationType());
return Invocable.combine(handlerInvocationType, _container.getInvocationType());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.core.AbstractExtension;
import org.eclipse.jetty.websocket.core.Frame;
import org.eclipse.jetty.websocket.core.WebSocketComponents;
import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient;
import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents;
import org.eclipse.jetty.websocket.server.WebSocketUpgradeHandler;
import org.eclipse.jetty.websocket.tests.util.FutureCallback;
import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -66,7 +68,8 @@ public void start() throws Exception
wsHandler.configure(container ->
{
container.addMapping("/", (rq, rs, cb) -> serverSocket);
container.getWebSocketComponents().getExtensionRegistry().register(BlockingOutgoingExtension.class.getName(), BlockingOutgoingExtension.class);
WebSocketComponents components = WebSocketServerComponents.getWebSocketComponents(context);
components.getExtensionRegistry().register(BlockingOutgoingExtension.class.getName(), BlockingOutgoingExtension.class);
});

server.setHandler(context);
Expand Down
7 changes: 6 additions & 1 deletion jetty-ee10/jetty-ee10-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@
<artifactId>jetty-ee10-websocket-jakarta-client</artifactId>
<version>12.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee10.websocket</groupId>
<artifactId>jetty-ee10-websocket-jakarta-client-webapp</artifactId>
<version>12.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee10.websocket</groupId>
<artifactId>jetty-ee10-websocket-jakarta-common</artifactId>
Expand All @@ -137,7 +142,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee10.websocket</groupId>
<artifactId>jetty-ee10-websocket-jetty-client</artifactId>
<artifactId>jetty-ee10-websocket-jetty-client-webapp</artifactId>
<version>12.0.0-SNAPSHOT</version>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion jetty-ee10/jetty-ee10-home/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee10.websocket</groupId>
<artifactId>jetty-ee10-websocket-jetty-client</artifactId>
<artifactId>jetty-ee10-websocket-jetty-client-webapp</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee10.websocket</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.eclipse.jetty.ee10.websocket</groupId>
<artifactId>jetty-ee10-websocket</artifactId>
<version>12.0.0-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-ee10-websocket-jakarta-client-webapp</artifactId>
<name>EE10 :: Websocket :: Jakarta Client WebApp</name>

<properties>
<bundle-symbolic-name>${project.groupId}.jakarta.client.webapp</bundle-symbolic-name>
</properties>

<dependencies>
<dependency>
<groupId>org.eclipse.jetty.ee10.websocket</groupId>
<artifactId>jetty-ee10-websocket-jakarta-client</artifactId>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>manifest</goal>
</goals>
<configuration>
<instructions>
<Bundle-Description>jakarta.websocket.client WebApp Implementation</Bundle-Description>
<Export-Package>
org.eclipse.jetty.ee10.websocket.jakarta.client.webapp.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"
</Export-Package>
<Require-Capability>
osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)";resolution:=optional
</Require-Capability>
<Provide-Capability>
osgi.serviceloader;osgi.serviceloader=jakarta.servlet.ServletContainerInitializer
</Provide-Capability>
</instructions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// ========================================================================
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//

import org.eclipse.jetty.ee10.websocket.jakarta.client.webapp.JakartaWebSocketShutdownContainer;

module org.eclipse.jetty.ee10.websocket.jakarta.client.webapp
{
requires org.slf4j;
requires transitive jakarta.servlet;
requires transitive org.eclipse.jetty.ee10.websocket.jakarta.client;

exports org.eclipse.jetty.ee10.websocket.jakarta.client.webapp;

provides jakarta.servlet.ServletContainerInitializer with
JakartaWebSocketShutdownContainer;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ========================================================================
//

package org.eclipse.jetty.ee10.websocket.jakarta.client.internal;
package org.eclipse.jetty.ee10.websocket.jakarta.client.webapp;

import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.eclipse.jetty.ee10.websocket.jakarta.client.webapp.JakartaWebSocketShutdownContainer
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<optional>true</optional>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
Expand Down Expand Up @@ -78,8 +78,7 @@
osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)";resolution:=optional
</Require-Capability>
<Provide-Capability>
osgi.serviceloader;osgi.serviceloader=jakarta.websocket.ContainerProvider,
osgi.serviceloader;osgi.serviceloader=jakarta.servlet.ServletContainerInitializer
osgi.serviceloader;osgi.serviceloader=jakarta.websocket.ContainerProvider
</Provide-Capability>
</instructions>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@

requires transitive org.eclipse.jetty.ee10.websocket.jakarta.common;

requires static jakarta.servlet;

exports org.eclipse.jetty.ee10.websocket.jakarta.client;

provides jakarta.websocket.ContainerProvider with
org.eclipse.jetty.ee10.websocket.jakarta.client.JakartaWebSocketClientContainerProvider;

provides jakarta.servlet.ServletContainerInitializer with
org.eclipse.jetty.ee10.websocket.jakarta.client.internal.JakartaWebSocketShutdownContainer;
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public JakartaWebSocketConfiguration()
.protectAndExpose("org.eclipse.jetty.ee10.websocket.servlet.") // For WebSocketUpgradeFilter
.protectAndExpose("org.eclipse.jetty.ee10.websocket.jakarta.server.config.")
.protectAndExpose("org.eclipse.jetty.ee10.websocket.jakarta.client.JakartaWebSocketClientContainerProvider")
.protectAndExpose("org.eclipse.jetty.ee10.websocket.jakarta.client.internal.JakartaWebSocketShutdownContainer"));
.protectAndExpose("org.eclipse.jetty.ee10.websocket.jakarta.client.JakartaWebSocketShutdownContainer"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee10.websocket</groupId>
<artifactId>jetty-ee10-websocket-jakarta-client</artifactId>
<artifactId>jetty-ee10-websocket-jakarta-client-webapp</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee10.websocket</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.eclipse.jetty.client.Response;
import org.eclipse.jetty.ee10.webapp.Configuration;
import org.eclipse.jetty.ee10.websocket.jakarta.client.JakartaWebSocketClientContainerProvider;
import org.eclipse.jetty.ee10.websocket.jakarta.client.internal.JakartaWebSocketShutdownContainer;
import org.eclipse.jetty.ee10.websocket.jakarta.client.webapp.JakartaWebSocketShutdownContainer;
import org.eclipse.jetty.ee10.websocket.jakarta.common.JakartaWebSocketContainer;
import org.eclipse.jetty.ee10.websocket.jakarta.server.config.JakartaWebSocketConfiguration;
import org.eclipse.jetty.http.BadMessageException;
Expand Down Expand Up @@ -95,6 +95,7 @@ public WSServer.WebApp createWebSocketWebapp(String contextName) throws Exceptio
// Copy over the individual jars required for Jakarta WebSocket.
app.createWebInf();
app.copyLib(JakartaWebSocketClientContainerProvider.class, "jetty-ee10-websocket-jakarta-client.jar");
app.copyLib(JakartaWebSocketShutdownContainer.class, "jetty-ee10-websocket-jakarta-client-webapp.jar");
app.copyLib(JakartaWebSocketContainer.class, "jetty-ee10-websocket-jakarta-common.jar");
app.copyLib(ContainerLifeCycle.class, "jetty-util.jar");
app.copyLib(CoreClientUpgradeRequest.class, "jetty-websocket-core-client.jar");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>jetty-ee10-websocket-jetty-client</artifactId>
<name>EE10 :: Websocket :: Jetty Client</name>
<artifactId>jetty-ee10-websocket-jetty-client-webapp</artifactId>
<name>EE10 :: Websocket :: Jetty Client WebApp</name>

<properties>
<bundle-symbolic-name>${project.groupId}.client</bundle-symbolic-name>
<bundle-symbolic-name>${project.groupId}.client.webapp</bundle-symbolic-name>
</properties>

<build>
Expand Down Expand Up @@ -42,7 +42,6 @@
<dependency>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-webapp</artifactId>
<optional>true</optional>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ee10-annotations
websocket-jetty-client

[lib]
lib/ee10-websocket/jetty-ee10-websocket-jetty-client-${jetty.version}.jar
lib/ee10-websocket/jetty-ee10-websocket-jetty-client-webapp-${jetty.version}.jar

[jpms]
# The implementation needs to access method handles in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
// ========================================================================
//

import org.eclipse.jetty.ee10.websocket.client.config.JettyWebSocketClientConfiguration;

module org.eclipse.jetty.ee10.websocket.jetty.client
{
requires org.eclipse.jetty.websocket.client;

requires static org.eclipse.jetty.ee10.webapp;
requires transitive org.eclipse.jetty.ee10.webapp;

exports org.eclipse.jetty.ee10.websocket.client.config;

provides org.eclipse.jetty.ee10.webapp.Configuration with JettyWebSocketClientConfiguration;
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty.ee10.websocket</groupId>
<artifactId>jetty-ee10-websocket-jetty-client</artifactId>
<artifactId>jetty-ee10-websocket-jetty-client-webapp</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
3 changes: 2 additions & 1 deletion jetty-ee10/jetty-ee10-websocket/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@

<modules>
<module>jetty-ee10-websocket-jakarta-client</module>
<module>jetty-ee10-websocket-jakarta-client-webapp</module>
<module>jetty-ee10-websocket-jakarta-common</module>
<module>jetty-ee10-websocket-jakarta-server</module>
<module>jetty-ee10-websocket-jakarta-tests</module>
<module>jetty-ee10-websocket-jetty-client</module>
<module>jetty-ee10-websocket-jetty-client-webapp</module>
<module>jetty-ee10-websocket-jetty-server</module>
<module>jetty-ee10-websocket-jetty-tests</module>
<module>jetty-ee10-websocket-servlet</module>
Expand Down
Loading