From 121d8985177c8e80d85cb2c403d5dbe5e77da81b Mon Sep 17 00:00:00 2001 From: Lachlan Date: Wed, 2 Dec 2020 11:10:15 +1100 Subject: [PATCH] Move websocket-util classes into websocket-core (#5705) - Merge websocket-util classes into websocket-core - rename websocket-util-server to websocket-servlet - remove websocket-util * merge websocket-util into websocket-core-common * move websocket-util-server implementation to websocket-core-server * rename websocket-util-server to websocket-servlet * Negotiator should not need the WebSocketComponents, give this to handshaker instead * fix tests and WebSocketConfigurations * move exception classes in websocket-core-common * move MessageSinks and util to internal package * create internal package for websocket-core-client * fix JPMS warnings for websocket common modules * Fixed exports declarations to make MethodHandles.publicLookup() working properly. * fix broken tests with wrong WebSocketUpgradeFilter package name * remove -T3 option to not have parallel build * no need of jacoco here * do no reuse forks * remove logback dependency and disable debug log level * make this test dynamic instead of hardcoded version... * use -fae * change websocket-servlet bundle symbolic name * cleanup changes * restore bugs.... * Updates after review. Co-authored-by: Simone Bordet Co-authored-by: olivier lamy --- demos/embedded/pom.xml | 2 +- jetty-bom/pom.xml | 2 +- .../jetty-gcloud-session-manager/pom.xml | 2 +- jetty-home/pom.xml | 2 +- jetty-osgi/test-jetty-osgi/pom.xml | 2 +- .../eclipse/jetty/osgi/test/TestOSGiUtil.java | 3 +- jetty-websocket/pom.xml | 5 +- jetty-websocket/websocket-core-client/pom.xml | 18 +++ .../core/client/CoreClientUpgradeRequest.java | 4 +- .../core/client/WebSocketCoreClient.java | 1 + .../{ => internal}/HttpClientProvider.java | 2 +- .../{ => internal}/HttpUpgraderOverHTTP.java | 3 +- .../{ => internal}/HttpUpgraderOverHTTP2.java | 3 +- .../{ => internal}/XmlHttpClientProvider.java | 4 +- .../src/main/java/module-info.java | 22 +++- .../DuplicateAnnotationException.java | 4 +- .../exception}/InvalidSignatureException.java | 4 +- .../exception}/InvalidWebSocketException.java | 4 +- .../core/{ => internal}/MessageHandler.java | 9 +- .../messages/AbstractMessageSink.java | 2 +- .../messages/ByteArrayMessageSink.java | 4 +- .../messages/ByteBufferMessageSink.java | 4 +- .../messages/DispatchedMessageSink.java | 2 +- .../messages/InputStreamMessageSink.java | 2 +- .../messages/MessageInputStream.java | 2 +- .../messages/MessageOutputStream.java | 2 +- .../internal}/messages/MessageReader.java | 2 +- .../core/internal}/messages/MessageSink.java | 2 +- .../internal}/messages/MessageWriter.java | 2 +- .../messages/PartialByteArrayMessageSink.java | 2 +- .../PartialByteBufferMessageSink.java | 2 +- .../messages/PartialStringMessageSink.java | 2 +- .../internal}/messages/ReaderMessageSink.java | 2 +- .../internal}/messages/StringMessageSink.java | 2 +- .../core/internal}/util/InvokerUtils.java | 3 +- .../core/internal}/util/ReflectUtils.java | 5 +- .../core/internal}/util/TextUtils.java | 2 +- .../core/server}/FrameHandlerFactory.java | 2 +- .../core/server}/ServerUpgradeRequest.java | 13 +- .../core/server}/ServerUpgradeResponse.java | 10 +- .../core/server}/WebSocketCreator.java | 6 +- .../core/server}/WebSocketMappings.java | 116 +++++++----------- ...tiation.java => WebSocketNegotiation.java} | 7 +- .../core/server/WebSocketNegotiator.java | 90 ++------------ .../core/server/WebSocketUpgradeHandler.java | 49 +++----- .../server/internal/AbstractHandshaker.java | 14 +-- .../server/internal/CreatorNegotiator.java | 86 +++++++++++++ .../server/{ => internal}/Handshaker.java | 12 +- .../server/internal/HandshakerSelector.java | 8 +- .../server/internal/RFC6455Handshaker.java | 8 +- .../server/internal/RFC6455Negotiation.java | 4 +- .../server/internal/RFC8441Handshaker.java | 6 +- .../server/internal/RFC8441Negotiation.java | 4 +- .../internal/UpgradeHttpServletRequest.java | 2 +- .../websocket/core/EchoFrameHandler.java | 7 +- .../jetty/websocket/core/FlushTest.java | 2 +- .../jetty/websocket/core/FrameBufferTest.java | 2 +- .../websocket/core/MessageHandlerTest.java | 1 + .../websocket/core/TestMessageHandler.java | 1 + .../websocket/core/TestUpgradeHandler.java | 49 -------- .../core/TestWebSocketNegotiator.java | 44 +------ .../core/TestWebSocketUpgradeHandler.java | 50 -------- .../core/WebSocketNegotiationTest.java | 8 +- .../jetty/websocket/core/WebSocketServer.java | 12 +- .../core/WebSocketUpgradeHandlerTest.java | 76 ++++++++++++ .../core/autobahn/AutobahnTests.java | 2 - .../core/autobahn/CoreAutobahnClient.java | 2 +- .../core/autobahn/CoreAutobahnServer.java | 8 +- .../core/chat/ChatWebSocketClient.java | 2 +- .../core/chat/ChatWebSocketServer.java | 16 ++- .../PerMessageDeflaterBufferSizeTest.java | 4 +- .../extensions/ValidationExtensionTest.java | 4 +- .../core/proxy/WebSocketProxyTest.java | 11 +- .../core}/util/MessageReaderTest.java | 4 +- .../core}/util/MessageWriterTest.java | 4 +- .../util/PartialStringMessageSinkTest.java | 4 +- .../core}/util/StringMessageSinkTest.java | 4 +- .../websocket-javax-client/pom.xml | 5 - .../AnnotatedClientEndpointConfig.java | 2 +- .../JavaxWebSocketClientContainer.java | 2 +- ...vaxWebSocketClientFrameHandlerFactory.java | 2 +- .../websocket-javax-common/pom.xml | 5 - .../src/main/java/module-info.java | 1 - .../common/JavaxWebSocketAsyncRemote.java | 6 +- .../common/JavaxWebSocketBasicRemote.java | 2 +- .../common/JavaxWebSocketFrameHandler.java | 10 +- .../JavaxWebSocketFrameHandlerFactory.java | 16 +-- .../JavaxWebSocketFrameHandlerMetadata.java | 2 +- .../common/JavaxWebSocketMessageMetadata.java | 2 +- .../common/JavaxWebSocketRemoteEndpoint.java | 4 +- .../javax/common/JavaxWebSocketSession.java | 2 +- .../common/decoders/AvailableDecoders.java | 6 +- .../common/encoders/AvailableEncoders.java | 6 +- .../messages/AbstractDecodedMessageSink.java | 2 +- .../messages/DecodedBinaryMessageSink.java | 4 +- .../DecodedBinaryStreamMessageSink.java | 4 +- .../messages/DecodedTextMessageSink.java | 4 +- .../DecodedTextStreamMessageSink.java | 4 +- .../common/DummyFrameHandlerFactory.java | 2 +- ...ebSocketFrameHandlerBadSignaturesTest.java | 2 +- ...SocketFrameHandlerOnMessageBinaryTest.java | 2 +- ...ebSocketFrameHandlerOnMessageTextTest.java | 2 +- .../messages/InputStreamMessageSinkTest.java | 2 +- .../messages/ReaderMessageSinkTest.java | 2 +- .../util/InvokerUtilsStaticParamsTest.java | 4 +- .../javax/common/util/InvokerUtilsTest.java | 4 +- .../common/util/NameParamIdentifier.java | 2 +- .../javax/common/util/ReflectUtilsTest.java | 2 +- .../websocket-javax-server/pom.xml | 2 +- .../main/config/modules/websocket-javax.mod | 3 +- .../src/main/java/module-info.java | 7 +- .../config/JavaxWebSocketConfiguration.java | 2 +- ...xWebSocketServletContainerInitializer.java | 6 +- .../AnnotatedServerEndpointConfig.java | 4 +- .../internal/JavaxServerUpgradeRequest.java | 2 +- .../internal/JavaxWebSocketCreator.java | 6 +- .../JavaxWebSocketServerContainer.java | 8 +- ...vaxWebSocketServerFrameHandlerFactory.java | 6 +- .../server/internal/JsrHandshakeRequest.java | 2 +- .../server/internal/JsrHandshakeResponse.java | 2 +- .../server/internal/PathParamIdentifier.java | 4 +- .../tests/CompletableFutureMethodHandle.java | 4 +- .../websocket/javax/tests/CoreServer.java | 65 ++-------- .../framehandlers/FrameHandlerTracker.java | 2 +- .../javax/tests/framehandlers/StaticText.java | 2 +- .../tests/framehandlers/WholeMessageEcho.java | 2 +- .../tests/matchers/IsMessageHandlerType.java | 2 +- .../javax/tests/client/CookiesTest.java | 4 +- .../client/DecoderReaderManySmallTest.java | 2 +- .../tests/client/MessageReceivingTest.java | 22 ++-- .../tests/coders/AvailableDecodersTest.java | 2 +- .../tests/coders/AvailableEncodersTest.java | 2 +- .../javax/tests/coders/DecoderListTest.java | 2 +- .../javax/tests/server/AddEndpointTest.java | 1 - .../javax/tests/server/AltFilterTest.java | 2 +- .../tests/server/DeploymentExceptionTest.java | 2 +- .../src/test/resources/alt-filter-web.xml | 6 +- .../wsuf-alt-config-via-listener.xml | 2 +- .../resources/wsuf-config-via-listener.xml | 2 +- .../wsuf-config-via-servlet-init.xml | 2 +- .../config/modules/websocket-jetty-client.mod | 1 - .../DelegatedJettyClientUpgradeResponse.java | 3 - .../websocket-jetty-common/pom.xml | 2 +- .../src/main/java/module-info.java | 1 - .../common/JettyWebSocketFrameHandler.java | 6 +- .../JettyWebSocketFrameHandlerFactory.java | 28 ++--- .../JettyWebSocketFrameHandlerMetadata.java | 2 +- .../jetty/websocket/common/EndPoints.java | 2 +- .../common/LocalEndpointMetadataTest.java | 12 +- .../common/MessageInputStreamTest.java | 2 +- .../common/MessageOutputStreamTest.java | 2 +- .../common/OutgoingMessageCapture.java | 6 +- .../common/invoke/InvokerUtilsTest.java | 4 +- .../common/invoke/NameParamIdentifier.java | 2 +- .../websocket-jetty-server/pom.xml | 2 +- .../main/config/modules/websocket-jetty.mod | 3 +- .../src/main/java/module-info.java | 3 +- .../server/JettyWebSocketServerContainer.java | 28 ++--- .../server/JettyWebSocketServlet.java | 15 ++- .../config/JettyWebSocketConfiguration.java | 4 +- ...yWebSocketServletContainerInitializer.java | 2 +- .../DelegatedServerUpgradeRequest.java | 2 +- .../DelegatedServerUpgradeResponse.java | 2 +- .../JettyServerFrameHandlerFactory.java | 6 +- .../jetty/websocket/tests/EchoSocket.java | 1 - .../jetty/websocket/tests/ErrorCloseTest.java | 1 + .../tests/JettyWebSocketFilterTest.java | 2 +- .../tests/JettyWebSocketNegotiationTest.java | 43 +++++++ .../tests/WebSocketOverHTTP2Test.java | 2 +- .../tests/server/PartialListenerTest.java | 2 +- .../src/test/resources/wsuf-ordering1.xml | 2 +- .../src/test/resources/wsuf-ordering2.xml | 8 +- .../pom.xml | 18 ++- .../src/main/java/module-info.java | 8 +- .../servlet}/WebSocketUpgradeFilter.java | 6 +- jetty-websocket/websocket-util-server/pom.xml | 93 -------------- .../src/main/java/module-info.java | 27 ---- .../test/resources/jetty-logging.properties | 1 - 178 files changed, 685 insertions(+), 860 deletions(-) rename jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/{ => internal}/HttpClientProvider.java (96%) rename jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/{ => internal}/HttpUpgraderOverHTTP.java (97%) rename jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/{ => internal}/HttpUpgraderOverHTTP2.java (94%) rename jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/{ => internal}/XmlHttpClientProvider.java (94%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception}/DuplicateAnnotationException.java (93%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception}/InvalidSignatureException.java (94%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception}/InvalidWebSocketException.java (91%) rename jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/{ => internal}/MessageHandler.java (96%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/messages/AbstractMessageSink.java (95%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/messages/ByteArrayMessageSink.java (96%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/messages/ByteBufferMessageSink.java (96%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/messages/DispatchedMessageSink.java (99%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/messages/InputStreamMessageSink.java (95%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/messages/MessageInputStream.java (99%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/messages/MessageOutputStream.java (99%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/messages/MessageReader.java (98%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/messages/MessageSink.java (95%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/messages/MessageWriter.java (97%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/messages/PartialByteArrayMessageSink.java (96%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/messages/PartialByteBufferMessageSink.java (96%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/messages/PartialStringMessageSink.java (97%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/messages/ReaderMessageSink.java (95%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/messages/StringMessageSink.java (97%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/util/InvokerUtils.java (99%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/util/ReflectUtils.java (98%) rename jetty-websocket/{websocket-util/src/main/java/org/eclipse/jetty/websocket => websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal}/util/TextUtils.java (98%) rename jetty-websocket/{websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal => websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server}/FrameHandlerFactory.java (96%) rename jetty-websocket/{websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal => websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server}/ServerUpgradeRequest.java (96%) rename jetty-websocket/{websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal => websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server}/ServerUpgradeResponse.java (95%) rename jetty-websocket/{websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal => websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server}/WebSocketCreator.java (86%) rename jetty-websocket/{websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal => websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server}/WebSocketMappings.java (71%) rename jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/{Negotiation.java => WebSocketNegotiation.java} (94%) create mode 100644 jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/CreatorNegotiator.java rename jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/{ => internal}/Handshaker.java (75%) rename jetty-websocket/{websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util => websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core}/server/internal/UpgradeHttpServletRequest.java (99%) delete mode 100644 jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestUpgradeHandler.java delete mode 100644 jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketUpgradeHandler.java create mode 100644 jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketUpgradeHandlerTest.java rename jetty-websocket/{websocket-util/src/test/java/org/eclipse/jetty/websocket => websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core}/util/MessageReaderTest.java (97%) rename jetty-websocket/{websocket-util/src/test/java/org/eclipse/jetty/websocket => websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core}/util/MessageWriterTest.java (98%) rename jetty-websocket/{websocket-util/src/test/java/org/eclipse/jetty/websocket => websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core}/util/PartialStringMessageSinkTest.java (97%) rename jetty-websocket/{websocket-util/src/test/java/org/eclipse/jetty/websocket => websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core}/util/StringMessageSinkTest.java (98%) rename jetty-websocket/{websocket-util => websocket-servlet}/pom.xml (77%) rename jetty-websocket/{websocket-util => websocket-servlet}/src/main/java/module-info.java (79%) rename jetty-websocket/{websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server => websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet}/WebSocketUpgradeFilter.java (97%) delete mode 100644 jetty-websocket/websocket-util-server/pom.xml delete mode 100644 jetty-websocket/websocket-util-server/src/main/java/module-info.java delete mode 100644 jetty-websocket/websocket-util/src/test/resources/jetty-logging.properties diff --git a/demos/embedded/pom.xml b/demos/embedded/pom.xml index 1a0cde082d0..dff3c9f69be 100644 --- a/demos/embedded/pom.xml +++ b/demos/embedded/pom.xml @@ -63,7 +63,7 @@ org.eclipse.jetty.websocket - websocket-util-server + websocket-servlet ${project.version} diff --git a/jetty-bom/pom.xml b/jetty-bom/pom.xml index ad8357a1e85..6cb6e4ece0e 100644 --- a/jetty-bom/pom.xml +++ b/jetty-bom/pom.xml @@ -359,7 +359,7 @@ org.eclipse.jetty.websocket - websocket-util-server + websocket-servlet 10.0.0-SNAPSHOT diff --git a/jetty-gcloud/jetty-gcloud-session-manager/pom.xml b/jetty-gcloud/jetty-gcloud-session-manager/pom.xml index 93093f2b624..b4ad7355ace 100644 --- a/jetty-gcloud/jetty-gcloud-session-manager/pom.xml +++ b/jetty-gcloud/jetty-gcloud-session-manager/pom.xml @@ -43,7 +43,7 @@ org.eclipse.jetty.websocket - websocket-util-server + websocket-servlet ${project.version} test diff --git a/jetty-home/pom.xml b/jetty-home/pom.xml index 595cb10fda8..82a909ae5bc 100644 --- a/jetty-home/pom.xml +++ b/jetty-home/pom.xml @@ -620,7 +620,7 @@ org.eclipse.jetty.websocket - websocket-util-server + websocket-servlet ${project.version} diff --git a/jetty-osgi/test-jetty-osgi/pom.xml b/jetty-osgi/test-jetty-osgi/pom.xml index 52a27baa1ca..8c8bb65d240 100644 --- a/jetty-osgi/test-jetty-osgi/pom.xml +++ b/jetty-osgi/test-jetty-osgi/pom.xml @@ -316,7 +316,7 @@ org.eclipse.jetty.websocket - websocket-util-server + websocket-servlet ${project.version} runtime diff --git a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java index ae1039583c3..f64f4f6e6af 100644 --- a/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java +++ b/jetty-osgi/test-jetty-osgi/src/test/java/org/eclipse/jetty/osgi/test/TestOSGiUtil.java @@ -186,8 +186,7 @@ public class TestOSGiUtil res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-core-server").versionAsInProject().start()); res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-core-client").versionAsInProject().start()); res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-core-common").versionAsInProject().start()); - res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-util").versionAsInProject().start()); - res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-util-server").versionAsInProject().start()); + res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-servlet").versionAsInProject().start()); res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-jetty-api").versionAsInProject().start()); res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-jetty-server").versionAsInProject().start()); res.add(mavenBundle().groupId("org.eclipse.jetty.websocket").artifactId("websocket-jetty-client").versionAsInProject().start()); diff --git a/jetty-websocket/pom.xml b/jetty-websocket/pom.xml index f6d97ef4cf2..082b8b56fcb 100644 --- a/jetty-websocket/pom.xml +++ b/jetty-websocket/pom.xml @@ -28,9 +28,8 @@ websocket-javax-client websocket-javax-server websocket-javax-tests - - websocket-util - websocket-util-server + + websocket-servlet diff --git a/jetty-websocket/websocket-core-client/pom.xml b/jetty-websocket/websocket-core-client/pom.xml index 5924b661527..de982a6ccc6 100644 --- a/jetty-websocket/websocket-core-client/pom.xml +++ b/jetty-websocket/websocket-core-client/pom.xml @@ -77,6 +77,24 @@ + + org.apache.felix + maven-bundle-plugin + true + + + generate-manifest + + manifest + + + + *,org.eclipse.jetty.websocket.core.client.internal.* + + + + + diff --git a/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/CoreClientUpgradeRequest.java b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/CoreClientUpgradeRequest.java index b9535643759..2497210ca2f 100644 --- a/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/CoreClientUpgradeRequest.java +++ b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/CoreClientUpgradeRequest.java @@ -52,6 +52,8 @@ import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.WebSocketConstants; +import org.eclipse.jetty.websocket.core.client.internal.HttpUpgraderOverHTTP; +import org.eclipse.jetty.websocket.core.client.internal.HttpUpgraderOverHTTP2; import org.eclipse.jetty.websocket.core.exception.UpgradeException; import org.eclipse.jetty.websocket.core.exception.WebSocketException; import org.eclipse.jetty.websocket.core.internal.ExtensionStack; @@ -281,7 +283,7 @@ public abstract class CoreClientUpgradeRequest extends HttpRequest implements Re public abstract FrameHandler getFrameHandler(); - void requestComplete() + public void requestComplete() { // Add extensions header filtering out internal extensions and internal parameters. String extensionString = requestedExtensions.stream() diff --git a/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java index 8e4ab6182b5..3fc29fbf9f5 100644 --- a/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java +++ b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java @@ -32,6 +32,7 @@ import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry; +import org.eclipse.jetty.websocket.core.client.internal.HttpClientProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/HttpClientProvider.java b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpClientProvider.java similarity index 96% rename from jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/HttpClientProvider.java rename to jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpClientProvider.java index 935e768482e..e614233ada6 100644 --- a/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/HttpClientProvider.java +++ b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpClientProvider.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.core.client; +package org.eclipse.jetty.websocket.core.client.internal; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.util.thread.QueuedThreadPool; diff --git a/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/HttpUpgraderOverHTTP.java b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpUpgraderOverHTTP.java similarity index 97% rename from jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/HttpUpgraderOverHTTP.java rename to jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpUpgraderOverHTTP.java index 318fd537a8e..d91d70c22c6 100644 --- a/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/HttpUpgraderOverHTTP.java +++ b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpUpgraderOverHTTP.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.core.client; +package org.eclipse.jetty.websocket.core.client.internal; import java.nio.charset.StandardCharsets; import java.util.Base64; @@ -34,6 +34,7 @@ import org.eclipse.jetty.http.PreEncodedHttpField; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.WebSocketConstants; +import org.eclipse.jetty.websocket.core.client.CoreClientUpgradeRequest; import org.eclipse.jetty.websocket.core.internal.WebSocketCore; public class HttpUpgraderOverHTTP implements HttpUpgrader diff --git a/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/HttpUpgraderOverHTTP2.java b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpUpgraderOverHTTP2.java similarity index 94% rename from jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/HttpUpgraderOverHTTP2.java rename to jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpUpgraderOverHTTP2.java index 6b3cd28ba01..a59e6159e58 100644 --- a/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/HttpUpgraderOverHTTP2.java +++ b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/HttpUpgraderOverHTTP2.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.core.client; +package org.eclipse.jetty.websocket.core.client.internal; import org.eclipse.jetty.client.HttpRequest; import org.eclipse.jetty.client.HttpResponse; @@ -27,6 +27,7 @@ import org.eclipse.jetty.http.PreEncodedHttpField; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.WebSocketConstants; +import org.eclipse.jetty.websocket.core.client.CoreClientUpgradeRequest; public class HttpUpgraderOverHTTP2 implements HttpUpgrader { diff --git a/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/XmlHttpClientProvider.java b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/XmlHttpClientProvider.java similarity index 94% rename from jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/XmlHttpClientProvider.java rename to jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/XmlHttpClientProvider.java index af9962bc3d3..6bc2b5c59dd 100644 --- a/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/XmlHttpClientProvider.java +++ b/jetty-websocket/websocket-core-client/src/main/java/org/eclipse/jetty/websocket/core/client/internal/XmlHttpClientProvider.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.core.client; +package org.eclipse.jetty.websocket.core.client.internal; import java.net.URL; @@ -26,7 +26,7 @@ import org.eclipse.jetty.xml.XmlConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -class XmlHttpClientProvider implements HttpClientProvider +public class XmlHttpClientProvider implements HttpClientProvider { private static final Logger LOG = LoggerFactory.getLogger(XmlHttpClientProvider.class); diff --git a/jetty-websocket/websocket-core-common/src/main/java/module-info.java b/jetty-websocket/websocket-core-common/src/main/java/module-info.java index 43087904262..659ac5ac660 100644 --- a/jetty-websocket/websocket-core-common/src/main/java/module-info.java +++ b/jetty-websocket/websocket-core-common/src/main/java/module-info.java @@ -26,7 +26,27 @@ module org.eclipse.jetty.websocket.core.common { exports org.eclipse.jetty.websocket.core; exports org.eclipse.jetty.websocket.core.exception; - exports org.eclipse.jetty.websocket.core.internal to org.eclipse.jetty.websocket.core.client, org.eclipse.jetty.websocket.core.server, org.eclipse.jetty.util; + + exports org.eclipse.jetty.websocket.core.internal to + org.eclipse.jetty.websocket.core.client, + org.eclipse.jetty.websocket.core.server; + + // The Jetty & Javax API Layers need to access both access some internal utilities which we don't want to expose. + exports org.eclipse.jetty.websocket.core.internal.util to + org.eclipse.jetty.websocket.jetty.common, + org.eclipse.jetty.websocket.jetty.client, + org.eclipse.jetty.websocket.jetty.server, + org.eclipse.jetty.websocket.javax.common, + org.eclipse.jetty.websocket.javax.client, + org.eclipse.jetty.websocket.javax.server; + + exports org.eclipse.jetty.websocket.core.internal.messages to + org.eclipse.jetty.websocket.jetty.common, + org.eclipse.jetty.websocket.jetty.client, + org.eclipse.jetty.websocket.jetty.server, + org.eclipse.jetty.websocket.javax.common, + org.eclipse.jetty.websocket.javax.client, + org.eclipse.jetty.websocket.javax.server; requires org.eclipse.jetty.http; requires transitive org.eclipse.jetty.io; diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/DuplicateAnnotationException.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/DuplicateAnnotationException.java similarity index 93% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/DuplicateAnnotationException.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/DuplicateAnnotationException.java index df3a7b49fa8..f868c5d7864 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/DuplicateAnnotationException.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/DuplicateAnnotationException.java @@ -16,11 +16,13 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util; +package org.eclipse.jetty.websocket.core.exception; import java.lang.annotation.Annotation; import java.lang.reflect.Method; +import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils; + @SuppressWarnings("serial") public class DuplicateAnnotationException extends InvalidWebSocketException { diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/InvalidSignatureException.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/InvalidSignatureException.java similarity index 94% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/InvalidSignatureException.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/InvalidSignatureException.java index 388b0faae47..8c780d7c61b 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/InvalidSignatureException.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/InvalidSignatureException.java @@ -16,12 +16,14 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util; +package org.eclipse.jetty.websocket.core.exception; import java.lang.annotation.Annotation; import java.lang.invoke.MethodType; import java.lang.reflect.Method; +import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils; + @SuppressWarnings("serial") public class InvalidSignatureException extends InvalidWebSocketException { diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/InvalidWebSocketException.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/InvalidWebSocketException.java similarity index 91% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/InvalidWebSocketException.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/InvalidWebSocketException.java index 8b8329f4e38..294ec23ba5c 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/InvalidWebSocketException.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/exception/InvalidWebSocketException.java @@ -16,9 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util; - -import org.eclipse.jetty.websocket.core.exception.WebSocketException; +package org.eclipse.jetty.websocket.core.exception; /** * Indicating that the provided Class is not a valid WebSocket per the chosen API. diff --git a/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/MessageHandler.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/MessageHandler.java similarity index 96% rename from jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/MessageHandler.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/MessageHandler.java index 4a2620ddf4d..20239959fb9 100644 --- a/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/MessageHandler.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/MessageHandler.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.core; +package org.eclipse.jetty.websocket.core.internal; import java.io.ByteArrayOutputStream; import java.nio.ByteBuffer; @@ -27,6 +27,11 @@ import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.IteratingNestedCallback; import org.eclipse.jetty.util.Utf8Appendable; import org.eclipse.jetty.util.Utf8StringBuilder; +import org.eclipse.jetty.websocket.core.CloseStatus; +import org.eclipse.jetty.websocket.core.CoreSession; +import org.eclipse.jetty.websocket.core.Frame; +import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.exception.BadPayloadException; import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; import org.slf4j.Logger; @@ -87,7 +92,7 @@ public class MessageHandler implements FrameHandler }; } - protected static final Logger LOG = LoggerFactory.getLogger(MessageHandler.class); + private static final Logger LOG = LoggerFactory.getLogger(MessageHandler.class); private CoreSession coreSession; private Utf8StringBuilder textMessageBuffer; diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/AbstractMessageSink.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/AbstractMessageSink.java similarity index 95% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/AbstractMessageSink.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/AbstractMessageSink.java index 14d1cc85713..e91595cb8fe 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/AbstractMessageSink.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/AbstractMessageSink.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.messages; +package org.eclipse.jetty.websocket.core.internal.messages; import java.lang.invoke.MethodHandle; import java.util.Objects; diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/ByteArrayMessageSink.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/ByteArrayMessageSink.java similarity index 96% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/ByteArrayMessageSink.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/ByteArrayMessageSink.java index 4b84a54156d..414b353f819 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/ByteArrayMessageSink.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/ByteArrayMessageSink.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.messages; +package org.eclipse.jetty.websocket.core.internal.messages; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -28,8 +28,8 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; +import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; -import org.eclipse.jetty.websocket.util.InvalidSignatureException; public class ByteArrayMessageSink extends AbstractMessageSink { diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/ByteBufferMessageSink.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/ByteBufferMessageSink.java similarity index 96% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/ByteBufferMessageSink.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/ByteBufferMessageSink.java index 0c255e4e267..4273d1853cb 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/ByteBufferMessageSink.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/ByteBufferMessageSink.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.messages; +package org.eclipse.jetty.websocket.core.internal.messages; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -29,8 +29,8 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; +import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; -import org.eclipse.jetty.websocket.util.InvalidSignatureException; public class ByteBufferMessageSink extends AbstractMessageSink { diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/DispatchedMessageSink.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/DispatchedMessageSink.java similarity index 99% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/DispatchedMessageSink.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/DispatchedMessageSink.java index 805dd70790f..f3a1d3e9bec 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/DispatchedMessageSink.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/DispatchedMessageSink.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.messages; +package org.eclipse.jetty.websocket.core.internal.messages; import java.io.Closeable; import java.lang.invoke.MethodHandle; diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/InputStreamMessageSink.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/InputStreamMessageSink.java similarity index 95% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/InputStreamMessageSink.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/InputStreamMessageSink.java index 161b367dd2e..373c9dda7d4 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/InputStreamMessageSink.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/InputStreamMessageSink.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.messages; +package org.eclipse.jetty.websocket.core.internal.messages; import java.lang.invoke.MethodHandle; diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/MessageInputStream.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/MessageInputStream.java similarity index 99% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/MessageInputStream.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/MessageInputStream.java index c3bc6986769..1fdbadcca17 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/MessageInputStream.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/MessageInputStream.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.messages; +package org.eclipse.jetty.websocket.core.internal.messages; import java.io.IOException; import java.io.InputStream; diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/MessageOutputStream.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/MessageOutputStream.java similarity index 99% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/MessageOutputStream.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/MessageOutputStream.java index e3b841bc05e..f1083b56549 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/MessageOutputStream.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/MessageOutputStream.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.messages; +package org.eclipse.jetty.websocket.core.internal.messages; import java.io.IOException; import java.io.OutputStream; diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/MessageReader.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/MessageReader.java similarity index 98% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/MessageReader.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/MessageReader.java index e20e7da922e..3e513ce8cd4 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/MessageReader.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/MessageReader.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.messages; +package org.eclipse.jetty.websocket.core.internal.messages; import java.io.IOException; import java.io.Reader; diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/MessageSink.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/MessageSink.java similarity index 95% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/MessageSink.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/MessageSink.java index d1b5842d2c5..a014ff0ee32 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/MessageSink.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/MessageSink.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.messages; +package org.eclipse.jetty.websocket.core.internal.messages; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.Frame; diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/MessageWriter.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/MessageWriter.java similarity index 97% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/MessageWriter.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/MessageWriter.java index 4dbde70a72d..ec4b41f3139 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/MessageWriter.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/MessageWriter.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.messages; +package org.eclipse.jetty.websocket.core.internal.messages; import java.io.IOException; import java.io.Writer; diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/PartialByteArrayMessageSink.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/PartialByteArrayMessageSink.java similarity index 96% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/PartialByteArrayMessageSink.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/PartialByteArrayMessageSink.java index bf7058cbe0c..0f84e79ab55 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/PartialByteArrayMessageSink.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/PartialByteArrayMessageSink.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.messages; +package org.eclipse.jetty.websocket.core.internal.messages; import java.lang.invoke.MethodHandle; diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/PartialByteBufferMessageSink.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/PartialByteBufferMessageSink.java similarity index 96% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/PartialByteBufferMessageSink.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/PartialByteBufferMessageSink.java index 9336e93aa52..3df06633dec 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/PartialByteBufferMessageSink.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/PartialByteBufferMessageSink.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.messages; +package org.eclipse.jetty.websocket.core.internal.messages; import java.lang.invoke.MethodHandle; diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/PartialStringMessageSink.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/PartialStringMessageSink.java similarity index 97% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/PartialStringMessageSink.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/PartialStringMessageSink.java index 457bb1461ea..360e6d3ad3c 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/PartialStringMessageSink.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/PartialStringMessageSink.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.messages; +package org.eclipse.jetty.websocket.core.internal.messages; import java.lang.invoke.MethodHandle; import java.util.Objects; diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/ReaderMessageSink.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/ReaderMessageSink.java similarity index 95% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/ReaderMessageSink.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/ReaderMessageSink.java index df70a7cc7b8..37bf49eb302 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/ReaderMessageSink.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/ReaderMessageSink.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.messages; +package org.eclipse.jetty.websocket.core.internal.messages; import java.lang.invoke.MethodHandle; diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/StringMessageSink.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/StringMessageSink.java similarity index 97% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/StringMessageSink.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/StringMessageSink.java index 78fef1afb1b..dabf1024d67 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/messages/StringMessageSink.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/messages/StringMessageSink.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.messages; +package org.eclipse.jetty.websocket.core.internal.messages; import java.lang.invoke.MethodHandle; diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/InvokerUtils.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/util/InvokerUtils.java similarity index 99% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/InvokerUtils.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/util/InvokerUtils.java index 8a3bc181b80..a24f065794c 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/InvokerUtils.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/util/InvokerUtils.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util; +package org.eclipse.jetty.websocket.core.internal.util; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/ReflectUtils.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/util/ReflectUtils.java similarity index 98% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/ReflectUtils.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/util/ReflectUtils.java index bb1a33e6e99..62530c4b854 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/ReflectUtils.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/util/ReflectUtils.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util; +package org.eclipse.jetty.websocket.core.internal.util; import java.lang.annotation.Annotation; import java.lang.invoke.MethodType; @@ -31,6 +31,9 @@ import java.util.List; import java.util.regex.Pattern; import java.util.stream.Stream; +import org.eclipse.jetty.websocket.core.exception.DuplicateAnnotationException; +import org.eclipse.jetty.websocket.core.exception.InvalidWebSocketException; + public class ReflectUtils { diff --git a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/TextUtils.java b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/util/TextUtils.java similarity index 98% rename from jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/TextUtils.java rename to jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/util/TextUtils.java index 20563f8af40..5f96bf616b7 100644 --- a/jetty-websocket/websocket-util/src/main/java/org/eclipse/jetty/websocket/util/TextUtils.java +++ b/jetty-websocket/websocket-core-common/src/main/java/org/eclipse/jetty/websocket/core/internal/util/TextUtils.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util; +package org.eclipse.jetty.websocket.core.internal.util; /** * Collection of utility methods for Text content diff --git a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/FrameHandlerFactory.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/FrameHandlerFactory.java similarity index 96% rename from jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/FrameHandlerFactory.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/FrameHandlerFactory.java index 1eb7c367fee..b39c8123f3e 100644 --- a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/FrameHandlerFactory.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/FrameHandlerFactory.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.server.internal; +package org.eclipse.jetty.websocket.core.server; import org.eclipse.jetty.websocket.core.FrameHandler; diff --git a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/ServerUpgradeRequest.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/ServerUpgradeRequest.java similarity index 96% rename from jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/ServerUpgradeRequest.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/ServerUpgradeRequest.java index 81a9b31e98f..31e88f31f23 100644 --- a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/ServerUpgradeRequest.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/ServerUpgradeRequest.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.server.internal; +package org.eclipse.jetty.websocket.core.server; import java.net.HttpCookie; import java.net.InetSocketAddress; @@ -41,22 +41,19 @@ import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.util.URIUtil; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.WebSocketConstants; -import org.eclipse.jetty.websocket.core.server.Negotiation; +import org.eclipse.jetty.websocket.core.server.internal.UpgradeHttpServletRequest; -/** - * Holder of request data for a WebSocket upgrade request. - */ public class ServerUpgradeRequest { private final URI requestURI; private final String queryString; private final UpgradeHttpServletRequest request; private final boolean secure; - private final Negotiation negotiation; + private final WebSocketNegotiation negotiation; private List cookies; private Map> parameterMap; - public ServerUpgradeRequest(Negotiation negotiation) throws BadMessageException + public ServerUpgradeRequest(WebSocketNegotiation negotiation) throws BadMessageException { this.negotiation = negotiation; HttpServletRequest httpRequest = negotiation.getRequest(); @@ -114,7 +111,7 @@ public class ServerUpgradeRequest /** * @return The extensions offered - * @see Negotiation#getOfferedExtensions() + * @see WebSocketNegotiation#getOfferedExtensions() */ public List getExtensions() { diff --git a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/ServerUpgradeResponse.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/ServerUpgradeResponse.java similarity index 95% rename from jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/ServerUpgradeResponse.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/ServerUpgradeResponse.java index 9c3743136a7..2951475f168 100644 --- a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/ServerUpgradeResponse.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/ServerUpgradeResponse.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.server.internal; +package org.eclipse.jetty.websocket.core.server; import java.io.IOException; import java.util.ArrayList; @@ -31,17 +31,13 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.websocket.core.ExtensionConfig; -import org.eclipse.jetty.websocket.core.server.Negotiation; -/** - * Servlet Specific UpgradeResponse implementation. - */ public class ServerUpgradeResponse { private final HttpServletResponse response; - private final Negotiation negotiation; + private final WebSocketNegotiation negotiation; - public ServerUpgradeResponse(Negotiation negotiation) + public ServerUpgradeResponse(WebSocketNegotiation negotiation) { this.negotiation = negotiation; this.response = negotiation.getResponse(); diff --git a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/WebSocketCreator.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketCreator.java similarity index 86% rename from jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/WebSocketCreator.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketCreator.java index 9479a66d367..be320be7e73 100644 --- a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/WebSocketCreator.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketCreator.java @@ -16,13 +16,13 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.server.internal; +package org.eclipse.jetty.websocket.core.server; /** * Abstract WebSocket creator interface. *

- * Should you desire filtering of the WebSocket object creation due to criteria such as origin or sub-protocol, then you will be required to implement a custom - * WebSocketCreator implementation. + * Should you desire filtering of the WebSocket object creation due to criteria such as origin or sub-protocol, + * then you will be required to implement a custom WebSocketCreator implementation. *

*/ public interface WebSocketCreator diff --git a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/WebSocketMappings.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketMappings.java similarity index 71% rename from jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/WebSocketMappings.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketMappings.java index 687818b1c96..ee5dc0f4f08 100644 --- a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/WebSocketMappings.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketMappings.java @@ -16,10 +16,9 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.server.internal; +package org.eclipse.jetty.websocket.core.server; import java.io.IOException; -import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; @@ -39,10 +38,9 @@ import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.exception.WebSocketException; -import org.eclipse.jetty.websocket.core.server.Handshaker; -import org.eclipse.jetty.websocket.core.server.Negotiation; -import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; -import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents; +import org.eclipse.jetty.websocket.core.server.internal.CreatorNegotiator; +import org.eclipse.jetty.websocket.core.server.internal.Handshaker; +import org.eclipse.jetty.websocket.core.server.internal.HandshakerSelector; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -61,20 +59,14 @@ public class WebSocketMappings implements Dumpable, LifeCycle.Listener private static final Logger LOG = LoggerFactory.getLogger(WebSocketMappings.class); public static final String WEBSOCKET_MAPPING_ATTRIBUTE = WebSocketMappings.class.getName(); - public static WebSocketMappings getMapping(ServletContext servletContext) + public static WebSocketMappings getWebSocketNegotiator(ServletContext servletContext) { return (WebSocketMappings)servletContext.getAttribute(WEBSOCKET_MAPPING_ATTRIBUTE); } - public WebSocketCreator getMapping(PathSpec pathSpec) + public static WebSocketMappings ensureMappings(ServletContext servletContext) { - Negotiator cn = mappings.get(pathSpec); - return cn == null ? null : cn.getWebSocketCreator(); - } - - public static WebSocketMappings ensureMapping(ServletContext servletContext) - { - WebSocketMappings mapping = getMapping(servletContext); + WebSocketMappings mapping = getWebSocketNegotiator(servletContext); if (mapping == null) { mapping = new WebSocketMappings(WebSocketServerComponents.getWebSocketComponents(servletContext)); @@ -123,9 +115,9 @@ public class WebSocketMappings implements Dumpable, LifeCycle.Listener throw new IllegalArgumentException("Unrecognized path spec syntax [" + rawSpec + "]"); } - private final PathMappings mappings = new PathMappings<>(); + private final PathMappings mappings = new PathMappings<>(); private final WebSocketComponents components; - private final Handshaker handshaker = Handshaker.newInstance(); + private final Handshaker handshaker = new HandshakerSelector(); public WebSocketMappings() { @@ -161,6 +153,19 @@ public class WebSocketMappings implements Dumpable, LifeCycle.Listener Dumpable.dumpObjects(out, indent, this, mappings); } + public WebSocketNegotiator getWebSocketNegotiator(PathSpec pathSpec) + { + return mappings.get(pathSpec); + } + + public WebSocketCreator getWebSocketCreator(PathSpec pathSpec) + { + WebSocketNegotiator negotiator = getWebSocketNegotiator(pathSpec); + if (negotiator instanceof CreatorNegotiator) + return ((CreatorNegotiator)negotiator).getWebSocketCreator(); + return null; + } + /** * Manually add a WebSocket mapping. *

@@ -171,12 +176,28 @@ public class WebSocketMappings implements Dumpable, LifeCycle.Listener * * @param pathSpec the pathspec to respond on * @param creator the websocket creator to activate on the provided mapping. - * @param factory the factory to use to create a FrameHandler for the websocket + * @param factory the factory to use to create a FrameHandler for the websocket. * @param customizer the customizer to use to customize the WebSocket session. */ public void addMapping(PathSpec pathSpec, WebSocketCreator creator, FrameHandlerFactory factory, Configuration.Customizer customizer) throws WebSocketException { - mappings.put(pathSpec, new Negotiator(creator, factory, customizer)); + mappings.put(pathSpec, new CreatorNegotiator(creator, factory, customizer)); + } + + /** + * Manually add a WebSocket mapping. + *

+ * If mapping is added before this configuration is started, then it is persisted through + * stop/start of this configuration's lifecycle. Otherwise it will be removed when + * this configuration is stopped. + *

+ * + * @param pathSpec the pathspec to respond on + * @param negotiator the WebSocketNegotiator to use to create a FrameHandler for the websocket. + */ + public void addMapping(PathSpec pathSpec, WebSocketNegotiator negotiator) throws WebSocketException + { + mappings.put(pathSpec, negotiator); } public boolean removeMapping(PathSpec pathSpec) @@ -193,7 +214,7 @@ public class WebSocketMappings implements Dumpable, LifeCycle.Listener */ public WebSocketNegotiator getMatchedNegotiator(String target, Consumer pathSpecConsumer) { - MappedResource mapping = this.mappings.getMatch(target); + MappedResource mapping = this.mappings.getMatch(target); if (mapping == null) return null; @@ -224,59 +245,6 @@ public class WebSocketMappings implements Dumpable, LifeCycle.Listener LOG.debug("WebSocket Negotiated detected on {} for endpoint {}", target, negotiator); // We have an upgrade request - return handshaker.upgradeRequest(negotiator, request, response, defaultCustomizer); - } - - private class Negotiator extends WebSocketNegotiator.AbstractNegotiator - { - private final WebSocketCreator creator; - private final FrameHandlerFactory factory; - - public Negotiator(WebSocketCreator creator, FrameHandlerFactory factory, Configuration.Customizer customizer) - { - super(components, customizer); - this.creator = creator; - this.factory = factory; - } - - public WebSocketCreator getWebSocketCreator() - { - return creator; - } - - @Override - public FrameHandler negotiate(Negotiation negotiation) throws IOException - { - ServletContext servletContext = negotiation.getRequest().getServletContext(); - if (servletContext == null) - throw new IllegalStateException("null servletContext from request"); - - ServerUpgradeRequest upgradeRequest = new ServerUpgradeRequest(negotiation); - ServerUpgradeResponse upgradeResponse = new ServerUpgradeResponse(negotiation); - - AtomicReference result = new AtomicReference<>(); - ((ContextHandler.Context)servletContext).getContextHandler().handle(() -> - result.set(creator.createWebSocket(upgradeRequest, upgradeResponse))); - Object websocketPojo = result.get(); - - // Handling for response forbidden (and similar paths) - if (upgradeResponse.isCommitted()) - return null; - - if (websocketPojo == null) - { - // no creation, sorry - upgradeResponse.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "WebSocket Endpoint Creation Refused"); - return null; - } - - return factory.newFrameHandler(websocketPojo, upgradeRequest, upgradeResponse); - } - - @Override - public String toString() - { - return String.format("%s@%x{%s,%s,%s}", getClass().getSimpleName(), hashCode(), creator, factory, getCustomizer()); - } + return handshaker.upgradeRequest(negotiator, request, response, components, defaultCustomizer); } } diff --git a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/Negotiation.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketNegotiation.java similarity index 94% rename from jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/Negotiation.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketNegotiation.java index 34fc7eb7fdf..8f8020f38b7 100644 --- a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/Negotiation.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketNegotiation.java @@ -33,9 +33,8 @@ import org.eclipse.jetty.http.QuotedCSV; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.WebSocketComponents; -import org.eclipse.jetty.websocket.core.internal.ExtensionStack; -public abstract class Negotiation +public abstract class WebSocketNegotiation { private final Request baseRequest; private final HttpServletRequest request; @@ -45,10 +44,9 @@ public abstract class Negotiation private List offeredExtensions; private List negotiatedExtensions; private List offeredProtocols; - private ExtensionStack extensionStack; private String protocol; - public Negotiation(Request baseRequest, HttpServletRequest request, HttpServletResponse response, WebSocketComponents webSocketComponents) + public WebSocketNegotiation(Request baseRequest, HttpServletRequest request, HttpServletResponse response, WebSocketComponents webSocketComponents) { this.baseRequest = baseRequest; this.request = request; @@ -180,7 +178,6 @@ public abstract class Negotiation if (extensions == offeredExtensions) return; negotiatedExtensions = extensions; - extensionStack = null; } @Override diff --git a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketNegotiator.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketNegotiator.java index 49815689baf..e02811ac870 100644 --- a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketNegotiator.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketNegotiator.java @@ -21,77 +21,41 @@ package org.eclipse.jetty.websocket.core.server; import java.io.IOException; import java.util.function.Function; -import org.eclipse.jetty.io.ByteBufferPool; -import org.eclipse.jetty.util.DecoratedObjectFactory; import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.FrameHandler; -import org.eclipse.jetty.websocket.core.WebSocketComponents; -import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry; public interface WebSocketNegotiator extends Configuration.Customizer { - FrameHandler negotiate(Negotiation negotiation) throws IOException; + FrameHandler negotiate(WebSocketNegotiation negotiation) throws IOException; - WebSocketExtensionRegistry getExtensionRegistry(); - - DecoratedObjectFactory getObjectFactory(); - - ByteBufferPool getByteBufferPool(); - - WebSocketComponents getWebSocketComponents(); - - static WebSocketNegotiator from(Function negotiate) + static WebSocketNegotiator from(Function negotiate) { - return new AbstractNegotiator() + return from(negotiate, null); + } + + static WebSocketNegotiator from(Function negotiate, Configuration.Customizer customizer) + { + return new AbstractNegotiator(customizer) { @Override - public FrameHandler negotiate(Negotiation negotiation) + public FrameHandler negotiate(WebSocketNegotiation negotiation) { return negotiate.apply(negotiation); } }; } - static WebSocketNegotiator from(Function negotiate, Configuration.Customizer customizer) + abstract class AbstractNegotiator extends Configuration.ConfigurationCustomizer implements WebSocketNegotiator { - return new AbstractNegotiator(null, customizer) - { - @Override - public FrameHandler negotiate(Negotiation negotiation) - { - return negotiate.apply(negotiation); - } - }; - } - - static WebSocketNegotiator from( - Function negotiate, - WebSocketComponents components, - Configuration.Customizer customizer) - { - return new AbstractNegotiator(components, customizer) - { - @Override - public FrameHandler negotiate(Negotiation negotiation) - { - return negotiate.apply(negotiation); - } - }; - } - - abstract class AbstractNegotiator implements WebSocketNegotiator - { - final WebSocketComponents components; final Configuration.Customizer customizer; public AbstractNegotiator() { - this(null, null); + this(null); } - public AbstractNegotiator(WebSocketComponents components, Configuration.Customizer customizer) + public AbstractNegotiator(Configuration.Customizer customizer) { - this.components = components == null ? new WebSocketComponents() : components; this.customizer = customizer; } @@ -100,35 +64,7 @@ public interface WebSocketNegotiator extends Configuration.Customizer { if (customizer != null) customizer.customize(configurable); - } - - @Override - public WebSocketExtensionRegistry getExtensionRegistry() - { - return components.getExtensionRegistry(); - } - - @Override - public DecoratedObjectFactory getObjectFactory() - { - return components.getObjectFactory(); - } - - @Override - public ByteBufferPool getByteBufferPool() - { - return components.getBufferPool(); - } - - @Override - public WebSocketComponents getWebSocketComponents() - { - return components; - } - - public Configuration.Customizer getCustomizer() - { - return customizer; + super.customize(configurable); } } } diff --git a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketUpgradeHandler.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketUpgradeHandler.java index e85fda1d2be..9e443b8a968 100644 --- a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketUpgradeHandler.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/WebSocketUpgradeHandler.java @@ -19,65 +19,46 @@ package org.eclipse.jetty.websocket.core.server; import java.io.IOException; -import java.util.Objects; -import java.util.function.Function; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.eclipse.jetty.http.pathmap.PathSpecSet; +import org.eclipse.jetty.http.pathmap.PathSpec; +import org.eclipse.jetty.http.pathmap.ServletPathSpec; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.handler.HandlerWrapper; -import org.eclipse.jetty.websocket.core.FrameHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.eclipse.jetty.websocket.core.Configuration; +import org.eclipse.jetty.websocket.core.WebSocketComponents; public class WebSocketUpgradeHandler extends HandlerWrapper { - private static final Logger LOG = LoggerFactory.getLogger(WebSocketUpgradeHandler.class); - final Handshaker handshaker = Handshaker.newInstance(); - final PathSpecSet paths = new PathSpecSet(); - final WebSocketNegotiator negotiator; + private final WebSocketMappings mappings; + private final Configuration.ConfigurationCustomizer customizer = new Configuration.ConfigurationCustomizer(); - public WebSocketUpgradeHandler( - Function negotiate, - String... pathSpecs) + public WebSocketUpgradeHandler() { - this(WebSocketNegotiator.from(negotiate), pathSpecs); + this(new WebSocketComponents()); } - public WebSocketUpgradeHandler(WebSocketNegotiator negotiator, String... pathSpecs) + public WebSocketUpgradeHandler(WebSocketComponents components) { - this.negotiator = Objects.requireNonNull(negotiator); - addPathSpec(pathSpecs); + this.mappings = new WebSocketMappings(components); } - public WebSocketNegotiator getWebSocketNegotiator() + public void addMapping(String pathSpec, WebSocketNegotiator negotiator) { - return negotiator; + mappings.addMapping(new ServletPathSpec(pathSpec), negotiator); } - public void addPathSpec(String... pathSpecs) + public void addMapping(PathSpec pathSpec, WebSocketNegotiator negotiator) { - if (pathSpecs != null) - { - for (String spec : pathSpecs) - { - this.paths.add(spec); - } - } + mappings.addMapping(pathSpec, negotiator); } @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - if (!paths.isEmpty() && !paths.test(target)) - { - super.handle(target, baseRequest, request, response); - return; - } - - if (handshaker.upgradeRequest(negotiator, request, response, null)) + if (mappings.upgrade(request, response, customizer)) return; if (!baseRequest.isHandled()) diff --git a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java index 6dde83487ff..870aa7c7561 100644 --- a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/AbstractHandshaker.java @@ -47,8 +47,7 @@ import org.eclipse.jetty.websocket.core.internal.ExtensionStack; import org.eclipse.jetty.websocket.core.internal.Negotiated; import org.eclipse.jetty.websocket.core.internal.WebSocketConnection; import org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession; -import org.eclipse.jetty.websocket.core.server.Handshaker; -import org.eclipse.jetty.websocket.core.server.Negotiation; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiation; import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -59,13 +58,12 @@ public abstract class AbstractHandshaker implements Handshaker private static final HttpField SERVER_VERSION = new PreEncodedHttpField(HttpHeader.SERVER, HttpConfiguration.SERVER_VERSION); @Override - public boolean upgradeRequest(WebSocketNegotiator negotiator, HttpServletRequest request, HttpServletResponse response, Configuration.Customizer defaultCustomizer) throws IOException + public boolean upgradeRequest(WebSocketNegotiator negotiator, HttpServletRequest request, HttpServletResponse response, WebSocketComponents components, Configuration.Customizer defaultCustomizer) throws IOException { if (!validateRequest(request)) return false; - WebSocketComponents components = negotiator.getWebSocketComponents(); - Negotiation negotiation = newNegotiation(request, response, components); + WebSocketNegotiation negotiation = newNegotiation(request, response, components); if (LOG.isDebugEnabled()) LOG.debug("negotiation {}", negotiation); negotiation.negotiate(); @@ -173,11 +171,11 @@ public abstract class AbstractHandshaker implements Handshaker protected abstract boolean validateRequest(HttpServletRequest request); - protected abstract Negotiation newNegotiation(HttpServletRequest request, HttpServletResponse response, WebSocketComponents webSocketComponents); + protected abstract WebSocketNegotiation newNegotiation(HttpServletRequest request, HttpServletResponse response, WebSocketComponents webSocketComponents); protected abstract boolean validateFrameHandler(FrameHandler frameHandler, HttpServletResponse response); - protected boolean validateNegotiation(Negotiation negotiation) + protected boolean validateNegotiation(WebSocketNegotiation negotiation) { if (!negotiation.validateHeaders()) { @@ -219,5 +217,5 @@ public abstract class AbstractHandshaker implements Handshaker return new WebSocketConnection(endPoint, executor, scheduler, byteBufferPool, coreSession); } - protected abstract void prepareResponse(Response response, Negotiation negotiation); + protected abstract void prepareResponse(Response response, WebSocketNegotiation negotiation); } diff --git a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/CreatorNegotiator.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/CreatorNegotiator.java new file mode 100644 index 00000000000..f594267c3ca --- /dev/null +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/CreatorNegotiator.java @@ -0,0 +1,86 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under +// the terms of the Eclipse Public License 2.0 which is available at +// https://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: +// the Apache License v2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0 +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.websocket.core.server.internal; + +import java.io.IOException; +import java.util.concurrent.atomic.AtomicReference; +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.server.handler.ContextHandler; +import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.core.server.FrameHandlerFactory; +import org.eclipse.jetty.websocket.core.server.ServerUpgradeRequest; +import org.eclipse.jetty.websocket.core.server.ServerUpgradeResponse; +import org.eclipse.jetty.websocket.core.server.WebSocketCreator; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiation; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; + +public class CreatorNegotiator extends WebSocketNegotiator.AbstractNegotiator +{ + private final WebSocketCreator creator; + private final FrameHandlerFactory factory; + + public CreatorNegotiator(WebSocketCreator creator, FrameHandlerFactory factory, Customizer customizer) + { + super(customizer); + this.creator = creator; + this.factory = factory; + } + + public WebSocketCreator getWebSocketCreator() + { + return creator; + } + + @Override + public FrameHandler negotiate(WebSocketNegotiation negotiation) throws IOException + { + ServletContext servletContext = negotiation.getRequest().getServletContext(); + if (servletContext == null) + throw new IllegalStateException("null servletContext from request"); + + ServerUpgradeRequest upgradeRequest = new ServerUpgradeRequest(negotiation); + ServerUpgradeResponse upgradeResponse = new ServerUpgradeResponse(negotiation); + + AtomicReference result = new AtomicReference<>(); + ((ContextHandler.Context)servletContext).getContextHandler().handle(() -> + result.set(creator.createWebSocket(upgradeRequest, upgradeResponse))); + Object websocketPojo = result.get(); + + // Handling for response forbidden (and similar paths) + if (upgradeResponse.isCommitted()) + return null; + + if (websocketPojo == null) + { + // no creation, sorry + upgradeResponse.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "WebSocket Endpoint Creation Refused"); + return null; + } + + return factory.newFrameHandler(websocketPojo, upgradeRequest, upgradeResponse); + } + + @Override + public String toString() + { + return String.format("%s@%x{%s,%s}", getClass().getSimpleName(), hashCode(), creator, factory); + } +} diff --git a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/Handshaker.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/Handshaker.java similarity index 75% rename from jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/Handshaker.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/Handshaker.java index e3cc18fc7ea..ac68abe9347 100644 --- a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/Handshaker.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/Handshaker.java @@ -16,21 +16,17 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.core.server; +package org.eclipse.jetty.websocket.core.server.internal; import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.websocket.core.Configuration; -import org.eclipse.jetty.websocket.core.server.internal.HandshakerSelector; +import org.eclipse.jetty.websocket.core.WebSocketComponents; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; public interface Handshaker { - static Handshaker newInstance() - { - return new HandshakerSelector(); - } - - boolean upgradeRequest(WebSocketNegotiator negotiator, HttpServletRequest request, HttpServletResponse response, Configuration.Customizer defaultCustomizer) throws IOException; + boolean upgradeRequest(WebSocketNegotiator negotiator, HttpServletRequest request, HttpServletResponse response, WebSocketComponents components, Configuration.Customizer defaultCustomizer) throws IOException; } diff --git a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/HandshakerSelector.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/HandshakerSelector.java index 30a59cd2219..001b8ca502e 100644 --- a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/HandshakerSelector.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/HandshakerSelector.java @@ -23,7 +23,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.websocket.core.Configuration; -import org.eclipse.jetty.websocket.core.server.Handshaker; +import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; /** @@ -37,10 +37,10 @@ public class HandshakerSelector implements Handshaker private final RFC8441Handshaker rfc8441 = new RFC8441Handshaker(); @Override - public boolean upgradeRequest(WebSocketNegotiator negotiator, HttpServletRequest request, HttpServletResponse response, Configuration.Customizer defaultCustomizer) throws IOException + public boolean upgradeRequest(WebSocketNegotiator negotiator, HttpServletRequest request, HttpServletResponse response, WebSocketComponents components, Configuration.Customizer defaultCustomizer) throws IOException { // Try HTTP/1.1 WS upgrade, if this fails try an HTTP/2 WS upgrade if no response was committed. - return rfc6455.upgradeRequest(negotiator, request, response, defaultCustomizer) || - !response.isCommitted() && rfc8441.upgradeRequest(negotiator, request, response, defaultCustomizer); + return rfc6455.upgradeRequest(negotiator, request, response, components, defaultCustomizer) || + !response.isCommitted() && rfc8441.upgradeRequest(negotiator, request, response, components, defaultCustomizer); } } diff --git a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Handshaker.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Handshaker.java index 2c4df763b0b..73f06c0e176 100644 --- a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Handshaker.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Handshaker.java @@ -37,7 +37,7 @@ import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.internal.WebSocketConnection; import org.eclipse.jetty.websocket.core.internal.WebSocketCore; import org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession; -import org.eclipse.jetty.websocket.core.server.Negotiation; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiation; public final class RFC6455Handshaker extends AbstractHandshaker { @@ -65,13 +65,13 @@ public final class RFC6455Handshaker extends AbstractHandshaker } @Override - protected Negotiation newNegotiation(HttpServletRequest request, HttpServletResponse response, WebSocketComponents webSocketComponents) + protected WebSocketNegotiation newNegotiation(HttpServletRequest request, HttpServletResponse response, WebSocketComponents webSocketComponents) { return new RFC6455Negotiation(Request.getBaseRequest(request), request, response, webSocketComponents); } @Override - protected boolean validateNegotiation(Negotiation negotiation) + protected boolean validateNegotiation(WebSocketNegotiation negotiation) { boolean result = super.validateNegotiation(negotiation); if (!result) @@ -103,7 +103,7 @@ public final class RFC6455Handshaker extends AbstractHandshaker } @Override - protected void prepareResponse(Response response, Negotiation negotiation) + protected void prepareResponse(Response response, WebSocketNegotiation negotiation) { response.setStatus(HttpServletResponse.SC_SWITCHING_PROTOCOLS); HttpFields.Mutable responseFields = response.getHttpFields(); diff --git a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Negotiation.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Negotiation.java index b36a46a3b37..f376e10781e 100644 --- a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Negotiation.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC6455Negotiation.java @@ -27,9 +27,9 @@ import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.http.QuotedCSV; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.websocket.core.WebSocketComponents; -import org.eclipse.jetty.websocket.core.server.Negotiation; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiation; -public class RFC6455Negotiation extends Negotiation +public class RFC6455Negotiation extends WebSocketNegotiation { private boolean successful; private String key; diff --git a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Handshaker.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Handshaker.java index 138d7f47844..b0339fe1c7e 100644 --- a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Handshaker.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Handshaker.java @@ -33,7 +33,7 @@ import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.internal.WebSocketConnection; import org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession; -import org.eclipse.jetty.websocket.core.server.Negotiation; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiation; public class RFC8441Handshaker extends AbstractHandshaker { @@ -58,7 +58,7 @@ public class RFC8441Handshaker extends AbstractHandshaker } @Override - protected Negotiation newNegotiation(HttpServletRequest request, HttpServletResponse response, WebSocketComponents webSocketComponents) + protected WebSocketNegotiation newNegotiation(HttpServletRequest request, HttpServletResponse response, WebSocketComponents webSocketComponents) { return new RFC8441Negotiation(Request.getBaseRequest(request), request, response, webSocketComponents); } @@ -87,7 +87,7 @@ public class RFC8441Handshaker extends AbstractHandshaker } @Override - protected void prepareResponse(Response response, Negotiation negotiation) + protected void prepareResponse(Response response, WebSocketNegotiation negotiation) { response.setStatus(HttpStatus.OK_200); } diff --git a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Negotiation.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Negotiation.java index c8e3e6570d9..f3b85a4d15d 100644 --- a/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Negotiation.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/RFC8441Negotiation.java @@ -25,9 +25,9 @@ import org.eclipse.jetty.http.BadMessageException; import org.eclipse.jetty.http.MetaData; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.websocket.core.WebSocketComponents; -import org.eclipse.jetty.websocket.core.server.Negotiation; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiation; -public class RFC8441Negotiation extends Negotiation +public class RFC8441Negotiation extends WebSocketNegotiation { public RFC8441Negotiation(Request baseRequest, HttpServletRequest request, HttpServletResponse response, WebSocketComponents components) throws BadMessageException { diff --git a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/UpgradeHttpServletRequest.java b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/UpgradeHttpServletRequest.java similarity index 99% rename from jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/UpgradeHttpServletRequest.java rename to jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/UpgradeHttpServletRequest.java index 93482fcc5a5..264d42a7b34 100644 --- a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/internal/UpgradeHttpServletRequest.java +++ b/jetty-websocket/websocket-core-server/src/main/java/org/eclipse/jetty/websocket/core/server/internal/UpgradeHttpServletRequest.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.server.internal; +package org.eclipse.jetty.websocket.core.server.internal; import java.io.BufferedReader; import java.net.InetSocketAddress; diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/EchoFrameHandler.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/EchoFrameHandler.java index ee38f271f92..ee9885279ea 100644 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/EchoFrameHandler.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/EchoFrameHandler.java @@ -29,6 +29,11 @@ public class EchoFrameHandler extends TestAsyncFrameHandler throwOnFrame = true; } + public EchoFrameHandler() + { + super(EchoFrameHandler.class.getName()); + } + public EchoFrameHandler(String name) { super(name); @@ -48,7 +53,7 @@ public class EchoFrameHandler extends TestAsyncFrameHandler { if (LOG.isDebugEnabled()) LOG.debug("[{}] echoDataFrame {}", name, frame); - Frame echo = Frame.copy(frame).setMask(null); + Frame echo = new Frame(frame.getOpCode(), frame.isFin(), frame.getPayload()); coreSession.sendFrame(echo, callback, false); } else diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/FlushTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/FlushTest.java index e17524caaf9..a1b5cee76bc 100644 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/FlushTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/FlushTest.java @@ -48,7 +48,7 @@ public class FlushTest @BeforeEach public void startup() throws Exception { - WebSocketNegotiator negotiator = WebSocketNegotiator.from((negotiation) -> serverHandler); + WebSocketNegotiator negotiator = new TestWebSocketNegotiator(serverHandler); server = new WebSocketServer(negotiator); client = new WebSocketCoreClient(null, components); diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/FrameBufferTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/FrameBufferTest.java index 9acce6884bd..ede061c0468 100644 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/FrameBufferTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/FrameBufferTest.java @@ -47,7 +47,7 @@ public class FrameBufferTest extends WebSocketTester @BeforeEach public void startup() throws Exception { - WebSocketNegotiator negotiator = WebSocketNegotiator.from((negotiation) -> serverHandler); + WebSocketNegotiator negotiator = new TestWebSocketNegotiator(serverHandler); server = new WebSocketServer(negotiator); client = new WebSocketCoreClient(null, components); diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/MessageHandlerTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/MessageHandlerTest.java index fc14e360b83..d14be334d8a 100644 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/MessageHandlerTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/MessageHandlerTest.java @@ -31,6 +31,7 @@ import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.FutureCallback; import org.eclipse.jetty.websocket.core.exception.BadPayloadException; import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; +import org.eclipse.jetty.websocket.core.internal.MessageHandler; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestMessageHandler.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestMessageHandler.java index b03310fabf0..0a026fdf1d3 100644 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestMessageHandler.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestMessageHandler.java @@ -24,6 +24,7 @@ import java.util.concurrent.CountDownLatch; import org.eclipse.jetty.util.BlockingArrayQueue; import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.websocket.core.internal.MessageHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestUpgradeHandler.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestUpgradeHandler.java deleted file mode 100644 index 8cbb9543598..00000000000 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestUpgradeHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://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: -// the Apache License v2.0 which is available at -// https://www.apache.org/licenses/LICENSE-2.0 -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// ======================================================================== -// - -package org.eclipse.jetty.websocket.core; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.eclipse.jetty.server.Request; -import org.eclipse.jetty.server.handler.AbstractHandler; -import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; -import org.eclipse.jetty.websocket.core.server.WebSocketUpgradeHandler; - -public class TestUpgradeHandler extends WebSocketUpgradeHandler -{ - public TestUpgradeHandler(WebSocketNegotiator negotiator) - { - super(negotiator); - setHandler(new AbstractHandler() - { - @Override - public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - response.setStatus(200); - response.setContentType("text/plain"); - response.getOutputStream().println("Test WS Upgrade Handler!"); - baseRequest.setHandled(true); - } - }); - } -} diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketNegotiator.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketNegotiator.java index 0b78759587c..06b89962604 100644 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketNegotiator.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketNegotiator.java @@ -21,29 +21,26 @@ package org.eclipse.jetty.websocket.core; import java.io.IOException; import java.util.List; -import org.eclipse.jetty.io.ByteBufferPool; -import org.eclipse.jetty.util.DecoratedObjectFactory; -import org.eclipse.jetty.websocket.core.server.Negotiation; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiation; import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; -public class TestWebSocketNegotiator implements WebSocketNegotiator +public class TestWebSocketNegotiator extends WebSocketNegotiator.AbstractNegotiator { - final WebSocketComponents components; private final FrameHandler frameHandler; public TestWebSocketNegotiator(FrameHandler frameHandler) { - this (frameHandler, new WebSocketComponents()); + this(frameHandler, null); } - public TestWebSocketNegotiator(FrameHandler frameHandler, WebSocketComponents components) + public TestWebSocketNegotiator(FrameHandler frameHandler, Configuration.Customizer customizer) { - this.components = components; + super(customizer); this.frameHandler = frameHandler; } @Override - public FrameHandler negotiate(Negotiation negotiation) throws IOException + public FrameHandler negotiate(WebSocketNegotiation negotiation) throws IOException { List offeredSubprotocols = negotiation.getOfferedSubprotocols(); if (!offeredSubprotocols.isEmpty()) @@ -51,33 +48,4 @@ public class TestWebSocketNegotiator implements WebSocketNegotiator return frameHandler; } - - @Override - public void customize(Configuration configurable) - { - } - - @Override - public WebSocketExtensionRegistry getExtensionRegistry() - { - return components.getExtensionRegistry(); - } - - @Override - public DecoratedObjectFactory getObjectFactory() - { - return components.getObjectFactory(); - } - - @Override - public ByteBufferPool getByteBufferPool() - { - return components.getBufferPool(); - } - - @Override - public WebSocketComponents getWebSocketComponents() - { - return components; - } } diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketUpgradeHandler.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketUpgradeHandler.java deleted file mode 100644 index c75eb8ceeaf..00000000000 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/TestWebSocketUpgradeHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://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: -// the Apache License v2.0 which is available at -// https://www.apache.org/licenses/LICENSE-2.0 -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// ======================================================================== -// - -package org.eclipse.jetty.websocket.core; - -import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.eclipse.jetty.server.Request; -import org.eclipse.jetty.server.handler.AbstractHandler; -import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; -import org.eclipse.jetty.websocket.core.server.WebSocketUpgradeHandler; - -public class TestWebSocketUpgradeHandler extends WebSocketUpgradeHandler -{ - public TestWebSocketUpgradeHandler(WebSocketNegotiator negotiator) - { - super(negotiator); - - setHandler(new AbstractHandler() - { - @Override - public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) - throws IOException, ServletException - { - response.setStatus(200); - response.setContentType("text/plain"); - response.getOutputStream().println("Hello World!"); - baseRequest.setHandled(true); - } - }); - } -} diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java index bc853bf3b56..d652fe4752b 100644 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketNegotiationTest.java @@ -42,7 +42,7 @@ import org.eclipse.jetty.websocket.core.client.UpgradeListener; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; import org.eclipse.jetty.websocket.core.exception.UpgradeException; import org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession; -import org.eclipse.jetty.websocket.core.server.Negotiation; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiation; import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -81,10 +81,10 @@ public class WebSocketNegotiationTest extends WebSocketTester @BeforeEach public void startup() throws Exception { - WebSocketNegotiator negotiator = new WebSocketNegotiator.AbstractNegotiator(components, null) + WebSocketNegotiator negotiator = new WebSocketNegotiator.AbstractNegotiator() { @Override - public FrameHandler negotiate(Negotiation negotiation) throws IOException + public FrameHandler negotiate(WebSocketNegotiation negotiation) throws IOException { if (negotiation.getOfferedSubprotocols().isEmpty()) { @@ -127,7 +127,7 @@ public class WebSocketNegotiationTest extends WebSocketTester } }; - server = new WebSocketServer(negotiator); + server = new WebSocketServer(components, negotiator, false); client = new WebSocketCoreClient(null, components); server.start(); diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketServer.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketServer.java index c74cbf7a490..3696cc2579b 100644 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketServer.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketServer.java @@ -27,7 +27,7 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.util.ssl.SslContextFactory; -import org.eclipse.jetty.websocket.core.server.Negotiation; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiation; import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; import org.eclipse.jetty.websocket.core.server.WebSocketUpgradeHandler; @@ -73,6 +73,11 @@ public class WebSocketServer } public WebSocketServer(WebSocketNegotiator negotiator, boolean tls) + { + this(new WebSocketComponents(), negotiator, tls); + } + + public WebSocketServer(WebSocketComponents components, WebSocketNegotiator negotiator, boolean tls) { ServerConnector connector; if (tls) @@ -84,7 +89,8 @@ public class WebSocketServer ContextHandler context = new ContextHandler("/"); server.setHandler(context); - WebSocketUpgradeHandler upgradeHandler = new WebSocketUpgradeHandler(negotiator); + WebSocketUpgradeHandler upgradeHandler = new WebSocketUpgradeHandler(components); + upgradeHandler.addMapping("/*", negotiator); context.setHandler(upgradeHandler); } @@ -111,7 +117,7 @@ public class WebSocketServer } @Override - public FrameHandler negotiate(Negotiation negotiation) throws IOException + public FrameHandler negotiate(WebSocketNegotiation negotiation) throws IOException { List offeredSubprotocols = negotiation.getOfferedSubprotocols(); if (!offeredSubprotocols.isEmpty()) diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketUpgradeHandlerTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketUpgradeHandlerTest.java new file mode 100644 index 00000000000..7f700a385c5 --- /dev/null +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/WebSocketUpgradeHandlerTest.java @@ -0,0 +1,76 @@ +// +// ======================================================================== +// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under +// the terms of the Eclipse Public License 2.0 which is available at +// https://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: +// the Apache License v2.0 which is available at +// https://www.apache.org/licenses/LICENSE-2.0 +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.websocket.core; + +import java.net.URI; +import java.util.concurrent.TimeUnit; + +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.ServerConnector; +import org.eclipse.jetty.util.Callback; +import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; +import org.eclipse.jetty.websocket.core.server.WebSocketUpgradeHandler; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class WebSocketUpgradeHandlerTest +{ + private Server server; + private WebSocketCoreClient client; + private URI serverUri; + + @BeforeEach + public void before() throws Exception + { + server = new Server(); + ServerConnector connector = new ServerConnector(server); + server.addConnector(connector); + + WebSocketUpgradeHandler upgradeHandler = new WebSocketUpgradeHandler(); + upgradeHandler.addMapping("/path/echo", new TestWebSocketNegotiator(new EchoFrameHandler())); + server.setHandler(upgradeHandler); + server.start(); + + client = new WebSocketCoreClient(); + client.start(); + + serverUri = URI.create("ws://localhost:" + connector.getLocalPort()); + } + + @AfterEach + public void after() throws Exception + { + server.stop(); + client.stop(); + } + + @Test + public void testUpgradeByWebSocketUpgradeHandler() throws Exception + { + TestMessageHandler clientEndpoint = new TestMessageHandler(); + CoreSession coreSession = client.connect(clientEndpoint, serverUri.resolve("/path/echo")).get(5, TimeUnit.SECONDS); + assertNotNull(coreSession); + coreSession.close(Callback.NOOP); + assertTrue(clientEndpoint.closeLatch.await(5, TimeUnit.SECONDS)); + } +} diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/AutobahnTests.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/AutobahnTests.java index 03075cf227e..e0299c984c5 100644 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/AutobahnTests.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/AutobahnTests.java @@ -52,14 +52,12 @@ import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; import org.testcontainers.utility.DockerStatus; import org.testcontainers.utility.MountableFile; -import org.testcontainers.utility.TestcontainersConfiguration; import static org.junit.jupiter.api.Assertions.assertTrue; @Testcontainers public class AutobahnTests { - private static final Logger LOG = LoggerFactory.getLogger(AutobahnTests.class); private static final Path USER_DIR = Paths.get(System.getProperty("user.dir")); diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java index 51e33942388..c3d6885789b 100644 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnClient.java @@ -28,10 +28,10 @@ import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.Jetty; import org.eclipse.jetty.util.UrlEncoded; import org.eclipse.jetty.websocket.core.CoreSession; -import org.eclipse.jetty.websocket.core.MessageHandler; import org.eclipse.jetty.websocket.core.TestMessageHandler; import org.eclipse.jetty.websocket.core.client.CoreClientUpgradeRequest; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; +import org.eclipse.jetty.websocket.core.internal.MessageHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnServer.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnServer.java index 4b8f65b6e4f..bfae30329f4 100644 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnServer.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/autobahn/CoreAutobahnServer.java @@ -21,6 +21,8 @@ package org.eclipse.jetty.websocket.core.autobahn; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.ContextHandler; +import org.eclipse.jetty.websocket.core.TestWebSocketNegotiator; +import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.server.WebSocketUpgradeHandler; /** @@ -78,9 +80,11 @@ public class CoreAutobahnServer ContextHandler context = new ContextHandler("/"); server.setHandler(context); - WebSocketUpgradeHandler handler = new WebSocketUpgradeHandler((neg) -> new AutobahnFrameHandler()); - context.setHandler(handler); + WebSocketComponents components = new WebSocketComponents(); + WebSocketUpgradeHandler handler = new WebSocketUpgradeHandler(components); + handler.addMapping("/*", new TestWebSocketNegotiator(new AutobahnFrameHandler())); + context.setHandler(handler); server.start(); return server; } diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketClient.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketClient.java index 9e4f85659d5..491f866a6a6 100644 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketClient.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketClient.java @@ -28,9 +28,9 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.eclipse.jetty.util.Callback; -import org.eclipse.jetty.websocket.core.MessageHandler; import org.eclipse.jetty.websocket.core.client.CoreClientUpgradeRequest; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; +import org.eclipse.jetty.websocket.core.internal.MessageHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketServer.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketServer.java index fee18160955..ab54f772b59 100644 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketServer.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/chat/ChatWebSocketServer.java @@ -26,6 +26,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.eclipse.jetty.http.pathmap.ServletPathSpec; import org.eclipse.jetty.server.HttpConnectionFactory; import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Server; @@ -36,18 +37,23 @@ import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.CloseStatus; import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.FrameHandler; -import org.eclipse.jetty.websocket.core.MessageHandler; -import org.eclipse.jetty.websocket.core.server.Negotiation; +import org.eclipse.jetty.websocket.core.WebSocketComponents; +import org.eclipse.jetty.websocket.core.internal.MessageHandler; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiation; import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; import org.eclipse.jetty.websocket.core.server.WebSocketUpgradeHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import static org.eclipse.jetty.util.Callback.NOOP; public class ChatWebSocketServer { + protected static final Logger LOG = LoggerFactory.getLogger(ChatWebSocketServer.class); + private final Set members = new HashSet<>(); - private FrameHandler negotiate(Negotiation negotiation) + private FrameHandler negotiate(WebSocketNegotiation negotiation) { // Finalize negotiations in API layer involves: // + MAY mutate the policy @@ -113,7 +119,9 @@ public class ChatWebSocketServer server.setHandler(context); ChatWebSocketServer chat = new ChatWebSocketServer(); - WebSocketUpgradeHandler upgradeHandler = new WebSocketUpgradeHandler(WebSocketNegotiator.from(chat::negotiate)); + WebSocketComponents components = new WebSocketComponents(); + WebSocketUpgradeHandler upgradeHandler = new WebSocketUpgradeHandler(components); + upgradeHandler.addMapping(new ServletPathSpec("/*"), WebSocketNegotiator.from(chat::negotiate)); context.setHandler(upgradeHandler); upgradeHandler.setHandler(new AbstractHandler() diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java index 445249b9e9b..ad980f7560a 100644 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflaterBufferSizeTest.java @@ -41,7 +41,7 @@ import org.eclipse.jetty.websocket.core.WebSocketServer; import org.eclipse.jetty.websocket.core.client.CoreClientUpgradeRequest; import org.eclipse.jetty.websocket.core.client.UpgradeListener; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; -import org.eclipse.jetty.websocket.core.server.Negotiation; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiation; import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; import org.hamcrest.Matchers; import org.junit.jupiter.api.BeforeEach; @@ -69,7 +69,7 @@ public class PerMessageDeflaterBufferSizeTest int inflateBufferSize = -1; @Override - public FrameHandler negotiate(Negotiation negotiation) throws IOException + public FrameHandler negotiate(WebSocketNegotiation negotiation) throws IOException { for (ExtensionConfig extensionConfig : negotiation.getOfferedExtensions()) { diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/ValidationExtensionTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/ValidationExtensionTest.java index 50e79eacfb7..07e504cb0ce 100644 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/ValidationExtensionTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/extensions/ValidationExtensionTest.java @@ -35,7 +35,7 @@ import org.eclipse.jetty.websocket.core.TestFrameHandler; import org.eclipse.jetty.websocket.core.TestWebSocketNegotiator; import org.eclipse.jetty.websocket.core.WebSocketServer; import org.eclipse.jetty.websocket.core.WebSocketTester; -import org.eclipse.jetty.websocket.core.server.Negotiation; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiation; import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -58,7 +58,7 @@ public class ValidationExtensionTest extends WebSocketTester WebSocketNegotiator negotiator = new TestWebSocketNegotiator(serverHandler) { @Override - public FrameHandler negotiate(Negotiation negotiation) throws IOException + public FrameHandler negotiate(WebSocketNegotiation negotiation) throws IOException { List negotiatedExtensions = new ArrayList<>(); negotiatedExtensions.add(ExtensionConfig.parse( diff --git a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java index a132bb3bdda..a002e710d9c 100644 --- a/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/proxy/WebSocketProxyTest.java @@ -45,6 +45,7 @@ import org.eclipse.jetty.websocket.core.EchoFrameHandler; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.TestAsyncFrameHandler; +import org.eclipse.jetty.websocket.core.TestWebSocketNegotiator; import org.eclipse.jetty.websocket.core.client.CoreClientUpgradeRequest; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; import org.eclipse.jetty.websocket.core.internal.WebSocketCoreSession; @@ -112,14 +113,16 @@ public class WebSocketProxyTest ContextHandler serverContext = new ContextHandler("/server"); serverFrameHandler = new EchoFrameHandler("SERVER"); - WebSocketNegotiator negotiator = WebSocketNegotiator.from((negotiation) -> serverFrameHandler, defaultCustomizer); - WebSocketUpgradeHandler upgradeHandler = new WebSocketUpgradeHandler(negotiator); + WebSocketNegotiator negotiator = new TestWebSocketNegotiator(serverFrameHandler, defaultCustomizer); + WebSocketUpgradeHandler upgradeHandler = new WebSocketUpgradeHandler(); + upgradeHandler.addMapping("/*", negotiator); serverContext.setHandler(upgradeHandler); handlers.addHandler(serverContext); ContextHandler proxyContext = new ContextHandler("/proxy"); - negotiator = WebSocketNegotiator.from((negotiation) -> proxy.client2Proxy, defaultCustomizer); - upgradeHandler = new WebSocketUpgradeHandler(negotiator); + negotiator = WebSocketNegotiator.from(negotiation -> proxy.client2Proxy, defaultCustomizer); + upgradeHandler = new WebSocketUpgradeHandler(); + upgradeHandler.addMapping("/*", negotiator); proxyContext.setHandler(upgradeHandler); handlers.addHandler(proxyContext); diff --git a/jetty-websocket/websocket-util/src/test/java/org/eclipse/jetty/websocket/util/MessageReaderTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/util/MessageReaderTest.java similarity index 97% rename from jetty-websocket/websocket-util/src/test/java/org/eclipse/jetty/websocket/util/MessageReaderTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/util/MessageReaderTest.java index eb676efec42..b0b198253a4 100644 --- a/jetty-websocket/websocket-util/src/test/java/org/eclipse/jetty/websocket/util/MessageReaderTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/util/MessageReaderTest.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util; +package org.eclipse.jetty.websocket.core.util; import java.io.IOException; import java.nio.ByteBuffer; @@ -31,7 +31,7 @@ import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.util.messages.MessageReader; +import org.eclipse.jetty.websocket.core.internal.messages.MessageReader; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-util/src/test/java/org/eclipse/jetty/websocket/util/MessageWriterTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/util/MessageWriterTest.java similarity index 98% rename from jetty-websocket/websocket-util/src/test/java/org/eclipse/jetty/websocket/util/MessageWriterTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/util/MessageWriterTest.java index a1c26f60f69..94362bd661e 100644 --- a/jetty-websocket/websocket-util/src/test/java/org/eclipse/jetty/websocket/util/MessageWriterTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/util/MessageWriterTest.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util; +package org.eclipse.jetty.websocket.core.util; import java.io.IOException; import java.nio.charset.MalformedInputException; @@ -32,7 +32,7 @@ import org.eclipse.jetty.util.Utf8StringBuilder; import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.util.messages.MessageWriter; +import org.eclipse.jetty.websocket.core.internal.messages.MessageWriter; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/jetty-websocket/websocket-util/src/test/java/org/eclipse/jetty/websocket/util/PartialStringMessageSinkTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/util/PartialStringMessageSinkTest.java similarity index 97% rename from jetty-websocket/websocket-util/src/test/java/org/eclipse/jetty/websocket/util/PartialStringMessageSinkTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/util/PartialStringMessageSinkTest.java index 6569d8aed3b..9bf61014db8 100644 --- a/jetty-websocket/websocket-util/src/test/java/org/eclipse/jetty/websocket/util/PartialStringMessageSinkTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/util/PartialStringMessageSinkTest.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util; +package org.eclipse.jetty.websocket.core.util; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -34,7 +34,7 @@ import org.eclipse.jetty.util.Utf8Appendable; import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.util.messages.PartialStringMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.PartialStringMessageSink; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-util/src/test/java/org/eclipse/jetty/websocket/util/StringMessageSinkTest.java b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/util/StringMessageSinkTest.java similarity index 98% rename from jetty-websocket/websocket-util/src/test/java/org/eclipse/jetty/websocket/util/StringMessageSinkTest.java rename to jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/util/StringMessageSinkTest.java index 8696ec91565..ff7c0ea371b 100644 --- a/jetty-websocket/websocket-util/src/test/java/org/eclipse/jetty/websocket/util/StringMessageSinkTest.java +++ b/jetty-websocket/websocket-core-tests/src/test/java/org/eclipse/jetty/websocket/core/util/StringMessageSinkTest.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util; +package org.eclipse.jetty.websocket.core.util; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -32,7 +32,7 @@ import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; -import org.eclipse.jetty.websocket.util.messages.StringMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.StringMessageSink; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/jetty-websocket/websocket-javax-client/pom.xml b/jetty-websocket/websocket-javax-client/pom.xml index 3d3f594e723..cb44b77f76e 100644 --- a/jetty-websocket/websocket-javax-client/pom.xml +++ b/jetty-websocket/websocket-javax-client/pom.xml @@ -24,11 +24,6 @@ websocket-javax-common ${project.version} - - org.eclipse.jetty.websocket - websocket-util - ${project.version} - org.eclipse.jetty.websocket websocket-core-client diff --git a/jetty-websocket/websocket-javax-client/src/main/java/org/eclipse/jetty/websocket/javax/client/internal/AnnotatedClientEndpointConfig.java b/jetty-websocket/websocket-javax-client/src/main/java/org/eclipse/jetty/websocket/javax/client/internal/AnnotatedClientEndpointConfig.java index 6a207d9223c..979635b5122 100644 --- a/jetty-websocket/websocket-javax-client/src/main/java/org/eclipse/jetty/websocket/javax/client/internal/AnnotatedClientEndpointConfig.java +++ b/jetty-websocket/websocket-javax-client/src/main/java/org/eclipse/jetty/websocket/javax/client/internal/AnnotatedClientEndpointConfig.java @@ -23,8 +23,8 @@ import java.util.List; import javax.websocket.ClientEndpoint; import javax.websocket.ClientEndpointConfig; +import org.eclipse.jetty.websocket.core.exception.InvalidWebSocketException; import org.eclipse.jetty.websocket.javax.common.ClientEndpointConfigWrapper; -import org.eclipse.jetty.websocket.util.InvalidWebSocketException; public class AnnotatedClientEndpointConfig extends ClientEndpointConfigWrapper { diff --git a/jetty-websocket/websocket-javax-client/src/main/java/org/eclipse/jetty/websocket/javax/client/internal/JavaxWebSocketClientContainer.java b/jetty-websocket/websocket-javax-client/src/main/java/org/eclipse/jetty/websocket/javax/client/internal/JavaxWebSocketClientContainer.java index 8202b43a44a..b13371b5e9f 100644 --- a/jetty-websocket/websocket-javax-client/src/main/java/org/eclipse/jetty/websocket/javax/client/internal/JavaxWebSocketClientContainer.java +++ b/jetty-websocket/websocket-javax-client/src/main/java/org/eclipse/jetty/websocket/javax/client/internal/JavaxWebSocketClientContainer.java @@ -40,6 +40,7 @@ import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; +import org.eclipse.jetty.websocket.core.exception.InvalidWebSocketException; import org.eclipse.jetty.websocket.core.exception.UpgradeException; import org.eclipse.jetty.websocket.core.exception.WebSocketTimeoutException; import org.eclipse.jetty.websocket.javax.common.ConfiguredEndpoint; @@ -47,7 +48,6 @@ import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketContainer; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketExtensionConfig; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandler; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory; -import org.eclipse.jetty.websocket.util.InvalidWebSocketException; /** * Container for Client use of the javax.websocket API. diff --git a/jetty-websocket/websocket-javax-client/src/main/java/org/eclipse/jetty/websocket/javax/client/internal/JavaxWebSocketClientFrameHandlerFactory.java b/jetty-websocket/websocket-javax-client/src/main/java/org/eclipse/jetty/websocket/javax/client/internal/JavaxWebSocketClientFrameHandlerFactory.java index ec33f0e1266..b7c65ca7c8e 100644 --- a/jetty-websocket/websocket-javax-client/src/main/java/org/eclipse/jetty/websocket/javax/client/internal/JavaxWebSocketClientFrameHandlerFactory.java +++ b/jetty-websocket/websocket-javax-client/src/main/java/org/eclipse/jetty/websocket/javax/client/internal/JavaxWebSocketClientFrameHandlerFactory.java @@ -21,10 +21,10 @@ package org.eclipse.jetty.websocket.javax.client.internal; import javax.websocket.ClientEndpoint; import javax.websocket.EndpointConfig; +import org.eclipse.jetty.websocket.core.internal.util.InvokerUtils; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketContainer; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerMetadata; -import org.eclipse.jetty.websocket.util.InvokerUtils; public class JavaxWebSocketClientFrameHandlerFactory extends JavaxWebSocketFrameHandlerFactory { diff --git a/jetty-websocket/websocket-javax-common/pom.xml b/jetty-websocket/websocket-javax-common/pom.xml index 5788cfeb68a..4ceac71d1db 100644 --- a/jetty-websocket/websocket-javax-common/pom.xml +++ b/jetty-websocket/websocket-javax-common/pom.xml @@ -70,11 +70,6 @@ org.eclipse.jetty.toolchain jetty-javax-websocket-api - - org.eclipse.jetty.websocket - websocket-util - ${project.version} - org.eclipse.jetty.websocket websocket-core-client diff --git a/jetty-websocket/websocket-javax-common/src/main/java/module-info.java b/jetty-websocket/websocket-javax-common/src/main/java/module-info.java index 97397c3d70e..705e6d822f9 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/module-info.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/module-info.java @@ -26,5 +26,4 @@ module org.eclipse.jetty.websocket.javax.common requires org.slf4j; requires transitive jetty.websocket.api; requires transitive org.eclipse.jetty.websocket.core.client; - requires transitive org.eclipse.jetty.websocket.util; } diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketAsyncRemote.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketAsyncRemote.java index 185c89715c8..8f169315ea1 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketAsyncRemote.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketAsyncRemote.java @@ -31,9 +31,9 @@ import org.eclipse.jetty.util.FutureCallback; import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.util.TextUtils; -import org.eclipse.jetty.websocket.util.messages.MessageOutputStream; -import org.eclipse.jetty.websocket.util.messages.MessageWriter; +import org.eclipse.jetty.websocket.core.internal.messages.MessageOutputStream; +import org.eclipse.jetty.websocket.core.internal.messages.MessageWriter; +import org.eclipse.jetty.websocket.core.internal.util.TextUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketBasicRemote.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketBasicRemote.java index 2519e4be72f..c7993dc2cd8 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketBasicRemote.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketBasicRemote.java @@ -31,7 +31,7 @@ import org.eclipse.jetty.util.FutureCallback; import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.util.TextUtils; +import org.eclipse.jetty.websocket.core.internal.util.TextUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java index 884f6581de5..29975cd6fc8 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandler.java @@ -45,17 +45,17 @@ import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.exception.WebSocketException; +import org.eclipse.jetty.websocket.core.internal.messages.MessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.PartialByteArrayMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.PartialByteBufferMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.PartialStringMessageSink; +import org.eclipse.jetty.websocket.core.internal.util.InvokerUtils; import org.eclipse.jetty.websocket.javax.common.decoders.AvailableDecoders; import org.eclipse.jetty.websocket.javax.common.decoders.RegisteredDecoder; import org.eclipse.jetty.websocket.javax.common.messages.DecodedBinaryMessageSink; import org.eclipse.jetty.websocket.javax.common.messages.DecodedBinaryStreamMessageSink; import org.eclipse.jetty.websocket.javax.common.messages.DecodedTextMessageSink; import org.eclipse.jetty.websocket.javax.common.messages.DecodedTextStreamMessageSink; -import org.eclipse.jetty.websocket.util.InvokerUtils; -import org.eclipse.jetty.websocket.util.messages.MessageSink; -import org.eclipse.jetty.websocket.util.messages.PartialByteArrayMessageSink; -import org.eclipse.jetty.websocket.util.messages.PartialByteBufferMessageSink; -import org.eclipse.jetty.websocket.util.messages.PartialStringMessageSink; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerFactory.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerFactory.java index 853dc88d639..ebdc6630456 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerFactory.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerFactory.java @@ -43,20 +43,20 @@ import javax.websocket.Session; import org.eclipse.jetty.http.pathmap.UriTemplatePathSpec; import org.eclipse.jetty.websocket.core.CoreSession; +import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; +import org.eclipse.jetty.websocket.core.exception.InvalidWebSocketException; +import org.eclipse.jetty.websocket.core.internal.messages.MessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.PartialByteArrayMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.PartialByteBufferMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.PartialStringMessageSink; +import org.eclipse.jetty.websocket.core.internal.util.InvokerUtils; +import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils; import org.eclipse.jetty.websocket.javax.common.decoders.RegisteredDecoder; import org.eclipse.jetty.websocket.javax.common.messages.AbstractDecodedMessageSink; import org.eclipse.jetty.websocket.javax.common.messages.DecodedBinaryMessageSink; import org.eclipse.jetty.websocket.javax.common.messages.DecodedBinaryStreamMessageSink; import org.eclipse.jetty.websocket.javax.common.messages.DecodedTextMessageSink; import org.eclipse.jetty.websocket.javax.common.messages.DecodedTextStreamMessageSink; -import org.eclipse.jetty.websocket.util.InvalidSignatureException; -import org.eclipse.jetty.websocket.util.InvalidWebSocketException; -import org.eclipse.jetty.websocket.util.InvokerUtils; -import org.eclipse.jetty.websocket.util.ReflectUtils; -import org.eclipse.jetty.websocket.util.messages.MessageSink; -import org.eclipse.jetty.websocket.util.messages.PartialByteArrayMessageSink; -import org.eclipse.jetty.websocket.util.messages.PartialByteBufferMessageSink; -import org.eclipse.jetty.websocket.util.messages.PartialStringMessageSink; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerMetadata.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerMetadata.java index 52d96b78026..f0870bac3a7 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerMetadata.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerMetadata.java @@ -23,9 +23,9 @@ import javax.websocket.Encoder; import javax.websocket.EndpointConfig; import org.eclipse.jetty.http.pathmap.UriTemplatePathSpec; +import org.eclipse.jetty.websocket.core.exception.InvalidWebSocketException; import org.eclipse.jetty.websocket.javax.common.decoders.AvailableDecoders; import org.eclipse.jetty.websocket.javax.common.encoders.AvailableEncoders; -import org.eclipse.jetty.websocket.util.InvalidWebSocketException; public class JavaxWebSocketFrameHandlerMetadata { diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketMessageMetadata.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketMessageMetadata.java index bd98e8dd594..2dbaf5fd251 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketMessageMetadata.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketMessageMetadata.java @@ -21,8 +21,8 @@ package org.eclipse.jetty.websocket.javax.common; import java.lang.invoke.MethodHandle; import java.util.List; +import org.eclipse.jetty.websocket.core.internal.messages.MessageSink; import org.eclipse.jetty.websocket.javax.common.decoders.RegisteredDecoder; -import org.eclipse.jetty.websocket.util.messages.MessageSink; public class JavaxWebSocketMessageMetadata { diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketRemoteEndpoint.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketRemoteEndpoint.java index 718b2553d76..e837d4a4776 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketRemoteEndpoint.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketRemoteEndpoint.java @@ -34,8 +34,8 @@ import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.OutgoingFrames; import org.eclipse.jetty.websocket.core.exception.WebSocketException; -import org.eclipse.jetty.websocket.util.messages.MessageOutputStream; -import org.eclipse.jetty.websocket.util.messages.MessageWriter; +import org.eclipse.jetty.websocket.core.internal.messages.MessageOutputStream; +import org.eclipse.jetty.websocket.core.internal.messages.MessageWriter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketSession.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketSession.java index 13b4701fd2b..b97389d7329 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketSession.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketSession.java @@ -43,9 +43,9 @@ import javax.websocket.WebSocketContainer; import org.eclipse.jetty.util.FutureCallback; import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.ExtensionConfig; +import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils; import org.eclipse.jetty.websocket.javax.common.decoders.AvailableDecoders; import org.eclipse.jetty.websocket.javax.common.encoders.AvailableEncoders; -import org.eclipse.jetty.websocket.util.ReflectUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/decoders/AvailableDecoders.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/decoders/AvailableDecoders.java index b0174ee1e91..25b3b584032 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/decoders/AvailableDecoders.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/decoders/AvailableDecoders.java @@ -30,9 +30,9 @@ import java.util.stream.Stream; import javax.websocket.Decoder; import javax.websocket.EndpointConfig; -import org.eclipse.jetty.websocket.util.InvalidSignatureException; -import org.eclipse.jetty.websocket.util.InvalidWebSocketException; -import org.eclipse.jetty.websocket.util.ReflectUtils; +import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; +import org.eclipse.jetty.websocket.core.exception.InvalidWebSocketException; +import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils; public class AvailableDecoders implements Iterable { diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/encoders/AvailableEncoders.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/encoders/AvailableEncoders.java index dac4741c4a9..3bd0b70495f 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/encoders/AvailableEncoders.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/encoders/AvailableEncoders.java @@ -29,10 +29,10 @@ import java.util.stream.Collectors; import javax.websocket.Encoder; import javax.websocket.EndpointConfig; +import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; +import org.eclipse.jetty.websocket.core.exception.InvalidWebSocketException; +import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils; import org.eclipse.jetty.websocket.javax.common.InitException; -import org.eclipse.jetty.websocket.util.InvalidSignatureException; -import org.eclipse.jetty.websocket.util.InvalidWebSocketException; -import org.eclipse.jetty.websocket.util.ReflectUtils; public class AvailableEncoders implements Predicate> { diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/AbstractDecodedMessageSink.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/AbstractDecodedMessageSink.java index 9ae040bb9c6..1ce2d09fc60 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/AbstractDecodedMessageSink.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/AbstractDecodedMessageSink.java @@ -28,8 +28,8 @@ import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.exception.CloseException; +import org.eclipse.jetty.websocket.core.internal.messages.MessageSink; import org.eclipse.jetty.websocket.javax.common.decoders.RegisteredDecoder; -import org.eclipse.jetty.websocket.util.messages.MessageSink; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedBinaryMessageSink.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedBinaryMessageSink.java index bd2b2aa9d1f..541ee79b20b 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedBinaryMessageSink.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedBinaryMessageSink.java @@ -28,10 +28,10 @@ import javax.websocket.Decoder; import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.exception.CloseException; +import org.eclipse.jetty.websocket.core.internal.messages.ByteBufferMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.MessageSink; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory; import org.eclipse.jetty.websocket.javax.common.decoders.RegisteredDecoder; -import org.eclipse.jetty.websocket.util.messages.ByteBufferMessageSink; -import org.eclipse.jetty.websocket.util.messages.MessageSink; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedBinaryStreamMessageSink.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedBinaryStreamMessageSink.java index 38c40b45ac7..1700b8d230c 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedBinaryStreamMessageSink.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedBinaryStreamMessageSink.java @@ -29,10 +29,10 @@ import javax.websocket.Decoder; import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.exception.CloseException; +import org.eclipse.jetty.websocket.core.internal.messages.InputStreamMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.MessageSink; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory; import org.eclipse.jetty.websocket.javax.common.decoders.RegisteredDecoder; -import org.eclipse.jetty.websocket.util.messages.InputStreamMessageSink; -import org.eclipse.jetty.websocket.util.messages.MessageSink; public class DecodedBinaryStreamMessageSink extends AbstractDecodedMessageSink.Stream> { diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedTextMessageSink.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedTextMessageSink.java index ff1749550c5..45c40b6b38e 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedTextMessageSink.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedTextMessageSink.java @@ -27,10 +27,10 @@ import javax.websocket.Decoder; import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.exception.CloseException; +import org.eclipse.jetty.websocket.core.internal.messages.MessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.StringMessageSink; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory; import org.eclipse.jetty.websocket.javax.common.decoders.RegisteredDecoder; -import org.eclipse.jetty.websocket.util.messages.MessageSink; -import org.eclipse.jetty.websocket.util.messages.StringMessageSink; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedTextStreamMessageSink.java b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedTextStreamMessageSink.java index ff2caa4730a..e261ef1b44c 100644 --- a/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedTextStreamMessageSink.java +++ b/jetty-websocket/websocket-javax-common/src/main/java/org/eclipse/jetty/websocket/javax/common/messages/DecodedTextStreamMessageSink.java @@ -29,10 +29,10 @@ import javax.websocket.Decoder; import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.exception.CloseException; +import org.eclipse.jetty.websocket.core.internal.messages.MessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.ReaderMessageSink; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory; import org.eclipse.jetty.websocket.javax.common.decoders.RegisteredDecoder; -import org.eclipse.jetty.websocket.util.messages.MessageSink; -import org.eclipse.jetty.websocket.util.messages.ReaderMessageSink; public class DecodedTextStreamMessageSink extends AbstractDecodedMessageSink.Stream> { diff --git a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/DummyFrameHandlerFactory.java b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/DummyFrameHandlerFactory.java index 5ac2117464a..3fd09b7e3aa 100644 --- a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/DummyFrameHandlerFactory.java +++ b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/DummyFrameHandlerFactory.java @@ -22,7 +22,7 @@ import javax.websocket.ClientEndpoint; import javax.websocket.ClientEndpointConfig; import javax.websocket.EndpointConfig; -import org.eclipse.jetty.websocket.util.InvokerUtils; +import org.eclipse.jetty.websocket.core.internal.util.InvokerUtils; public class DummyFrameHandlerFactory extends JavaxWebSocketFrameHandlerFactory { diff --git a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerBadSignaturesTest.java b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerBadSignaturesTest.java index cf4b7dc9e75..8a1cd30e2c6 100644 --- a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerBadSignaturesTest.java +++ b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerBadSignaturesTest.java @@ -25,7 +25,7 @@ import javax.websocket.OnError; import javax.websocket.OnOpen; import javax.websocket.Session; -import org.eclipse.jetty.websocket.util.InvalidSignatureException; +import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerOnMessageBinaryTest.java b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerOnMessageBinaryTest.java index 2d05a5b3e8e..bb1e86b84ee 100644 --- a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerOnMessageBinaryTest.java +++ b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerOnMessageBinaryTest.java @@ -29,8 +29,8 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; +import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; import org.eclipse.jetty.websocket.javax.common.sockets.TrackingSocket; -import org.eclipse.jetty.websocket.util.InvalidSignatureException; import org.hamcrest.Matcher; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerOnMessageTextTest.java b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerOnMessageTextTest.java index ccb95e2674e..c7c598be805 100644 --- a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerOnMessageTextTest.java +++ b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/JavaxWebSocketFrameHandlerOnMessageTextTest.java @@ -29,8 +29,8 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; +import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; import org.eclipse.jetty.websocket.javax.common.sockets.TrackingSocket; -import org.eclipse.jetty.websocket.util.InvalidSignatureException; import org.hamcrest.Matcher; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/messages/InputStreamMessageSinkTest.java b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/messages/InputStreamMessageSinkTest.java index eb8a9fb32fe..f381cf7eba0 100644 --- a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/messages/InputStreamMessageSinkTest.java +++ b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/messages/InputStreamMessageSinkTest.java @@ -35,8 +35,8 @@ import org.eclipse.jetty.util.FutureCallback; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; +import org.eclipse.jetty.websocket.core.internal.messages.InputStreamMessageSink; import org.eclipse.jetty.websocket.javax.common.AbstractSessionTest; -import org.eclipse.jetty.websocket.util.messages.InputStreamMessageSink; import org.junit.jupiter.api.Test; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/messages/ReaderMessageSinkTest.java b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/messages/ReaderMessageSinkTest.java index 3bab792edca..01c796d4daf 100644 --- a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/messages/ReaderMessageSinkTest.java +++ b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/messages/ReaderMessageSinkTest.java @@ -32,7 +32,7 @@ import org.eclipse.jetty.util.FutureCallback; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.util.messages.ReaderMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.ReaderMessageSink; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/util/InvokerUtilsStaticParamsTest.java b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/util/InvokerUtilsStaticParamsTest.java index d9b5b131afe..fe352c0543d 100644 --- a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/util/InvokerUtilsStaticParamsTest.java +++ b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/util/InvokerUtilsStaticParamsTest.java @@ -26,9 +26,9 @@ import java.util.Map; import javax.websocket.Session; import org.eclipse.jetty.util.annotation.Name; +import org.eclipse.jetty.websocket.core.internal.util.InvokerUtils; +import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory; -import org.eclipse.jetty.websocket.util.InvokerUtils; -import org.eclipse.jetty.websocket.util.ReflectUtils; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/util/InvokerUtilsTest.java b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/util/InvokerUtilsTest.java index 54c6e51fa7f..3e7cefa44e0 100644 --- a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/util/InvokerUtilsTest.java +++ b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/util/InvokerUtilsTest.java @@ -24,8 +24,8 @@ import java.lang.invoke.MethodHandles; import java.lang.reflect.Method; import org.eclipse.jetty.util.annotation.Name; -import org.eclipse.jetty.websocket.util.InvokerUtils; -import org.eclipse.jetty.websocket.util.ReflectUtils; +import org.eclipse.jetty.websocket.core.internal.util.InvokerUtils; +import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/util/NameParamIdentifier.java b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/util/NameParamIdentifier.java index 9ecb0e20cf1..05731d67e80 100644 --- a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/util/NameParamIdentifier.java +++ b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/util/NameParamIdentifier.java @@ -22,7 +22,7 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Method; import org.eclipse.jetty.util.annotation.Name; -import org.eclipse.jetty.websocket.util.InvokerUtils; +import org.eclipse.jetty.websocket.core.internal.util.InvokerUtils; /** * Simple {@link InvokerUtils.ParamIdentifier} diff --git a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/util/ReflectUtilsTest.java b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/util/ReflectUtilsTest.java index 9d7026334d9..ec8e53f9d6e 100644 --- a/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/util/ReflectUtilsTest.java +++ b/jetty-websocket/websocket-javax-common/src/test/java/org/eclipse/jetty/websocket/javax/common/util/ReflectUtilsTest.java @@ -18,7 +18,7 @@ package org.eclipse.jetty.websocket.javax.common.util; -import org.eclipse.jetty.websocket.util.ReflectUtils; +import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/jetty-websocket/websocket-javax-server/pom.xml b/jetty-websocket/websocket-javax-server/pom.xml index a0251b8779c..d380a257888 100644 --- a/jetty-websocket/websocket-javax-server/pom.xml +++ b/jetty-websocket/websocket-javax-server/pom.xml @@ -22,7 +22,7 @@ org.eclipse.jetty.websocket - websocket-util-server + websocket-servlet ${project.version} diff --git a/jetty-websocket/websocket-javax-server/src/main/config/modules/websocket-javax.mod b/jetty-websocket/websocket-javax-server/src/main/config/modules/websocket-javax.mod index 48e0dff9169..c0b07f11047 100644 --- a/jetty-websocket/websocket-javax-server/src/main/config/modules/websocket-javax.mod +++ b/jetty-websocket/websocket-javax-server/src/main/config/modules/websocket-javax.mod @@ -14,8 +14,7 @@ annotations lib/websocket/websocket-core-common-${jetty.version}.jar lib/websocket/websocket-core-client-${jetty.version}.jar lib/websocket/websocket-core-server-${jetty.version}.jar -lib/websocket/websocket-util-${jetty.version}.jar -lib/websocket/websocket-util-server-${jetty.version}.jar +lib/websocket/websocket-servlet-${jetty.version}.jar lib/websocket/jetty-javax-websocket-api-1.1.2.jar lib/websocket/websocket-javax-client-${jetty.version}.jar lib/websocket/websocket-javax-common-${jetty.version}.jar diff --git a/jetty-websocket/websocket-javax-server/src/main/java/module-info.java b/jetty-websocket/websocket-javax-server/src/main/java/module-info.java index c4ad6598d80..e61520f2c6a 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/module-info.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/module-info.java @@ -28,13 +28,14 @@ module org.eclipse.jetty.websocket.javax.server { exports org.eclipse.jetty.websocket.javax.server.config; + requires org.eclipse.jetty.websocket.core.server; requires org.eclipse.jetty.websocket.javax.common; - requires org.eclipse.jetty.websocket.util.server; + requires org.eclipse.jetty.websocket.servlet; requires org.slf4j; requires transitive org.eclipse.jetty.webapp; requires transitive org.eclipse.jetty.websocket.javax.client; - provides ServletContainerInitializer with JavaxWebSocketServletContainerInitializer; - provides ServerEndpointConfig.Configurator with ContainerDefaultConfigurator; provides Configuration with JavaxWebSocketConfiguration; + provides ServerEndpointConfig.Configurator with ContainerDefaultConfigurator; + provides ServletContainerInitializer with JavaxWebSocketServletContainerInitializer; } diff --git a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/config/JavaxWebSocketConfiguration.java b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/config/JavaxWebSocketConfiguration.java index a6ab2692f04..c3dfceffc95 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/config/JavaxWebSocketConfiguration.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/config/JavaxWebSocketConfiguration.java @@ -37,7 +37,7 @@ public class JavaxWebSocketConfiguration extends AbstractConfiguration addDependencies(WebXmlConfiguration.class, MetaInfConfiguration.class, WebInfConfiguration.class, FragmentConfiguration.class); addDependents("org.eclipse.jetty.annotations.AnnotationConfiguration", WebAppConfiguration.class.getName()); - protectAndExpose("org.eclipse.jetty.websocket.util.server."); // For WebSocketUpgradeFilter + protectAndExpose("org.eclipse.jetty.websocket.servlet."); // For WebSocketUpgradeFilter protectAndExpose("org.eclipse.jetty.websocket.javax.server.config."); protectAndExpose("org.eclipse.jetty.websocket.javax.client.JavaxWebSocketClientContainerProvider"); hide("org.eclipse.jetty.websocket.javax.server.internal"); diff --git a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/config/JavaxWebSocketServletContainerInitializer.java b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/config/JavaxWebSocketServletContainerInitializer.java index 41933a8f0db..632271a65f6 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/config/JavaxWebSocketServletContainerInitializer.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/config/JavaxWebSocketServletContainerInitializer.java @@ -37,10 +37,10 @@ import org.eclipse.jetty.servlet.listener.ContainerInitializer; import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.thread.ThreadClassLoaderScope; import org.eclipse.jetty.websocket.core.WebSocketComponents; +import org.eclipse.jetty.websocket.core.server.WebSocketMappings; import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents; import org.eclipse.jetty.websocket.javax.server.internal.JavaxWebSocketServerContainer; -import org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter; -import org.eclipse.jetty.websocket.util.server.internal.WebSocketMappings; +import org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -153,7 +153,7 @@ public class JavaxWebSocketServletContainerInitializer implements ServletContain { WebSocketComponents components = WebSocketServerComponents.ensureWebSocketComponents(context.getServer(), context.getServletContext()); FilterHolder filterHolder = WebSocketUpgradeFilter.ensureFilter(context.getServletContext()); - WebSocketMappings mapping = WebSocketMappings.ensureMapping(context.getServletContext()); + WebSocketMappings mapping = WebSocketMappings.ensureMappings(context.getServletContext()); serverContainer = JavaxWebSocketServerContainer.ensureContainer(context.getServletContext()); if (LOG.isDebugEnabled()) diff --git a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/AnnotatedServerEndpointConfig.java b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/AnnotatedServerEndpointConfig.java index 23af02b0575..a3414e8d56a 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/AnnotatedServerEndpointConfig.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/AnnotatedServerEndpointConfig.java @@ -120,9 +120,9 @@ public class AnnotatedServerEndpointConfig extends ServerEndpointConfigWrapper // Instantiate the provided configurator try { - return anno.configurator().newInstance(); + return anno.configurator().getConstructor().newInstance(); } - catch (InstantiationException | IllegalAccessException e) + catch (Exception e) { StringBuilder err = new StringBuilder(); err.append("Unable to instantiate ServerEndpoint.configurator() of "); diff --git a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxServerUpgradeRequest.java b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxServerUpgradeRequest.java index fb530a6b384..f0733e1d794 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxServerUpgradeRequest.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxServerUpgradeRequest.java @@ -21,8 +21,8 @@ package org.eclipse.jetty.websocket.javax.server.internal; import java.net.URI; import java.security.Principal; +import org.eclipse.jetty.websocket.core.server.ServerUpgradeRequest; import org.eclipse.jetty.websocket.javax.common.UpgradeRequest; -import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest; public class JavaxServerUpgradeRequest implements UpgradeRequest { diff --git a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketCreator.java b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketCreator.java index c428010a221..5b50bb4c05f 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketCreator.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketCreator.java @@ -34,13 +34,13 @@ import org.eclipse.jetty.http.pathmap.UriTemplatePathSpec; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry; +import org.eclipse.jetty.websocket.core.server.ServerUpgradeRequest; +import org.eclipse.jetty.websocket.core.server.ServerUpgradeResponse; +import org.eclipse.jetty.websocket.core.server.WebSocketCreator; import org.eclipse.jetty.websocket.javax.common.ConfiguredEndpoint; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketContainer; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketExtension; import org.eclipse.jetty.websocket.javax.common.ServerEndpointConfigWrapper; -import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest; -import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeResponse; -import org.eclipse.jetty.websocket.util.server.internal.WebSocketCreator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerContainer.java b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerContainer.java index 55708c7d3a5..d51b42da8a8 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerContainer.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerContainer.java @@ -37,13 +37,13 @@ import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; +import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; +import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils; +import org.eclipse.jetty.websocket.core.server.WebSocketMappings; import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents; import org.eclipse.jetty.websocket.javax.client.internal.JavaxWebSocketClientContainer; import org.eclipse.jetty.websocket.javax.server.config.ContainerDefaultConfigurator; import org.eclipse.jetty.websocket.javax.server.config.JavaxWebSocketServletContainerInitializer; -import org.eclipse.jetty.websocket.util.InvalidSignatureException; -import org.eclipse.jetty.websocket.util.ReflectUtils; -import org.eclipse.jetty.websocket.util.server.internal.WebSocketMappings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -98,7 +98,7 @@ public class JavaxWebSocketServerContainer extends JavaxWebSocketClientContainer // Create the Jetty ServerContainer implementation container = new JavaxWebSocketServerContainer( - WebSocketMappings.ensureMapping(servletContext), + WebSocketMappings.ensureMappings(servletContext), WebSocketServerComponents.getWebSocketComponents(servletContext), coreClientSupplier); contextHandler.addManaged(container); diff --git a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerFrameHandlerFactory.java b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerFrameHandlerFactory.java index e9e69a3a1cf..191551260d7 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerFrameHandlerFactory.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JavaxWebSocketServerFrameHandlerFactory.java @@ -23,12 +23,12 @@ import javax.websocket.server.ServerEndpoint; import org.eclipse.jetty.http.pathmap.UriTemplatePathSpec; import org.eclipse.jetty.websocket.core.FrameHandler; +import org.eclipse.jetty.websocket.core.server.FrameHandlerFactory; +import org.eclipse.jetty.websocket.core.server.ServerUpgradeRequest; +import org.eclipse.jetty.websocket.core.server.ServerUpgradeResponse; import org.eclipse.jetty.websocket.javax.client.internal.JavaxWebSocketClientFrameHandlerFactory; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketContainer; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerMetadata; -import org.eclipse.jetty.websocket.util.server.internal.FrameHandlerFactory; -import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest; -import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeResponse; public class JavaxWebSocketServerFrameHandlerFactory extends JavaxWebSocketClientFrameHandlerFactory implements FrameHandlerFactory { diff --git a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JsrHandshakeRequest.java b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JsrHandshakeRequest.java index 280cecd27e4..96abb136de3 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JsrHandshakeRequest.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JsrHandshakeRequest.java @@ -25,7 +25,7 @@ import java.util.Map; import javax.websocket.server.HandshakeRequest; import org.eclipse.jetty.http.pathmap.PathSpec; -import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest; +import org.eclipse.jetty.websocket.core.server.ServerUpgradeRequest; public class JsrHandshakeRequest implements HandshakeRequest { diff --git a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JsrHandshakeResponse.java b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JsrHandshakeResponse.java index b55ec99f3fd..985ae03e0cd 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JsrHandshakeResponse.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/JsrHandshakeResponse.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import javax.websocket.HandshakeResponse; -import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeResponse; +import org.eclipse.jetty.websocket.core.server.ServerUpgradeResponse; public class JsrHandshakeResponse implements HandshakeResponse { diff --git a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/PathParamIdentifier.java b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/PathParamIdentifier.java index 44410741311..173712b1a64 100644 --- a/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/PathParamIdentifier.java +++ b/jetty-websocket/websocket-javax-server/src/main/java/org/eclipse/jetty/websocket/javax/server/internal/PathParamIdentifier.java @@ -22,8 +22,8 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Method; import javax.websocket.server.PathParam; -import org.eclipse.jetty.websocket.util.InvalidSignatureException; -import org.eclipse.jetty.websocket.util.InvokerUtils; +import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; +import org.eclipse.jetty.websocket.core.internal.util.InvokerUtils; /** * Method argument identifier for {@link javax.websocket.server.PathParam} annotations. diff --git a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/CompletableFutureMethodHandle.java b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/CompletableFutureMethodHandle.java index c7008dea780..2aedea8bc66 100644 --- a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/CompletableFutureMethodHandle.java +++ b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/CompletableFutureMethodHandle.java @@ -23,9 +23,9 @@ import java.lang.invoke.MethodHandles; import java.lang.reflect.Method; import java.util.concurrent.CompletableFuture; +import org.eclipse.jetty.websocket.core.internal.util.InvokerUtils; +import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketFrameHandlerFactory; -import org.eclipse.jetty.websocket.util.InvokerUtils; -import org.eclipse.jetty.websocket.util.ReflectUtils; public class CompletableFutureMethodHandle { diff --git a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/CoreServer.java b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/CoreServer.java index d3a3314fd6e..43920839d1f 100644 --- a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/CoreServer.java +++ b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/CoreServer.java @@ -23,19 +23,14 @@ import java.net.URI; import java.util.List; import java.util.function.Function; -import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.handler.DefaultHandler; import org.eclipse.jetty.server.handler.HandlerList; -import org.eclipse.jetty.util.DecoratedObjectFactory; import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.thread.QueuedThreadPool; -import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.FrameHandler; -import org.eclipse.jetty.websocket.core.WebSocketComponents; -import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry; -import org.eclipse.jetty.websocket.core.server.Negotiation; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiation; import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; import org.eclipse.jetty.websocket.core.server.WebSocketUpgradeHandler; import org.eclipse.jetty.websocket.javax.tests.framehandlers.FrameEcho; @@ -49,12 +44,12 @@ public class CoreServer extends ContainerLifeCycle private URI serverUri; private URI wsUri; - public CoreServer(Function negotiationFunction) + public CoreServer(Function negotiationFunction) { - this(new BaseNegotiator() + this(new WebSocketNegotiator.AbstractNegotiator() { @Override - public FrameHandler negotiate(Negotiation negotiation) throws IOException + public FrameHandler negotiate(WebSocketNegotiation negotiation) throws IOException { return negotiationFunction.apply(negotiation); } @@ -81,7 +76,9 @@ public class CoreServer extends ContainerLifeCycle server.addConnector(connector); // Add Handler - server.setHandler(new HandlerList(new WebSocketUpgradeHandler(negotiator), new DefaultHandler())); + WebSocketUpgradeHandler upgradeHandler = new WebSocketUpgradeHandler(); + upgradeHandler.addMapping("/*", negotiator); + server.setHandler(new HandlerList(upgradeHandler, new DefaultHandler())); // Start Server addBean(server); @@ -104,49 +101,10 @@ public class CoreServer extends ContainerLifeCycle return wsUri; } - public abstract static class BaseNegotiator implements WebSocketNegotiator - { - protected final WebSocketComponents components; - - public BaseNegotiator() - { - this.components = new WebSocketComponents(); - } - - @Override - public void customize(Configuration configurable) - { - } - - @Override - public WebSocketExtensionRegistry getExtensionRegistry() - { - return components.getExtensionRegistry(); - } - - @Override - public DecoratedObjectFactory getObjectFactory() - { - return components.getObjectFactory(); - } - - @Override - public ByteBufferPool getByteBufferPool() - { - return components.getBufferPool(); - } - - @Override - public WebSocketComponents getWebSocketComponents() - { - return components; - } - } - - public static class EchoNegotiator extends BaseNegotiator + public static class EchoNegotiator extends WebSocketNegotiator.AbstractNegotiator { @Override - public FrameHandler negotiate(Negotiation negotiation) throws IOException + public FrameHandler negotiate(WebSocketNegotiation negotiation) throws IOException { List offeredSubProtocols = negotiation.getOfferedSubprotocols(); @@ -174,10 +132,5 @@ public class CoreServer extends ContainerLifeCycle return null; } } - - @Override - public void customize(Configuration configurable) - { - } } } diff --git a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/FrameHandlerTracker.java b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/FrameHandlerTracker.java index 3326b58f979..05c7c43e0f5 100644 --- a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/FrameHandlerTracker.java +++ b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/FrameHandlerTracker.java @@ -28,7 +28,7 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.websocket.core.CloseStatus; import org.eclipse.jetty.websocket.core.CoreSession; -import org.eclipse.jetty.websocket.core.MessageHandler; +import org.eclipse.jetty.websocket.core.internal.MessageHandler; public class FrameHandlerTracker extends MessageHandler { diff --git a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/StaticText.java b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/StaticText.java index f135c3a44d8..617ab45d857 100644 --- a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/StaticText.java +++ b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/StaticText.java @@ -19,7 +19,7 @@ package org.eclipse.jetty.websocket.javax.tests.framehandlers; import org.eclipse.jetty.util.Callback; -import org.eclipse.jetty.websocket.core.MessageHandler; +import org.eclipse.jetty.websocket.core.internal.MessageHandler; public class StaticText extends MessageHandler { diff --git a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/WholeMessageEcho.java b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/WholeMessageEcho.java index 12a4d31fcf1..a9dfe6f767e 100644 --- a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/WholeMessageEcho.java +++ b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/framehandlers/WholeMessageEcho.java @@ -21,7 +21,7 @@ package org.eclipse.jetty.websocket.javax.tests.framehandlers; import java.nio.ByteBuffer; import org.eclipse.jetty.util.Callback; -import org.eclipse.jetty.websocket.core.MessageHandler; +import org.eclipse.jetty.websocket.core.internal.MessageHandler; public class WholeMessageEcho extends MessageHandler { diff --git a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/matchers/IsMessageHandlerType.java b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/matchers/IsMessageHandlerType.java index bc77695fc28..f28de668ab6 100644 --- a/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/matchers/IsMessageHandlerType.java +++ b/jetty-websocket/websocket-javax-tests/src/main/java/org/eclipse/jetty/websocket/javax/tests/matchers/IsMessageHandlerType.java @@ -22,10 +22,10 @@ import javax.websocket.Decoder; import javax.websocket.MessageHandler; import javax.websocket.PongMessage; +import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils; import org.eclipse.jetty.websocket.javax.common.JavaxWebSocketSession; import org.eclipse.jetty.websocket.javax.common.decoders.RegisteredDecoder; import org.eclipse.jetty.websocket.javax.tests.MessageType; -import org.eclipse.jetty.websocket.util.ReflectUtils; import org.hamcrest.Description; import org.hamcrest.TypeSafeMatcher; diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/CookiesTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/CookiesTest.java index 86434f4204e..58fc7706d85 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/CookiesTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/CookiesTest.java @@ -35,7 +35,7 @@ import javax.websocket.WebSocketContainer; import org.eclipse.jetty.util.FuturePromise; import org.eclipse.jetty.websocket.core.FrameHandler; -import org.eclipse.jetty.websocket.core.server.Negotiation; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiation; import org.eclipse.jetty.websocket.javax.tests.CoreServer; import org.eclipse.jetty.websocket.javax.tests.DummyEndpoint; import org.eclipse.jetty.websocket.javax.tests.framehandlers.StaticText; @@ -54,7 +54,7 @@ public class CookiesTest { private CoreServer server; - protected void startServer(Function negotiationFunction) throws Exception + protected void startServer(Function negotiationFunction) throws Exception { server = new CoreServer(negotiationFunction); server.start(); diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/DecoderReaderManySmallTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/DecoderReaderManySmallTest.java index caf99771299..b187053e1f9 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/DecoderReaderManySmallTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/DecoderReaderManySmallTest.java @@ -36,7 +36,7 @@ import javax.websocket.Session; import javax.websocket.WebSocketContainer; import org.eclipse.jetty.util.Callback; -import org.eclipse.jetty.websocket.core.MessageHandler; +import org.eclipse.jetty.websocket.core.internal.MessageHandler; import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; import org.eclipse.jetty.websocket.javax.tests.CoreServer; import org.eclipse.jetty.websocket.javax.tests.WSEventTracker; diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/MessageReceivingTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/MessageReceivingTest.java index 9699f2a3bc0..e4b22c18938 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/MessageReceivingTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/client/MessageReceivingTest.java @@ -39,15 +39,15 @@ import javax.websocket.WebSocketContainer; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.component.LifeCycle; -import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.FrameHandler; -import org.eclipse.jetty.websocket.core.MessageHandler; import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.core.server.Negotiation; +import org.eclipse.jetty.websocket.core.internal.MessageHandler; +import org.eclipse.jetty.websocket.core.internal.util.TextUtils; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiation; +import org.eclipse.jetty.websocket.core.server.WebSocketNegotiator; import org.eclipse.jetty.websocket.javax.tests.CoreServer; import org.eclipse.jetty.websocket.javax.tests.DataUtils; -import org.eclipse.jetty.websocket.util.TextUtils; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; @@ -342,17 +342,18 @@ public class MessageReceivingTest } } - public static class ServerMessageNegotiator extends CoreServer.BaseNegotiator + public static class ServerMessageNegotiator extends WebSocketNegotiator.AbstractNegotiator { private static final int MAX_MESSAGE_SIZE = (1024 * 1024) + 2; public ServerMessageNegotiator() { - super(); + setMaxBinaryMessageSize(MAX_MESSAGE_SIZE); + setMaxTextMessageSize(MAX_MESSAGE_SIZE); } @Override - public FrameHandler negotiate(Negotiation negotiation) throws IOException + public FrameHandler negotiate(WebSocketNegotiation negotiation) throws IOException { List offeredSubProtocols = negotiation.getOfferedSubprotocols(); @@ -378,13 +379,6 @@ public class MessageReceivingTest return null; } - - @Override - public void customize(Configuration configurable) - { - configurable.setMaxBinaryMessageSize(MAX_MESSAGE_SIZE); - configurable.setMaxTextMessageSize(MAX_MESSAGE_SIZE); - } } public static class TestEndpoint extends Endpoint diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/coders/AvailableDecodersTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/coders/AvailableDecodersTest.java index e279680f6f3..2059159739e 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/coders/AvailableDecodersTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/coders/AvailableDecodersTest.java @@ -31,10 +31,10 @@ import javax.websocket.Decoder; import javax.websocket.EndpointConfig; import org.eclipse.jetty.toolchain.test.Hex; +import org.eclipse.jetty.websocket.core.exception.InvalidWebSocketException; import org.eclipse.jetty.websocket.javax.common.decoders.AvailableDecoders; import org.eclipse.jetty.websocket.javax.common.decoders.IntegerDecoder; import org.eclipse.jetty.websocket.javax.common.decoders.RegisteredDecoder; -import org.eclipse.jetty.websocket.util.InvalidWebSocketException; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/coders/AvailableEncodersTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/coders/AvailableEncodersTest.java index acde049e045..6c71fea89e5 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/coders/AvailableEncodersTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/coders/AvailableEncodersTest.java @@ -30,10 +30,10 @@ import javax.websocket.Encoder; import javax.websocket.EndpointConfig; import org.eclipse.jetty.toolchain.test.Hex; +import org.eclipse.jetty.websocket.core.exception.InvalidWebSocketException; import org.eclipse.jetty.websocket.javax.client.internal.BasicClientEndpointConfig; import org.eclipse.jetty.websocket.javax.common.encoders.AvailableEncoders; import org.eclipse.jetty.websocket.javax.common.encoders.IntegerEncoder; -import org.eclipse.jetty.websocket.util.InvalidWebSocketException; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/coders/DecoderListTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/coders/DecoderListTest.java index 28d96a65280..20ca7096eca 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/coders/DecoderListTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/coders/DecoderListTest.java @@ -39,12 +39,12 @@ import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.IO; +import org.eclipse.jetty.websocket.core.exception.InvalidWebSocketException; import org.eclipse.jetty.websocket.javax.client.internal.JavaxWebSocketClientContainer; import org.eclipse.jetty.websocket.javax.common.decoders.AbstractDecoder; import org.eclipse.jetty.websocket.javax.server.config.JavaxWebSocketServletContainerInitializer; import org.eclipse.jetty.websocket.javax.tests.EventSocket; import org.eclipse.jetty.websocket.javax.tests.WSURI; -import org.eclipse.jetty.websocket.util.InvalidWebSocketException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/AddEndpointTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/AddEndpointTest.java index 66e654c3527..ac93de20ace 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/AddEndpointTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/AddEndpointTest.java @@ -40,7 +40,6 @@ import org.eclipse.jetty.util.component.LifeCycle; import org.eclipse.jetty.websocket.javax.server.config.JavaxWebSocketServletContainerInitializer; import org.eclipse.jetty.websocket.javax.tests.WSURI; import org.eclipse.jetty.websocket.javax.tests.client.samples.CloseSocket; -import org.eclipse.jetty.websocket.javax.tests.server.sockets.BasicOpenCloseSocket; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/AltFilterTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/AltFilterTest.java index 831e991e7ce..c478a6ddd94 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/AltFilterTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/AltFilterTest.java @@ -30,7 +30,7 @@ import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.javax.tests.Fuzzer; import org.eclipse.jetty.websocket.javax.tests.WSServer; import org.eclipse.jetty.websocket.javax.tests.server.sockets.echo.BasicEchoSocket; -import org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter; +import org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/DeploymentExceptionTest.java b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/DeploymentExceptionTest.java index e8abab0ecc6..467c0b87fa7 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/DeploymentExceptionTest.java +++ b/jetty-websocket/websocket-javax-tests/src/test/java/org/eclipse/jetty/websocket/javax/tests/server/DeploymentExceptionTest.java @@ -29,6 +29,7 @@ import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.HandlerCollection; import org.eclipse.jetty.servlet.ServletContextHandler; +import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; import org.eclipse.jetty.websocket.javax.server.config.JavaxWebSocketServletContainerInitializer; import org.eclipse.jetty.websocket.javax.tests.server.sockets.InvalidCloseIntSocket; import org.eclipse.jetty.websocket.javax.tests.server.sockets.InvalidErrorErrorSocket; @@ -36,7 +37,6 @@ import org.eclipse.jetty.websocket.javax.tests.server.sockets.InvalidErrorIntSoc import org.eclipse.jetty.websocket.javax.tests.server.sockets.InvalidOpenCloseReasonSocket; import org.eclipse.jetty.websocket.javax.tests.server.sockets.InvalidOpenIntSocket; import org.eclipse.jetty.websocket.javax.tests.server.sockets.InvalidOpenSessionIntSocket; -import org.eclipse.jetty.websocket.util.InvalidSignatureException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.ParameterizedTest; diff --git a/jetty-websocket/websocket-javax-tests/src/test/resources/alt-filter-web.xml b/jetty-websocket/websocket-javax-tests/src/test/resources/alt-filter-web.xml index 867fead5585..33f124437f7 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/resources/alt-filter-web.xml +++ b/jetty-websocket/websocket-javax-tests/src/test/resources/alt-filter-web.xml @@ -12,12 +12,12 @@ - org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter - org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter + org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter + org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter - org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter + org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter /echo/* diff --git a/jetty-websocket/websocket-javax-tests/src/test/resources/wsuf-alt-config-via-listener.xml b/jetty-websocket/websocket-javax-tests/src/test/resources/wsuf-alt-config-via-listener.xml index 647d0947663..1479493aff3 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/resources/wsuf-alt-config-via-listener.xml +++ b/jetty-websocket/websocket-javax-tests/src/test/resources/wsuf-alt-config-via-listener.xml @@ -12,7 +12,7 @@ wsuf-alt - org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter + org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter configAttributeKey alt.config diff --git a/jetty-websocket/websocket-javax-tests/src/test/resources/wsuf-config-via-listener.xml b/jetty-websocket/websocket-javax-tests/src/test/resources/wsuf-config-via-listener.xml index 595de89a035..d9811f6e0e5 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/resources/wsuf-config-via-listener.xml +++ b/jetty-websocket/websocket-javax-tests/src/test/resources/wsuf-config-via-listener.xml @@ -16,7 +16,7 @@ wsuf - org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter + org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter diff --git a/jetty-websocket/websocket-javax-tests/src/test/resources/wsuf-config-via-servlet-init.xml b/jetty-websocket/websocket-javax-tests/src/test/resources/wsuf-config-via-servlet-init.xml index 56a333bfee1..f8c8fbf61e9 100644 --- a/jetty-websocket/websocket-javax-tests/src/test/resources/wsuf-config-via-servlet-init.xml +++ b/jetty-websocket/websocket-javax-tests/src/test/resources/wsuf-config-via-servlet-init.xml @@ -18,7 +18,7 @@ wsuf - org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter + org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter diff --git a/jetty-websocket/websocket-jetty-client/src/main/config/modules/websocket-jetty-client.mod b/jetty-websocket/websocket-jetty-client/src/main/config/modules/websocket-jetty-client.mod index 0e35bf32ce4..78420f79fb4 100644 --- a/jetty-websocket/websocket-jetty-client/src/main/config/modules/websocket-jetty-client.mod +++ b/jetty-websocket/websocket-jetty-client/src/main/config/modules/websocket-jetty-client.mod @@ -13,7 +13,6 @@ annotations [lib] lib/websocket/websocket-core-common-${jetty.version}.jar lib/websocket/websocket-core-client-${jetty.version}.jar -lib/websocket/websocket-util-${jetty.version}.jar lib/websocket/websocket-jetty-api-${jetty.version}.jar lib/websocket/websocket-jetty-common-${jetty.version}.jar lib/websocket/websocket-jetty-client-${jetty.version}.jar diff --git a/jetty-websocket/websocket-jetty-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java b/jetty-websocket/websocket-jetty-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java index c967c537075..15148e7d9d2 100644 --- a/jetty-websocket/websocket-jetty-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java +++ b/jetty-websocket/websocket-jetty-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DelegatedJettyClientUpgradeResponse.java @@ -20,15 +20,12 @@ package org.eclipse.jetty.websocket.client.impl; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; import org.eclipse.jetty.client.HttpResponse; -import org.eclipse.jetty.http.HttpField; -import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.websocket.api.ExtensionConfig; import org.eclipse.jetty.websocket.api.UpgradeResponse; diff --git a/jetty-websocket/websocket-jetty-common/pom.xml b/jetty-websocket/websocket-jetty-common/pom.xml index b3809d06724..de119c47126 100644 --- a/jetty-websocket/websocket-jetty-common/pom.xml +++ b/jetty-websocket/websocket-jetty-common/pom.xml @@ -53,7 +53,7 @@ org.eclipse.jetty.websocket - websocket-util + websocket-core-common ${project.version} diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/module-info.java b/jetty-websocket/websocket-jetty-common/src/main/java/module-info.java index 848cf00520f..2e235491619 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/module-info.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/module-info.java @@ -27,7 +27,6 @@ module org.eclipse.jetty.websocket.jetty.common requires org.slf4j; requires transitive org.eclipse.jetty.websocket.core.common; requires transitive org.eclipse.jetty.websocket.jetty.api; - requires transitive org.eclipse.jetty.websocket.util; provides ExtensionConfig.Parser with ExtensionConfigParser; } diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java index 484235984fc..7303f244529 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandler.java @@ -40,14 +40,14 @@ import org.eclipse.jetty.websocket.core.FrameHandler; import org.eclipse.jetty.websocket.core.OpCode; import org.eclipse.jetty.websocket.core.exception.BadPayloadException; import org.eclipse.jetty.websocket.core.exception.CloseException; +import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; import org.eclipse.jetty.websocket.core.exception.MessageTooLargeException; import org.eclipse.jetty.websocket.core.exception.ProtocolException; import org.eclipse.jetty.websocket.core.exception.UpgradeException; import org.eclipse.jetty.websocket.core.exception.WebSocketException; import org.eclipse.jetty.websocket.core.exception.WebSocketTimeoutException; -import org.eclipse.jetty.websocket.util.InvalidSignatureException; -import org.eclipse.jetty.websocket.util.InvokerUtils; -import org.eclipse.jetty.websocket.util.messages.MessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.MessageSink; +import org.eclipse.jetty.websocket.core.internal.util.InvokerUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerFactory.java b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerFactory.java index da579a24477..c571fd0e60f 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerFactory.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerFactory.java @@ -51,18 +51,18 @@ import org.eclipse.jetty.websocket.api.annotations.OnWebSocketFrame; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; import org.eclipse.jetty.websocket.api.annotations.WebSocket; import org.eclipse.jetty.websocket.core.CoreSession; -import org.eclipse.jetty.websocket.util.InvalidSignatureException; -import org.eclipse.jetty.websocket.util.InvalidWebSocketException; -import org.eclipse.jetty.websocket.util.InvokerUtils; -import org.eclipse.jetty.websocket.util.ReflectUtils; -import org.eclipse.jetty.websocket.util.messages.ByteArrayMessageSink; -import org.eclipse.jetty.websocket.util.messages.ByteBufferMessageSink; -import org.eclipse.jetty.websocket.util.messages.InputStreamMessageSink; -import org.eclipse.jetty.websocket.util.messages.MessageSink; -import org.eclipse.jetty.websocket.util.messages.PartialByteBufferMessageSink; -import org.eclipse.jetty.websocket.util.messages.PartialStringMessageSink; -import org.eclipse.jetty.websocket.util.messages.ReaderMessageSink; -import org.eclipse.jetty.websocket.util.messages.StringMessageSink; +import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; +import org.eclipse.jetty.websocket.core.exception.InvalidWebSocketException; +import org.eclipse.jetty.websocket.core.internal.messages.ByteArrayMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.ByteBufferMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.InputStreamMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.MessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.PartialByteBufferMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.PartialStringMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.ReaderMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.StringMessageSink; +import org.eclipse.jetty.websocket.core.internal.util.InvokerUtils; +import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils; /** * Factory to create {@link JettyWebSocketFrameHandler} instances suitable for @@ -135,7 +135,7 @@ public class JettyWebSocketFrameHandlerFactory extends ContainerLifeCycle final MethodHandle pongHandle = InvokerUtils.bindTo(metadata.getPongHandle(), endpointInstance); BatchMode batchMode = metadata.getBatchMode(); - JettyWebSocketFrameHandler frameHandler = new JettyWebSocketFrameHandler( + return new JettyWebSocketFrameHandler( container, endpointInstance, openHandle, closeHandle, errorHandle, @@ -144,8 +144,6 @@ public class JettyWebSocketFrameHandlerFactory extends ContainerLifeCycle frameHandle, pingHandle, pongHandle, batchMode, metadata); - - return frameHandler; } public static MessageSink createMessageSink(MethodHandle msgHandle, Class sinkClass, Executor executor, WebSocketSession session) diff --git a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerMetadata.java b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerMetadata.java index ae782768f90..3b6b4930fb1 100644 --- a/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerMetadata.java +++ b/jetty-websocket/websocket-jetty-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketFrameHandlerMetadata.java @@ -23,7 +23,7 @@ import java.lang.invoke.MethodHandle; import org.eclipse.jetty.websocket.api.BatchMode; import org.eclipse.jetty.websocket.api.exceptions.InvalidWebSocketException; import org.eclipse.jetty.websocket.core.Configuration; -import org.eclipse.jetty.websocket.util.messages.MessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.MessageSink; public class JettyWebSocketFrameHandlerMetadata extends Configuration.ConfigurationCustomizer { diff --git a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/EndPoints.java b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/EndPoints.java index 4ec9847e0af..c9d6f360e34 100644 --- a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/EndPoints.java +++ b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/EndPoints.java @@ -38,7 +38,7 @@ import org.eclipse.jetty.websocket.api.annotations.OnWebSocketFrame; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; import org.eclipse.jetty.websocket.api.annotations.WebSocket; import org.eclipse.jetty.websocket.core.CloseStatus; -import org.eclipse.jetty.websocket.util.TextUtils; +import org.eclipse.jetty.websocket.core.internal.util.TextUtils; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.notNullValue; diff --git a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/LocalEndpointMetadataTest.java b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/LocalEndpointMetadataTest.java index de31a6b5047..e22401e5f79 100644 --- a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/LocalEndpointMetadataTest.java +++ b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/LocalEndpointMetadataTest.java @@ -19,12 +19,12 @@ package org.eclipse.jetty.websocket.common; import org.eclipse.jetty.websocket.api.exceptions.InvalidWebSocketException; -import org.eclipse.jetty.websocket.util.DuplicateAnnotationException; -import org.eclipse.jetty.websocket.util.InvalidSignatureException; -import org.eclipse.jetty.websocket.util.messages.ByteArrayMessageSink; -import org.eclipse.jetty.websocket.util.messages.InputStreamMessageSink; -import org.eclipse.jetty.websocket.util.messages.ReaderMessageSink; -import org.eclipse.jetty.websocket.util.messages.StringMessageSink; +import org.eclipse.jetty.websocket.core.exception.DuplicateAnnotationException; +import org.eclipse.jetty.websocket.core.exception.InvalidSignatureException; +import org.eclipse.jetty.websocket.core.internal.messages.ByteArrayMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.InputStreamMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.ReaderMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.StringMessageSink; import org.hamcrest.Matcher; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; diff --git a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/MessageInputStreamTest.java b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/MessageInputStreamTest.java index b7fe9197f99..46bc68f091d 100644 --- a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/MessageInputStreamTest.java +++ b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/MessageInputStreamTest.java @@ -32,7 +32,7 @@ import org.eclipse.jetty.util.FutureCallback; import org.eclipse.jetty.util.IO; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.util.messages.MessageInputStream; +import org.eclipse.jetty.websocket.core.internal.messages.MessageInputStream; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/MessageOutputStreamTest.java b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/MessageOutputStreamTest.java index f090d20a4de..39bd1ccfaf5 100644 --- a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/MessageOutputStreamTest.java +++ b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/MessageOutputStreamTest.java @@ -23,7 +23,7 @@ import java.util.Arrays; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.util.BufferUtil; -import org.eclipse.jetty.websocket.util.messages.MessageOutputStream; +import org.eclipse.jetty.websocket.core.internal.messages.MessageOutputStream; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/OutgoingMessageCapture.java b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/OutgoingMessageCapture.java index 366827f169f..3beacd8d0bc 100644 --- a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/OutgoingMessageCapture.java +++ b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/OutgoingMessageCapture.java @@ -31,9 +31,9 @@ import org.eclipse.jetty.websocket.core.CloseStatus; import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.OpCode; -import org.eclipse.jetty.websocket.util.messages.ByteBufferMessageSink; -import org.eclipse.jetty.websocket.util.messages.MessageSink; -import org.eclipse.jetty.websocket.util.messages.StringMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.ByteBufferMessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.MessageSink; +import org.eclipse.jetty.websocket.core.internal.messages.StringMessageSink; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/invoke/InvokerUtilsTest.java b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/invoke/InvokerUtilsTest.java index 315d7ee4fe7..1f1632ceb28 100644 --- a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/invoke/InvokerUtilsTest.java +++ b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/invoke/InvokerUtilsTest.java @@ -24,8 +24,8 @@ import java.lang.invoke.MethodHandles; import java.lang.reflect.Method; import org.eclipse.jetty.util.annotation.Name; -import org.eclipse.jetty.websocket.util.InvokerUtils; -import org.eclipse.jetty.websocket.util.ReflectUtils; +import org.eclipse.jetty.websocket.core.internal.util.InvokerUtils; +import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/invoke/NameParamIdentifier.java b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/invoke/NameParamIdentifier.java index 5caedfa43cb..3c4c0d3d413 100644 --- a/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/invoke/NameParamIdentifier.java +++ b/jetty-websocket/websocket-jetty-common/src/test/java/org/eclipse/jetty/websocket/common/invoke/NameParamIdentifier.java @@ -22,7 +22,7 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Method; import org.eclipse.jetty.util.annotation.Name; -import org.eclipse.jetty.websocket.util.InvokerUtils; +import org.eclipse.jetty.websocket.core.internal.util.InvokerUtils; /** * Simple {@link InvokerUtils.ParamIdentifier} diff --git a/jetty-websocket/websocket-jetty-server/pom.xml b/jetty-websocket/websocket-jetty-server/pom.xml index 0387a72b773..321280eafc1 100644 --- a/jetty-websocket/websocket-jetty-server/pom.xml +++ b/jetty-websocket/websocket-jetty-server/pom.xml @@ -27,7 +27,7 @@ org.eclipse.jetty.websocket - websocket-util-server + websocket-servlet ${project.version} diff --git a/jetty-websocket/websocket-jetty-server/src/main/config/modules/websocket-jetty.mod b/jetty-websocket/websocket-jetty-server/src/main/config/modules/websocket-jetty.mod index 8194e1e7488..e9d04d710d8 100644 --- a/jetty-websocket/websocket-jetty-server/src/main/config/modules/websocket-jetty.mod +++ b/jetty-websocket/websocket-jetty-server/src/main/config/modules/websocket-jetty.mod @@ -12,8 +12,7 @@ annotations [lib] lib/websocket/websocket-core-common-${jetty.version}.jar lib/websocket/websocket-core-server-${jetty.version}.jar -lib/websocket/websocket-util-${jetty.version}.jar -lib/websocket/websocket-util-server-${jetty.version}.jar +lib/websocket/websocket-servlet-${jetty.version}.jar lib/websocket/websocket-jetty-api-${jetty.version}.jar lib/websocket/websocket-jetty-common-${jetty.version}.jar lib/websocket/websocket-jetty-server-${jetty.version}.jar diff --git a/jetty-websocket/websocket-jetty-server/src/main/java/module-info.java b/jetty-websocket/websocket-jetty-server/src/main/java/module-info.java index 6156e8d5a30..13530d91438 100644 --- a/jetty-websocket/websocket-jetty-server/src/main/java/module-info.java +++ b/jetty-websocket/websocket-jetty-server/src/main/java/module-info.java @@ -28,8 +28,9 @@ module org.eclipse.jetty.websocket.jetty.server exports org.eclipse.jetty.websocket.server.config; requires jetty.servlet.api; + requires org.eclipse.jetty.websocket.core.server; requires org.eclipse.jetty.websocket.jetty.common; - requires org.eclipse.jetty.websocket.util.server; + requires org.eclipse.jetty.websocket.servlet; requires org.slf4j; requires transitive org.eclipse.jetty.webapp; requires transitive org.eclipse.jetty.websocket.jetty.api; diff --git a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServerContainer.java b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServerContainer.java index df55e866e82..7277dd6cb37 100644 --- a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServerContainer.java +++ b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServerContainer.java @@ -37,17 +37,15 @@ import org.eclipse.jetty.websocket.api.WebSocketPolicy; import org.eclipse.jetty.websocket.api.WebSocketSessionListener; import org.eclipse.jetty.websocket.common.SessionTracker; import org.eclipse.jetty.websocket.core.Configuration; -import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.exception.WebSocketException; -import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents; +import org.eclipse.jetty.websocket.core.internal.util.ReflectUtils; +import org.eclipse.jetty.websocket.core.server.FrameHandlerFactory; +import org.eclipse.jetty.websocket.core.server.WebSocketMappings; import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer; import org.eclipse.jetty.websocket.server.internal.DelegatedServerUpgradeRequest; import org.eclipse.jetty.websocket.server.internal.DelegatedServerUpgradeResponse; import org.eclipse.jetty.websocket.server.internal.JettyServerFrameHandlerFactory; -import org.eclipse.jetty.websocket.util.ReflectUtils; -import org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter; -import org.eclipse.jetty.websocket.util.server.internal.FrameHandlerFactory; -import org.eclipse.jetty.websocket.util.server.internal.WebSocketMappings; +import org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,10 +73,8 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements executor = contextHandler.getServer().getThreadPool(); // Create the Jetty ServerContainer implementation - container = new JettyWebSocketServerContainer( - contextHandler, - WebSocketMappings.ensureMapping(servletContext), - WebSocketServerComponents.getWebSocketComponents(servletContext), executor); + WebSocketMappings mappings = WebSocketMappings.ensureMappings(servletContext); + container = new JettyWebSocketServerContainer(contextHandler, mappings, executor); servletContext.setAttribute(JETTY_WEBSOCKET_CONTAINER_ATTRIBUTE, container); contextHandler.addManaged(container); contextHandler.addEventListener(container); @@ -91,7 +87,6 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements private final ServletContextHandler contextHandler; private final WebSocketMappings webSocketMappings; - private final WebSocketComponents components; private final FrameHandlerFactory frameHandlerFactory; private final Executor executor; private final Configuration.ConfigurationCustomizer customizer = new Configuration.ConfigurationCustomizer(); @@ -103,15 +98,13 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements * Main entry point for {@link JettyWebSocketServletContainerInitializer}. * * @param webSocketMappings the {@link WebSocketMappings} that this container belongs to - * @param components the {@link WebSocketComponents} instance to use * @param executor the {@link Executor} to use */ - JettyWebSocketServerContainer(ServletContextHandler contextHandler, WebSocketMappings webSocketMappings, WebSocketComponents components, Executor executor) + JettyWebSocketServerContainer(ServletContextHandler contextHandler, WebSocketMappings webSocketMappings, Executor executor) { this.contextHandler = contextHandler; this.webSocketMappings = webSocketMappings; this.executor = executor; - this.components = components; // Ensure there is a FrameHandlerFactory JettyServerFrameHandlerFactory factory = contextHandler.getBean(JettyServerFrameHandlerFactory.class); @@ -130,7 +123,7 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements public void addMapping(String pathSpec, JettyWebSocketCreator creator) { PathSpec ps = WebSocketMappings.parsePathSpec(pathSpec); - if (webSocketMappings.getMapping(ps) != null) + if (webSocketMappings.getWebSocketNegotiator(ps) != null) throw new WebSocketException("Duplicate WebSocket Mapping for PathSpec"); WebSocketUpgradeFilter.ensureFilter(contextHandler.getServletContext()); @@ -157,11 +150,6 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements }); } - public WebSocketComponents getWebSocketComponents() - { - return components; - } - @Override public Executor getExecutor() { diff --git a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServlet.java b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServlet.java index 7ce3a0e7478..8cf98be4ecf 100644 --- a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServlet.java +++ b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/JettyWebSocketServlet.java @@ -31,16 +31,16 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.websocket.core.Configuration; import org.eclipse.jetty.websocket.core.WebSocketComponents; +import org.eclipse.jetty.websocket.core.server.FrameHandlerFactory; +import org.eclipse.jetty.websocket.core.server.ServerUpgradeRequest; +import org.eclipse.jetty.websocket.core.server.ServerUpgradeResponse; +import org.eclipse.jetty.websocket.core.server.WebSocketCreator; +import org.eclipse.jetty.websocket.core.server.WebSocketMappings; import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents; import org.eclipse.jetty.websocket.server.internal.DelegatedServerUpgradeRequest; import org.eclipse.jetty.websocket.server.internal.DelegatedServerUpgradeResponse; import org.eclipse.jetty.websocket.server.internal.JettyServerFrameHandlerFactory; -import org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter; -import org.eclipse.jetty.websocket.util.server.internal.FrameHandlerFactory; -import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest; -import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeResponse; -import org.eclipse.jetty.websocket.util.server.internal.WebSocketCreator; -import org.eclipse.jetty.websocket.util.server.internal.WebSocketMappings; +import org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -249,10 +249,9 @@ public abstract class JettyWebSocketServlet extends HttpServlet @Override public JettyWebSocketCreator getMapping(String pathSpec) { - WebSocketCreator creator = mapping.getMapping(WebSocketMappings.parsePathSpec(pathSpec)); + WebSocketCreator creator = mapping.getWebSocketCreator(WebSocketMappings.parsePathSpec(pathSpec)); if (creator instanceof WrappedJettyCreator) return ((WrappedJettyCreator)creator).getJettyWebSocketCreator(); - return null; } diff --git a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/config/JettyWebSocketConfiguration.java b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/config/JettyWebSocketConfiguration.java index 5115c0005e0..624c68fc878 100644 --- a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/config/JettyWebSocketConfiguration.java +++ b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/config/JettyWebSocketConfiguration.java @@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory; *

Websocket Configuration

*

This configuration configures the WebAppContext server/system classes to * be able to see the {@code org.eclipse.jetty.websocket.api}, {@code org.eclipse.jetty.websocket.server} and - * {@code org.eclipse.jetty.websocket.util.server} packages.

+ * {@code org.eclipse.jetty.websocket.servlet} packages.

*/ public class JettyWebSocketConfiguration extends AbstractConfiguration { @@ -44,7 +44,7 @@ public class JettyWebSocketConfiguration extends AbstractConfiguration protectAndExpose("org.eclipse.jetty.websocket.api."); protectAndExpose("org.eclipse.jetty.websocket.server."); - protectAndExpose("org.eclipse.jetty.websocket.util.server."); // For WebSocketUpgradeFilter + protectAndExpose("org.eclipse.jetty.websocket.servlet."); // For WebSocketUpgradeFilter hide("org.eclipse.jetty.server.internal."); hide("org.eclipse.jetty.server.config."); } diff --git a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/config/JettyWebSocketServletContainerInitializer.java b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/config/JettyWebSocketServletContainerInitializer.java index ad064fbbe5b..bd947819d63 100644 --- a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/config/JettyWebSocketServletContainerInitializer.java +++ b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/config/JettyWebSocketServletContainerInitializer.java @@ -25,9 +25,9 @@ import javax.servlet.ServletContext; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.listener.ContainerInitializer; import org.eclipse.jetty.websocket.core.WebSocketComponents; +import org.eclipse.jetty.websocket.core.server.WebSocketMappings; import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents; import org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer; -import org.eclipse.jetty.websocket.util.server.internal.WebSocketMappings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/DelegatedServerUpgradeRequest.java b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/DelegatedServerUpgradeRequest.java index 1969e792b4c..789e2c59971 100644 --- a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/DelegatedServerUpgradeRequest.java +++ b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/DelegatedServerUpgradeRequest.java @@ -33,8 +33,8 @@ import javax.servlet.http.HttpSession; import org.eclipse.jetty.websocket.api.ExtensionConfig; import org.eclipse.jetty.websocket.common.JettyExtensionConfig; +import org.eclipse.jetty.websocket.core.server.ServerUpgradeRequest; import org.eclipse.jetty.websocket.server.JettyServerUpgradeRequest; -import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest; public class DelegatedServerUpgradeRequest implements JettyServerUpgradeRequest { diff --git a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/DelegatedServerUpgradeResponse.java b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/DelegatedServerUpgradeResponse.java index 287e3649266..8ea5d42f578 100644 --- a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/DelegatedServerUpgradeResponse.java +++ b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/DelegatedServerUpgradeResponse.java @@ -26,8 +26,8 @@ import java.util.stream.Collectors; import org.eclipse.jetty.websocket.api.ExtensionConfig; import org.eclipse.jetty.websocket.common.JettyExtensionConfig; +import org.eclipse.jetty.websocket.core.server.ServerUpgradeResponse; import org.eclipse.jetty.websocket.server.JettyServerUpgradeResponse; -import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeResponse; public class DelegatedServerUpgradeResponse implements JettyServerUpgradeResponse { diff --git a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/JettyServerFrameHandlerFactory.java b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/JettyServerFrameHandlerFactory.java index b7e594aedb1..5b085ea9b8b 100644 --- a/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/JettyServerFrameHandlerFactory.java +++ b/jetty-websocket/websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/internal/JettyServerFrameHandlerFactory.java @@ -27,9 +27,9 @@ import org.eclipse.jetty.websocket.api.WebSocketContainer; import org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandler; import org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandlerFactory; import org.eclipse.jetty.websocket.core.FrameHandler; -import org.eclipse.jetty.websocket.util.server.internal.FrameHandlerFactory; -import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeRequest; -import org.eclipse.jetty.websocket.util.server.internal.ServerUpgradeResponse; +import org.eclipse.jetty.websocket.core.server.FrameHandlerFactory; +import org.eclipse.jetty.websocket.core.server.ServerUpgradeRequest; +import org.eclipse.jetty.websocket.core.server.ServerUpgradeResponse; public class JettyServerFrameHandlerFactory extends JettyWebSocketFrameHandlerFactory implements FrameHandlerFactory, LifeCycle.Listener { diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/EchoSocket.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/EchoSocket.java index d1c7db2f4c2..7672f85ab56 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/EchoSocket.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/EchoSocket.java @@ -21,7 +21,6 @@ package org.eclipse.jetty.websocket.tests; import java.io.IOException; import java.nio.ByteBuffer; -import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.api.annotations.WebSocket; @SuppressWarnings("unused") diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/ErrorCloseTest.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/ErrorCloseTest.java index b4a850bb5ca..0c335d953c0 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/ErrorCloseTest.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/ErrorCloseTest.java @@ -257,6 +257,7 @@ public class ErrorCloseTest serverSocket.methodsToThrow.add(methodToThrow); EventSocket clientSocket = new EventSocket(); client.connect(clientSocket, serverUri).get(5, TimeUnit.SECONDS); + assertTrue(serverSocket.openLatch.await(5, TimeUnit.SECONDS)); try (StacklessLogging ignored = new StacklessLogging(WebSocketSession.class)) { diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebSocketFilterTest.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebSocketFilterTest.java index a11772e67e1..e02813c72d6 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebSocketFilterTest.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebSocketFilterTest.java @@ -51,7 +51,7 @@ import org.eclipse.jetty.websocket.client.WebSocketClient; import org.eclipse.jetty.websocket.core.WebSocketConstants; import org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer; import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer; -import org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter; +import org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebSocketNegotiationTest.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebSocketNegotiationTest.java index 7e81b1a24af..af0618d12c7 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebSocketNegotiationTest.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/JettyWebSocketNegotiationTest.java @@ -22,7 +22,10 @@ import java.net.URI; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; +import org.eclipse.jetty.client.HttpRequest; +import org.eclipse.jetty.client.HttpResponse; import org.eclipse.jetty.logging.StacklessLogging; import org.eclipse.jetty.server.HttpChannel; import org.eclipse.jetty.server.Server; @@ -30,11 +33,14 @@ import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; +import org.eclipse.jetty.websocket.client.JettyUpgradeListener; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer; import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer; +import org.hamcrest.Matchers; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; @@ -110,4 +116,41 @@ public class JettyWebSocketNegotiationTest assertThat(t.getMessage(), containsString("500 Server Error")); } } + + @Disabled("Work in progress; ServerUpgradeResponse in websocket-core throws NPEs") + @Test + public void testManualNegotiationInCreator() throws Exception + { + JettyWebSocketServerContainer container = JettyWebSocketServerContainer.getContainer(contextHandler.getServletContext()); + container.addMapping("/", (req, resp) -> + { + long matchedExts = req.getExtensions().stream() + .filter(ec -> "permessage-deflate".equals(ec.getName())) + .filter(ec -> ec.getParameters().containsKey("client_no_context_takeover")) + .count(); + assertThat(matchedExts, Matchers.is(1L)); + + // Manually drop the param so it is not negotiated in the extension stack. + resp.setHeader("Sec-WebSocket-Extensions", "permessage-deflate"); + return new EchoSocket(); + }); + + URI uri = URI.create("ws://localhost:" + connector.getLocalPort() + "/filterPath"); + EventSocket socket = new EventSocket(); + AtomicReference responseReference = new AtomicReference<>(); + ClientUpgradeRequest upgradeRequest = new ClientUpgradeRequest(); + upgradeRequest.addExtensions("permessage-deflate;client_no_context_takeover"); + JettyUpgradeListener upgradeListener = new JettyUpgradeListener() + { + @Override + public void onHandshakeResponse(HttpRequest request, HttpResponse response) + { + responseReference.set(response); + } + }; + + client.connect(socket, uri, upgradeRequest, upgradeListener).get(5, TimeUnit.SECONDS); + HttpResponse httpResponse = responseReference.get(); + System.err.println(httpResponse.getHeaders()); + } } diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/WebSocketOverHTTP2Test.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/WebSocketOverHTTP2Test.java index 87725e66085..3b15549f19b 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/WebSocketOverHTTP2Test.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/WebSocketOverHTTP2Test.java @@ -61,10 +61,10 @@ import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.StatusCode; import org.eclipse.jetty.websocket.api.exceptions.UpgradeException; import org.eclipse.jetty.websocket.client.WebSocketClient; +import org.eclipse.jetty.websocket.core.server.internal.UpgradeHttpServletRequest; import org.eclipse.jetty.websocket.server.JettyWebSocketServlet; import org.eclipse.jetty.websocket.server.JettyWebSocketServletFactory; import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer; -import org.eclipse.jetty.websocket.util.server.internal.UpgradeHttpServletRequest; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/PartialListenerTest.java b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/PartialListenerTest.java index 36bc27041e5..48aa15d318a 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/PartialListenerTest.java +++ b/jetty-websocket/websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/server/PartialListenerTest.java @@ -40,6 +40,7 @@ import org.eclipse.jetty.websocket.api.util.WSURI; import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.eclipse.jetty.websocket.common.WebSocketSession; +import org.eclipse.jetty.websocket.core.internal.util.TextUtils; import org.eclipse.jetty.websocket.server.JettyServerUpgradeRequest; import org.eclipse.jetty.websocket.server.JettyServerUpgradeResponse; import org.eclipse.jetty.websocket.server.JettyWebSocketCreator; @@ -47,7 +48,6 @@ import org.eclipse.jetty.websocket.server.JettyWebSocketServlet; import org.eclipse.jetty.websocket.server.JettyWebSocketServletFactory; import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer; import org.eclipse.jetty.websocket.tests.CloseTrackingEndpoint; -import org.eclipse.jetty.websocket.util.TextUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/jetty-websocket/websocket-jetty-tests/src/test/resources/wsuf-ordering1.xml b/jetty-websocket/websocket-jetty-tests/src/test/resources/wsuf-ordering1.xml index b93d673a43b..85bad9fa7d5 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/resources/wsuf-ordering1.xml +++ b/jetty-websocket/websocket-jetty-tests/src/test/resources/wsuf-ordering1.xml @@ -8,7 +8,7 @@ wsuf-alt - org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter + org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter idleTimeout 5999 diff --git a/jetty-websocket/websocket-jetty-tests/src/test/resources/wsuf-ordering2.xml b/jetty-websocket/websocket-jetty-tests/src/test/resources/wsuf-ordering2.xml index a733873a671..456e5a17864 100644 --- a/jetty-websocket/websocket-jetty-tests/src/test/resources/wsuf-ordering2.xml +++ b/jetty-websocket/websocket-jetty-tests/src/test/resources/wsuf-ordering2.xml @@ -9,7 +9,7 @@ wsuf-alt - org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter + org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter idleTimeout 5999 @@ -22,11 +22,11 @@ - org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter - org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter + org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter + org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter - org.eclipse.jetty.websocket.util.server.WebSocketUpgradeFilter + org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter /* diff --git a/jetty-websocket/websocket-util/pom.xml b/jetty-websocket/websocket-servlet/pom.xml similarity index 77% rename from jetty-websocket/websocket-util/pom.xml rename to jetty-websocket/websocket-servlet/pom.xml index cafdccef949..063d33cb1de 100644 --- a/jetty-websocket/websocket-util/pom.xml +++ b/jetty-websocket/websocket-servlet/pom.xml @@ -7,11 +7,11 @@ 4.0.0 - websocket-util - Jetty :: Websocket :: org.eclipse.jetty.websocket :: Util + websocket-servlet + Jetty :: Websocket :: Servlet - ${project.groupId}.util + ${project.groupId}.servlet @@ -48,7 +48,12 @@ org.eclipse.jetty.websocket - websocket-core-common + websocket-core-server + ${project.version} + + + org.eclipse.jetty + jetty-servlet ${project.version} @@ -60,5 +65,10 @@ jetty-slf4j-impl test + + org.eclipse.jetty.toolchain + jetty-test-helper + test + diff --git a/jetty-websocket/websocket-util/src/main/java/module-info.java b/jetty-websocket/websocket-servlet/src/main/java/module-info.java similarity index 79% rename from jetty-websocket/websocket-util/src/main/java/module-info.java rename to jetty-websocket/websocket-servlet/src/main/java/module-info.java index fdca115546e..e3912db017a 100644 --- a/jetty-websocket/websocket-util/src/main/java/module-info.java +++ b/jetty-websocket/websocket-servlet/src/main/java/module-info.java @@ -16,11 +16,11 @@ // ======================================================================== // -module org.eclipse.jetty.websocket.util +module org.eclipse.jetty.websocket.servlet { - exports org.eclipse.jetty.websocket.util; - exports org.eclipse.jetty.websocket.util.messages; + exports org.eclipse.jetty.websocket.servlet; - requires transitive org.eclipse.jetty.websocket.core.common; + requires transitive org.eclipse.jetty.servlet; + requires org.eclipse.jetty.websocket.core.server; requires org.slf4j; } diff --git a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/WebSocketUpgradeFilter.java b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketUpgradeFilter.java similarity index 97% rename from jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/WebSocketUpgradeFilter.java rename to jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketUpgradeFilter.java index 08318d1c440..e97db08eb33 100644 --- a/jetty-websocket/websocket-util-server/src/main/java/org/eclipse/jetty/websocket/util/server/WebSocketUpgradeFilter.java +++ b/jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketUpgradeFilter.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.util.server; +package org.eclipse.jetty.websocket.servlet; import java.io.IOException; import java.time.Duration; @@ -41,7 +41,7 @@ import org.eclipse.jetty.util.annotation.ManagedObject; import org.eclipse.jetty.util.component.Dumpable; import org.eclipse.jetty.util.thread.AutoLock; import org.eclipse.jetty.websocket.core.Configuration; -import org.eclipse.jetty.websocket.util.server.internal.WebSocketMappings; +import org.eclipse.jetty.websocket.core.server.WebSocketMappings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -171,7 +171,7 @@ public class WebSocketUpgradeFilter implements Filter, Dumpable @Override public void init(FilterConfig config) throws ServletException { - mapping = WebSocketMappings.ensureMapping(config.getServletContext()); + mapping = WebSocketMappings.ensureMappings(config.getServletContext()); String max = config.getInitParameter("idleTimeout"); if (max == null) diff --git a/jetty-websocket/websocket-util-server/pom.xml b/jetty-websocket/websocket-util-server/pom.xml deleted file mode 100644 index 3fd5fc74a48..00000000000 --- a/jetty-websocket/websocket-util-server/pom.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - org.eclipse.jetty.websocket - websocket-parent - 10.0.0-SNAPSHOT - - - 4.0.0 - websocket-util-server - Jetty :: Websocket :: org.eclipse.jetty.websocket :: Util-Server - - - ${project.groupId}.util.server - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - - - ban-java-servlet-api - - enforce - - - - - - javax.servlet - servletapi - org.eclipse.jetty.orbit:javax.servlet - org.mortbay.jetty:servlet-api - jetty:servlet-api - jetty-servlet-api - - - - - - - - - org.apache.felix - maven-bundle-plugin - true - - - generate-manifest - - manifest - - - - *,org.eclipse.jetty.websocket.util.server.internal.* - - - - - - - - - - - org.eclipse.jetty.websocket - websocket-core-server - ${project.version} - - - org.eclipse.jetty - jetty-servlet - ${project.version} - provided - - - org.slf4j - slf4j-api - - - org.eclipse.jetty - jetty-slf4j-impl - test - - - org.eclipse.jetty.toolchain - jetty-test-helper - test - - - diff --git a/jetty-websocket/websocket-util-server/src/main/java/module-info.java b/jetty-websocket/websocket-util-server/src/main/java/module-info.java deleted file mode 100644 index c067bea8bf3..00000000000 --- a/jetty-websocket/websocket-util-server/src/main/java/module-info.java +++ /dev/null @@ -1,27 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2020 Mort Bay Consulting Pty Ltd and others. -// -// This program and the accompanying materials are made available under -// the terms of the Eclipse Public License 2.0 which is available at -// https://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: -// the Apache License v2.0 which is available at -// https://www.apache.org/licenses/LICENSE-2.0 -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// ======================================================================== -// - -module org.eclipse.jetty.websocket.util.server -{ - exports org.eclipse.jetty.websocket.util.server; - exports org.eclipse.jetty.websocket.util.server.internal to org.eclipse.jetty.websocket.jetty.server, org.eclipse.jetty.websocket.javax.server; - - requires org.slf4j; - requires transitive org.eclipse.jetty.servlet; - requires transitive org.eclipse.jetty.websocket.core.server; -} diff --git a/jetty-websocket/websocket-util/src/test/resources/jetty-logging.properties b/jetty-websocket/websocket-util/src/test/resources/jetty-logging.properties deleted file mode 100644 index 376b9b6babb..00000000000 --- a/jetty-websocket/websocket-util/src/test/resources/jetty-logging.properties +++ /dev/null @@ -1 +0,0 @@ -# Jetty Logging using jetty-slf4j-impl