Skip to content

Commit

Permalink
Issue #9396 - fixes to resolve WebSocket JPMS warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Lachlan Roberts <[email protected]>
  • Loading branch information
lachlan-roberts committed Jun 14, 2023
1 parent d3e88a9 commit b0923b2
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@
requires org.eclipse.jetty.websocket.client;

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

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

0 comments on commit b0923b2

Please sign in to comment.