Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jetty-websocket')
-rw-r--r--jetty-websocket/javax-websocket-client-impl/pom.xml2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/AbstractJsrRemote.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/ClientContainer.java81
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/DecoderFactory.java25
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/EncoderFactory.java24
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JettyClientContainerProvider.java10
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrExtension.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrSession.java9
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrSessionFactory.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrUpgradeListener.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerFactory.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerWrapper.java4
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/AnnotatedEndpointMetadata.java6
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/AnnotatedEndpointScanner.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/IJsrMethod.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrCallable.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrEvents.java8
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdBinary.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdDecoder.java4
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdOnClose.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdOnError.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdOnOpen.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdText.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnCloseCallable.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnErrorCallable.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageBinaryCallable.java6
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageBinaryStreamCallable.java4
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessagePongCallable.java4
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageTextCallable.java5
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageTextStreamCallable.java4
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnOpenCallable.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/BooleanDecoder.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/ByteDecoder.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/CharacterDecoder.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/DoubleDecoder.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/IntegerDecoder.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/ShortDecoder.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/StringDecoder.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/BooleanEncoder.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/ByteEncoder.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/CharacterEncoder.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/DoubleEncoder.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/FloatEncoder.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/IntegerEncoder.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/LongEncoder.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/ShortEncoder.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/StringEncoder.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/endpoints/JsrAnnotatedEventDriver.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/messages/BinaryPartialOnMessage.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/messages/TextPartialMessage.java7
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/messages/TextPartialOnMessage.java18
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/CoderMetadata.java4
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/CoderMetadataSet.java4
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/DuplicateCoderException.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/AnnotatedEndpointConfigTest.java5
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/ConfiguratorTest.java4
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/CookiesTest.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderFactoryTest.java9
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderManySmallTest.java6
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderTest.java13
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EncoderFactoryTest.java9
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EncoderTest.java9
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EndpointEchoClient.java5
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EndpointEchoTest.java5
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/JsrSessionTest.java11
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerFactoryTest.java9
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/ClientAnnotatedEndpointScanner_InvalidSignaturesTest.java5
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/TrackingSocket.java9
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidCloseIntSocket.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidErrorErrorSocket.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidErrorExceptionSocket.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidErrorIntSocket.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidOpenCloseReasonSocket.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidOpenIntSocket.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidOpenSessionIntSocket.java2
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/misbehaving/MisbehavingClassTest.java5
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/samples/DummyConnection.java156
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/samples/ExtDecoder.java1
-rw-r--r--jetty-websocket/javax-websocket-client-impl/src/test/resources/jetty-logging.properties3
-rw-r--r--jetty-websocket/javax-websocket-server-impl/pom.xml19
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/AnnotatedServerEndpointConfig.java19
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/AnnotatedServerEndpointMetadata.java7
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/BasicServerEndpointConfig.java18
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ContainerDefaultConfigurator.java (renamed from jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/BasicServerEndpointConfigurator.java)26
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/JsrCreator.java19
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/PathParamServerEndpointConfig.java5
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java75
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/WebSocketServerContainerInitializer.java22
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/pathmap/WebSocketPathSpec.java3
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/main/resources/META-INF/services/javax.websocket.server.ServerEndpointConfig$Configurator2
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/AnnotatedServerEndpointTest.java2
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/BasicEndpointTest.java2
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/BinaryStreamTest.java1
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ConfiguratorTest.java28
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/IdleTimeoutTest.java8
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/JettyServerEndpointConfiguratorTest.java2
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/JsrBatchModeTest.java1
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/MemoryUsageTest.java6
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/OnPartialTest.java19
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/PingPongTest.java3
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ServerAnnotatedEndpointScanner_GoodSignaturesTest.java6
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ServerAnnotatedEndpointScanner_InvalidSignaturesTest.java11
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/SessionTest.java2
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/StreamTest.java65
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/TextStreamTest.java1
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/TrackingSocket.java9
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/WSServer.java4
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/browser/JsrBrowserSocket.java5
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidCloseIntSocket.java1
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidErrorErrorSocket.java1
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidErrorExceptionSocket.java1
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidErrorIntSocket.java1
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidOpenCloseReasonSocket.java1
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidOpenIntSocket.java1
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidOpenSessionIntSocket.java2
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/BasicEchoEndpointConfigContextListener.java2
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/BasicEchoEndpointContextListener.java2
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/BasicEchoSocketConfigContextListener.java2
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/LargeEchoDefaultSocket.java1
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/idletimeout/IdleTimeoutContextListener.java2
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/pong/PongSocket.java1
-rw-r--r--jetty-websocket/pom.xml30
-rw-r--r--jetty-websocket/websocket-api/pom.xml2
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/BatchMode.java4
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/InvalidWebSocketException.java2
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/RemoteEndpoint.java44
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/Session.java9
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/UpgradeResponse.java4
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketConnectionListener.java61
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketFrameListener.java34
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketListener.java42
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketPartialListener.java58
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketPingPongListener.java43
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketClose.java2
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketConnect.java2
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketError.java3
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketFrame.java6
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketMessage.java3
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/Extension.java6
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/ExtensionConfig.java1
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/Frame.java3
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/OutgoingFrames.java4
-rw-r--r--jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/util/QuoteUtil.java18
-rw-r--r--jetty-websocket/websocket-api/src/test/java/org/eclipse/jetty/websocket/api/util/QuoteUtilTest.java4
-rw-r--r--jetty-websocket/websocket-client/pom.xml2
-rw-r--r--jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeRequest.java3
-rw-r--r--jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeResponse.java8
-rw-r--r--jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java116
-rw-r--r--jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/ConnectPromise.java15
-rw-r--r--jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/ConnectionManager.java73
-rw-r--r--jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java116
-rw-r--r--jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientConnection.java27
-rw-r--r--jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java2
-rw-r--r--jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/package-info.java9
-rw-r--r--jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/BadNetworkTest.java6
-rw-r--r--jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientCloseTest.java26
-rw-r--r--jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientConnectTest.java36
-rw-r--r--jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/CookieTest.java8
-rw-r--r--jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/JettyTrackingSocket.java6
-rw-r--r--jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerReadThread.java12
-rw-r--r--jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerWriteThread.java6
-rw-r--r--jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/SessionTest.java19
-rw-r--r--jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/SlowClientTest.java8
-rw-r--r--jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/SlowServerTest.java10
-rw-r--r--jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/TomcatServerQuirksTest.java9
-rw-r--r--jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/WebSocketClientTest.java31
-rw-r--r--jetty-websocket/websocket-common/pom.xml2
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/BlockingWriteCallback.java13
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/ConnectionState.java3
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/LogicalConnection.java19
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/OpCode.java3
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Parser.java10
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketFrame.java3
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java165
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSessionFactory.java25
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java18
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/EventDriverFactory.java4
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerEventDriver.java84
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerImpl.java5
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/AbstractMethodAnnotationScanner.java1
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/CallableMethod.java3
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/AbstractExtension.java9
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/FrameCaptureExtension.java (renamed from jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/FrameDebugExtension.java)95
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/WebSocketExtensionFactory.java16
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/CompressExtension.java39
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageDeflateExtension.java2
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/DataFrame.java3
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/ReadOnlyDelegatedFrame.java112
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java158
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/FrameFlusher.java2
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/FutureWriteCallback.java2
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/IOState.java20
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/http/HttpResponseHeaderParser.java4
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/payload/PayloadProcessor.java1
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageInputStream.java2
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageReader.java3
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageWriter.java2
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/package-info.java2
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/scopes/SimpleContainerScope.java108
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/scopes/WebSocketContainerScope.java67
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/scopes/WebSocketSessionScope.java39
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/util/TextUtil.java1
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/util/Utf8PartialBuilder.java63
-rw-r--r--jetty-websocket/websocket-common/src/test/java/examples/ListenerFrameSocket.java53
-rw-r--r--jetty-websocket/websocket-common/src/test/java/examples/ListenerPartialSocket.java60
-rw-r--r--jetty-websocket/websocket-common/src/test/java/examples/ListenerPingPongSocket.java60
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/CloseInfoTest.java12
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java2
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java4
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/WebSocketFrameTest.java2
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/WebSocketRemoteEndpointTest.java2
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java3
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java3
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java4
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadBinarySignatureSocket.java5
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadDuplicateBinarySocket.java4
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadDuplicateFrameSocket.java2
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadTextSignatureSocket.java2
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/FrameSocket.java1
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventCapture.java8
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventDriverTest.java25
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStackTest.java9
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/ExtensionTool.java9
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/FragmentExtensionTest.java7
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/IdentityExtensionTest.java5
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageDeflateExtensionTest.java130
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/LocalWebSocketConnection.java12
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/LocalWebSocketSession.java7
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageInputStreamTest.java3
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageOutputStreamTest.java7
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageWriterTest.java11
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/TrackingInputStreamSocket.java4
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/Utf8CharBufferTest.java2
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadClient.java83
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadServer.java609
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadServerConnection.java614
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/ByteBufferAssert.java5
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/DummyConnection.java (renamed from jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/DummyConnection.java)15
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/Fuzzer.java3
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IBlockheadClient.java79
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IBlockheadServerConnection.java68
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IncomingFramesCapture.java3
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/LeakTrackingBufferPoolRule.java6
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/OutgoingFramesCapture.java6
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/OutgoingNetworkBytesCapture.java6
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/RawFrameBuilder.java2
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/UnitGenerator.java2
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/UnitParser.java1
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/util/Sha1Sum.java110
-rw-r--r--jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/util/Utf8PartialBuilderTest.java86
-rw-r--r--jetty-websocket/websocket-server/pom.xml26
-rw-r--r--jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/HandshakeRFC6455.java1
-rw-r--r--jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketHandshake.java5
-rw-r--r--jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerConnection.java22
-rw-r--r--jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketServerFactory.java175
-rw-r--r--jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeFilter.java7
-rw-r--r--jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/pathmap/PathMappings.java2
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/AnnotatedMaxMessageSizeTest.java2
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ChromeTest.java3
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/DecoratorsLegacyTest.java181
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/DecoratorsTest.java179
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FirefoxTest.java3
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FragmentExtensionTest.java3
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/IdentityExtensionTest.java3
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/IdleTimeoutTest.java4
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ManyConnectionsCleanupTest.java369
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/PerMessageDeflateExtensionTest.java176
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/RequestHeadersTest.java4
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/SimpleServletServer.java8
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/TooFastClientTest.java84
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketCloseTest.java17
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketInvalidVersionTest.java4
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketOverSSLTest.java7
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketServerSessionTest.java9
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketServletRFCTest.java8
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/AbstractABCase.java3
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase1.java16
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase2.java11
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase3.java7
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase4.java10
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase5.java21
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6.java13
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7.java12
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7_BadStatusCodes.java2
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7_GoodStatusCodes.java2
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase9.java42
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/browser/BrowserDebugTool.java7
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/CaptureSocket.java16
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/helper/SafariD00.java8
-rw-r--r--jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/misbehaving/MisbehavingClassTest.java5
-rw-r--r--jetty-websocket/websocket-server/src/test/resources/jetty-logging.properties5
-rw-r--r--jetty-websocket/websocket-servlet/pom.xml20
-rw-r--r--jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/ServletUpgradeRequest.java10
-rw-r--r--jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/ServletUpgradeResponse.java1
-rw-r--r--jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketCreator.java2
-rw-r--r--jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketServlet.java8
-rw-r--r--jetty-websocket/websocket-servlet/src/main/java/org/eclipse/jetty/websocket/servlet/WebSocketServletFactory.java10
297 files changed, 4702 insertions, 1996 deletions
diff --git a/jetty-websocket/javax-websocket-client-impl/pom.xml b/jetty-websocket/javax-websocket-client-impl/pom.xml
index dc4763b848..ee1e1ced71 100644
--- a/jetty-websocket/javax-websocket-client-impl/pom.xml
+++ b/jetty-websocket/javax-websocket-client-impl/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-parent</artifactId>
- <version>9.2.15-SNAPSHOT</version>
+ <version>9.3.7-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/AbstractJsrRemote.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/AbstractJsrRemote.java
index aed0f25519..00a77bccb0 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/AbstractJsrRemote.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/AbstractJsrRemote.java
@@ -21,6 +21,7 @@ package org.eclipse.jetty.websocket.jsr356;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.concurrent.Future;
+
import javax.websocket.EncodeException;
import javax.websocket.Encoder;
import javax.websocket.RemoteEndpoint;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/ClientContainer.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/ClientContainer.java
index b6366c370e..d693d1d250 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/ClientContainer.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/ClientContainer.java
@@ -30,6 +30,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
+
import javax.websocket.ClientEndpoint;
import javax.websocket.ClientEndpointConfig;
import javax.websocket.DeploymentException;
@@ -39,18 +40,24 @@ import javax.websocket.Extension;
import javax.websocket.Session;
import javax.websocket.WebSocketContainer;
+import org.eclipse.jetty.io.ByteBufferPool;
+import org.eclipse.jetty.util.DecoratedObjectFactory;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.util.thread.ShutdownThread;
import org.eclipse.jetty.websocket.api.InvalidWebSocketException;
+import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.ExtensionFactory;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.client.io.UpgradeListener;
+import org.eclipse.jetty.websocket.common.SessionFactory;
import org.eclipse.jetty.websocket.common.SessionListener;
import org.eclipse.jetty.websocket.common.WebSocketSession;
+import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.jsr356.annotations.AnnotatedEndpointScanner;
import org.eclipse.jetty.websocket.jsr356.client.AnnotatedClientEndpointMetadata;
import org.eclipse.jetty.websocket.jsr356.client.EmptyClientEndpointConfig;
@@ -66,10 +73,12 @@ import org.eclipse.jetty.websocket.jsr356.metadata.EndpointMetadata;
* <p>
* This should be specific to a JVM if run in a standalone mode. or specific to a WebAppContext if running on the Jetty server.
*/
-public class ClientContainer extends ContainerLifeCycle implements WebSocketContainer, SessionListener
+public class ClientContainer extends ContainerLifeCycle implements WebSocketContainer, WebSocketContainerScope, SessionListener
{
private static final Logger LOG = Log.getLogger(ClientContainer.class);
+ /** The delegated Container Scope */
+ private final WebSocketContainerScope scopeDelegate;
/** Tracking all primitive decoders for the container */
private final DecoderFactory decoderFactory;
/** Tracking all primitive encoders for the container */
@@ -85,30 +94,28 @@ public class ClientContainer extends ContainerLifeCycle implements WebSocketCont
public ClientContainer()
{
// This constructor is used with Standalone JSR Client usage.
- this(null);
+ this(new SimpleContainerScope(WebSocketPolicy.newClientPolicy()));
client.setDaemon(true);
}
- public ClientContainer(Executor executor)
+ public ClientContainer(WebSocketContainerScope scope)
{
- endpointClientMetadataCache = new ConcurrentHashMap<>();
- decoderFactory = new DecoderFactory(PrimitiveDecoderMetadataSet.INSTANCE);
- encoderFactory = new EncoderFactory(PrimitiveEncoderMetadataSet.INSTANCE);
-
- EmptyClientEndpointConfig empty = new EmptyClientEndpointConfig();
- decoderFactory.init(empty);
- encoderFactory.init(empty);
-
boolean trustAll = Boolean.getBoolean("org.eclipse.jetty.websocket.jsr356.ssl-trust-all");
- client = new WebSocketClient(new SslContextFactory(trustAll), executor);
+ this.scopeDelegate = scope;
+ client = new WebSocketClient(scope, new SslContextFactory(trustAll));
client.setEventDriverFactory(new JsrEventDriverFactory(client.getPolicy()));
- client.setSessionFactory(new JsrSessionFactory(this,this,client));
+ SessionFactory sessionFactory = new JsrSessionFactory(this,this,client);
+ client.setSessionFactory(sessionFactory);
addBean(client);
+ this.endpointClientMetadataCache = new ConcurrentHashMap<>();
+ this.decoderFactory = new DecoderFactory(this,PrimitiveDecoderMetadataSet.INSTANCE);
+ this.encoderFactory = new EncoderFactory(this,PrimitiveEncoderMetadataSet.INSTANCE);
+
ShutdownThread.register(this);
}
-
+
private Session connect(EndpointInstance instance, URI path) throws IOException
{
Objects.requireNonNull(instance,"EndpointInstance cannot be null");
@@ -186,7 +193,18 @@ public class ClientContainer extends ContainerLifeCycle implements WebSocketCont
EndpointInstance instance = newClientEndpointInstance(endpoint,null);
return connect(instance,path);
}
-
+
+ @Override
+ protected void doStart() throws Exception
+ {
+ super.doStart();
+
+ // Initialize the default decoder / encoder factories
+ EmptyClientEndpointConfig empty = new EmptyClientEndpointConfig();
+ this.decoderFactory.init(empty);
+ this.encoderFactory.init(empty);
+ }
+
@Override
protected void doStop() throws Exception
{
@@ -195,6 +213,12 @@ public class ClientContainer extends ContainerLifeCycle implements WebSocketCont
super.doStop();
}
+ @Override
+ public ByteBufferPool getBufferPool()
+ {
+ return scopeDelegate.getBufferPool();
+ }
+
public WebSocketClient getClient()
{
return client;
@@ -279,6 +303,12 @@ public class ClientContainer extends ContainerLifeCycle implements WebSocketCont
}
@Override
+ public Executor getExecutor()
+ {
+ return scopeDelegate.getExecutor();
+ }
+
+ @Override
public Set<Extension> getInstalledExtensions()
{
Set<Extension> ret = new HashSet<>();
@@ -292,14 +322,33 @@ public class ClientContainer extends ContainerLifeCycle implements WebSocketCont
return ret;
}
+ @Override
+ public DecoratedObjectFactory getObjectFactory()
+ {
+ return scopeDelegate.getObjectFactory();
+ }
+
/**
* Used in {@link Session#getOpenSessions()}
+ * @return the set of open sessions
*/
public Set<Session> getOpenSessions()
{
return Collections.unmodifiableSet(this.openSessions);
}
+ @Override
+ public WebSocketPolicy getPolicy()
+ {
+ return scopeDelegate.getPolicy();
+ }
+
+ @Override
+ public SslContextFactory getSslContextFactory()
+ {
+ return scopeDelegate.getSslContextFactory();
+ }
+
private EndpointInstance newClientEndpointInstance(Class<?> endpointClass, ClientEndpointConfig config)
{
try
@@ -357,7 +406,7 @@ public class ClientContainer extends ContainerLifeCycle implements WebSocketCont
Session.class.getName());
}
}
-
+
@Override
public void setAsyncSendTimeout(long ms)
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/DecoderFactory.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/DecoderFactory.java
index 4554b14abc..71a3af770e 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/DecoderFactory.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/DecoderFactory.java
@@ -19,12 +19,16 @@
package org.eclipse.jetty.websocket.jsr356;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
+
import javax.websocket.Decoder;
import javax.websocket.EndpointConfig;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketSessionScope;
import org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata;
import org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadataSet;
@@ -71,18 +75,26 @@ public class DecoderFactory implements Configurable
private static final Logger LOG = Log.getLogger(DecoderFactory.class);
private final DecoderMetadataSet metadatas;
+ private final WebSocketContainerScope containerScope;
private DecoderFactory parentFactory;
private Map<Class<?>, Wrapper> activeWrappers;
- public DecoderFactory(DecoderMetadataSet metadatas)
+ public DecoderFactory(WebSocketContainerScope containerScope, DecoderMetadataSet metadatas)
{
- this.metadatas = metadatas;
- this.activeWrappers = new ConcurrentHashMap<>();
+ this(containerScope,metadatas,null);
+ }
+
+ public DecoderFactory(WebSocketSessionScope sessionScope, DecoderMetadataSet metadatas, DecoderFactory parentFactory)
+ {
+ this(sessionScope.getContainerScope(),metadatas,parentFactory);
}
- public DecoderFactory(DecoderMetadataSet metadatas, DecoderFactory parentFactory)
+ protected DecoderFactory(WebSocketContainerScope containerScope, DecoderMetadataSet metadatas, DecoderFactory parentFactory)
{
- this(metadatas);
+ Objects.requireNonNull(containerScope,"Container Scope cannot be null");
+ this.containerScope = containerScope;
+ this.metadatas = metadatas;
+ this.activeWrappers = new ConcurrentHashMap<>();
this.parentFactory = parentFactory;
}
@@ -102,6 +114,7 @@ public class DecoderFactory implements Configurable
{
LOG.debug("getMetadataFor({})",type);
}
+
DecoderMetadata metadata = metadatas.getMetadataByType(type);
if (metadata != null)
@@ -172,7 +185,7 @@ public class DecoderFactory implements Configurable
Class<? extends Decoder> decoderClass = metadata.getCoderClass();
try
{
- Decoder decoder = decoderClass.newInstance();
+ Decoder decoder = containerScope.getObjectFactory().createInstance(decoderClass);
return new Wrapper(decoder,metadata);
}
catch (InstantiationException | IllegalAccessException e)
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/EncoderFactory.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/EncoderFactory.java
index 29fedecb14..d5165d45a1 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/EncoderFactory.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/EncoderFactory.java
@@ -19,12 +19,16 @@
package org.eclipse.jetty.websocket.jsr356;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
+
import javax.websocket.Encoder;
import javax.websocket.EndpointConfig;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketSessionScope;
import org.eclipse.jetty.websocket.jsr356.metadata.EncoderMetadata;
import org.eclipse.jetty.websocket.jsr356.metadata.EncoderMetadataSet;
@@ -64,18 +68,26 @@ public class EncoderFactory implements Configurable
private static final Logger LOG = Log.getLogger(EncoderFactory.class);
private final EncoderMetadataSet metadatas;
+ private final WebSocketContainerScope containerScope;
private EncoderFactory parentFactory;
private Map<Class<?>, Wrapper> activeWrappers;
- public EncoderFactory(EncoderMetadataSet metadatas)
+ public EncoderFactory(WebSocketContainerScope containerScope, EncoderMetadataSet metadatas)
{
- this.metadatas = metadatas;
- this.activeWrappers = new ConcurrentHashMap<>();
+ this(containerScope,metadatas,null);
+ }
+
+ public EncoderFactory(WebSocketSessionScope sessionScope, EncoderMetadataSet metadatas, EncoderFactory parentFactory)
+ {
+ this(sessionScope.getContainerScope(),metadatas,parentFactory);
}
- public EncoderFactory(EncoderMetadataSet metadatas, EncoderFactory parentFactory)
+ protected EncoderFactory(WebSocketContainerScope containerScope, EncoderMetadataSet metadatas, EncoderFactory parentFactory)
{
- this(metadatas);
+ Objects.requireNonNull(containerScope,"Container Scope cannot be null");
+ this.containerScope = containerScope;
+ this.metadatas = metadatas;
+ this.activeWrappers = new ConcurrentHashMap<>();
this.parentFactory = parentFactory;
}
@@ -166,7 +178,7 @@ public class EncoderFactory implements Configurable
Class<? extends Encoder> encoderClass = metadata.getCoderClass();
try
{
- Encoder encoder = encoderClass.newInstance();
+ Encoder encoder = containerScope.getObjectFactory().createInstance(encoderClass);
return new Wrapper(encoder,metadata);
}
catch (InstantiationException | IllegalAccessException e)
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JettyClientContainerProvider.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JettyClientContainerProvider.java
index eb043bcc46..3fafe70a3c 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JettyClientContainerProvider.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JettyClientContainerProvider.java
@@ -22,16 +22,24 @@ import javax.websocket.ContainerProvider;
import javax.websocket.WebSocketContainer;
/**
- * Client {@link ContainerProvider} implementation
+ * Client {@link ContainerProvider} implementation.
+ * <p>
+ * Created by a {@link java.util.ServiceLoader} call in the
+ * {@link javax.websocket.ContainerProvider#getWebSocketContainer()} call.
*/
public class JettyClientContainerProvider extends ContainerProvider
{
+ /**
+ * Used by {@link ContainerProvider#getWebSocketContainer()} to get a new instance
+ * of the Client {@link WebSocketContainer}.
+ */
@Override
protected WebSocketContainer getContainer()
{
ClientContainer container = new ClientContainer();
try
{
+ // We need to start this container properly.
container.start();
return container;
}
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrExtension.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrExtension.java
index 49814ab808..f07d70fa5e 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrExtension.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrExtension.java
@@ -58,6 +58,7 @@ public class JsrExtension implements Extension
/**
* A configured extension
+ * @param cfg the configuration for the extension
*/
public JsrExtension(ExtensionConfig cfg)
{
@@ -73,6 +74,7 @@ public class JsrExtension implements Extension
/**
* A potential (unconfigured) extension
+ * @param name the name of the extension
*/
public JsrExtension(String name)
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrSession.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrSession.java
index a1988cff40..c1fa532a8f 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrSession.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrSession.java
@@ -29,6 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
+
import javax.websocket.CloseReason;
import javax.websocket.EndpointConfig;
import javax.websocket.Extension;
@@ -73,9 +74,9 @@ public class JsrSession extends WebSocketSession implements javax.websocket.Sess
private JsrAsyncRemote asyncRemote;
private JsrBasicRemote basicRemote;
- public JsrSession(URI requestURI, EventDriver websocket, LogicalConnection connection, ClientContainer container, String id, SessionListener... sessionListeners)
+ public JsrSession(ClientContainer container, String id, URI requestURI, EventDriver websocket, LogicalConnection connection, SessionListener... sessionListeners)
{
- super(requestURI, websocket, connection, sessionListeners);
+ super(container, requestURI, websocket, connection, sessionListeners);
if (!(websocket instanceof AbstractJsrEventDriver))
{
throw new IllegalArgumentException("Cannot use, not a JSR WebSocket: " + websocket);
@@ -85,8 +86,8 @@ public class JsrSession extends WebSocketSession implements javax.websocket.Sess
this.metadata = jsr.getMetadata();
this.container = container;
this.id = id;
- this.decoderFactory = new DecoderFactory(metadata.getDecoders(),container.getDecoderFactory());
- this.encoderFactory = new EncoderFactory(metadata.getEncoders(),container.getEncoderFactory());
+ this.decoderFactory = new DecoderFactory(this,metadata.getDecoders(),container.getDecoderFactory());
+ this.encoderFactory = new EncoderFactory(this,metadata.getEncoders(),container.getEncoderFactory());
this.messageHandlerFactory = new MessageHandlerFactory();
this.wrappers = new MessageHandlerWrapper[MessageType.values().length];
this.messageHandlerSet = new HashSet<>();
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrSessionFactory.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrSessionFactory.java
index 3893a4c7e1..26e0c8683f 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrSessionFactory.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrSessionFactory.java
@@ -43,7 +43,7 @@ public class JsrSessionFactory implements SessionFactory
@Override
public WebSocketSession createSession(URI requestURI, EventDriver websocket, LogicalConnection connection)
{
- return new JsrSession(requestURI,websocket,connection,container,getNextId(),listeners);
+ return new JsrSession(container,getNextId(),requestURI,websocket,connection,listeners);
}
public String getNextId()
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrUpgradeListener.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrUpgradeListener.java
index e711a3a687..d57d71abc5 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrUpgradeListener.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrUpgradeListener.java
@@ -21,6 +21,7 @@ package org.eclipse.jetty.websocket.jsr356;
import java.net.HttpCookie;
import java.util.List;
import java.util.Map;
+
import javax.websocket.ClientEndpointConfig.Configurator;
import org.eclipse.jetty.websocket.api.UpgradeRequest;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerFactory.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerFactory.java
index f715c1bf1d..4db4ec1fa0 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerFactory.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerFactory.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+
import javax.websocket.MessageHandler;
import org.eclipse.jetty.util.log.Log;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerWrapper.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerWrapper.java
index d0e0ff5ca8..aef7ea276f 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerWrapper.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerWrapper.java
@@ -19,6 +19,8 @@
package org.eclipse.jetty.websocket.jsr356;
import javax.websocket.MessageHandler;
+import javax.websocket.MessageHandler.Partial;
+import javax.websocket.MessageHandler.Whole;
import org.eclipse.jetty.websocket.jsr356.metadata.MessageHandlerMetadata;
@@ -71,7 +73,7 @@ public class MessageHandlerWrapper
}
/**
- * Flag for a onMessage() method that wants MessageHandler.{@link Whole} with a Decoder that is based on {@link TextStream} or {@link BinaryStream}
+ * Flag for a onMessage() method that wants MessageHandler.{@link Whole} with a Decoder that is based on {@link javax.websocket.Decoder.TextStream} or {@link javax.websocket.Decoder.BinaryStream}
*
* @return true for Streaming based Decoder, false for normal decoder for whole messages.
*/
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/AnnotatedEndpointMetadata.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/AnnotatedEndpointMetadata.java
index 253f88caac..f3304ecf3f 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/AnnotatedEndpointMetadata.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/AnnotatedEndpointMetadata.java
@@ -22,6 +22,10 @@ import java.lang.annotation.Annotation;
import java.util.LinkedList;
import javax.websocket.EndpointConfig;
+import javax.websocket.OnClose;
+import javax.websocket.OnError;
+import javax.websocket.OnMessage;
+import javax.websocket.OnOpen;
import org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata;
import org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadataSet;
@@ -33,6 +37,8 @@ import org.eclipse.jetty.websocket.jsr356.metadata.EndpointMetadata;
*
* @param <T>
* the annotation this metadata is based off of
+ * @param <C>
+ * the endpoint configuration this is based off of
*/
public abstract class AnnotatedEndpointMetadata<T extends Annotation, C extends EndpointConfig> implements EndpointMetadata
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/AnnotatedEndpointScanner.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/AnnotatedEndpointScanner.java
index f710ed20c1..63e189b502 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/AnnotatedEndpointScanner.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/AnnotatedEndpointScanner.java
@@ -22,6 +22,7 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.List;
+
import javax.websocket.EndpointConfig;
import javax.websocket.OnClose;
import javax.websocket.OnError;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/IJsrMethod.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/IJsrMethod.java
index 2e031137d9..4172535652 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/IJsrMethod.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/IJsrMethod.java
@@ -21,6 +21,7 @@ package org.eclipse.jetty.websocket.jsr356.annotations;
import java.lang.reflect.Method;
import javax.websocket.Decoder;
+import javax.websocket.OnMessage;
import org.eclipse.jetty.websocket.jsr356.MessageType;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrCallable.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrCallable.java
index c22af6d671..e78620e8f8 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrCallable.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrCallable.java
@@ -57,6 +57,7 @@ public abstract class JsrCallable extends CallableMethod
/**
* Copy Constructor
+ * @param copy the JsrCallable to copy from
*/
public JsrCallable(JsrCallable copy)
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrEvents.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrEvents.java
index 745daabe0f..76670a8524 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrEvents.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrEvents.java
@@ -24,9 +24,14 @@ import java.io.Reader;
import java.lang.annotation.Annotation;
import java.nio.ByteBuffer;
import java.util.Map;
+
import javax.websocket.CloseReason;
import javax.websocket.DecodeException;
import javax.websocket.EndpointConfig;
+import javax.websocket.OnClose;
+import javax.websocket.OnError;
+import javax.websocket.OnMessage;
+import javax.websocket.OnOpen;
import javax.websocket.RemoteEndpoint;
import org.eclipse.jetty.util.log.Log;
@@ -35,6 +40,8 @@ import org.eclipse.jetty.websocket.jsr356.JsrSession;
/**
* The live event methods found for a specific Annotated Endpoint
+ * @param <T> the annotation type
+ * @param <C> the endpoint config type
*/
public class JsrEvents<T extends Annotation, C extends EndpointConfig>
{
@@ -148,6 +155,7 @@ public class JsrEvents<T extends Annotation, C extends EndpointConfig>
{
if (onError == null)
{
+ LOG.warn("Unable to report throwable to websocket (no @OnError handler declared): " + websocket.getClass().getName(), cause);
return;
}
onError.call(websocket,cause);
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdBinary.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdBinary.java
index 42c759716a..e157583e9a 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdBinary.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdBinary.java
@@ -21,6 +21,8 @@ package org.eclipse.jetty.websocket.jsr356.annotations;
import java.io.InputStream;
import java.nio.ByteBuffer;
+import javax.websocket.OnMessage;
+
import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException;
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
import org.eclipse.jetty.websocket.jsr356.decoders.ByteArrayDecoder;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdDecoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdDecoder.java
index 81d237f476..a56343b55e 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdDecoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdDecoder.java
@@ -18,12 +18,14 @@
package org.eclipse.jetty.websocket.jsr356.annotations;
+import javax.websocket.OnMessage;
+
import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException;
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
import org.eclipse.jetty.websocket.jsr356.metadata.DecoderMetadata;
/**
- * Param handling for Text or Binary &#064;{@link OnMessage} parameters declared as {@link Decoder}s
+ * Param handling for Text or Binary &#064;{@link OnMessage} parameters declared as {@link javax.websocket.Decoder}s
*/
public class JsrParamIdDecoder extends JsrParamIdOnMessage implements IJsrParamId
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdOnClose.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdOnClose.java
index e52e8d1dda..0b6b4b668d 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdOnClose.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdOnClose.java
@@ -19,6 +19,7 @@
package org.eclipse.jetty.websocket.jsr356.annotations;
import javax.websocket.CloseReason;
+import javax.websocket.OnClose;
import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException;
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdOnError.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdOnError.java
index db9d200bbb..6db14dfdae 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdOnError.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdOnError.java
@@ -18,6 +18,8 @@
package org.eclipse.jetty.websocket.jsr356.annotations;
+import javax.websocket.OnError;
+
import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException;
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdOnOpen.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdOnOpen.java
index d0b096f6c3..d7391ab109 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdOnOpen.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdOnOpen.java
@@ -19,6 +19,7 @@
package org.eclipse.jetty.websocket.jsr356.annotations;
import javax.websocket.EndpointConfig;
+import javax.websocket.OnOpen;
import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException;
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdText.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdText.java
index 9973cc8e1f..acf1bd7bdd 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdText.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/JsrParamIdText.java
@@ -20,6 +20,8 @@ package org.eclipse.jetty.websocket.jsr356.annotations;
import java.io.Reader;
+import javax.websocket.OnMessage;
+
import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException;
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
import org.eclipse.jetty.websocket.jsr356.decoders.BooleanDecoder;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnCloseCallable.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnCloseCallable.java
index 9f989fd112..501580fba3 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnCloseCallable.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnCloseCallable.java
@@ -23,6 +23,7 @@ import java.lang.reflect.Method;
import javax.websocket.CloseReason;
import javax.websocket.CloseReason.CloseCodes;
import javax.websocket.Decoder;
+import javax.websocket.OnClose;
import org.eclipse.jetty.websocket.common.CloseInfo;
import org.eclipse.jetty.websocket.jsr356.JsrSession;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnErrorCallable.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnErrorCallable.java
index 9b9a109c7a..18a6130120 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnErrorCallable.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnErrorCallable.java
@@ -21,6 +21,7 @@ package org.eclipse.jetty.websocket.jsr356.annotations;
import java.lang.reflect.Method;
import javax.websocket.Decoder;
+import javax.websocket.OnError;
import org.eclipse.jetty.websocket.jsr356.JsrSession;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageBinaryCallable.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageBinaryCallable.java
index d6dba84940..d7a281c4c0 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageBinaryCallable.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageBinaryCallable.java
@@ -23,6 +23,7 @@ import java.nio.ByteBuffer;
import javax.websocket.DecodeException;
import javax.websocket.Decoder;
+import javax.websocket.OnMessage;
import org.eclipse.jetty.websocket.jsr356.JsrSession;
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
@@ -30,9 +31,9 @@ import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
/**
* Callable for {@link OnMessage} annotated methods with a whole or partial binary messages.
* <p>
- * Not for use with {@link InputStream} based {@link OnMessage} method objects.
+ * Not for use with {@link java.io.InputStream} based {@link OnMessage} method objects.
*
- * @see Binary
+ * @see javax.websocket.Decoder.Binary
*/
public class OnMessageBinaryCallable extends OnMessageCallable
{
@@ -45,6 +46,7 @@ public class OnMessageBinaryCallable extends OnMessageCallable
/**
* Copy Constructor
+ * @param copy the callable to copy
*/
public OnMessageBinaryCallable(OnMessageCallable copy)
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageBinaryStreamCallable.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageBinaryStreamCallable.java
index 428c179ecd..41f8c1be51 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageBinaryStreamCallable.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageBinaryStreamCallable.java
@@ -25,6 +25,7 @@ import java.lang.reflect.Method;
import javax.websocket.DecodeException;
import javax.websocket.Decoder;
+import javax.websocket.OnMessage;
import org.eclipse.jetty.websocket.jsr356.JsrSession;
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
@@ -32,7 +33,7 @@ import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
/**
* Callable for {@link OnMessage} annotated methods for {@link InputStream} based binary message objects
*
- * @see BinaryStream
+ * @see javax.websocket.Decoder.BinaryStream
*/
public class OnMessageBinaryStreamCallable extends OnMessageCallable
{
@@ -45,6 +46,7 @@ public class OnMessageBinaryStreamCallable extends OnMessageCallable
/**
* Copy Constructor
+ * @param copy the callable to copy from
*/
public OnMessageBinaryStreamCallable(OnMessageCallable copy)
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessagePongCallable.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessagePongCallable.java
index 8da5597855..4b9cb63a0f 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessagePongCallable.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessagePongCallable.java
@@ -21,6 +21,9 @@ package org.eclipse.jetty.websocket.jsr356.annotations;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
+import javax.websocket.OnMessage;
+import javax.websocket.PongMessage;
+
import org.eclipse.jetty.websocket.jsr356.JsrPongMessage;
import org.eclipse.jetty.websocket.jsr356.JsrSession;
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
@@ -37,6 +40,7 @@ public class OnMessagePongCallable extends OnMessageCallable
/**
* Copy Constructor
+ * @param copy the callable to copy from
*/
public OnMessagePongCallable(OnMessageCallable copy)
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageTextCallable.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageTextCallable.java
index a9bfb9270c..4944f825d7 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageTextCallable.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageTextCallable.java
@@ -18,10 +18,12 @@
package org.eclipse.jetty.websocket.jsr356.annotations;
+import java.io.Reader;
import java.lang.reflect.Method;
import javax.websocket.DecodeException;
import javax.websocket.Decoder;
+import javax.websocket.OnMessage;
import org.eclipse.jetty.websocket.jsr356.JsrSession;
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
@@ -31,7 +33,7 @@ import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
* <p>
* Not for use with {@link Reader} based {@link OnMessage} method objects.
*
- * @see Text
+ * @see javax.websocket.Decoder.Text
*/
public class OnMessageTextCallable extends OnMessageCallable
{
@@ -44,6 +46,7 @@ public class OnMessageTextCallable extends OnMessageCallable
/**
* Copy Constructor
+ * @param copy the callable to copy from
*/
public OnMessageTextCallable(OnMessageCallable copy)
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageTextStreamCallable.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageTextStreamCallable.java
index 67312d7f10..fb9ef17dfe 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageTextStreamCallable.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnMessageTextStreamCallable.java
@@ -24,6 +24,7 @@ import java.lang.reflect.Method;
import javax.websocket.DecodeException;
import javax.websocket.Decoder;
+import javax.websocket.OnMessage;
import org.eclipse.jetty.websocket.jsr356.JsrSession;
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
@@ -31,7 +32,7 @@ import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
/**
* Callable for {@link OnMessage} annotated methods for {@link Reader} based text message objects
*
- * @see TextStream
+ * @see javax.websocket.Decoder.TextStream
*/
public class OnMessageTextStreamCallable extends OnMessageCallable
{
@@ -44,6 +45,7 @@ public class OnMessageTextStreamCallable extends OnMessageCallable
/**
* Copy Constructor
+ * @param copy the callable to copy from
*/
public OnMessageTextStreamCallable(OnMessageCallable copy)
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnOpenCallable.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnOpenCallable.java
index 9c9414a964..617ea3361a 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnOpenCallable.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/annotations/OnOpenCallable.java
@@ -22,6 +22,7 @@ import java.lang.reflect.Method;
import javax.websocket.Decoder;
import javax.websocket.EndpointConfig;
+import javax.websocket.OnOpen;
import org.eclipse.jetty.websocket.jsr356.JsrSession;
import org.eclipse.jetty.websocket.jsr356.annotations.Param.Role;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/BooleanDecoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/BooleanDecoder.java
index c18c5666c7..4ee6f3f2a9 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/BooleanDecoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/BooleanDecoder.java
@@ -23,7 +23,7 @@ import javax.websocket.Decoder;
/**
- * Default implementation of the {@link Text} Message to {@link Boolean} decoder.
+ * Default implementation of the {@link javax.websocket.Decoder.Text} Message to {@link Boolean} decoder.
* <p>
* Note: delegates to {@link Boolean#parseBoolean(String)} and will only support "true" and "false" as boolean values.
*/
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/ByteDecoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/ByteDecoder.java
index 5bdd8d6905..74f931c589 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/ByteDecoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/ByteDecoder.java
@@ -23,7 +23,7 @@ import javax.websocket.Decoder;
/**
- * Default implementation of the {@link Text} Message to {@link Byte} decoder
+ * Default implementation of the {@link javax.websocket.Decoder.Text} Message to {@link Byte} decoder
*/
public class ByteDecoder extends AbstractDecoder implements Decoder.Text<Byte>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/CharacterDecoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/CharacterDecoder.java
index b092fcb520..53b3a93445 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/CharacterDecoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/CharacterDecoder.java
@@ -23,7 +23,7 @@ import javax.websocket.Decoder;
/**
- * Default implementation of the {@link Text} Message to {@link Character} decoder
+ * Default implementation of the {@link javax.websocket.Decoder.Text} Message to {@link Character} decoder
*/
public class CharacterDecoder extends AbstractDecoder implements Decoder.Text<Character>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/DoubleDecoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/DoubleDecoder.java
index 1bb9c6fcd5..ee2662f44e 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/DoubleDecoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/DoubleDecoder.java
@@ -23,7 +23,7 @@ import javax.websocket.Decoder;
/**
- * Default implementation of the {@link Text} Message to {@link Double} to decoder
+ * Default implementation of the {@link javax.websocket.Decoder.Text} Message to {@link Double} to decoder
*/
public class DoubleDecoder extends AbstractDecoder implements Decoder.Text<Double>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/IntegerDecoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/IntegerDecoder.java
index 0cee891225..6cc4026a1f 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/IntegerDecoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/IntegerDecoder.java
@@ -23,7 +23,7 @@ import javax.websocket.Decoder;
/**
- * Default implementation of the {@link Text} Message to {@link Integer} decoder
+ * Default implementation of the {@link javax.websocket.Decoder.Text} Message to {@link Integer} decoder
*/
public class IntegerDecoder extends AbstractDecoder implements Decoder.Text<Integer>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/ShortDecoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/ShortDecoder.java
index 95133a372d..66e4e45a78 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/ShortDecoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/ShortDecoder.java
@@ -23,7 +23,7 @@ import javax.websocket.Decoder;
/**
- * Default implementation of the {@link Text} Message to {@link Short} decoder
+ * Default implementation of the {@link javax.websocket.Decoder.Text} Message to {@link Short} decoder
*/
public class ShortDecoder extends AbstractDecoder implements Decoder.Text<Short>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/StringDecoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/StringDecoder.java
index 94bf773a22..e99780c54d 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/StringDecoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/decoders/StringDecoder.java
@@ -23,7 +23,7 @@ import javax.websocket.Decoder;
/**
- * Default implementation of the {@link Text} Message to {@link String} decoder
+ * Default implementation of the {@link javax.websocket.Decoder.Text} Message to {@link String} decoder
*/
public class StringDecoder extends AbstractDecoder implements Decoder.Text<String>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/BooleanEncoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/BooleanEncoder.java
index c4f22d292c..9b9f68bfd6 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/BooleanEncoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/BooleanEncoder.java
@@ -22,7 +22,7 @@ import javax.websocket.EncodeException;
import javax.websocket.Encoder;
/**
- * Default encoder for {@link Boolean} to {@link Text} Message encoder
+ * Default encoder for {@link Boolean} to {@link javax.websocket.Encoder.Text} Message encoder
*/
public class BooleanEncoder extends AbstractEncoder implements Encoder.Text<Boolean>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/ByteEncoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/ByteEncoder.java
index 3963d05b03..4fa090aab5 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/ByteEncoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/ByteEncoder.java
@@ -22,7 +22,7 @@ import javax.websocket.EncodeException;
import javax.websocket.Encoder;
/**
- * Default encoder for {@link Byte} to {@link Text} Message encoder
+ * Default encoder for {@link Byte} to {@link javax.websocket.Encoder.Text} Message encoder
*/
public class ByteEncoder extends AbstractEncoder implements Encoder.Text<Byte>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/CharacterEncoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/CharacterEncoder.java
index 87d1fa34ec..ba828fa7af 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/CharacterEncoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/CharacterEncoder.java
@@ -22,7 +22,7 @@ import javax.websocket.EncodeException;
import javax.websocket.Encoder;
/**
- * Default encoder for {@link Character} to {@link Text} Message encoder
+ * Default encoder for {@link Character} to {@link javax.websocket.Encoder.Text} Message encoder
*/
public class CharacterEncoder extends AbstractEncoder implements Encoder.Text<Character>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/DoubleEncoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/DoubleEncoder.java
index bc97d2232b..0831b8b8ee 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/DoubleEncoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/DoubleEncoder.java
@@ -22,7 +22,7 @@ import javax.websocket.EncodeException;
import javax.websocket.Encoder;
/**
- * Default encoder for {@link Double} to {@link Text} Message encoder
+ * Default encoder for {@link Double} to {@link javax.websocket.Encoder.Text} Message encoder
*/
public class DoubleEncoder extends AbstractEncoder implements Encoder.Text<Double>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/FloatEncoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/FloatEncoder.java
index a9df32abed..b5dda8dbd8 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/FloatEncoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/FloatEncoder.java
@@ -21,7 +21,7 @@ package org.eclipse.jetty.websocket.jsr356.encoders;
import javax.websocket.EncodeException;
import javax.websocket.Encoder;
/**
- * Default encoder for {@link Float} to {@link Text} Message encoder
+ * Default encoder for {@link Float} to {@link javax.websocket.Encoder.Text} Message encoder
*/
public class FloatEncoder extends AbstractEncoder implements Encoder.Text<Float>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/IntegerEncoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/IntegerEncoder.java
index 124c8401b1..067227c387 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/IntegerEncoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/IntegerEncoder.java
@@ -22,7 +22,7 @@ import javax.websocket.EncodeException;
import javax.websocket.Encoder;
/**
- * Default encoder for {@link Integer} to {@link Text} Message encoder
+ * Default encoder for {@link Integer} to {@link javax.websocket.Encoder.Text} Message encoder
*/
public class IntegerEncoder extends AbstractEncoder implements Encoder.Text<Integer>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/LongEncoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/LongEncoder.java
index f41a5700a4..1b387742d5 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/LongEncoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/LongEncoder.java
@@ -22,7 +22,7 @@ import javax.websocket.EncodeException;
import javax.websocket.Encoder;
/**
- * Default encoder for {@link Long} to {@link Text} Message encoder
+ * Default encoder for {@link Long} to {@link javax.websocket.Encoder.Text} Message encoder
*/
public class LongEncoder extends AbstractEncoder implements Encoder.Text<Long>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/ShortEncoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/ShortEncoder.java
index c2b55af59a..e82eb6dc3a 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/ShortEncoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/ShortEncoder.java
@@ -22,7 +22,7 @@ import javax.websocket.EncodeException;
import javax.websocket.Encoder;
/**
- * Default encoder for {@link Short} to {@link Text} Message encoder
+ * Default encoder for {@link Short} to {@link javax.websocket.Encoder.Text} Message encoder
*/
public class ShortEncoder extends AbstractEncoder implements Encoder.Text<Short>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/StringEncoder.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/StringEncoder.java
index 701d53b6f6..66f7071258 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/StringEncoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/encoders/StringEncoder.java
@@ -22,7 +22,7 @@ import javax.websocket.EncodeException;
import javax.websocket.Encoder;
/**
- * Default encoder for {@link String} to {@link Text} Message encoder
+ * Default encoder for {@link String} to {@link javax.websocket.Encoder.Text} Message encoder
*/
public class StringEncoder extends AbstractEncoder implements Encoder.Text<String>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/endpoints/JsrAnnotatedEventDriver.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/endpoints/JsrAnnotatedEventDriver.java
index 8ec9efb3dc..3d4dde1238 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/endpoints/JsrAnnotatedEventDriver.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/endpoints/JsrAnnotatedEventDriver.java
@@ -26,6 +26,7 @@ import java.util.Map;
import javax.websocket.CloseReason;
import javax.websocket.DecodeException;
+import javax.websocket.MessageHandler.Whole;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.log.Log;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/messages/BinaryPartialOnMessage.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/messages/BinaryPartialOnMessage.java
index d73824263c..68332adbce 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/messages/BinaryPartialOnMessage.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/messages/BinaryPartialOnMessage.java
@@ -21,6 +21,8 @@ package org.eclipse.jetty.websocket.jsr356.messages;
import java.io.IOException;
import java.nio.ByteBuffer;
+import javax.websocket.OnMessage;
+
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.common.message.MessageAppender;
import org.eclipse.jetty.websocket.jsr356.endpoints.JsrAnnotatedEventDriver;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/messages/TextPartialMessage.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/messages/TextPartialMessage.java
index 21d06b5d2e..97689198ab 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/messages/TextPartialMessage.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/messages/TextPartialMessage.java
@@ -24,8 +24,8 @@ import java.nio.ByteBuffer;
import javax.websocket.MessageHandler;
import javax.websocket.MessageHandler.Partial;
-import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.common.message.MessageAppender;
+import org.eclipse.jetty.websocket.common.util.Utf8PartialBuilder;
import org.eclipse.jetty.websocket.jsr356.MessageHandlerWrapper;
/**
@@ -36,19 +36,22 @@ public class TextPartialMessage implements MessageAppender
@SuppressWarnings("unused")
private final MessageHandlerWrapper msgWrapper;
private final MessageHandler.Partial<String> partialHandler;
+ private final Utf8PartialBuilder utf8Partial;
@SuppressWarnings("unchecked")
public TextPartialMessage(MessageHandlerWrapper wrapper)
{
this.msgWrapper = wrapper;
this.partialHandler = (Partial<String>)wrapper.getHandler();
+ this.utf8Partial = new Utf8PartialBuilder();
}
@Override
public void appendFrame(ByteBuffer payload, boolean isLast) throws IOException
{
+ String partialText = utf8Partial.toPartialString(payload);
// No decoders for Partial messages per JSR-356 (PFD1 spec)
- partialHandler.onMessage(BufferUtil.toUTF8String(payload.slice()),isLast);
+ partialHandler.onMessage(partialText,isLast);
}
@Override
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/messages/TextPartialOnMessage.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/messages/TextPartialOnMessage.java
index 69d830e9d7..24fd0bbdeb 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/messages/TextPartialOnMessage.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/messages/TextPartialOnMessage.java
@@ -21,8 +21,10 @@ package org.eclipse.jetty.websocket.jsr356.messages;
import java.io.IOException;
import java.nio.ByteBuffer;
-import org.eclipse.jetty.util.BufferUtil;
+import javax.websocket.OnMessage;
+
import org.eclipse.jetty.websocket.common.message.MessageAppender;
+import org.eclipse.jetty.websocket.common.util.Utf8PartialBuilder;
import org.eclipse.jetty.websocket.jsr356.endpoints.JsrAnnotatedEventDriver;
/**
@@ -31,12 +33,14 @@ import org.eclipse.jetty.websocket.jsr356.endpoints.JsrAnnotatedEventDriver;
public class TextPartialOnMessage implements MessageAppender
{
private final JsrAnnotatedEventDriver driver;
+ private final Utf8PartialBuilder utf8Partial;
private boolean finished;
public TextPartialOnMessage(JsrAnnotatedEventDriver driver)
{
this.driver = driver;
this.finished = false;
+ this.utf8Partial = new Utf8PartialBuilder();
}
@Override
@@ -46,15 +50,9 @@ public class TextPartialOnMessage implements MessageAppender
{
throw new IOException("Cannot append to finished buffer");
}
- if (payload == null)
- {
- driver.onPartialTextMessage("",isLast);
- }
- else
- {
- String text = BufferUtil.toUTF8String(payload);
- driver.onPartialTextMessage(text,isLast);
- }
+
+ String text = utf8Partial.toPartialString(payload);
+ driver.onPartialTextMessage(text,isLast);
}
@Override
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/CoderMetadata.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/CoderMetadata.java
index 6333315766..38ac535f43 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/CoderMetadata.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/CoderMetadata.java
@@ -21,10 +21,10 @@ package org.eclipse.jetty.websocket.jsr356.metadata;
import org.eclipse.jetty.websocket.jsr356.MessageType;
/**
- * The immutable base metadata for a coder ({@link Decoder} or {@link Encoder}
+ * The immutable base metadata for a coder ({@link javax.websocket.Decoder} or {@link javax.websocket.Encoder}
*
* @param <T>
- * the specific type of coder ({@link Decoder} or {@link Encoder}
+ * the specific type of coder ({@link javax.websocket.Decoder} or {@link javax.websocket.Encoder}
*/
public abstract class CoderMetadata<T>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/CoderMetadataSet.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/CoderMetadataSet.java
index 38a962dd54..ded82019de 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/CoderMetadataSet.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/CoderMetadataSet.java
@@ -24,13 +24,15 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
+import org.eclipse.jetty.websocket.api.InvalidWebSocketException;
+
/**
* An durable collection of {@link CoderMetadata}.
* <p>
* This is a write-only collection, and cannot be modified once initialized.
*
* @param <T>
- * The type of coder ({@link Decoder} or {@link Encoder}
+ * The type of coder ({@link javax.websocket.Decoder} or {@link javax.websocket.Encoder}
* @param <M>
* The metadata for the coder
*/
diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/DuplicateCoderException.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/DuplicateCoderException.java
index 331cc31af6..c7cbe137d3 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/DuplicateCoderException.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/metadata/DuplicateCoderException.java
@@ -21,7 +21,7 @@ package org.eclipse.jetty.websocket.jsr356.metadata;
import org.eclipse.jetty.websocket.api.InvalidWebSocketException;
/**
- * Thrown when a duplicate coder is encountered when attempting to identify a Endpoint's metadata ( {@link Decoder} or {@link Encoder})
+ * Thrown when a duplicate coder is encountered when attempting to identify a Endpoint's metadata ({@link javax.websocket.Decoder} or {@link javax.websocket.Encoder})
*/
public class DuplicateCoderException extends InvalidWebSocketException
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/AnnotatedEndpointConfigTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/AnnotatedEndpointConfigTest.java
index bd3fd2cf4f..cbfe8d41d3 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/AnnotatedEndpointConfigTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/AnnotatedEndpointConfigTest.java
@@ -18,7 +18,10 @@
package org.eclipse.jetty.websocket.jsr356;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
import java.net.URI;
import java.util.List;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/ConfiguratorTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/ConfiguratorTest.java
index bbea2d8f6a..29805808fb 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/ConfiguratorTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/ConfiguratorTest.java
@@ -18,7 +18,7 @@
package org.eclipse.jetty.websocket.jsr356;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.notNullValue;
import java.net.URI;
import java.util.List;
@@ -40,7 +40,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
/**
- * Tests of {@link Configurator}
+ * Tests of {@link javax.websocket.ClientEndpointConfig.Configurator}
*/
public class ConfiguratorTest
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/CookiesTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/CookiesTest.java
index 3597cca16b..cf835f1cc8 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/CookiesTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/CookiesTest.java
@@ -23,6 +23,7 @@ import java.net.URI;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+
import javax.websocket.ClientEndpointConfig;
import javax.websocket.ContainerProvider;
import javax.websocket.Endpoint;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderFactoryTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderFactoryTest.java
index 07bc9abb40..ccdafb4e13 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderFactoryTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderFactoryTest.java
@@ -25,6 +25,9 @@ import java.util.Date;
import javax.websocket.Decoder;
+import org.eclipse.jetty.websocket.api.WebSocketPolicy;
+import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.jsr356.decoders.ByteArrayDecoder;
import org.eclipse.jetty.websocket.jsr356.decoders.ByteBufferDecoder;
import org.eclipse.jetty.websocket.jsr356.decoders.DateDecoder;
@@ -56,9 +59,11 @@ public class DecoderFactoryTest
@Before
public void initDecoderFactory()
{
- DecoderFactory primitivesFactory = new DecoderFactory(PrimitiveDecoderMetadataSet.INSTANCE);
+ WebSocketContainerScope containerScope = new SimpleContainerScope(WebSocketPolicy.newClientPolicy());
+
+ DecoderFactory primitivesFactory = new DecoderFactory(containerScope,PrimitiveDecoderMetadataSet.INSTANCE);
metadatas = new DecoderMetadataSet();
- factory = new DecoderFactory(metadatas,primitivesFactory);
+ factory = new DecoderFactory(containerScope,metadatas,primitivesFactory);
}
@Test
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderManySmallTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderManySmallTest.java
index ec1d09cb2b..f4bd99f783 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderManySmallTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderManySmallTest.java
@@ -42,13 +42,15 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
-import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
+import org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
+@Ignore("Not working atm")
public class DecoderReaderManySmallTest
{
public static class EventId
@@ -111,7 +113,7 @@ public class DecoderReaderManySmallTest
private static class EventIdServer implements Runnable
{
private BlockheadServer server;
- private ServerConnection sconnection;
+ private IBlockheadServerConnection sconnection;
private CountDownLatch connectLatch = new CountDownLatch(1);
public EventIdServer(BlockheadServer server)
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderTest.java
index c031b99f19..abb3e896ff 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/DecoderReaderTest.java
@@ -50,7 +50,7 @@ import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.ContinuationFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
-import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
+import org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -135,13 +135,14 @@ public class DecoderReaderTest
}
@OnMessage
- public void onMessage(Quotes msg)
+ public synchronized void onMessage(Quotes msg)
{
+ Integer h=hashCode();
messageQueue.add(msg);
- System.out.printf("Quotes from: %s%n",msg.author);
+ System.out.printf("%x: Quotes from: %s%n",h,msg.author);
for (String quote : msg.quotes)
{
- System.out.printf(" - %s%n",quote);
+ System.out.printf("%x: - %s%n",h,quote);
}
}
@@ -154,7 +155,7 @@ public class DecoderReaderTest
private static class QuoteServer implements Runnable
{
private BlockheadServer server;
- private ServerConnection sconnection;
+ private IBlockheadServerConnection sconnection;
private CountDownLatch connectLatch = new CountDownLatch(1);
public QuoteServer(BlockheadServer server)
@@ -271,8 +272,8 @@ public class DecoderReaderTest
}
// TODO analyse and fix
- @Ignore
@Test
+ @Ignore ("Quotes appear to be able to arrive in any order?")
public void testTwoQuotes() throws Exception
{
QuotesSocket quoter = new QuotesSocket();
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EncoderFactoryTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EncoderFactoryTest.java
index dca75c2066..86a691bd63 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EncoderFactoryTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EncoderFactoryTest.java
@@ -22,6 +22,9 @@ import static org.hamcrest.Matchers.is;
import javax.websocket.Encoder;
+import org.eclipse.jetty.websocket.api.WebSocketPolicy;
+import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.jsr356.encoders.IntegerEncoder;
import org.eclipse.jetty.websocket.jsr356.encoders.LongEncoder;
import org.eclipse.jetty.websocket.jsr356.encoders.PrimitiveEncoderMetadataSet;
@@ -53,9 +56,11 @@ public class EncoderFactoryTest
@Before
public void initEncoderFactory()
{
- EncoderFactory primitivesFactory = new EncoderFactory(PrimitiveEncoderMetadataSet.INSTANCE);
+ WebSocketContainerScope containerScope = new SimpleContainerScope(WebSocketPolicy.newClientPolicy());
+
+ EncoderFactory primitivesFactory = new EncoderFactory(containerScope,PrimitiveEncoderMetadataSet.INSTANCE);
metadatas = new EncoderMetadataSet();
- factory = new EncoderFactory(metadatas,primitivesFactory);
+ factory = new EncoderFactory(containerScope,metadatas,primitivesFactory);
}
@Test
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EncoderTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EncoderTest.java
index 7ce1381323..b29691af9a 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EncoderTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EncoderTest.java
@@ -18,6 +18,8 @@
package org.eclipse.jetty.websocket.jsr356;
+import static org.hamcrest.Matchers.containsString;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@@ -26,6 +28,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+
import javax.websocket.ClientEndpointConfig;
import javax.websocket.ContainerProvider;
import javax.websocket.EncodeException;
@@ -42,22 +45,20 @@ import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
-import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
+import org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import static org.hamcrest.Matchers.containsString;
-
public class EncoderTest
{
private static class EchoServer implements Runnable
{
private Thread thread;
private BlockheadServer server;
- private ServerConnection sconnection;
+ private IBlockheadServerConnection sconnection;
private CountDownLatch connectLatch = new CountDownLatch(1);
public EchoServer(BlockheadServer server)
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EndpointEchoClient.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EndpointEchoClient.java
index 0728b422d1..9b74af5e62 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EndpointEchoClient.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EndpointEchoClient.java
@@ -18,7 +18,10 @@
package org.eclipse.jetty.websocket.jsr356;
+import static org.hamcrest.Matchers.notNullValue;
+
import java.io.IOException;
+
import javax.websocket.CloseReason;
import javax.websocket.Endpoint;
import javax.websocket.EndpointConfig;
@@ -28,8 +31,6 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.junit.Assert;
-import static org.hamcrest.Matchers.notNullValue;
-
/**
* Basic Echo Client from extended Endpoint
*/
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EndpointEchoTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EndpointEchoTest.java
index 82b47b2325..9149033331 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EndpointEchoTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/EndpointEchoTest.java
@@ -18,8 +18,11 @@
package org.eclipse.jetty.websocket.jsr356;
+import static org.hamcrest.Matchers.instanceOf;
+
import java.net.URI;
import java.util.concurrent.TimeUnit;
+
import javax.websocket.ContainerProvider;
import javax.websocket.Session;
import javax.websocket.WebSocketContainer;
@@ -35,8 +38,6 @@ import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
-import static org.hamcrest.Matchers.instanceOf;
-
public class EndpointEchoTest
{
private static final Logger LOG = Log.getLogger(EndpointEchoTest.class);
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/JsrSessionTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/JsrSessionTest.java
index a342ca1ea1..773198c995 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/JsrSessionTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/JsrSessionTest.java
@@ -18,14 +18,18 @@
package org.eclipse.jetty.websocket.jsr356;
+import static org.hamcrest.Matchers.*;
+
import java.net.URI;
import java.nio.ByteBuffer;
+
import javax.websocket.ClientEndpointConfig;
import javax.websocket.DeploymentException;
import javax.websocket.MessageHandler;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.common.events.EventDriver;
+import org.eclipse.jetty.websocket.common.test.DummyConnection;
import org.eclipse.jetty.websocket.jsr356.client.EmptyClientEndpointConfig;
import org.eclipse.jetty.websocket.jsr356.client.SimpleEndpointMetadata;
import org.eclipse.jetty.websocket.jsr356.endpoints.EndpointInstance;
@@ -34,14 +38,11 @@ import org.eclipse.jetty.websocket.jsr356.handlers.ByteArrayWholeHandler;
import org.eclipse.jetty.websocket.jsr356.handlers.ByteBufferPartialHandler;
import org.eclipse.jetty.websocket.jsr356.handlers.LongMessageHandler;
import org.eclipse.jetty.websocket.jsr356.handlers.StringWholeHandler;
-import org.eclipse.jetty.websocket.jsr356.samples.DummyConnection;
import org.eclipse.jetty.websocket.jsr356.samples.DummyEndpoint;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import static org.hamcrest.Matchers.instanceOf;
-
public class JsrSessionTest
{
private ClientContainer container;
@@ -60,10 +61,10 @@ public class JsrSessionTest
// Executor executor = null;
EndpointInstance ei = new EndpointInstance(websocket,config,metadata);
-
+
EventDriver driver = new JsrEndpointEventDriver(policy,ei);
DummyConnection connection = new DummyConnection();
- session = new JsrSession(requestURI,driver,connection,container,id);
+ session = new JsrSession(container,id,requestURI,driver,connection);
}
@Test
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerFactoryTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerFactoryTest.java
index 5ec7b31377..609612bc1e 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerFactoryTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/MessageHandlerFactoryTest.java
@@ -25,6 +25,9 @@ import java.util.List;
import javax.websocket.DeploymentException;
+import org.eclipse.jetty.websocket.api.WebSocketPolicy;
+import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.jsr356.decoders.PrimitiveDecoderMetadataSet;
import org.eclipse.jetty.websocket.jsr356.handlers.ByteArrayPartialHandler;
import org.eclipse.jetty.websocket.jsr356.handlers.StringPartialHandler;
@@ -44,9 +47,11 @@ public class MessageHandlerFactoryTest
@Before
public void init() throws DeploymentException
{
- DecoderFactory primitivesFactory = new DecoderFactory(PrimitiveDecoderMetadataSet.INSTANCE);
+ WebSocketContainerScope containerScope = new SimpleContainerScope(WebSocketPolicy.newClientPolicy());
+
+ DecoderFactory primitivesFactory = new DecoderFactory(containerScope,PrimitiveDecoderMetadataSet.INSTANCE);
metadatas = new DecoderMetadataSet();
- decoders = new DecoderFactory(metadatas,primitivesFactory);
+ decoders = new DecoderFactory(containerScope,metadatas,primitivesFactory);
factory = new MessageHandlerFactory();
}
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/ClientAnnotatedEndpointScanner_InvalidSignaturesTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/ClientAnnotatedEndpointScanner_InvalidSignaturesTest.java
index b5e8fb18f7..6db77fa617 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/ClientAnnotatedEndpointScanner_InvalidSignaturesTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/ClientAnnotatedEndpointScanner_InvalidSignaturesTest.java
@@ -18,10 +18,13 @@
package org.eclipse.jetty.websocket.jsr356.endpoints;
+import static org.hamcrest.Matchers.containsString;
+
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+
import javax.websocket.ClientEndpoint;
import javax.websocket.ClientEndpointConfig;
import javax.websocket.DeploymentException;
@@ -48,8 +51,6 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import static org.hamcrest.Matchers.containsString;
-
/**
* Test {@link AnnotatedEndpointScanner} against various simple, 1 method, {@link ClientEndpoint} annotated classes with invalid signatures.
*/
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/TrackingSocket.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/TrackingSocket.java
index c6f13c12bb..c1877cf305 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/TrackingSocket.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/TrackingSocket.java
@@ -18,8 +18,13 @@
package org.eclipse.jetty.websocket.jsr356.endpoints;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+
import javax.websocket.CloseReason;
import javax.websocket.CloseReason.CloseCode;
@@ -28,10 +33,6 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.junit.Assert;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
/**
* Abstract base socket used for tracking state and events within the socket for testing reasons.
*/
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidCloseIntSocket.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidCloseIntSocket.java
index 63faaec339..52c5dc14a3 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidCloseIntSocket.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidCloseIntSocket.java
@@ -28,6 +28,7 @@ public class InvalidCloseIntSocket extends TrackingSocket
{
/**
* Invalid Close Method Declaration (parameter type int)
+ * @param statusCode the status code
*/
@OnClose
public void onClose(int statusCode)
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidErrorErrorSocket.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidErrorErrorSocket.java
index 65550ea07f..2b30078c61 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidErrorErrorSocket.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidErrorErrorSocket.java
@@ -28,6 +28,7 @@ public class InvalidErrorErrorSocket extends TrackingSocket
{
/**
* Invalid Error Method Declaration (parameter type Error)
+ * @param error the error
*/
@OnError
public void onError(Error error)
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidErrorExceptionSocket.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidErrorExceptionSocket.java
index 8899e5b192..bd191bdc7e 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidErrorExceptionSocket.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidErrorExceptionSocket.java
@@ -28,6 +28,7 @@ public class InvalidErrorExceptionSocket extends TrackingSocket
{
/**
* Invalid Error Method Declaration (parameter type Exception)
+ * @param e the extension
*/
@OnError
public void onError(Exception e)
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidErrorIntSocket.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidErrorIntSocket.java
index ab29ef4354..6e23ee6457 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidErrorIntSocket.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidErrorIntSocket.java
@@ -28,6 +28,7 @@ public class InvalidErrorIntSocket extends TrackingSocket
{
/**
* Invalid Error Method Declaration (parameter type int)
+ * @param errorCount the error count
*/
@OnError
public void onError(int errorCount)
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidOpenCloseReasonSocket.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidOpenCloseReasonSocket.java
index 702a221374..8fd202ae1f 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidOpenCloseReasonSocket.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidOpenCloseReasonSocket.java
@@ -29,6 +29,7 @@ public class InvalidOpenCloseReasonSocket extends TrackingSocket
{
/**
* Invalid Open Method Declaration (parameter type CloseReason)
+ * @param reason the close reason
*/
@OnOpen
public void onOpen(CloseReason reason)
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidOpenIntSocket.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidOpenIntSocket.java
index c52807416f..6abef152cf 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidOpenIntSocket.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidOpenIntSocket.java
@@ -28,6 +28,7 @@ public class InvalidOpenIntSocket extends TrackingSocket
{
/**
* Invalid Open Method Declaration (parameter type int)
+ * @param value the open value
*/
@OnOpen
public void onOpen(int value)
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidOpenSessionIntSocket.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidOpenSessionIntSocket.java
index bb73ed427b..737fb0507b 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidOpenSessionIntSocket.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/endpoints/samples/InvalidOpenSessionIntSocket.java
@@ -29,6 +29,8 @@ public class InvalidOpenSessionIntSocket extends TrackingSocket
{
/**
* Invalid Open Method Declaration (parameter of type int)
+ * @param session the session for the open
+ * @param count the open count
*/
@OnOpen
public void onOpen(Session session, int count)
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/misbehaving/MisbehavingClassTest.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/misbehaving/MisbehavingClassTest.java
index ce006483b9..a37cf51b2a 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/misbehaving/MisbehavingClassTest.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/misbehaving/MisbehavingClassTest.java
@@ -18,8 +18,9 @@
package org.eclipse.jetty.websocket.jsr356.misbehaving;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
import java.net.URI;
import java.util.concurrent.TimeUnit;
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/samples/DummyConnection.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/samples/DummyConnection.java
deleted file mode 100644
index 9a189514e2..0000000000
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/samples/DummyConnection.java
+++ /dev/null
@@ -1,156 +0,0 @@
-//
-// ========================================================================
-// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
-// ------------------------------------------------------------------------
-// All rights reserved. This program and the accompanying materials
-// are made available under the terms of the Eclipse Public License v1.0
-// and Apache License v2.0 which accompanies this distribution.
-//
-// The Eclipse Public License is available at
-// http://www.eclipse.org/legal/epl-v10.html
-//
-// The Apache License v2.0 is available at
-// http://www.opensource.org/licenses/apache2.0.php
-//
-// You may elect to redistribute this code under either of these licenses.
-// ========================================================================
-//
-
-package org.eclipse.jetty.websocket.jsr356.samples;
-
-import java.net.InetSocketAddress;
-import java.util.concurrent.Executor;
-
-import org.eclipse.jetty.io.ByteBufferPool;
-import org.eclipse.jetty.websocket.api.BatchMode;
-import org.eclipse.jetty.websocket.api.SuspendToken;
-import org.eclipse.jetty.websocket.api.WebSocketPolicy;
-import org.eclipse.jetty.websocket.api.WriteCallback;
-import org.eclipse.jetty.websocket.api.extensions.Frame;
-import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
-import org.eclipse.jetty.websocket.common.LogicalConnection;
-import org.eclipse.jetty.websocket.common.WebSocketSession;
-import org.eclipse.jetty.websocket.common.io.IOState;
-
-public class DummyConnection implements LogicalConnection
-{
- private IOState iostate;
-
- public DummyConnection()
- {
- this.iostate = new IOState();
- }
-
- @Override
- public void close()
- {
- }
-
- @Override
- public void close(int statusCode, String reason)
- {
- }
-
- @Override
- public void disconnect()
- {
- }
-
- @Override
- public ByteBufferPool getBufferPool()
- {
- return null;
- }
-
- @Override
- public Executor getExecutor()
- {
- return null;
- }
-
- @Override
- public long getIdleTimeout()
- {
- return 0;
- }
-
- @Override
- public IOState getIOState()
- {
- return this.iostate;
- }
-
- @Override
- public InetSocketAddress getLocalAddress()
- {
- return null;
- }
-
- @Override
- public long getMaxIdleTimeout()
- {
- return 0;
- }
-
- @Override
- public WebSocketPolicy getPolicy()
- {
- return null;
- }
-
- @Override
- public InetSocketAddress getRemoteAddress()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public WebSocketSession getSession()
- {
- return null;
- }
-
- @Override
- public boolean isOpen()
- {
- return false;
- }
-
- @Override
- public boolean isReading()
- {
- return false;
- }
-
- @Override
- public void outgoingFrame(Frame frame, WriteCallback callback, BatchMode batchMode)
- {
- }
-
- @Override
- public void resume()
- {
- }
-
- @Override
- public void setMaxIdleTimeout(long ms)
- {
- }
-
- @Override
- public void setNextIncomingFrames(IncomingFrames incoming)
- {
- }
-
- @Override
- public void setSession(WebSocketSession session)
- {
- }
-
- @Override
- public SuspendToken suspend()
- {
- return null;
- }
-}
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/samples/ExtDecoder.java b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/samples/ExtDecoder.java
index 65b9426e03..ad7f4523cf 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/samples/ExtDecoder.java
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/samples/ExtDecoder.java
@@ -22,6 +22,7 @@ import javax.websocket.Decoder;
/**
* Testing scenario of an extended Decoder interface
+ * @param <T> the decoder type
*/
public interface ExtDecoder<T> extends Decoder.Text<T>
{
diff --git a/jetty-websocket/javax-websocket-client-impl/src/test/resources/jetty-logging.properties b/jetty-websocket/javax-websocket-client-impl/src/test/resources/jetty-logging.properties
index 6c5baaec7f..3acadb6cad 100644
--- a/jetty-websocket/javax-websocket-client-impl/src/test/resources/jetty-logging.properties
+++ b/jetty-websocket/javax-websocket-client-impl/src/test/resources/jetty-logging.properties
@@ -1,5 +1,6 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
org.eclipse.jetty.LEVEL=WARN
-# org.eclipse.jetty.websocket.LEVEL=WARN
+# org.eclipse.jetty.websocket.LEVEL=INFO
+# org.eclipse.jetty.websocket.LEVEL=ALL
# org.eclipse.jetty.websocket.jsr356.LEVEL=DEBUG
diff --git a/jetty-websocket/javax-websocket-server-impl/pom.xml b/jetty-websocket/javax-websocket-server-impl/pom.xml
index 5abe579554..65f52c5f07 100644
--- a/jetty-websocket/javax-websocket-server-impl/pom.xml
+++ b/jetty-websocket/javax-websocket-server-impl/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-parent</artifactId>
- <version>9.2.15-SNAPSHOT</version>
+ <version>9.3.7-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -70,23 +70,6 @@
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptorRefs>
- <descriptorRef>config</descriptorRef>
- </descriptorRefs>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
</project>
diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/AnnotatedServerEndpointConfig.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/AnnotatedServerEndpointConfig.java
index ebc6ff9d41..3dc14762dc 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/AnnotatedServerEndpointConfig.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/AnnotatedServerEndpointConfig.java
@@ -32,6 +32,8 @@ import javax.websocket.Extension;
import javax.websocket.server.ServerEndpoint;
import javax.websocket.server.ServerEndpointConfig;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
+
public class AnnotatedServerEndpointConfig implements ServerEndpointConfig
{
private final Class<?> endpointClass;
@@ -44,12 +46,12 @@ public class AnnotatedServerEndpointConfig implements ServerEndpointConfig
private Map<String, Object> userProperties;
private List<Extension> extensions;
- public AnnotatedServerEndpointConfig(Class<?> endpointClass, ServerEndpoint anno) throws DeploymentException
+ public AnnotatedServerEndpointConfig(WebSocketContainerScope containerScope, Class<?> endpointClass, ServerEndpoint anno) throws DeploymentException
{
- this(endpointClass,anno,null);
+ this(containerScope,endpointClass,anno,null);
}
- public AnnotatedServerEndpointConfig(Class<?> endpointClass, ServerEndpoint anno, ServerEndpointConfig baseConfig) throws DeploymentException
+ public AnnotatedServerEndpointConfig(WebSocketContainerScope containerScope, Class<?> endpointClass, ServerEndpoint anno, ServerEndpointConfig baseConfig) throws DeploymentException
{
ServerEndpointConfig.Configurator configr = null;
@@ -109,23 +111,25 @@ public class AnnotatedServerEndpointConfig implements ServerEndpointConfig
{
userProperties.putAll(baseConfig.getUserProperties());
}
+
+ ServerEndpointConfig.Configurator cfgr;
if (anno.configurator() == ServerEndpointConfig.Configurator.class)
{
if (configr != null)
{
- this.configurator = configr;
+ cfgr = configr;
}
else
{
- this.configurator = BasicServerEndpointConfigurator.INSTANCE;
+ cfgr = new ContainerDefaultConfigurator();
}
}
else
{
try
{
- this.configurator = anno.configurator().newInstance();
+ cfgr = anno.configurator().newInstance();
}
catch (InstantiationException | IllegalAccessException e)
{
@@ -137,6 +141,9 @@ public class AnnotatedServerEndpointConfig implements ServerEndpointConfig
throw new DeploymentException(err.toString(),e);
}
}
+
+ // Make sure all Configurators obtained are decorated
+ this.configurator = containerScope.getObjectFactory().decorate(cfgr);
}
@Override
diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/AnnotatedServerEndpointMetadata.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/AnnotatedServerEndpointMetadata.java
index b5deb90657..5e0f82b9a7 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/AnnotatedServerEndpointMetadata.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/AnnotatedServerEndpointMetadata.java
@@ -25,6 +25,7 @@ import javax.websocket.server.ServerEndpoint;
import javax.websocket.server.ServerEndpointConfig;
import org.eclipse.jetty.websocket.api.InvalidWebSocketException;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.jsr356.annotations.AnnotatedEndpointMetadata;
import org.eclipse.jetty.websocket.jsr356.annotations.IJsrParamId;
@@ -33,7 +34,7 @@ public class AnnotatedServerEndpointMetadata extends AnnotatedEndpointMetadata<S
private final ServerEndpoint endpoint;
private final AnnotatedServerEndpointConfig config;
- protected AnnotatedServerEndpointMetadata(Class<?> websocket, ServerEndpointConfig baseConfig) throws DeploymentException
+ protected AnnotatedServerEndpointMetadata(WebSocketContainerScope containerScope, Class<?> websocket, ServerEndpointConfig baseConfig) throws DeploymentException
{
super(websocket);
@@ -44,9 +45,9 @@ public class AnnotatedServerEndpointMetadata extends AnnotatedEndpointMetadata<S
}
this.endpoint = anno;
- this.config = new AnnotatedServerEndpointConfig(websocket,anno,baseConfig);
+ this.config = new AnnotatedServerEndpointConfig(containerScope,websocket,anno,baseConfig);
- getDecoders().addAll(anno.decoders());
+ getDecoders().addAll(anno.decoders());
getEncoders().addAll(anno.encoders());
}
diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/BasicServerEndpointConfig.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/BasicServerEndpointConfig.java
index 5b9bb7012f..1156917350 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/BasicServerEndpointConfig.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/BasicServerEndpointConfig.java
@@ -28,6 +28,8 @@ import javax.websocket.Encoder;
import javax.websocket.Extension;
import javax.websocket.server.ServerEndpointConfig;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
+
public class BasicServerEndpointConfig implements ServerEndpointConfig
{
private final List<Class<? extends Decoder>> decoders;
@@ -39,7 +41,7 @@ public class BasicServerEndpointConfig implements ServerEndpointConfig
private final String path;
private Map<String, Object> userProperties;
- public BasicServerEndpointConfig(Class<?> endpointClass, String path)
+ public BasicServerEndpointConfig(WebSocketContainerScope containerScope, Class<?> endpointClass, String path)
{
this.endpointClass = endpointClass;
this.path = path;
@@ -49,10 +51,10 @@ public class BasicServerEndpointConfig implements ServerEndpointConfig
this.subprotocols = new ArrayList<>();
this.extensions = new ArrayList<>();
this.userProperties = new HashMap<>();
- this.configurator = BasicServerEndpointConfigurator.INSTANCE;
+ this.configurator = new ContainerDefaultConfigurator();
}
- public BasicServerEndpointConfig(ServerEndpointConfig copy)
+ public BasicServerEndpointConfig(WebSocketContainerScope containerScope, ServerEndpointConfig copy)
{
// immutable concepts
this.endpointClass = copy.getEndpointClass();
@@ -62,15 +64,21 @@ public class BasicServerEndpointConfig implements ServerEndpointConfig
this.encoders = copy.getEncoders();
this.subprotocols = copy.getSubprotocols();
this.extensions = copy.getExtensions();
+
+ ServerEndpointConfig.Configurator cfgr;
+
if (copy.getConfigurator() != null)
{
- this.configurator = copy.getConfigurator();
+ cfgr = copy.getConfigurator();
}
else
{
- this.configurator = BasicServerEndpointConfigurator.INSTANCE;
+ cfgr = new ContainerDefaultConfigurator();
}
+ // Make sure all Configurators obtained are decorated
+ this.configurator = containerScope.getObjectFactory().decorate(cfgr);
+
// mutable concepts
this.userProperties = new HashMap<>(copy.getUserProperties());
}
diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/BasicServerEndpointConfigurator.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ContainerDefaultConfigurator.java
index fc7d7fdce0..dd20bf15b5 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/BasicServerEndpointConfigurator.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ContainerDefaultConfigurator.java
@@ -19,20 +19,37 @@
package org.eclipse.jetty.websocket.jsr356.server;
import java.util.List;
+import java.util.ServiceLoader;
+
import javax.websocket.Extension;
import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;
+import javax.websocket.server.ServerEndpointConfig.Configurator;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.util.QuoteUtil;
-public class BasicServerEndpointConfigurator extends ServerEndpointConfig.Configurator
+/**
+ * The "Container Default Configurator" per the JSR-356 spec.
+ *
+ * @see ServiceLoader behavior of {@link javax.websocket.server.ServerEndpointConfig.Configurator}
+ */
+public final class ContainerDefaultConfigurator extends Configurator
{
- private static final Logger LOG = Log.getLogger(BasicServerEndpointConfigurator.class);
+ private static final Logger LOG = Log.getLogger(ContainerDefaultConfigurator.class);
private static final String NO_SUBPROTOCOL = "";
- public static final ServerEndpointConfig.Configurator INSTANCE = new BasicServerEndpointConfigurator();
+
+ /**
+ * Default Constructor required, as
+ * javax.websocket.server.ServerEndpointConfig$Configurator.fetchContainerDefaultConfigurator()
+ * will be the one that instantiates this class in most cases.
+ */
+ public ContainerDefaultConfigurator()
+ {
+ super();
+ }
@Override
public boolean checkOrigin(String originHeaderValue)
@@ -47,8 +64,11 @@ public class BasicServerEndpointConfigurator extends ServerEndpointConfig.Config
{
LOG.debug(".getEndpointInstance({})",endpointClass);
}
+
try
{
+ // Since this is started via a ServiceLoader, this class has no Scope or context
+ // that can be used to obtain a ObjectFactory from.
return endpointClass.newInstance();
}
catch (IllegalAccessException e)
diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/JsrCreator.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/JsrCreator.java
index b261f61dd8..60016f4d1d 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/JsrCreator.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/JsrCreator.java
@@ -27,12 +27,14 @@ import java.util.Map;
import javax.websocket.Extension;
import javax.websocket.Extension.Parameter;
import javax.websocket.server.ServerEndpointConfig;
+import javax.websocket.server.ServerEndpointConfig.Configurator;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.extensions.ExtensionFactory;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.jsr356.JsrExtension;
import org.eclipse.jetty.websocket.jsr356.endpoints.EndpointInstance;
import org.eclipse.jetty.websocket.jsr356.server.pathmap.WebSocketPathSpec;
@@ -47,11 +49,13 @@ public class JsrCreator implements WebSocketCreator
public static final String PROP_LOCAL_ADDRESS = "javax.websocket.endpoint.localAddress";
public static final String PROP_LOCALES = "javax.websocket.upgrade.locales";
private static final Logger LOG = Log.getLogger(JsrCreator.class);
+ private final WebSocketContainerScope containerScope;
private final ServerEndpointMetadata metadata;
private final ExtensionFactory extensionFactory;
- public JsrCreator(ServerEndpointMetadata metadata, ExtensionFactory extensionFactory)
+ public JsrCreator(WebSocketContainerScope containerScope, ServerEndpointMetadata metadata, ExtensionFactory extensionFactory)
{
+ this.containerScope = containerScope;
this.metadata = metadata;
this.extensionFactory = extensionFactory;
}
@@ -64,11 +68,11 @@ public class JsrCreator implements WebSocketCreator
// Get raw config, as defined when the endpoint was added to the container
ServerEndpointConfig config = metadata.getConfig();
-
+
// Establish a copy of the config, so that the UserProperties are unique
// per upgrade request.
- config = new BasicServerEndpointConfig(config);
-
+ config = new BasicServerEndpointConfig(containerScope, config);
+
// Bug 444617 - Expose localAddress and remoteAddress for jsr modify handshake to use
// This is being implemented as an optional set of userProperties so that
// it is not JSR api breaking. A few users on #jetty and a few from cometd
@@ -139,7 +143,10 @@ public class JsrCreator implements WebSocketCreator
try
{
Class<?> endpointClass = config.getEndpointClass();
- Object endpoint = config.getConfigurator().getEndpointInstance(endpointClass);
+ Configurator configr = config.getConfigurator();
+ Object endpoint = configr.getEndpointInstance(endpointClass);
+ // Do not decorate here (let the Connection and Session start first)
+ // This will allow CDI to see Session for injection into Endpoint classes.
PathSpec pathSpec = hsreq.getRequestPathSpec();
if (pathSpec instanceof WebSocketPathSpec)
{
@@ -147,7 +154,7 @@ public class JsrCreator implements WebSocketCreator
WebSocketPathSpec wspathSpec = (WebSocketPathSpec)pathSpec;
String requestPath = req.getRequestPath();
// Wrap the config with the path spec information
- config = new PathParamServerEndpointConfig(config,wspathSpec,requestPath);
+ config = new PathParamServerEndpointConfig(containerScope,config,wspathSpec,requestPath);
}
return new EndpointInstance(endpoint,config,metadata);
}
diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/PathParamServerEndpointConfig.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/PathParamServerEndpointConfig.java
index d5a906daf4..d709a0039a 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/PathParamServerEndpointConfig.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/PathParamServerEndpointConfig.java
@@ -23,6 +23,7 @@ import java.util.Map;
import javax.websocket.server.ServerEndpointConfig;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.jsr356.server.pathmap.WebSocketPathSpec;
/**
@@ -32,9 +33,9 @@ public class PathParamServerEndpointConfig extends BasicServerEndpointConfig imp
{
private final Map<String, String> pathParamMap;
- public PathParamServerEndpointConfig(ServerEndpointConfig config, WebSocketPathSpec pathSpec, String requestPath)
+ public PathParamServerEndpointConfig(WebSocketContainerScope containerScope, ServerEndpointConfig config, WebSocketPathSpec pathSpec, String requestPath)
{
- super(config);
+ super(containerScope, config);
Map<String, String> pathMap = pathSpec.getPathParams(requestPath);
pathParamMap = new HashMap<String, String>();
diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java
index f8829ee1e6..7fdba0426d 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/ServerContainer.java
@@ -18,6 +18,8 @@
package org.eclipse.jetty.websocket.jsr356.server;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.Executor;
import javax.websocket.DeploymentException;
@@ -43,16 +45,19 @@ public class ServerContainer extends ClientContainer implements javax.websocket.
private final MappedWebSocketCreator mappedCreator;
private final WebSocketServerFactory webSocketServerFactory;
+ private List<Class<?>> deferredEndpointClasses;
+ private List<ServerEndpointConfig> deferredEndpointConfigs;
public ServerContainer(MappedWebSocketCreator creator, WebSocketServerFactory factory, Executor executor)
{
- super(executor);
+ super(factory);
this.mappedCreator = creator;
this.webSocketServerFactory = factory;
EventDriverFactory eventDriverFactory = this.webSocketServerFactory.getEventDriverFactory();
eventDriverFactory.addImplementation(new JsrServerEndpointImpl());
eventDriverFactory.addImplementation(new JsrServerExtendsEndpointImpl());
this.webSocketServerFactory.addSessionFactory(new JsrSessionFactory(this,this));
+ addBean(webSocketServerFactory);
}
public EndpointInstance newClientEndpointInstance(Object endpoint, ServerEndpointConfig config, String path)
@@ -67,7 +72,7 @@ public class ServerContainer extends ClientContainer implements javax.websocket.
}
else
{
- cec = new BasicServerEndpointConfig(endpoint.getClass(),path);
+ cec = new BasicServerEndpointConfig(this,endpoint.getClass(),path);
}
}
return new EndpointInstance(endpoint,cec,metadata);
@@ -76,25 +81,73 @@ public class ServerContainer extends ClientContainer implements javax.websocket.
@Override
public void addEndpoint(Class<?> endpointClass) throws DeploymentException
{
- ServerEndpointMetadata metadata = getServerEndpointMetadata(endpointClass,null);
- addEndpoint(metadata);
+ if (isStarted() || isStarting())
+ {
+ ServerEndpointMetadata metadata = getServerEndpointMetadata(endpointClass,null);
+ addEndpoint(metadata);
+ }
+ else
+ {
+ if (deferredEndpointClasses == null)
+ {
+ deferredEndpointClasses = new ArrayList<Class<?>>();
+ }
+ deferredEndpointClasses.add(endpointClass);
+ }
}
- public void addEndpoint(ServerEndpointMetadata metadata) throws DeploymentException
+ private void addEndpoint(ServerEndpointMetadata metadata) throws DeploymentException
{
- JsrCreator creator = new JsrCreator(metadata,webSocketServerFactory.getExtensionFactory());
+ JsrCreator creator = new JsrCreator(this,metadata,webSocketServerFactory.getExtensionFactory());
mappedCreator.addMapping(new WebSocketPathSpec(metadata.getPath()),creator);
}
@Override
public void addEndpoint(ServerEndpointConfig config) throws DeploymentException
{
- if (LOG.isDebugEnabled())
+ if (isStarted() || isStarting())
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("addEndpoint({}) path={} endpoint={}",config,config.getPath(),config.getEndpointClass());
+ }
+ ServerEndpointMetadata metadata = getServerEndpointMetadata(config.getEndpointClass(),config);
+ addEndpoint(metadata);
+ }
+ else
+ {
+ if (deferredEndpointConfigs == null)
+ {
+ deferredEndpointConfigs = new ArrayList<ServerEndpointConfig>();
+ }
+ deferredEndpointConfigs.add(config);
+ }
+ }
+
+ @Override
+ protected void doStart() throws Exception
+ {
+ // Proceed with Normal Startup
+ super.doStart();
+
+ // Process Deferred Endpoints
+ if (deferredEndpointClasses != null)
{
- LOG.debug("addEndpoint({}) path={} endpoint={}",config,config.getPath(),config.getEndpointClass());
+ for (Class<?> endpointClass : deferredEndpointClasses)
+ {
+ addEndpoint(endpointClass);
+ }
+ deferredEndpointClasses.clear();
+ }
+
+ if (deferredEndpointConfigs != null)
+ {
+ for (ServerEndpointConfig config : deferredEndpointConfigs)
+ {
+ addEndpoint(config);
+ }
+ deferredEndpointConfigs.clear();
}
- ServerEndpointMetadata metadata = getServerEndpointMetadata(config.getEndpointClass(),config);
- addEndpoint(metadata);
}
public ServerEndpointMetadata getServerEndpointMetadata(final Class<?> endpoint, final ServerEndpointConfig config) throws DeploymentException
@@ -105,7 +158,7 @@ public class ServerContainer extends ClientContainer implements javax.websocket.
if (anno != null)
{
// Annotated takes precedence here
- AnnotatedServerEndpointMetadata ametadata = new AnnotatedServerEndpointMetadata(endpoint,config);
+ AnnotatedServerEndpointMetadata ametadata = new AnnotatedServerEndpointMetadata(this,endpoint,config);
AnnotatedEndpointScanner<ServerEndpoint, ServerEndpointConfig> scanner = new AnnotatedEndpointScanner<>(ametadata);
metadata = ametadata;
scanner.scan();
diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/WebSocketServerContainerInitializer.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/WebSocketServerContainerInitializer.java
index 708d9460ca..7592c46022 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/WebSocketServerContainerInitializer.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/WebSocketServerContainerInitializer.java
@@ -20,6 +20,7 @@ package org.eclipse.jetty.websocket.jsr356.server.deploy;
import java.util.HashSet;
import java.util.Set;
+
import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@@ -32,6 +33,7 @@ import javax.websocket.server.ServerEndpointConfig;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.util.DecoratedObjectFactory;
import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@@ -49,6 +51,10 @@ public class WebSocketServerContainerInitializer implements ServletContainerInit
* Jetty Native approach.
* <p>
* Note: this will add the Upgrade filter to the existing list, with no regard for order. It will just be tacked onto the end of the list.
+ *
+ * @param context the servlet context handler
+ * @return the created websocket server container
+ * @throws ServletException if unable to create the websocket server container
*/
public static ServerContainer configureContext(ServletContextHandler context) throws ServletException
{
@@ -69,6 +75,11 @@ public class WebSocketServerContainerInitializer implements ServletContainerInit
* Servlet 3.1 approach.
* <p>
* This will use Servlet 3.1 techniques on the {@link ServletContext} to add a filter at the start of the filter chain.
+ *
+ * @param context the servlet context
+ * @param jettyContext the jetty servlet context handler
+ * @return the created websocket server container
+ * @throws ServletException if unable to create the websocket server container
*/
public static ServerContainer configureContext(ServletContext context, ServletContextHandler jettyContext) throws ServletException
{
@@ -163,7 +174,16 @@ public class WebSocketServerContainerInitializer implements ServletContainerInit
// Store a reference to the ServerContainer per javax.websocket spec 1.0 final section 6.4 Programmatic Server Deployment
context.setAttribute(javax.websocket.server.ServerContainer.class.getName(),jettyContainer);
-
+
+ // Establish the DecoratedObjectFactory thread local
+ // for various ServiceLoader initiated components to use.
+ DecoratedObjectFactory instantiator = (DecoratedObjectFactory)context.getAttribute(DecoratedObjectFactory.ATTR);
+ if (instantiator == null)
+ {
+ LOG.info("Using WebSocket local DecoratedObjectFactory - none found in ServletContext");
+ instantiator = new DecoratedObjectFactory();
+ }
+
if (LOG.isDebugEnabled())
{
LOG.debug("Found {} classes",c.size());
diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/pathmap/WebSocketPathSpec.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/pathmap/WebSocketPathSpec.java
index bddf58141e..014466a60e 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/pathmap/WebSocketPathSpec.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/pathmap/WebSocketPathSpec.java
@@ -29,6 +29,9 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.websocket.server.PathParam;
+import javax.websocket.server.ServerEndpoint;
+
import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/resources/META-INF/services/javax.websocket.server.ServerEndpointConfig$Configurator b/jetty-websocket/javax-websocket-server-impl/src/main/resources/META-INF/services/javax.websocket.server.ServerEndpointConfig$Configurator
index 57e3ef37cb..7f67aa0a84 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/main/resources/META-INF/services/javax.websocket.server.ServerEndpointConfig$Configurator
+++ b/jetty-websocket/javax-websocket-server-impl/src/main/resources/META-INF/services/javax.websocket.server.ServerEndpointConfig$Configurator
@@ -1 +1 @@
-org.eclipse.jetty.websocket.jsr356.server.BasicServerEndpointConfigurator \ No newline at end of file
+org.eclipse.jetty.websocket.jsr356.server.ContainerDefaultConfigurator \ No newline at end of file
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/AnnotatedServerEndpointTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/AnnotatedServerEndpointTest.java
index 2c510e5d8c..17de44c152 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/AnnotatedServerEndpointTest.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/AnnotatedServerEndpointTest.java
@@ -18,7 +18,7 @@
package org.eclipse.jetty.websocket.jsr356.server;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsString;
import java.io.File;
import java.net.URI;
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/BasicEndpointTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/BasicEndpointTest.java
index 05f7284fb1..001448fac9 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/BasicEndpointTest.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/BasicEndpointTest.java
@@ -35,7 +35,7 @@ import org.junit.Rule;
import org.junit.Test;
/**
- * Example of an {@link Endpoint} extended echo server added programmatically via the
+ * Example of an {@link javax.websocket.Endpoint} extended echo server added programmatically via the
* {@link ServerContainer#addEndpoint(javax.websocket.server.ServerEndpointConfig)}
*/
public class BasicEndpointTest
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/BinaryStreamTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/BinaryStreamTest.java
index 790c0cfee1..05c330a963 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/BinaryStreamTest.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/BinaryStreamTest.java
@@ -26,6 +26,7 @@ import java.net.URI;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+
import javax.websocket.ClientEndpoint;
import javax.websocket.ContainerProvider;
import javax.websocket.OnMessage;
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ConfiguratorTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ConfiguratorTest.java
index 0678367102..8cccdab192 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ConfiguratorTest.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ConfiguratorTest.java
@@ -18,7 +18,8 @@
package org.eclipse.jetty.websocket.jsr356.server;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -50,6 +51,7 @@ import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.BlockheadClient;
import org.eclipse.jetty.websocket.common.test.HttpResponse;
+import org.eclipse.jetty.websocket.common.test.IBlockheadClient;
import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
import org.junit.AfterClass;
import org.junit.Assert;
@@ -302,7 +304,7 @@ public class ConfiguratorTest
{
URI uri = baseServerUri.resolve("/empty");
- try (BlockheadClient client = new BlockheadClient(uri))
+ try (IBlockheadClient client = new BlockheadClient(uri))
{
client.addExtensions("identity");
client.connect();
@@ -317,7 +319,7 @@ public class ConfiguratorTest
{
URI uri = baseServerUri.resolve("/no-extensions");
- try (BlockheadClient client = new BlockheadClient(uri))
+ try (IBlockheadClient client = new BlockheadClient(uri))
{
client.addExtensions("identity");
client.connect();
@@ -332,7 +334,7 @@ public class ConfiguratorTest
{
URI uri = baseServerUri.resolve("/capture-request-headers");
- try (BlockheadClient client = new BlockheadClient(uri))
+ try (IBlockheadClient client = new BlockheadClient(uri))
{
client.addHeader("X-Dummy: Bogus\r\n");
client.connect();
@@ -352,7 +354,7 @@ public class ConfiguratorTest
URI uri = baseServerUri.resolve("/unique-user-props");
// First request
- try (BlockheadClient client = new BlockheadClient(uri))
+ try (IBlockheadClient client = new BlockheadClient(uri))
{
client.connect();
client.sendStandardRequest();
@@ -365,7 +367,7 @@ public class ConfiguratorTest
}
// Second request
- try (BlockheadClient client = new BlockheadClient(uri))
+ try (IBlockheadClient client = new BlockheadClient(uri))
{
client.connect();
client.sendStandardRequest();
@@ -389,7 +391,7 @@ public class ConfiguratorTest
URI uri = baseServerUri.resolve("/addr");
// First request
- try (BlockheadClient client = new BlockheadClient(uri))
+ try (IBlockheadClient client = new BlockheadClient(uri))
{
client.connect();
client.sendStandardRequest();
@@ -416,6 +418,7 @@ public class ConfiguratorTest
/**
* Test of Sec-WebSocket-Protocol, as seen in RFC-6455, 1 protocol
+ * @throws Exception on test failure
*/
@Test
public void testProtocol_Single() throws Exception
@@ -423,7 +426,7 @@ public class ConfiguratorTest
URI uri = baseServerUri.resolve("/protocols");
ProtocolsConfigurator.seenProtocols.set(null);
- try (BlockheadClient client = new BlockheadClient(uri))
+ try (IBlockheadClient client = new BlockheadClient(uri))
{
client.addHeader("Sec-WebSocket-Protocol: echo\r\n");
client.connect();
@@ -439,6 +442,7 @@ public class ConfiguratorTest
/**
* Test of Sec-WebSocket-Protocol, as seen in RFC-6455, 3 protocols
+ * @throws Exception on test failure
*/
@Test
public void testProtocol_Triple() throws Exception
@@ -446,7 +450,7 @@ public class ConfiguratorTest
URI uri = baseServerUri.resolve("/protocols");
ProtocolsConfigurator.seenProtocols.set(null);
- try (BlockheadClient client = new BlockheadClient(uri))
+ try (IBlockheadClient client = new BlockheadClient(uri))
{
client.addHeader("Sec-WebSocket-Protocol: echo, chat, status\r\n");
client.connect();
@@ -462,6 +466,7 @@ public class ConfiguratorTest
/**
* Test of Sec-WebSocket-Protocol, using all lowercase header
+ * @throws Exception on test failure
*/
@Test
public void testProtocol_LowercaseHeader() throws Exception
@@ -469,7 +474,7 @@ public class ConfiguratorTest
URI uri = baseServerUri.resolve("/protocols");
ProtocolsConfigurator.seenProtocols.set(null);
- try (BlockheadClient client = new BlockheadClient(uri))
+ try (IBlockheadClient client = new BlockheadClient(uri))
{
client.addHeader("sec-websocket-protocol: echo, chat, status\r\n");
client.connect();
@@ -485,6 +490,7 @@ public class ConfiguratorTest
/**
* Test of Sec-WebSocket-Protocol, using non-spec case header
+ * @throws Exception on test failure
*/
@Test
public void testProtocol_AltHeaderCase() throws Exception
@@ -492,7 +498,7 @@ public class ConfiguratorTest
URI uri = baseServerUri.resolve("/protocols");
ProtocolsConfigurator.seenProtocols.set(null);
- try (BlockheadClient client = new BlockheadClient(uri))
+ try (IBlockheadClient client = new BlockheadClient(uri))
{
client.addHeader("Sec-Websocket-Protocol: echo, chat, status\r\n");
client.connect();
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/IdleTimeoutTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/IdleTimeoutTest.java
index 101ddfbdee..42d7ce01be 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/IdleTimeoutTest.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/IdleTimeoutTest.java
@@ -18,6 +18,10 @@
package org.eclipse.jetty.websocket.jsr356.server;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
import java.io.IOException;
import java.net.URI;
import java.util.Queue;
@@ -42,10 +46,6 @@ import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
-import static org.hamcrest.Matchers.empty;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
public class IdleTimeoutTest
{
private static final Logger LOG = Log.getLogger(IdleTimeoutTest.class);
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/JettyServerEndpointConfiguratorTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/JettyServerEndpointConfiguratorTest.java
index 2f1dba9f01..189052437b 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/JettyServerEndpointConfiguratorTest.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/JettyServerEndpointConfiguratorTest.java
@@ -48,6 +48,6 @@ public class JettyServerEndpointConfiguratorTest
ServerEndpointConfig.Configurator configr = iter.next();
assertThat("Configurator",configr,notNullValue());
- assertThat("COnfigurator type",configr,instanceOf(BasicServerEndpointConfigurator.class));
+ assertThat("Configurator type",configr,instanceOf(ContainerDefaultConfigurator.class));
}
}
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/JsrBatchModeTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/JsrBatchModeTest.java
index bf92e706c3..c03d3c90ba 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/JsrBatchModeTest.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/JsrBatchModeTest.java
@@ -22,6 +22,7 @@ import java.net.URI;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
+
import javax.websocket.ClientEndpointConfig;
import javax.websocket.ContainerProvider;
import javax.websocket.Endpoint;
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/MemoryUsageTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/MemoryUsageTest.java
index 854f28e75d..ccf9bebebd 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/MemoryUsageTest.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/MemoryUsageTest.java
@@ -18,7 +18,7 @@
package org.eclipse.jetty.websocket.jsr356.server;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.lessThan;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
@@ -114,8 +114,8 @@ public class MemoryUsageTest
long heapUsed = heapAfter.getUsed() - heapBefore.getUsed();
long nonHeapUsed = nonHeapAfter.getUsed() - nonHeapBefore.getUsed();
-// System.out.println("heapUsed = " + heapUsed);
-// System.out.println("nonHeapUsed = " + nonHeapUsed);
+ System.out.println("heapUsed = " + heapUsed);
+ System.out.println("nonHeapUsed = " + nonHeapUsed);
// new CountDownLatch(1).await();
// Assume no more than 25 KiB per session pair (client and server).
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/OnPartialTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/OnPartialTest.java
index 3f1affd9e1..30d45495a0 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/OnPartialTest.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/OnPartialTest.java
@@ -18,9 +18,13 @@
package org.eclipse.jetty.websocket.jsr356.server;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
+
import javax.websocket.server.ServerEndpoint;
import javax.websocket.server.ServerEndpointConfig;
@@ -31,6 +35,9 @@ import org.eclipse.jetty.websocket.common.events.EventDriverFactory;
import org.eclipse.jetty.websocket.common.events.EventDriverImpl;
import org.eclipse.jetty.websocket.common.frames.ContinuationFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
+import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
+import org.eclipse.jetty.websocket.common.test.DummyConnection;
import org.eclipse.jetty.websocket.jsr356.ClientContainer;
import org.eclipse.jetty.websocket.jsr356.JsrSession;
import org.eclipse.jetty.websocket.jsr356.annotations.AnnotatedEndpointScanner;
@@ -41,9 +48,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
public class OnPartialTest
{
@Rule
@@ -65,8 +69,11 @@ public class OnPartialTest
Class<?> endpoint = websocket.getClass();
ServerEndpoint anno = endpoint.getAnnotation(ServerEndpoint.class);
Assert.assertThat("Endpoint: " + endpoint + " should be annotated with @ServerEndpoint",anno,notNullValue());
- ServerEndpointConfig config = new BasicServerEndpointConfig(endpoint,"/");
- AnnotatedServerEndpointMetadata metadata = new AnnotatedServerEndpointMetadata(endpoint,config);
+
+ WebSocketContainerScope containerScope = new SimpleContainerScope(policy);
+
+ ServerEndpointConfig config = new BasicServerEndpointConfig(containerScope,endpoint,"/");
+ AnnotatedServerEndpointMetadata metadata = new AnnotatedServerEndpointMetadata(containerScope,endpoint,config);
AnnotatedEndpointScanner<ServerEndpoint, ServerEndpointConfig> scanner = new AnnotatedEndpointScanner<>(metadata);
scanner.scan();
EndpointInstance ei = new EndpointInstance(websocket,config,metadata);
@@ -79,7 +86,7 @@ public class OnPartialTest
DummyConnection connection = new DummyConnection();
ClientContainer container = new ClientContainer();
@SuppressWarnings("resource")
- JsrSession session = new JsrSession(requestURI,driver,connection,container,id);
+ JsrSession session = new JsrSession(container,id,requestURI,driver,connection);
session.setPolicy(policy);
session.open();
return driver;
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/PingPongTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/PingPongTest.java
index 5ed1cbb72d..70c5f5e2ee 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/PingPongTest.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/PingPongTest.java
@@ -18,7 +18,8 @@
package org.eclipse.jetty.websocket.jsr356.server;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.containsString;
import java.io.File;
import java.net.URI;
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ServerAnnotatedEndpointScanner_GoodSignaturesTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ServerAnnotatedEndpointScanner_GoodSignaturesTest.java
index 2718f42c86..09e7fdbcbe 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ServerAnnotatedEndpointScanner_GoodSignaturesTest.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ServerAnnotatedEndpointScanner_GoodSignaturesTest.java
@@ -34,6 +34,9 @@ import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
import javax.websocket.server.ServerEndpointConfig;
+import org.eclipse.jetty.websocket.api.WebSocketPolicy;
+import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.jsr356.annotations.AnnotatedEndpointScanner;
import org.eclipse.jetty.websocket.jsr356.annotations.JsrCallable;
import org.eclipse.jetty.websocket.jsr356.server.samples.BasicBinaryMessageByteBufferSocket;
@@ -182,7 +185,8 @@ public class ServerAnnotatedEndpointScanner_GoodSignaturesTest
@Test
public void testScan_Basic() throws Exception
{
- AnnotatedServerEndpointMetadata metadata = new AnnotatedServerEndpointMetadata(testcase.pojo,null);
+ WebSocketContainerScope container = new SimpleContainerScope(WebSocketPolicy.newClientPolicy());
+ AnnotatedServerEndpointMetadata metadata = new AnnotatedServerEndpointMetadata(container,testcase.pojo,null);
AnnotatedEndpointScanner<ServerEndpoint, ServerEndpointConfig> scanner = new AnnotatedEndpointScanner<>(metadata);
scanner.scan();
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ServerAnnotatedEndpointScanner_InvalidSignaturesTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ServerAnnotatedEndpointScanner_InvalidSignaturesTest.java
index c01f316372..aa9f0328a8 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ServerAnnotatedEndpointScanner_InvalidSignaturesTest.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ServerAnnotatedEndpointScanner_InvalidSignaturesTest.java
@@ -18,10 +18,13 @@
package org.eclipse.jetty.websocket.jsr356.server;
+import static org.hamcrest.Matchers.containsString;
+
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+
import javax.websocket.DeploymentException;
import javax.websocket.OnClose;
import javax.websocket.OnError;
@@ -31,7 +34,10 @@ import javax.websocket.server.ServerEndpointConfig;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
+import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.common.events.annotated.InvalidSignatureException;
+import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.jsr356.annotations.AnnotatedEndpointScanner;
import org.eclipse.jetty.websocket.jsr356.server.samples.InvalidCloseIntSocket;
import org.eclipse.jetty.websocket.jsr356.server.samples.InvalidErrorErrorSocket;
@@ -46,8 +52,6 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import static org.hamcrest.Matchers.containsString;
-
/**
* Test {@link AnnotatedEndpointScanner} against various simple, 1 method {@link ServerEndpoint} annotated classes with invalid signatures.
*/
@@ -93,7 +97,8 @@ public class ServerAnnotatedEndpointScanner_InvalidSignaturesTest
@Test
public void testScan_InvalidSignature() throws DeploymentException
{
- AnnotatedServerEndpointMetadata metadata = new AnnotatedServerEndpointMetadata(pojo,null);
+ WebSocketContainerScope container = new SimpleContainerScope(WebSocketPolicy.newClientPolicy());
+ AnnotatedServerEndpointMetadata metadata = new AnnotatedServerEndpointMetadata(container,pojo,null);
AnnotatedEndpointScanner<ServerEndpoint,ServerEndpointConfig> scanner = new AnnotatedEndpointScanner<>(metadata);
try
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/SessionTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/SessionTest.java
index 06a4600aa5..74587237d1 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/SessionTest.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/SessionTest.java
@@ -18,7 +18,7 @@
package org.eclipse.jetty.websocket.jsr356.server;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.is;
import java.net.URI;
import java.util.ArrayList;
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/StreamTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/StreamTest.java
index ff965616c2..7a39a44096 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/StreamTest.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/StreamTest.java
@@ -18,6 +18,9 @@
package org.eclipse.jetty.websocket.jsr356.server;
+import static org.hamcrest.Matchers.equalToIgnoringCase;
+import static org.hamcrest.Matchers.is;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -25,13 +28,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
-import java.security.DigestOutputStream;
-import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import javax.websocket.ClientEndpoint;
import javax.websocket.CloseReason;
@@ -60,7 +59,7 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
-import org.eclipse.jetty.websocket.common.util.Hex;
+import org.eclipse.jetty.websocket.common.util.Sha1Sum;
import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
import org.junit.AfterClass;
import org.junit.Assert;
@@ -68,9 +67,6 @@ import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
-import static org.hamcrest.Matchers.equalToIgnoringCase;
-import static org.hamcrest.Matchers.is;
-
public class StreamTest
{
private static final Logger LOG = Log.getLogger(StreamTest.class);
@@ -176,33 +172,12 @@ public class StreamTest
Assert.assertThat("Path should exist: " + file,file.exists(),is(true));
Assert.assertThat("Path should not be a directory:" + file,file.isDirectory(),is(false));
- String expectedSha1 = loadExpectedSha1Sum(sha1File);
- String actualSha1 = calculateSha1Sum(file);
+ String expectedSha1 = Sha1Sum.loadSha1(sha1File);
+ String actualSha1 = Sha1Sum.calculate(file);
Assert.assertThat("SHA1Sum of content: " + file,expectedSha1,equalToIgnoringCase(actualSha1));
}
- private String calculateSha1Sum(File file) throws IOException, NoSuchAlgorithmException
- {
- MessageDigest digest = MessageDigest.getInstance("SHA1");
- try (FileInputStream fis = new FileInputStream(file);
- NoOpOutputStream noop = new NoOpOutputStream();
- DigestOutputStream digester = new DigestOutputStream(noop,digest))
- {
- IO.copy(fis,digester);
- return Hex.asHex(digest.digest());
- }
- }
-
- private String loadExpectedSha1Sum(File sha1File) throws IOException
- {
- String contents = IO.readToString(sha1File);
- Pattern pat = Pattern.compile("^[0-9A-Fa-f]*");
- Matcher mat = pat.matcher(contents);
- Assert.assertTrue("Should have found HEX code in SHA1 file: " + sha1File,mat.find());
- return mat.group();
- }
-
@ClientEndpoint
public static class ClientSocket
{
@@ -317,32 +292,4 @@ public class StreamTest
t.printStackTrace(System.err);
}
}
-
- private static class NoOpOutputStream extends OutputStream
- {
- @Override
- public void write(byte[] b) throws IOException
- {
- }
-
- @Override
- public void write(byte[] b, int off, int len) throws IOException
- {
- }
-
- @Override
- public void flush() throws IOException
- {
- }
-
- @Override
- public void close() throws IOException
- {
- }
-
- @Override
- public void write(int b) throws IOException
- {
- }
- }
}
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/TextStreamTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/TextStreamTest.java
index ecc948a16c..11f5a0de23 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/TextStreamTest.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/TextStreamTest.java
@@ -25,6 +25,7 @@ import java.net.URI;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+
import javax.websocket.ClientEndpoint;
import javax.websocket.ContainerProvider;
import javax.websocket.OnMessage;
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/TrackingSocket.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/TrackingSocket.java
index 981884cb23..8683d53862 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/TrackingSocket.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/TrackingSocket.java
@@ -18,8 +18,13 @@
package org.eclipse.jetty.websocket.jsr356.server;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
+
import javax.websocket.CloseReason;
import javax.websocket.CloseReason.CloseCode;
@@ -28,10 +33,6 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.junit.Assert;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
/**
* Abstract base socket used for tracking state and events within the socket for testing reasons.
*/
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/WSServer.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/WSServer.java
index dedd13fcf5..b8bbd85888 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/WSServer.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/WSServer.java
@@ -18,6 +18,8 @@
package org.eclipse.jetty.websocket.jsr356.server;
+import static org.hamcrest.Matchers.notNullValue;
+
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
@@ -47,8 +49,6 @@ import org.eclipse.jetty.webapp.WebInfConfiguration;
import org.eclipse.jetty.webapp.WebXmlConfiguration;
import org.junit.Assert;
-import static org.hamcrest.Matchers.notNullValue;
-
/**
* Utility to build out exploded directory WebApps, in the /target/tests/ directory, for testing out servers that use javax.websocket endpoints.
* <p>
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/browser/JsrBrowserSocket.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/browser/JsrBrowserSocket.java
index ace05d8205..d3b5df270d 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/browser/JsrBrowserSocket.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/browser/JsrBrowserSocket.java
@@ -23,6 +23,7 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
import java.util.Random;
+
import javax.websocket.CloseReason;
import javax.websocket.OnClose;
import javax.websocket.OnMessage;
@@ -132,7 +133,7 @@ public class JsrBrowserSocket
}
case "many":
{
- String parts[] = val.split(",");
+ String parts[] = StringUtil.csvSplit(val);
int size = Integer.parseInt(parts[0]);
int count = Integer.parseInt(parts[1]);
@@ -141,7 +142,7 @@ public class JsrBrowserSocket
}
case "manythreads":
{
- String parts[] = val.split(",");
+ String parts[] = StringUtil.csvSplit(val);
int threadCount = Integer.parseInt(parts[0]);
int size = Integer.parseInt(parts[1]);
int count = Integer.parseInt(parts[2]);
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidCloseIntSocket.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidCloseIntSocket.java
index 956d3f4367..af20c584ad 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidCloseIntSocket.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidCloseIntSocket.java
@@ -28,6 +28,7 @@ public class InvalidCloseIntSocket extends TrackingSocket
{
/**
* Invalid Close Method Declaration (parameter type int)
+ * @param statusCode the status code
*/
@OnClose
public void onClose(int statusCode)
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidErrorErrorSocket.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidErrorErrorSocket.java
index 1f38f40bb9..a3fe92cd43 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidErrorErrorSocket.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidErrorErrorSocket.java
@@ -28,6 +28,7 @@ public class InvalidErrorErrorSocket extends TrackingSocket
{
/**
* Invalid Error Method Declaration (parameter type Error)
+ * @param error the error
*/
@OnError
public void onError(Error error)
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidErrorExceptionSocket.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidErrorExceptionSocket.java
index c2ec17ac2e..dce13d4e06 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidErrorExceptionSocket.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidErrorExceptionSocket.java
@@ -28,6 +28,7 @@ public class InvalidErrorExceptionSocket extends TrackingSocket
{
/**
* Invalid Error Method Declaration (parameter type Exception)
+ * @param e the exception
*/
@OnError
public void onError(Exception e)
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidErrorIntSocket.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidErrorIntSocket.java
index f6c2a340d1..48f45a3086 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidErrorIntSocket.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidErrorIntSocket.java
@@ -28,6 +28,7 @@ public class InvalidErrorIntSocket extends TrackingSocket
{
/**
* Invalid Error Method Declaration (parameter type int)
+ * @param errorCount the error count
*/
@OnError
public void onError(int errorCount)
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidOpenCloseReasonSocket.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidOpenCloseReasonSocket.java
index 41813598da..0e97246d4b 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidOpenCloseReasonSocket.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidOpenCloseReasonSocket.java
@@ -29,6 +29,7 @@ public class InvalidOpenCloseReasonSocket extends TrackingSocket
{
/**
* Invalid Open Method Declaration (parameter type CloseReason)
+ * @param reason the close reason
*/
@OnOpen
public void onOpen(CloseReason reason)
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidOpenIntSocket.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidOpenIntSocket.java
index fa87b658ad..91fabeaa53 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidOpenIntSocket.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidOpenIntSocket.java
@@ -28,6 +28,7 @@ public class InvalidOpenIntSocket extends TrackingSocket
{
/**
* Invalid Open Method Declaration (parameter type int)
+ * @param value the value
*/
@OnOpen
public void onOpen(int value)
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidOpenSessionIntSocket.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidOpenSessionIntSocket.java
index 9739b978c8..bed3f8f75f 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidOpenSessionIntSocket.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/InvalidOpenSessionIntSocket.java
@@ -29,6 +29,8 @@ public class InvalidOpenSessionIntSocket extends TrackingSocket
{
/**
* Invalid Open Method Declaration (parameter of type int)
+ * @param session the sesion
+ * @param count the count
*/
@OnOpen
public void onOpen(Session session, int count)
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/BasicEchoEndpointConfigContextListener.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/BasicEchoEndpointConfigContextListener.java
index fac2bffecb..94f58be02c 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/BasicEchoEndpointConfigContextListener.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/BasicEchoEndpointConfigContextListener.java
@@ -25,7 +25,7 @@ import javax.websocket.server.ServerContainer;
import javax.websocket.server.ServerEndpointConfig;
/**
- * Example of adding a server WebSocket (extending {@link Endpoint}) programmatically via config
+ * Example of adding a server WebSocket (extending {@link javax.websocket.Endpoint}) programmatically via config
*/
public class BasicEchoEndpointConfigContextListener implements ServletContextListener
{
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/BasicEchoEndpointContextListener.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/BasicEchoEndpointContextListener.java
index 89281e9561..3ac5f5c7e2 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/BasicEchoEndpointContextListener.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/BasicEchoEndpointContextListener.java
@@ -27,7 +27,7 @@ import javax.websocket.server.ServerEndpointConfig;
import org.eclipse.jetty.websocket.jsr356.server.samples.pong.PongMessageEndpoint;
/**
- * Example of adding a server WebSocket (extending {@link Endpoint}) programmatically directly.
+ * Example of adding a server WebSocket (extending {@link javax.websocket.Endpoint}) programmatically directly.
* <p>
* NOTE: this shouldn't work as the endpoint has no path associated with it.
*/
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/BasicEchoSocketConfigContextListener.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/BasicEchoSocketConfigContextListener.java
index 13185bc952..a6c9fb5229 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/BasicEchoSocketConfigContextListener.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/BasicEchoSocketConfigContextListener.java
@@ -25,7 +25,7 @@ import javax.websocket.server.ServerContainer;
import javax.websocket.server.ServerEndpointConfig;
/**
- * Example of adding a server socket (which extends {@link Endpoint}) programmatically via the {@link ServerContainer#addEndpoint(ServerEndpointConfig)}
+ * Example of adding a server socket (which extends {@link javax.websocket.Endpoint}) programmatically via the {@link ServerContainer#addEndpoint(ServerEndpointConfig)}
*/
public class BasicEchoSocketConfigContextListener implements ServletContextListener
{
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/LargeEchoDefaultSocket.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/LargeEchoDefaultSocket.java
index 6364b6c1e0..13415b1e4e 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/LargeEchoDefaultSocket.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/echo/LargeEchoDefaultSocket.java
@@ -20,6 +20,7 @@ package org.eclipse.jetty.websocket.jsr356.server.samples.echo;
import javax.websocket.OnMessage;
import javax.websocket.Session;
+import javax.websocket.WebSocketContainer;
import javax.websocket.server.ServerEndpoint;
/**
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/idletimeout/IdleTimeoutContextListener.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/idletimeout/IdleTimeoutContextListener.java
index dd2194ab16..5dbc69c5af 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/idletimeout/IdleTimeoutContextListener.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/idletimeout/IdleTimeoutContextListener.java
@@ -25,7 +25,7 @@ import javax.websocket.server.ServerContainer;
import javax.websocket.server.ServerEndpointConfig;
/**
- * Example of adding a server WebSocket (extending {@link Endpoint}) programmatically via config
+ * Example of adding a server WebSocket (extending {@link javax.websocket.Endpoint}) programmatically via config
*/
public class IdleTimeoutContextListener implements ServletContextListener
{
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/pong/PongSocket.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/pong/PongSocket.java
index 013908f6ba..06de3468a0 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/pong/PongSocket.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/samples/pong/PongSocket.java
@@ -19,6 +19,7 @@
package org.eclipse.jetty.websocket.jsr356.server.samples.pong;
import java.nio.charset.StandardCharsets;
+
import javax.websocket.EndpointConfig;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
diff --git a/jetty-websocket/pom.xml b/jetty-websocket/pom.xml
index 054a2bfd95..cc57deb73f 100644
--- a/jetty-websocket/pom.xml
+++ b/jetty-websocket/pom.xml
@@ -3,7 +3,7 @@
<parent>
<artifactId>jetty-project</artifactId>
<groupId>org.eclipse.jetty</groupId>
- <version>9.2.15-SNAPSHOT</version>
+ <version>9.3.7-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -33,34 +33,6 @@
</configuration>
</plugin>
<plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <executions>
- <execution>
- <goals>
- <goal>manifest</goal>
- </goals>
- <configuration>
- <instructions>
- <Export-Package>${bundle-symbolic-name}.*;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}"</Export-Package>
- <Import-Package>javax.servlet.*;version="[3.1,4.0)",org.eclipse.jetty.*;version="[9.0,10.0)",*</Import-Package>
- <_nouses>true</_nouses>
- </instructions>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
- </archive>
- </configuration>
- </plugin>
- <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>clirr-maven-plugin</artifactId>
<version>2.5</version>
diff --git a/jetty-websocket/websocket-api/pom.xml b/jetty-websocket/websocket-api/pom.xml
index 425cab0a3e..79cadd126d 100644
--- a/jetty-websocket/websocket-api/pom.xml
+++ b/jetty-websocket/websocket-api/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-parent</artifactId>
- <version>9.2.15-SNAPSHOT</version>
+ <version>9.3.7-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/BatchMode.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/BatchMode.java
index c92c776cc3..530cb0b61d 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/BatchMode.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/BatchMode.java
@@ -18,8 +18,10 @@
package org.eclipse.jetty.websocket.api;
+import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
+
/**
- * The possible batch modes when invoking {@link OutgoingFrames#outgoingFrame(Frame, WriteCallback, BatchMode)}.
+ * The possible batch modes when invoking {@link OutgoingFrames#outgoingFrame(org.eclipse.jetty.websocket.api.extensions.Frame, WriteCallback, BatchMode)}.
*/
public enum BatchMode
{
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/InvalidWebSocketException.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/InvalidWebSocketException.java
index 2dfeb85d41..f6bb061bef 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/InvalidWebSocketException.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/InvalidWebSocketException.java
@@ -18,6 +18,8 @@
package org.eclipse.jetty.websocket.api;
+import org.eclipse.jetty.websocket.api.annotations.WebSocket;
+
/**
* Indicating that the provided Class is not a valid WebSocket as defined by the API.
* <p>
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/RemoteEndpoint.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/RemoteEndpoint.java
index bbf9655708..990253fb1b 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/RemoteEndpoint.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/RemoteEndpoint.java
@@ -31,11 +31,14 @@ public interface RemoteEndpoint
*
* @param data
* the message to be sent
+ * @throws IOException
+ * if unable to send the bytes
*/
void sendBytes(ByteBuffer data) throws IOException;
/**
- * Initiates the asynchronous transmission of a binary message. This method returns before the message is transmitted. Developers may use the returned
+ * Initiates the asynchronous transmission of a binary message. This method returns before the message is
+ * transmitted. Developers may use the returned
* Future object to track progress of the transmission.
*
* @param data
@@ -45,7 +48,8 @@ public interface RemoteEndpoint
Future<Void> sendBytesByFuture(ByteBuffer data);
/**
- * Initiates the asynchronous transmission of a binary message. This method returns before the message is transmitted. Developers may provide a callback to
+ * Initiates the asynchronous transmission of a binary message. This method returns before the message is
+ * transmitted. Developers may provide a callback to
* be notified when the message has been transmitted or resulted in an error.
*
* @param data
@@ -56,38 +60,54 @@ public interface RemoteEndpoint
void sendBytes(ByteBuffer data, WriteCallback callback);
/**
- * Send a binary message in pieces, blocking until all of the message has been transmitted. The runtime reads the message in order. Non-final pieces are
+ * Send a binary message in pieces, blocking until all of the message has been transmitted. The runtime reads the
+ * message in order. Non-final pieces are
* sent with isLast set to false. The final piece must be sent with isLast set to true.
*
* @param fragment
* the piece of the message being sent
+ * @param isLast
+ * true if this is the last piece of the partial bytes
+ * @throws IOException
+ * if unable to send the partial bytes
*/
void sendPartialBytes(ByteBuffer fragment, boolean isLast) throws IOException;
/**
- * Send a text message in pieces, blocking until all of the message has been transmitted. The runtime reads the message in order. Non-final pieces are sent
+ * Send a text message in pieces, blocking until all of the message has been transmitted. The runtime reads the
+ * message in order. Non-final pieces are sent
* with isLast set to false. The final piece must be sent with isLast set to true.
*
* @param fragment
* the piece of the message being sent
+ * @param isLast
+ * true if this is the last piece of the partial bytes
+ * @throws IOException
+ * if unable to send the partial bytes
*/
void sendPartialString(String fragment, boolean isLast) throws IOException;
/**
- * Send a Ping message containing the given application data to the remote endpoint. The corresponding Pong message may be picked up using the
+ * Send a Ping message containing the given application data to the remote endpoint. The corresponding Pong message
+ * may be picked up using the
* MessageHandler.Pong handler.
*
* @param applicationData
* the data to be carried in the ping request
+ * @throws IOException
+ * if unable to send the ping
*/
void sendPing(ByteBuffer applicationData) throws IOException;
/**
- * Allows the developer to send an unsolicited Pong message containing the given application data in order to serve as a unidirectional heartbeat for the
+ * Allows the developer to send an unsolicited Pong message containing the given application data in order to serve
+ * as a unidirectional heartbeat for the
* session.
*
* @param applicationData
* the application data to be carried in the pong response.
+ * @throws IOException
+ * if unable to send the pong
*/
void sendPong(ByteBuffer applicationData) throws IOException;
@@ -98,11 +118,14 @@ public interface RemoteEndpoint
*
* @param text
* the message to be sent
+ * @throws IOException
+ * if unable to send the text message
*/
void sendString(String text) throws IOException;
/**
- * Initiates the asynchronous transmission of a text message. This method may return before the message is transmitted. Developers may use the returned
+ * Initiates the asynchronous transmission of a text message. This method may return before the message is
+ * transmitted. Developers may use the returned
* Future object to track progress of the transmission.
*
* @param text
@@ -112,7 +135,8 @@ public interface RemoteEndpoint
Future<Void> sendStringByFuture(String text);
/**
- * Initiates the asynchronous transmission of a text message. This method may return before the message is transmitted. Developers may provide a callback to
+ * Initiates the asynchronous transmission of a text message. This method may return before the message is
+ * transmitted. Developers may provide a callback to
* be notified when the message has been transmitted or resulted in an error.
*
* @param text
@@ -139,7 +163,9 @@ public interface RemoteEndpoint
/**
* Flushes messages that may have been batched by the implementation.
- * @throws IOException if the flush fails
+ *
+ * @throws IOException
+ * if the flush fails
* @see #getBatchMode()
*/
void flush() throws IOException;
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/Session.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/Session.java
index f9daa0e2e3..3d28ecb290 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/Session.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/Session.java
@@ -22,9 +22,10 @@ import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;
+import org.eclipse.jetty.websocket.api.annotations.OnWebSocketClose;
+
/**
* Session represents an active link of communications with a Remote WebSocket Endpoint.
- * <p>
*/
public interface Session extends Closeable
{
@@ -80,7 +81,11 @@ public interface Session extends Closeable
* Once called, any read/write activity on the websocket from this point will be indeterminate.
* <p>
* Once the underlying connection has been determined to be closed, the various onClose() events (either
- * {@link WebSocketListener#onWebSocketClose(int, String)} or {@link OnWebSocketClose}) will be called on your websocket.
+ * {@link WebSocketListener#onWebSocketClose(int, String)} or {@link OnWebSocketClose}) will be called on your
+ * websocket.
+ *
+ * @throws IOException
+ * if unable to disconnect
*
* @see #close()
* @see #close(CloseStatus)
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/UpgradeResponse.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/UpgradeResponse.java
index a98a6f39d7..91df0d723b 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/UpgradeResponse.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/UpgradeResponse.java
@@ -136,13 +136,15 @@ public class UpgradeResponse
/**
* Issue a forbidden upgrade response.
* <p>
- * This means that the websocket endpoint was valid, but the conditions to use a WebSocket resulted in a forbidden access.
+ * This means that the websocket endpoint was valid, but the conditions to use a WebSocket resulted in a forbidden
+ * access.
* <p>
* Use this when the origin or authentication is invalid.
*
* @param message
* the short 1 line detail message about the forbidden response
* @throws IOException
+ * if unable to send the forbidden
*/
public void sendForbidden(String message) throws IOException
{
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketConnectionListener.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketConnectionListener.java
new file mode 100644
index 0000000000..dc75fe6e91
--- /dev/null
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketConnectionListener.java
@@ -0,0 +1,61 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.websocket.api;
+
+/**
+ * Core WebSocket Connection Listener
+ */
+public interface WebSocketConnectionListener
+{
+ /**
+ * A Close Event was received.
+ * <p>
+ * The underlying Connection will be considered closed at this point.
+ *
+ * @param statusCode
+ * the close status code. (See {@link StatusCode})
+ * @param reason
+ * the optional reason for the close.
+ */
+ void onWebSocketClose(int statusCode, String reason);
+
+ /**
+ * A WebSocket {@link Session} has connected successfully and is ready to be used.
+ * <p>
+ * Note: It is a good idea to track this session as a field in your object so that you can write messages back via the {@link RemoteEndpoint}
+ *
+ * @param session
+ * the websocket session.
+ */
+ void onWebSocketConnect(Session session);
+
+ /**
+ * A WebSocket exception has occurred.
+ * <p>
+ * This is a way for the internal implementation to notify of exceptions occured during the processing of websocket.
+ * <p>
+ * Usually this occurs from bad / malformed incoming packets. (example: bad UTF8 data, frames that are too big, violations of the spec)
+ * <p>
+ * This will result in the {@link Session} being closed by the implementing side.
+ *
+ * @param cause
+ * the error that occurred.
+ */
+ void onWebSocketError(Throwable cause);
+}
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketFrameListener.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketFrameListener.java
new file mode 100644
index 0000000000..2f30b79a03
--- /dev/null
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketFrameListener.java
@@ -0,0 +1,34 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.websocket.api;
+
+import org.eclipse.jetty.websocket.api.extensions.Frame;
+
+/**
+ * WebSocket Frame Listener interface for incoming WebSocket frames.
+ */
+public interface WebSocketFrameListener extends WebSocketConnectionListener
+{
+ /**
+ * A WebSocket frame has been received.
+ *
+ * @param frame the immutable frame received
+ */
+ void onWebSocketFrame(Frame frame);
+}
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketListener.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketListener.java
index b86095154b..9bb12c4458 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketListener.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketListener.java
@@ -19,9 +19,9 @@
package org.eclipse.jetty.websocket.api;
/**
- * Basic WebSocket Listener interface for incoming WebSocket events.
+ * Basic WebSocket Listener interface for incoming WebSocket message events.
*/
-public interface WebSocketListener
+public interface WebSocketListener extends WebSocketConnectionListener
{
/**
* A WebSocket binary frame has been received.
@@ -36,45 +36,9 @@ public interface WebSocketListener
void onWebSocketBinary(byte payload[], int offset, int len);
/**
- * A Close Event was received.
- * <p>
- * The underlying Connection will be considered closed at this point.
- *
- * @param statusCode
- * the close status code. (See {@link StatusCode})
- * @param reason
- * the optional reason for the close.
- */
- void onWebSocketClose(int statusCode, String reason);
-
- /**
- * A WebSocket {@link Session} has connected successfully and is ready to be used.
- * <p>
- * Note: It is a good idea to track this session as a field in your object so that you can write messages back via the {@link RemoteEndpoint}
- *
- * @param session
- * the websocket session.
- */
- void onWebSocketConnect(Session session);
-
- /**
- * A WebSocket exception has occurred.
- * <p>
- * This is a way for the internal implementation to notify of exceptions occured during the processing of websocket.
- * <p>
- * Usually this occurs from bad / malformed incoming packets. (example: bad UTF8 data, frames that are too big, violations of the spec)
- * <p>
- * This will result in the {@link Session} being closed by the implementing side.
- *
- * @param error
- * the error that occurred.
- */
- void onWebSocketError(Throwable cause);
-
- /**
* A WebSocket Text frame was received.
*
- * @param message
+ * @param message the message
*/
void onWebSocketText(String message);
}
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketPartialListener.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketPartialListener.java
new file mode 100644
index 0000000000..a9d03cdb5c
--- /dev/null
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketPartialListener.java
@@ -0,0 +1,58 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.websocket.api;
+
+import java.nio.ByteBuffer;
+
+/**
+ * WebSocket Partial Message Listener interface for incoming WebSocket TEXT/BINARY/CONTINUATION frames.
+ */
+public interface WebSocketPartialListener extends WebSocketConnectionListener
+{
+ /**
+ * A WebSocket BINARY (or associated CONTINUATION) frame has been received.
+ * <p>
+ * <b>Important Note</b>: The payload <code>ByteBuffer</code> cannot be modified, and the ByteBuffer object itself
+ * will be recycled on completion of this method call, make a copy of the data contained within if you want to
+ * retain it between calls.
+ *
+ * @param payload
+ * the binary message frame payload
+ * @param fin
+ * true if this is the final frame, false otherwise
+ */
+ void onWebSocketPartialBinary(ByteBuffer payload, boolean fin);
+
+ /**
+ * A WebSocket TEXT (or associated CONTINUATION) frame has been received.
+ *
+ * @param payload
+ * the text message payload
+ * <p>
+ * Note that due to framing, there is a above average chance of any UTF8 sequences being split on the
+ * border between two frames will result in either the previous frame, or the next frame having an
+ * invalid UTF8 sequence, but the combined frames having a valid UTF8 sequence.
+ * <p>
+ * The String being provided here will not end in a split UTF8 sequence. Instead this partial sequence
+ * will be held over until the next frame is received.
+ * @param fin
+ * true if this is the final frame, false otherwise
+ */
+ void onWebSocketPartialText(String payload, boolean fin);
+}
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketPingPongListener.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketPingPongListener.java
new file mode 100644
index 0000000000..fa74c339d8
--- /dev/null
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/WebSocketPingPongListener.java
@@ -0,0 +1,43 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.websocket.api;
+
+import java.nio.ByteBuffer;
+
+/**
+ * WebSocket PING/PONG Listener interface for incoming WebSocket PING/PONG frames.
+ */
+public interface WebSocketPingPongListener extends WebSocketConnectionListener
+{
+ /**
+ * A WebSocket PING has been received.
+ *
+ * @param payload
+ * the ping payload
+ */
+ void onWebSocketPing(ByteBuffer payload);
+
+ /**
+ * A WebSocket PONG has been received.
+ *
+ * @param payload
+ * the pong payload
+ */
+ void onWebSocketPong(ByteBuffer payload);
+}
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketClose.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketClose.java
index a29fab3ef7..461663b733 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketClose.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketClose.java
@@ -24,6 +24,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.eclipse.jetty.websocket.api.Session;
+
/**
* Annotation for tagging methods to receive connection close events.
* <p>
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketConnect.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketConnect.java
index 89690f3e33..f74b3c6b08 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketConnect.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketConnect.java
@@ -24,6 +24,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.eclipse.jetty.websocket.api.Session;
+
/**
* Annotation for tagging methods to receive connection open events.
* <p>
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketError.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketError.java
index 1fb9e6bc6f..5ef8caa33c 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketError.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketError.java
@@ -24,12 +24,13 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.eclipse.jetty.websocket.api.Session;
+
/**
* Annotation for receiving websocket errors (exceptions) that have occurred internally in the websocket implementation.
* <p>
* Acceptable method patterns.<br>
* Note: <code>methodName</code> can be any name you want to use.
- * <p>
* <ol>
* <li><code>public void methodName({@link Throwable} error)</code></li>
* <li><code>public void methodName({@link Session} session, {@link Throwable} error)</code></li>
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketFrame.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketFrame.java
index f3bcd0dd3b..7dcae2343b 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketFrame.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketFrame.java
@@ -24,14 +24,16 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.eclipse.jetty.websocket.api.Session;
+
/**
* (ADVANCED) Annotation for tagging methods to receive frame events.
* <p>
* Acceptable method patterns.<br>
* Note: <code>methodName</code> can be any name you want to use.
* <ol>
- * <li><code>public void methodName({@link Frame} frame)</code></li>
- * <li><code>public void methodName({@link Session} session, {@link Frame} frame)</code></li>
+ * <li><code>public void methodName({@link org.eclipse.jetty.websocket.api.extensions.Frame} frame)</code></li>
+ * <li><code>public void methodName({@link Session} session, {@link org.eclipse.jetty.websocket.api.extensions.Frame} frame)</code></li>
* </ol>
*/
@Documented
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketMessage.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketMessage.java
index 74f687b4d2..eb96580ad4 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketMessage.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/annotations/OnWebSocketMessage.java
@@ -18,12 +18,15 @@
package org.eclipse.jetty.websocket.api.annotations;
+import java.io.Reader;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.eclipse.jetty.websocket.api.Session;
+
/**
* Annotation for tagging methods to receive Binary or Text Message events.
* <p>
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/Extension.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/Extension.java
index ebcb7dab1d..4cee100f03 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/Extension.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/Extension.java
@@ -36,6 +36,7 @@ public interface Extension extends IncomingFrames, OutgoingFrames
* The <code>Sec-WebSocket-Extensions</code> name for this extension.
* <p>
* Also known as the <a href="https://tools.ietf.org/html/rfc6455#section-9.1"><code>extension-token</code> per Section 9.1. Negotiating Extensions</a>.
+ * @return the name of the extension
*/
public String getName();
@@ -81,9 +82,4 @@ public interface Extension extends IncomingFrames, OutgoingFrames
* the next outgoing extension
*/
public void setNextOutgoingFrames(OutgoingFrames nextOutgoing);
-
- // TODO: Extension should indicate if it requires boundary of fragments to be preserved
-
- // TODO: Extension should indicate if it uses the Extension data field of frame for its own reasons.
-
}
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/ExtensionConfig.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/ExtensionConfig.java
index 1041bc5d74..5036eb7a5b 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/ExtensionConfig.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/ExtensionConfig.java
@@ -128,6 +128,7 @@ public class ExtensionConfig
/**
* Copy constructor
+ * @param copy the extension config to copy
*/
public ExtensionConfig(ExtensionConfig copy)
{
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/Frame.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/Frame.java
index 3dec2fa9db..ecce110651 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/Frame.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/Frame.java
@@ -103,8 +103,9 @@ public interface Frame
* Same as {@link #isFin()}
*
* @return true if final frame.
+ * @deprecated use {@link #isFin()} instead
*/
- // FIXME: remove
+ @Deprecated
public boolean isLast();
public boolean isMasked();
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/OutgoingFrames.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/OutgoingFrames.java
index 2f6cea3f42..9476cff437 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/OutgoingFrames.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/extensions/OutgoingFrames.java
@@ -28,10 +28,10 @@ public interface OutgoingFrames
{
/**
* A frame, and optional callback, intended for the network layer.
- * <p/>
+ * <p>
* Note: the frame can undergo many transformations in the various
* layers and extensions present in the implementation.
- * <p/>
+ * <p>
* If you are implementing a mutation, you are obliged to handle
* the incoming WriteCallback appropriately.
*
diff --git a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/util/QuoteUtil.java b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/util/QuoteUtil.java
index faf9674a10..f8d1f906e7 100644
--- a/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/util/QuoteUtil.java
+++ b/jetty-websocket/websocket-api/src/main/java/org/eclipse/jetty/websocket/api/util/QuoteUtil.java
@@ -27,7 +27,6 @@ import java.util.NoSuchElementException;
* Provide some consistent Http header value and Extension configuration parameter quoting support.
* <p>
* While QuotedStringTokenizer exists in jetty-util, and works great with http header values, using it in websocket-api is undesired.
- * <p>
* <ul>
* <li>Using QuotedStringTokenizer would introduce a dependency to jetty-util that would need to be exposed via the WebAppContext classloader</li>
* <li>ABNF defined extension parameter parsing requirements of RFC-6455 (WebSocket) ABNF, is slightly different than the ABNF parsing defined in RFC-2616
@@ -48,8 +47,6 @@ public class QuoteUtil
QUOTE_DOUBLE
}
- private static final boolean DEBUG = false;
-
private final String input;
private final String delims;
private StringBuilder token;
@@ -84,14 +81,6 @@ public class QuoteUtil
}
}
- private void debug(String format, Object... args)
- {
- if (DEBUG)
- {
- System.out.printf(format,args);
- }
- }
-
@Override
public boolean hasNext()
{
@@ -134,7 +123,7 @@ public class QuoteUtil
{
if (delims.indexOf(c) >= 0)
{
- debug("hasNext/t: %b [%s]%n",hasToken,token);
+ // System.out.printf("hasNext/t: %b [%s]%n",hasToken,token);
return hasToken;
}
else if (c == '\'')
@@ -193,10 +182,9 @@ public class QuoteUtil
break;
}
}
- debug("%s <%s> : [%s]%n",state,c,token);
+ // System.out.printf("%s <%s> : [%s]%n",state,c,token);
}
-
- debug("hasNext/e: %b [%s]%n",hasToken,token);
+ // System.out.printf("hasNext/e: %b [%s]%n",hasToken,token);
return hasToken;
}
diff --git a/jetty-websocket/websocket-api/src/test/java/org/eclipse/jetty/websocket/api/util/QuoteUtilTest.java b/jetty-websocket/websocket-api/src/test/java/org/eclipse/jetty/websocket/api/util/QuoteUtilTest.java
index d475ec0fa7..c3d8606d4b 100644
--- a/jetty-websocket/websocket-api/src/test/java/org/eclipse/jetty/websocket/api/util/QuoteUtilTest.java
+++ b/jetty-websocket/websocket-api/src/test/java/org/eclipse/jetty/websocket/api/util/QuoteUtilTest.java
@@ -18,8 +18,8 @@
package org.eclipse.jetty.websocket.api.util;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
import java.util.Iterator;
import java.util.NoSuchElementException;
diff --git a/jetty-websocket/websocket-client/pom.xml b/jetty-websocket/websocket-client/pom.xml
index 06bf8443c1..98af4976cd 100644
--- a/jetty-websocket/websocket-client/pom.xml
+++ b/jetty-websocket/websocket-client/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-parent</artifactId>
- <version>9.2.15-SNAPSHOT</version>
+ <version>9.3.7-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeRequest.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeRequest.java
index ac5873dc5e..67e00c0fab 100644
--- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeRequest.java
+++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeRequest.java
@@ -46,7 +46,6 @@ import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
public class ClientUpgradeRequest extends UpgradeRequest
{
private static final Logger LOG = Log.getLogger(ClientUpgradeRequest.class);
- private static final int MAX_KEYS = -1; // maximum number of parameter keys to decode
private static final Set<String> FORBIDDEN_HEADERS;
static
@@ -249,7 +248,7 @@ public class ClientUpgradeRequest extends UpgradeRequest
if (StringUtil.isNotBlank(query))
{
MultiMap<String> params = new MultiMap<String>();
- UrlEncoded.decodeTo(uri.getQuery(),params,StandardCharsets.UTF_8,MAX_KEYS);
+ UrlEncoded.decodeTo(uri.getQuery(),params,StandardCharsets.UTF_8);
for (String key : params.keySet())
{
diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeResponse.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeResponse.java
index 0c468765d2..10dfc9635b 100644
--- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeResponse.java
+++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/ClientUpgradeResponse.java
@@ -21,11 +21,15 @@ package org.eclipse.jetty.websocket.client;
import java.io.IOException;
import java.nio.ByteBuffer;
+import org.eclipse.jetty.util.BufferUtil;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.UpgradeResponse;
import org.eclipse.jetty.websocket.common.io.http.HttpResponseHeaderParseListener;
public class ClientUpgradeResponse extends UpgradeResponse implements HttpResponseHeaderParseListener
{
+ private static final Logger LOG = Log.getLogger(ClientUpgradeResponse.class);
private ByteBuffer remainingBuffer;
public ClientUpgradeResponse()
@@ -47,6 +51,10 @@ public class ClientUpgradeResponse extends UpgradeResponse implements HttpRespon
@Override
public void setRemainingBuffer(ByteBuffer remainingBuffer)
{
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Saving remaining header: {}",BufferUtil.toDetailString(remainingBuffer));
+ }
this.remainingBuffer = remainingBuffer;
}
}
diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java
index 3320d57a31..59a4d61eee 100644
--- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java
+++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java
@@ -22,9 +22,8 @@ import java.io.IOException;
import java.net.CookieStore;
import java.net.SocketAddress;
import java.net.URI;
-import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
-import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.Executor;
@@ -33,6 +32,7 @@ import java.util.concurrent.Future;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.io.SelectorManager;
+import org.eclipse.jetty.util.DecoratedObjectFactory;
import org.eclipse.jetty.util.HttpCookieStore;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
@@ -45,7 +45,6 @@ import org.eclipse.jetty.util.thread.Scheduler;
import org.eclipse.jetty.util.thread.ShutdownThread;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
-import org.eclipse.jetty.websocket.api.extensions.Extension;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.extensions.ExtensionFactory;
import org.eclipse.jetty.websocket.client.io.ConnectPromise;
@@ -60,15 +59,16 @@ import org.eclipse.jetty.websocket.common.WebSocketSessionFactory;
import org.eclipse.jetty.websocket.common.events.EventDriver;
import org.eclipse.jetty.websocket.common.events.EventDriverFactory;
import org.eclipse.jetty.websocket.common.extensions.WebSocketExtensionFactory;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
/**
* WebSocketClient provides a means of establishing connections to remote websocket endpoints.
*/
-public class WebSocketClient extends ContainerLifeCycle implements SessionListener
+public class WebSocketClient extends ContainerLifeCycle implements SessionListener, WebSocketContainerScope
{
private static final Logger LOG = Log.getLogger(WebSocketClient.class);
- private final WebSocketPolicy policy;
+ private final WebSocketPolicy policy = WebSocketPolicy.newClientPolicy();
private final SslContextFactory sslContextFactory;
private final WebSocketExtensionFactory extensionRegistry;
private boolean daemon = false;
@@ -76,18 +76,20 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
private SessionFactory sessionFactory;
private ByteBufferPool bufferPool;
private Executor executor;
+ private DecoratedObjectFactory objectFactory;
private Scheduler scheduler;
private CookieStore cookieStore;
private ConnectionManager connectionManager;
private Masker masker;
private SocketAddress bindAddress;
private long connectTimeout = SelectorManager.DEFAULT_CONNECT_TIMEOUT;
+ private boolean dispatchIO = true;
public WebSocketClient()
{
- this(null,null);
+ this((SslContextFactory)null,null);
}
-
+
public WebSocketClient(Executor executor)
{
this(null,executor);
@@ -108,28 +110,37 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
this(sslContextFactory,executor,new MappedByteBufferPool());
}
+ public WebSocketClient(WebSocketContainerScope scope)
+ {
+ this(scope.getSslContextFactory(), scope.getExecutor(), scope.getBufferPool(), scope.getObjectFactory());
+ }
+
+ public WebSocketClient(WebSocketContainerScope scope, SslContextFactory sslContextFactory)
+ {
+ this(sslContextFactory, scope.getExecutor(), scope.getBufferPool(), scope.getObjectFactory());
+ }
+
public WebSocketClient(SslContextFactory sslContextFactory, Executor executor, ByteBufferPool bufferPool)
{
+ this(sslContextFactory, executor, bufferPool, new DecoratedObjectFactory());
+ }
+
+ public WebSocketClient(SslContextFactory sslContextFactory, Executor executor, ByteBufferPool bufferPool, DecoratedObjectFactory objectFactory)
+ {
this.executor = executor;
this.sslContextFactory = sslContextFactory;
- this.policy = WebSocketPolicy.newClientPolicy();
this.bufferPool = bufferPool;
- this.extensionRegistry = new WebSocketExtensionFactory(policy,bufferPool);
-
- // Bug #431459 - unregistering compression extensions till they are more stable
- this.extensionRegistry.unregister("deflate-frame");
- this.extensionRegistry.unregister("permessage-deflate");
- this.extensionRegistry.unregister("x-webkit-deflate-frame");
+ this.objectFactory = objectFactory;
+ this.extensionRegistry = new WebSocketExtensionFactory(this);
this.masker = new RandomMasker();
this.eventDriverFactory = new EventDriverFactory(policy);
- this.sessionFactory = new WebSocketSessionFactory(this);
addBean(this.executor);
addBean(this.sslContextFactory);
addBean(this.bufferPool);
}
-
+
public Future<Session> connect(Object websocket, URI toUri) throws IOException
{
ClientUpgradeRequest request = new ClientUpgradeRequest(toUri);
@@ -184,7 +195,7 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
LOG.debug("connect websocket {} to {}",websocket,toUri);
// Grab Connection Manager
- initialiseClient();
+ initializeClient();
ConnectionManager manager = getConnectionManager();
// Setup Driver for user provided websocket
@@ -253,8 +264,18 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
cookieStore = new HttpCookieStore.Empty();
}
- super.doStart();
+ if(this.sessionFactory == null)
+ {
+ this.sessionFactory = new WebSocketSessionFactory(this);
+ }
+
+ if(this.objectFactory == null)
+ {
+ this.objectFactory = new DecoratedObjectFactory();
+ }
+ super.doStart();
+
if (LOG.isDebugEnabled())
LOG.debug("Started {}",this);
}
@@ -277,11 +298,16 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
}
super.doStop();
-
+
if (LOG.isDebugEnabled())
LOG.debug("Stopped {}",this);
}
+ public boolean isDispatchIO()
+ {
+ return dispatchIO;
+ }
+
/**
* Return the number of milliseconds for a timeout of an attempted write operation.
*
@@ -387,9 +413,15 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
return this.policy.getMaxTextMessageSize();
}
+ @Override
+ public DecoratedObjectFactory getObjectFactory()
+ {
+ return this.objectFactory;
+ }
+
public Set<WebSocketSession> getOpenSessions()
{
- return new HashSet<>(getBeans(WebSocketSession.class));
+ return Collections.unmodifiableSet(new HashSet<>(getBeans(WebSocketSession.class)));
}
public WebSocketPolicy getPolicy()
@@ -401,7 +433,7 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
{
return scheduler;
}
-
+
public SessionFactory getSessionFactory()
{
return sessionFactory;
@@ -416,29 +448,7 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
return sslContextFactory;
}
- public List<Extension> initExtensions(List<ExtensionConfig> requested)
- {
- List<Extension> extensions = new ArrayList<Extension>();
-
- for (ExtensionConfig cfg : requested)
- {
- Extension extension = extensionRegistry.newInstance(cfg);
-
- if (extension == null)
- {
- continue;
- }
-
- if (LOG.isDebugEnabled())
- LOG.debug("added {}",extension);
- extensions.add(extension);
- }
- if (LOG.isDebugEnabled())
- LOG.debug("extensions={}",extensions);
- return extensions;
- }
-
- private synchronized void initialiseClient() throws IOException
+ private synchronized void initializeClient() throws IOException
{
if (!ShutdownThread.isRegistered(this))
{
@@ -489,15 +499,26 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
{
if (LOG.isDebugEnabled())
LOG.debug("Session Opened: {}",session);
+ addManaged(session);
}
-
+
public void setAsyncWriteTimeout(long ms)
{
this.policy.setAsyncWriteTimeout(ms);
}
+ /**
+ * @param bindAddress the address to bind to
+ * @deprecated use {@link #setBindAddress(SocketAddress)} instead
+ */
+ @Deprecated
public void setBindAdddress(SocketAddress bindAddress)
{
+ setBindAddress(bindAddress);
+ }
+
+ public void setBindAddress(SocketAddress bindAddress)
+ {
this.bindAddress = bindAddress;
}
@@ -531,6 +552,11 @@ public class WebSocketClient extends ContainerLifeCycle implements SessionListen
this.daemon = daemon;
}
+ public void setDispatchIO(boolean dispatchIO)
+ {
+ this.dispatchIO = dispatchIO;
+ }
+
public void setEventDriverFactory(EventDriverFactory factory)
{
this.eventDriverFactory = factory;
diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/ConnectPromise.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/ConnectPromise.java
index 9230b6a403..ef1a58570f 100644
--- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/ConnectPromise.java
+++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/ConnectPromise.java
@@ -19,6 +19,8 @@
package org.eclipse.jetty.websocket.client.io;
import org.eclipse.jetty.util.FuturePromise;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.ClientUpgradeResponse;
@@ -32,12 +34,14 @@ import org.eclipse.jetty.websocket.common.events.EventDriver;
*/
public abstract class ConnectPromise extends FuturePromise<Session> implements Runnable
{
+ private static final Logger LOG = Log.getLogger(ConnectPromise.class);
private final WebSocketClient client;
private final EventDriver driver;
private final ClientUpgradeRequest request;
private final Masker masker;
private UpgradeListener upgradeListener;
private ClientUpgradeResponse response;
+ private WebSocketSession session;
public ConnectPromise(WebSocketClient client, EventDriver driver, ClientUpgradeRequest request)
{
@@ -97,11 +101,18 @@ public abstract class ConnectPromise extends FuturePromise<Session> implements R
this.upgradeListener = upgradeListener;
}
- public void succeeded(WebSocketSession session)
+ public void succeeded()
{
+ if(LOG.isDebugEnabled())
+ LOG.debug("{}.succeeded()",this.getClass().getSimpleName());
session.setUpgradeRequest(request);
session.setUpgradeResponse(response);
- session.open();
+ // session.open();
super.succeeded(session);
}
+
+ public void setSession(WebSocketSession session)
+ {
+ this.session = session;
+ }
}
diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/ConnectionManager.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/ConnectionManager.java
index 1aae226b1e..fb00e8f62e 100644
--- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/ConnectionManager.java
+++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/ConnectionManager.java
@@ -23,20 +23,13 @@ import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.net.URI;
import java.nio.channels.SocketChannel;
-import java.util.Collection;
-import java.util.Collections;
import java.util.Locale;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
-import org.eclipse.jetty.websocket.api.StatusCode;
-import org.eclipse.jetty.websocket.api.WebSocketException;
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.common.events.EventDriver;
/**
@@ -104,20 +97,6 @@ public class ConnectionManager extends ContainerLifeCycle
}
}
- private class VirtualConnect extends ConnectPromise
- {
- public VirtualConnect(WebSocketClient client, EventDriver driver, ClientUpgradeRequest request)
- {
- super(client,driver,request);
- }
-
- @Override
- public void run()
- {
- failed(new WebSocketException("MUX Not yet supported"));
- }
- }
-
private static final Logger LOG = Log.getLogger(ConnectionManager.class);
public static InetSocketAddress toSocketAddress(URI uri)
@@ -151,7 +130,6 @@ public class ConnectionManager extends ContainerLifeCycle
return new InetSocketAddress(uri.getHost(),port);
}
- private final Queue<WebSocketSession> sessions = new ConcurrentLinkedQueue<>();
private final WebSocketClient client;
private WebSocketClientSelectorManager selector;
@@ -160,41 +138,8 @@ public class ConnectionManager extends ContainerLifeCycle
this.client = client;
}
- public void addSession(WebSocketSession session)
- {
- sessions.add(session);
- }
-
- private void shutdownAllConnections()
- {
- for (WebSocketSession session : sessions)
- {
- if (session.getConnection() != null)
- {
- try
- {
- session.getConnection().close(
- StatusCode.SHUTDOWN,
- "Shutdown");
- }
- catch (Throwable t)
- {
- LOG.debug("During Shutdown All Connections",t);
- }
- }
- }
- }
-
public ConnectPromise connect(WebSocketClient client, EventDriver driver, ClientUpgradeRequest request)
{
- URI toUri = request.getRequestURI();
- String hostname = toUri.getHost();
-
- if (isVirtualConnectionPossibleTo(hostname))
- {
- return new VirtualConnect(client,driver,request);
- }
-
return new PhysicalConnect(client,driver,request);
}
@@ -212,8 +157,6 @@ public class ConnectionManager extends ContainerLifeCycle
@Override
protected void doStop() throws Exception
{
- shutdownAllConnections();
- sessions.clear();
super.doStop();
removeBean(selector);
}
@@ -223,17 +166,6 @@ public class ConnectionManager extends ContainerLifeCycle
return selector;
}
- public Collection<WebSocketSession> getSessions()
- {
- return Collections.unmodifiableCollection(sessions);
- }
-
- public boolean isVirtualConnectionPossibleTo(String hostname)
- {
- // TODO Auto-generated method stub
- return false;
- }
-
/**
* Factory method for new WebSocketClientSelectorManager (used by other projects like cometd)
*
@@ -245,9 +177,4 @@ public class ConnectionManager extends ContainerLifeCycle
{
return new WebSocketClientSelectorManager(client);
}
-
- public void removeSession(WebSocketSession session)
- {
- sessions.remove(session);
- }
}
diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java
index d4c4a7572f..dbe4faee41 100644
--- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java
+++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/UpgradeConnection.java
@@ -29,6 +29,7 @@ import java.util.concurrent.Executor;
import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.ByteBufferPool;
+import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.FutureCallback;
@@ -49,14 +50,18 @@ import org.eclipse.jetty.websocket.common.io.http.HttpResponseHeaderParser;
import org.eclipse.jetty.websocket.common.io.http.HttpResponseHeaderParser.ParseException;
/**
- * This is the initial connection handling that exists immediately after physical connection is established to destination server.
+ * This is the initial connection handling that exists immediately after physical connection is established to
+ * destination server.
* <p>
- * Eventually, upon successful Upgrade request/response, this connection swaps itself out for the WebSocektClientConnection handler.
+ * Eventually, upon successful Upgrade request/response, this connection swaps itself out for the
+ * WebSocektClientConnection handler.
*/
-public class UpgradeConnection extends AbstractConnection
+public class UpgradeConnection extends AbstractConnection implements Connection.UpgradeFrom
{
public class SendUpgradeRequest extends FutureCallback implements Runnable
{
+ private final Logger LOG = Log.getLogger(UpgradeConnection.SendUpgradeRequest.class);
+
@Override
public void run()
{
@@ -71,16 +76,20 @@ public class UpgradeConnection extends AbstractConnection
String rawRequest = request.generate();
- ByteBuffer buf = BufferUtil.toBuffer(rawRequest, StandardCharsets.UTF_8);
+ ByteBuffer buf = BufferUtil.toBuffer(rawRequest,StandardCharsets.UTF_8);
getEndPoint().write(this,buf);
}
@Override
public void succeeded()
{
- LOG.debug("Upgrade Request Write Success");
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Upgrade Request Write Success");
+ }
// Writing the request header is complete.
super.succeeded();
+ state = State.RESPONSE;
// start the interest in fill
fillInterested();
}
@@ -88,8 +97,12 @@ public class UpgradeConnection extends AbstractConnection
@Override
public void failed(Throwable cause)
{
- LOG.warn("Upgrade Request Write Failure", cause);
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Upgrade Request Write Failure",cause);
+ }
super.failed(cause);
+ state = State.FAILURE;
// Fail the connect promise when a fundamental exception during connect occurs.
connectPromise.failed(cause);
}
@@ -98,11 +111,21 @@ public class UpgradeConnection extends AbstractConnection
/** HTTP Response Code: 101 Switching Protocols */
private static final int SWITCHING_PROTOCOLS = 101;
+ private enum State
+ {
+ REQUEST,
+ RESPONSE,
+ FAILURE,
+ UPGRADE
+ }
+
private static final Logger LOG = Log.getLogger(UpgradeConnection.class);
private final ByteBufferPool bufferPool;
private final ConnectPromise connectPromise;
private final HttpResponseHeaderParser parser;
+ private State state = State.REQUEST;
private ClientUpgradeRequest request;
+ private ClientUpgradeResponse response;
public UpgradeConnection(EndPoint endp, Executor executor, ConnectPromise connectPromise)
{
@@ -121,12 +144,17 @@ public class UpgradeConnection extends AbstractConnection
// We need to gently close first, to allow
// SSL close alerts to be sent by Jetty
if (LOG.isDebugEnabled())
+ {
LOG.debug("Shutting down output {}",endPoint);
+ }
+
endPoint.shutdownOutput();
if (!onlyOutput)
{
if (LOG.isDebugEnabled())
+ {
LOG.debug("Closing {}",endPoint);
+ }
endPoint.close();
}
}
@@ -147,6 +175,12 @@ public class UpgradeConnection extends AbstractConnection
handshakeListener.onHandshakeResponse(response);
}
}
+
+ @Override
+ public ByteBuffer onUpgradeFrom()
+ {
+ return connectPromise.getResponse().getRemainingBuffer();
+ }
@Override
public void onFillable()
@@ -157,20 +191,25 @@ public class UpgradeConnection extends AbstractConnection
}
ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),false);
BufferUtil.clear(buffer);
- boolean readMore = false;
try
{
- readMore = read(buffer);
+ read(buffer);
}
finally
{
bufferPool.release(buffer);
}
- if (readMore)
+ if (state == State.RESPONSE)
{
+ // Continue Reading
fillInterested();
}
+ else if (state == State.UPGRADE)
+ {
+ // Stop Reading, upgrade the connection now
+ upgradeConnection(response);
+ }
}
@Override
@@ -179,27 +218,27 @@ public class UpgradeConnection extends AbstractConnection
super.onOpen();
getExecutor().execute(new SendUpgradeRequest());
}
-
+
@Override
public void onClose()
{
if (LOG.isDebugEnabled())
{
- LOG.warn("Closed connection {}",this);
+ LOG.debug("Closed connection {}",this);
}
super.onClose();
}
-
+
@Override
protected boolean onReadTimeout()
{
if (LOG.isDebugEnabled())
{
- LOG.warn("Timeout on connection {}",this);
+ LOG.debug("Timeout on connection {}",this);
}
-
+
failUpgrade(new IOException("Timeout while performing WebSocket Upgrade"));
-
+
return super.onReadTimeout();
}
@@ -208,9 +247,8 @@ public class UpgradeConnection extends AbstractConnection
*
* @param buffer
* the buffer to fill into from the endpoint
- * @return true if there is more to read, false if reading should stop
*/
- private boolean read(ByteBuffer buffer)
+ private void read(ByteBuffer buffer)
{
EndPoint endPoint = getEndPoint();
try
@@ -220,13 +258,14 @@ public class UpgradeConnection extends AbstractConnection
int filled = endPoint.fill(buffer);
if (filled == 0)
{
- return true;
+ return;
}
else if (filled < 0)
{
LOG.warn("read - EOF Reached");
+ state = State.FAILURE;
failUpgrade(new EOFException("Reading WebSocket Upgrade response"));
- return false;
+ return;
}
else
{
@@ -234,34 +273,32 @@ public class UpgradeConnection extends AbstractConnection
{
LOG.debug("Filled {} bytes - {}",filled,BufferUtil.toDetailString(buffer));
}
- ClientUpgradeResponse resp = (ClientUpgradeResponse)parser.parse(buffer);
- if (resp != null)
+ response = (ClientUpgradeResponse)parser.parse(buffer);
+ if (response != null)
{
// Got a response!
- validateResponse(resp);
- notifyConnect(resp);
- upgradeConnection(resp);
- if (buffer.hasRemaining())
- {
- LOG.debug("Has remaining client bytebuffer of {}",buffer.remaining());
- }
- return false; // do no more reading
+ validateResponse(response);
+ notifyConnect(response);
+ state = State.UPGRADE;
+ return; // do no more reading
}
}
}
}
catch (IOException | ParseException e)
{
+ LOG.ignore(e);
+ state = State.FAILURE;
UpgradeException ue = new UpgradeException(request.getRequestURI(),e);
connectPromise.failed(ue);
disconnect(false);
- return false;
}
catch (UpgradeException e)
{
+ LOG.ignore(e);
+ state = State.FAILURE;
connectPromise.failed(e);
disconnect(false);
- return false;
}
}
@@ -269,7 +306,7 @@ public class UpgradeConnection extends AbstractConnection
{
EndPoint endp = getEndPoint();
Executor executor = getExecutor();
-
+
EventDriver websocket = connectPromise.getDriver();
WebSocketPolicy policy = websocket.getPolicy();
@@ -278,9 +315,10 @@ public class UpgradeConnection extends AbstractConnection
SessionFactory sessionFactory = connectPromise.getClient().getSessionFactory();
WebSocketSession session = sessionFactory.createSession(request.getRequestURI(),websocket,connection);
session.setPolicy(policy);
+ session.setUpgradeRequest(request);
session.setUpgradeResponse(response);
-
- connection.setSession(session);
+ connection.addListener(session);
+ connectPromise.setSession(session);
// Initialize / Negotiate Extensions
ExtensionStack extensionStack = new ExtensionStack(connectPromise.getClient().getExtensionFactory());
@@ -297,13 +335,11 @@ public class UpgradeConnection extends AbstractConnection
session.setOutgoingHandler(extensionStack);
extensionStack.setNextOutgoing(connection);
- session.addBean(extensionStack);
+ session.addManaged(extensionStack);
connectPromise.getClient().addManaged(session);
// Now swap out the connection
- // TODO use endp.upgrade ???
- endp.setConnection(connection);
- connection.onOpen();
+ endp.upgrade(connection);
}
private void validateResponse(ClientUpgradeResponse response)
@@ -311,7 +347,9 @@ public class UpgradeConnection extends AbstractConnection
// Validate Response Status Code
if (response.getStatusCode() != SWITCHING_PROTOCOLS)
{
- throw new UpgradeException(request.getRequestURI(),response.getStatusCode(),"Didn't switch protocols");
+ // TODO: use jetty-http and org.eclipse.jetty.http.HttpStatus for more meaningful exception messages
+ throw new UpgradeException(request.getRequestURI(),response.getStatusCode(),"Didn't switch protocols, expected status <" + SWITCHING_PROTOCOLS
+ + ">, but got <" + response.getStatusCode() + ">");
}
// Validate Connection header
diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientConnection.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientConnection.java
index 4ee106c018..0aecca931f 100644
--- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientConnection.java
+++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientConnection.java
@@ -19,13 +19,10 @@
package org.eclipse.jetty.websocket.client.io;
import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.jetty.io.EndPoint;
-import org.eclipse.jetty.util.log.Log;
-import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.BatchMode;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.WriteCallback;
@@ -33,7 +30,6 @@ import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
import org.eclipse.jetty.websocket.client.masks.Masker;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
-import org.eclipse.jetty.websocket.common.WebSocketSession;
import org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection;
/**
@@ -41,7 +37,6 @@ import org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection;
*/
public class WebSocketClientConnection extends AbstractWebSocketConnection
{
- private static final Logger LOG = Log.getLogger(WebSocketClientConnection.class);
private final ConnectPromise connectPromise;
private final Masker masker;
private final AtomicBoolean opened = new AtomicBoolean(false);
@@ -67,32 +62,14 @@ public class WebSocketClientConnection extends AbstractWebSocketConnection
}
@Override
- public void onClose()
- {
- super.onClose();
- ConnectionManager connectionManager = connectPromise.getClient().getConnectionManager();
- connectionManager.removeSession(getSession());
- }
-
- @Override
public void onOpen()
{
+ super.onOpen();
boolean beenOpened = opened.getAndSet(true);
if (!beenOpened)
{
- WebSocketSession session = getSession();
- ConnectionManager connectionManager = connectPromise.getClient().getConnectionManager();
- connectionManager.addSession(session);
- connectPromise.succeeded(session);
-
- ByteBuffer extraBuf = connectPromise.getResponse().getRemainingBuffer();
- if (extraBuf.hasRemaining())
- {
- LOG.debug("Parsing extra remaining buffer from UpgradeConnection");
- getParser().parse(extraBuf);
- }
+ connectPromise.succeeded();
}
- super.onOpen();
}
/**
diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java
index 15597e3f95..35180c4aca 100644
--- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java
+++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java
@@ -22,11 +22,13 @@ import java.io.IOException;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;
import java.util.concurrent.Executor;
+
import javax.net.ssl.SSLEngine;
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
+import org.eclipse.jetty.io.ManagedSelector;
import org.eclipse.jetty.io.SelectChannelEndPoint;
import org.eclipse.jetty.io.SelectorManager;
import org.eclipse.jetty.io.ssl.SslConnection;
diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/package-info.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/package-info.java
index 22d436634c..6c0087bd55 100644
--- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/package-info.java
+++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/package-info.java
@@ -20,14 +20,15 @@
* Jetty WebSocket Client API
* <p>
* The core class is {@link org.eclipse.jetty.websocket.client.WebSocketClient}, which acts as a central configuration object (for example
- * for {@link org.eclipse.jetty.websocket.client.WebSocketClient#setConnectTimeout(int) connect timeouts}, {@link WebSocketClient#setCookieStore(CookieStore)
- * request cookie store}, etc.) and as a factory for WebSocket {@link org.eclipse.jetty.websocket.api.Session} objects.
+ * for {@link org.eclipse.jetty.websocket.client.WebSocketClient#setConnectTimeout(long)},
+ * {@link org.eclipse.jetty.websocket.client.WebSocketClient#setCookieStore(java.net.CookieStore)},
+ * etc.) and as a factory for WebSocket {@link org.eclipse.jetty.websocket.api.Session} objects.
* <p>
* The <a href="https://tools.ietf.org/html/rfc6455">WebSocket protocol</a> is based on a framing protocol built
* around an upgraded HTTP connection. It is primarily focused on the sending of messages (text or binary), with an
* occasional control frame (close, ping, pong) that this implementation uses.
- * <p />
- * {@link org.eclipse.jetty.websocket.client.WebSocketClient} holds a number of {@link org.eclipse.jetty.websocket.api.Session Sessions}, which in turn
+ * <p>
+ * {@link org.eclipse.jetty.websocket.client.WebSocketClient} holds a number of {@link org.eclipse.jetty.websocket.api.Session}, which in turn
* is used to manage physical vs virtual connection handling (mux extension).
*/
package org.eclipse.jetty.websocket.client;
diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/BadNetworkTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/BadNetworkTest.java
index 4aa4c63067..24b36193a4 100644
--- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/BadNetworkTest.java
+++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/BadNetworkTest.java
@@ -26,7 +26,7 @@ import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
-import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
+import org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.junit.After;
import org.junit.Before;
@@ -82,7 +82,7 @@ public class BadNetworkTest
URI wsUri = server.getWsUri();
Future<Session> future = client.connect(wsocket,wsUri);
- ServerConnection ssocket = server.accept();
+ IBlockheadServerConnection ssocket = server.accept();
ssocket.upgrade();
// Validate that we are connected
@@ -110,7 +110,7 @@ public class BadNetworkTest
URI wsUri = server.getWsUri();
Future<Session> future = client.connect(wsocket,wsUri);
- ServerConnection ssocket = server.accept();
+ IBlockheadServerConnection ssocket = server.accept();
ssocket.upgrade();
// Validate that we are connected
diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientCloseTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientCloseTest.java
index 01ca91b42a..2cbc3ab747 100644
--- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientCloseTest.java
+++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientCloseTest.java
@@ -35,8 +35,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.EofException;
+import org.eclipse.jetty.io.ManagedSelector;
import org.eclipse.jetty.io.SelectChannelEndPoint;
-import org.eclipse.jetty.io.SelectorManager.ManagedSelector;
import org.eclipse.jetty.toolchain.test.EventQueue;
import org.eclipse.jetty.toolchain.test.TestTracker;
import org.eclipse.jetty.util.BufferUtil;
@@ -58,7 +58,7 @@ import org.eclipse.jetty.websocket.common.WebSocketSession;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
-import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
+import org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.RawFrameBuilder;
import org.hamcrest.Matcher;
@@ -187,7 +187,7 @@ public class ClientCloseTest
private BlockheadServer server;
private WebSocketClient client;
- private void confirmConnection(CloseTrackingSocket clientSocket, Future<Session> clientFuture, ServerConnection serverConn) throws Exception
+ private void confirmConnection(CloseTrackingSocket clientSocket, Future<Session> clientFuture, IBlockheadServerConnection serverConns) throws Exception
{
// Wait for client connect on via future
clientFuture.get(500,TimeUnit.MILLISECONDS);
@@ -205,7 +205,7 @@ public class ClientCloseTest
testFut.get(500,TimeUnit.MILLISECONDS);
// Read Frame on server side
- IncomingFramesCapture serverCapture = serverConn.readFrames(1,500,TimeUnit.MILLISECONDS);
+ IncomingFramesCapture serverCapture = serverConns.readFrames(1,500,TimeUnit.MILLISECONDS);
serverCapture.assertNoErrors();
serverCapture.assertFrameCount(1);
WebSocketFrame frame = serverCapture.getFrames().poll();
@@ -213,7 +213,7 @@ public class ClientCloseTest
Assert.assertThat("Server received frame payload",frame.getPayloadAsUTF8(),is(echoMsg));
// Server send echo reply
- serverConn.write(new TextFrame().setPayload(echoMsg));
+ serverConns.write(new TextFrame().setPayload(echoMsg));
// Wait for received echo
clientSocket.messageQueue.awaitEventCount(1,1,TimeUnit.SECONDS);
@@ -231,7 +231,7 @@ public class ClientCloseTest
}
}
- private void confirmServerReceivedCloseFrame(ServerConnection serverConn, int expectedCloseCode, Matcher<String> closeReasonMatcher) throws IOException,
+ private void confirmServerReceivedCloseFrame(IBlockheadServerConnection serverConn, int expectedCloseCode, Matcher<String> closeReasonMatcher) throws IOException,
TimeoutException
{
IncomingFramesCapture serverCapture = serverConn.readFrames(1,500,TimeUnit.MILLISECONDS);
@@ -348,7 +348,7 @@ public class ClientCloseTest
Future<Session> clientConnectFuture = client.connect(clientSocket,server.getWsUri());
// Server accepts connect
- ServerConnection serverConn = server.accept();
+ IBlockheadServerConnection serverConn = server.accept();
serverConn.upgrade();
// client confirms connection via echo
@@ -397,7 +397,7 @@ public class ClientCloseTest
Future<Session> clientConnectFuture = client.connect(clientSocket,server.getWsUri());
// Server accepts connect
- ServerConnection serverConn = server.accept();
+ IBlockheadServerConnection serverConn = server.accept();
serverConn.upgrade();
// client confirms connection via echo
@@ -448,7 +448,7 @@ public class ClientCloseTest
Future<Session> clientConnectFuture = client.connect(clientSocket,server.getWsUri());
// Server accepts connect
- ServerConnection serverConn = server.accept();
+ IBlockheadServerConnection serverConn = server.accept();
serverConn.upgrade();
// client confirms connection via echo
@@ -496,7 +496,7 @@ public class ClientCloseTest
Future<Session> clientConnectFuture = client.connect(clientSocket,server.getWsUri());
// Server accepts connect
- ServerConnection serverConn = server.accept();
+ IBlockheadServerConnection serverConn = server.accept();
serverConn.upgrade();
// client confirms connection via echo
@@ -532,7 +532,7 @@ public class ClientCloseTest
Future<Session> clientConnectFuture = client.connect(clientSocket,server.getWsUri());
// Server accepts connect
- ServerConnection serverConn = server.accept();
+ IBlockheadServerConnection serverConn = server.accept();
serverConn.upgrade();
// client confirms connection via echo
@@ -564,7 +564,7 @@ public class ClientCloseTest
int clientCount = 3;
CloseTrackingSocket clientSockets[] = new CloseTrackingSocket[clientCount];
- ServerConnection serverConns[] = new ServerConnection[clientCount];
+ IBlockheadServerConnection serverConns[] = new IBlockheadServerConnection[clientCount];
// Connect Multiple Clients
for (int i = 0; i < clientCount; i++)
@@ -610,7 +610,7 @@ public class ClientCloseTest
Future<Session> clientConnectFuture = client.connect(clientSocket,server.getWsUri());
// Server accepts connect
- ServerConnection serverConn = server.accept();
+ IBlockheadServerConnection serverConn = server.accept();
serverConn.upgrade();
// client confirms connection via echo
diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientConnectTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientConnectTest.java
index 3801c03457..6f4110ef51 100644
--- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientConnectTest.java
+++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ClientConnectTest.java
@@ -19,6 +19,7 @@
package org.eclipse.jetty.websocket.client;
import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
import java.io.IOException;
import java.net.ConnectException;
@@ -36,7 +37,7 @@ import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.UpgradeException;
import org.eclipse.jetty.websocket.common.AcceptHash;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
-import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
+import org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.junit.After;
import org.junit.Assert;
@@ -111,6 +112,25 @@ public class ClientConnectTest
}
@Test
+ public void testUpgradeRequest() throws Exception
+ {
+ JettyTrackingSocket wsocket = new JettyTrackingSocket();
+
+ URI wsUri = server.getWsUri();
+ Future<Session> future = client.connect(wsocket,wsUri);
+
+ IBlockheadServerConnection connection = server.accept();
+ connection.upgrade();
+
+ Session sess = future.get(500,TimeUnit.MILLISECONDS);
+
+ sess.close();
+
+ assertThat("Connect.UpgradeRequest", wsocket.connectUpgradeRequest, notNullValue());
+ assertThat("Connect.UpgradeResponse", wsocket.connectUpgradeResponse, notNullValue());
+ }
+
+ @Test
public void testBadHandshake() throws Exception
{
JettyTrackingSocket wsocket = new JettyTrackingSocket();
@@ -118,7 +138,7 @@ public class ClientConnectTest
URI wsUri = server.getWsUri();
Future<Session> future = client.connect(wsocket,wsUri);
- ServerConnection connection = server.accept();
+ IBlockheadServerConnection connection = server.accept();
connection.readRequest();
// no upgrade, just fail with a 404 error
connection.respond("HTTP/1.1 404 NOT FOUND\r\n\r\n");
@@ -147,7 +167,7 @@ public class ClientConnectTest
URI wsUri = server.getWsUri();
Future<Session> future = client.connect(wsocket,wsUri);
- ServerConnection connection = server.accept();
+ IBlockheadServerConnection connection = server.accept();
connection.readRequest();
// Send OK to GET but not upgrade
connection.respond("HTTP/1.1 200 OK\r\n\r\n");
@@ -176,7 +196,7 @@ public class ClientConnectTest
URI wsUri = server.getWsUri();
Future<Session> future = client.connect(wsocket,wsUri);
- ServerConnection connection = server.accept();
+ IBlockheadServerConnection connection = server.accept();
List<String> requestLines = connection.readRequestLines();
String key = connection.parseWebSocketKey(requestLines);
@@ -212,7 +232,7 @@ public class ClientConnectTest
URI wsUri = server.getWsUri();
Future<Session> future = client.connect(wsocket,wsUri);
- ServerConnection connection = server.accept();
+ IBlockheadServerConnection connection = server.accept();
List<String> requestLines = connection.readRequestLines();
String key = connection.parseWebSocketKey(requestLines);
@@ -248,7 +268,7 @@ public class ClientConnectTest
URI wsUri = server.getWsUri();
Future<Session> future = client.connect(wsocket,wsUri);
- ServerConnection connection = server.accept();
+ IBlockheadServerConnection connection = server.accept();
List<String> requestLines = connection.readRequestLines();
String key = connection.parseWebSocketKey(requestLines);
@@ -284,7 +304,7 @@ public class ClientConnectTest
URI wsUri = server.getWsUri();
Future<Session> future = client.connect(wsocket,wsUri);
- ServerConnection connection = server.accept();
+ IBlockheadServerConnection connection = server.accept();
connection.readRequest();
// Upgrade badly
connection.respond("HTTP/1.1 101 Upgrade\r\n" + "Sec-WebSocket-Accept: rubbish\r\n" + "\r\n");
@@ -378,7 +398,7 @@ public class ClientConnectTest
URI wsUri = server.getWsUri();
Future<Session> future = client.connect(wsocket,wsUri);
- ServerConnection ssocket = server.accept();
+ IBlockheadServerConnection ssocket = server.accept();
Assert.assertNotNull(ssocket);
// Intentionally don't upgrade
// ssocket.upgrade();
diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/CookieTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/CookieTest.java
index a68c245057..02843ea352 100644
--- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/CookieTest.java
+++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/CookieTest.java
@@ -37,7 +37,7 @@ import org.eclipse.jetty.websocket.api.WebSocketAdapter;
import org.eclipse.jetty.websocket.api.util.QuoteUtil;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
-import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
+import org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -119,7 +119,7 @@ public class CookieTest
Future<Session> clientConnectFuture = client.connect(clientSocket,server.getWsUri());
// Server accepts connect
- ServerConnection serverConn = server.accept();
+ IBlockheadServerConnection serverConn = server.accept();
// client confirms upgrade and receipt of frame
String serverCookies = confirmClientUpgradeAndCookies(clientSocket,clientConnectFuture,serverConn);
@@ -144,7 +144,7 @@ public class CookieTest
Future<Session> clientConnectFuture = client.connect(clientSocket,server.getWsUri(),request);
// Server accepts connect
- ServerConnection serverConn = server.accept();
+ IBlockheadServerConnection serverConn = server.accept();
// client confirms upgrade and receipt of frame
String serverCookies = confirmClientUpgradeAndCookies(clientSocket,clientConnectFuture,serverConn);
@@ -152,7 +152,7 @@ public class CookieTest
Assert.assertThat("Cookies seen at server side",serverCookies,containsString("hello=\"world\""));
}
- private String confirmClientUpgradeAndCookies(CookieTrackingSocket clientSocket, Future<Session> clientConnectFuture, ServerConnection serverConn)
+ private String confirmClientUpgradeAndCookies(CookieTrackingSocket clientSocket, Future<Session> clientConnectFuture, IBlockheadServerConnection serverConn)
throws Exception
{
// Server upgrades
diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/JettyTrackingSocket.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/JettyTrackingSocket.java
index cbb5e59786..bb14d87be2 100644
--- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/JettyTrackingSocket.java
+++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/JettyTrackingSocket.java
@@ -30,6 +30,8 @@ import org.eclipse.jetty.toolchain.test.EventQueue;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.Session;
+import org.eclipse.jetty.websocket.api.UpgradeRequest;
+import org.eclipse.jetty.websocket.api.UpgradeResponse;
import org.eclipse.jetty.websocket.api.WebSocketAdapter;
import org.junit.Assert;
@@ -42,6 +44,8 @@ public class JettyTrackingSocket extends WebSocketAdapter
public int closeCode = -1;
public Exchanger<String> messageExchanger;
+ public UpgradeRequest connectUpgradeRequest;
+ public UpgradeResponse connectUpgradeResponse;
public StringBuilder closeMessage = new StringBuilder();
public CountDownLatch openLatch = new CountDownLatch(1);
public CountDownLatch closeLatch = new CountDownLatch(1);
@@ -124,6 +128,8 @@ public class JettyTrackingSocket extends WebSocketAdapter
public void onWebSocketConnect(Session session)
{
super.onWebSocketConnect(session);
+ connectUpgradeRequest = session.getUpgradeRequest();
+ connectUpgradeResponse = session.getUpgradeResponse();
openLatch.countDown();
}
diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerReadThread.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerReadThread.java
index 6bfcd399bb..f09f1c13fb 100644
--- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerReadThread.java
+++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerReadThread.java
@@ -18,6 +18,8 @@
package org.eclipse.jetty.websocket.client;
+import static org.hamcrest.Matchers.*;
+
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Queue;
@@ -32,24 +34,22 @@ import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.common.CloseInfo;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
-import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
+import org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection;
import org.junit.Assert;
-import static org.hamcrest.Matchers.is;
-
public class ServerReadThread extends Thread
{
private static final int BUFFER_SIZE = 8192;
private static final Logger LOG = Log.getLogger(ServerReadThread.class);
- private final ServerConnection conn;
+ private final IBlockheadServerConnection conn;
private boolean active = true;
private int slowness = -1; // disabled is default
private final AtomicInteger frameCount = new AtomicInteger();
private final CountDownLatch expectedMessageCount;
- public ServerReadThread(ServerConnection conn, int expectedMessages)
+ public ServerReadThread(IBlockheadServerConnection sconnection, int expectedMessages)
{
- this.conn = conn;
+ this.conn = sconnection;
this.expectedMessageCount = new CountDownLatch(expectedMessages);
}
diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerWriteThread.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerWriteThread.java
index b9f02ee9ab..9f7647e64e 100644
--- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerWriteThread.java
+++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerWriteThread.java
@@ -25,17 +25,17 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
-import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
+import org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection;
public class ServerWriteThread extends Thread
{
private static final Logger LOG = Log.getLogger(ServerWriteThread.class);
- private final ServerConnection conn;
+ private final IBlockheadServerConnection conn;
private int slowness = -1;
private int messageCount = 100;
private String message = "Hello";
- public ServerWriteThread(ServerConnection conn)
+ public ServerWriteThread(IBlockheadServerConnection conn)
{
this.conn = conn;
}
diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/SessionTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/SessionTest.java
index 011dc0b1ae..c1b972995e 100644
--- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/SessionTest.java
+++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/SessionTest.java
@@ -18,7 +18,10 @@
package org.eclipse.jetty.websocket.client;
+import static org.hamcrest.Matchers.*;
+
import java.net.URI;
+import java.util.Collection;
import java.util.Set;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -28,15 +31,12 @@ import org.eclipse.jetty.websocket.api.RemoteEndpoint;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.common.WebSocketSession;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
-import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
+import org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-
public class SessionTest
{
private BlockheadServer server;
@@ -70,7 +70,7 @@ public class SessionTest
request.setSubProtocols("echo");
Future<Session> future = client.connect(cliSock,wsUri,request);
- final ServerConnection srvSock = server.accept();
+ final IBlockheadServerConnection srvSock = server.accept();
srvSock.upgrade();
Session sess = future.get(500,TimeUnit.MILLISECONDS);
@@ -82,18 +82,21 @@ public class SessionTest
cliSock.assertWasOpened();
cliSock.assertNotClosed();
- Assert.assertThat("client.connectionManager.sessions.size",client.getConnectionManager().getSessions().size(),is(1));
+ Collection<WebSocketSession> sessions = client.getBeans(WebSocketSession.class);
+ Assert.assertThat("client.connectionManager.sessions.size",sessions.size(),is(1));
RemoteEndpoint remote = cliSock.getSession().getRemote();
remote.sendStringByFuture("Hello World!");
if (remote.getBatchMode() == BatchMode.ON)
+ {
remote.flush();
+ }
srvSock.echoMessage(1,500,TimeUnit.MILLISECONDS);
// wait for response from server
cliSock.waitForMessage(500,TimeUnit.MILLISECONDS);
Set<WebSocketSession> open = client.getOpenSessions();
- Assert.assertThat("Open Sessions.size", open.size(), is(1));
+ Assert.assertThat("(Before Close) Open Sessions.size", open.size(), is(1));
cliSock.assertMessage("Hello World!");
cliSock.close();
@@ -101,7 +104,7 @@ public class SessionTest
cliSock.waitForClose(500,TimeUnit.MILLISECONDS);
open = client.getOpenSessions();
- Assert.assertThat("Open Sessions.size", open.size(), is(0));
+ Assert.assertThat("(After Close) Open Sessions.size", open.size(), is(0));
}
finally
{
diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/SlowClientTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/SlowClientTest.java
index 564759742c..ef23cd1151 100644
--- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/SlowClientTest.java
+++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/SlowClientTest.java
@@ -18,6 +18,8 @@
package org.eclipse.jetty.websocket.client;
+import static org.hamcrest.Matchers.*;
+
import java.net.URI;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -27,15 +29,13 @@ import org.eclipse.jetty.toolchain.test.annotation.Slow;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
-import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
+import org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import static org.hamcrest.Matchers.is;
-
public class SlowClientTest
{
@Rule
@@ -81,7 +81,7 @@ public class SlowClientTest
URI wsUri = server.getWsUri();
Future<Session> future = client.connect(tsocket, wsUri);
- ServerConnection sconnection = server.accept();
+ IBlockheadServerConnection sconnection = server.accept();
sconnection.setSoTimeout(60000);
sconnection.upgrade();
diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/SlowServerTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/SlowServerTest.java
index c6b426a21d..bd936decfc 100644
--- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/SlowServerTest.java
+++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/SlowServerTest.java
@@ -18,6 +18,8 @@
package org.eclipse.jetty.websocket.client;
+import static org.hamcrest.Matchers.*;
+
import java.net.URI;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -28,15 +30,13 @@ import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.client.masks.ZeroMasker;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
-import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
+import org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
-import static org.hamcrest.Matchers.is;
-
public class SlowServerTest
{
@Rule
@@ -83,7 +83,7 @@ public class SlowServerTest
URI wsUri = server.getWsUri();
Future<Session> future = client.connect(tsocket,wsUri);
- ServerConnection sconnection = server.accept();
+ IBlockheadServerConnection sconnection = server.accept();
sconnection.setSoTimeout(60000);
sconnection.upgrade();
@@ -130,7 +130,7 @@ public class SlowServerTest
URI wsUri = server.getWsUri();
Future<Session> clientConnectFuture = client.connect(clientSocket,wsUri);
- ServerConnection serverConn = server.accept();
+ IBlockheadServerConnection serverConn = server.accept();
serverConn.setSoTimeout(60000);
serverConn.upgrade();
diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/TomcatServerQuirksTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/TomcatServerQuirksTest.java
index a3e2ae954f..c81dd2f82c 100644
--- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/TomcatServerQuirksTest.java
+++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/TomcatServerQuirksTest.java
@@ -28,7 +28,7 @@ import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.WebSocketAdapter;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
-import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
+import org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection;
import org.junit.Assert;
import org.junit.Test;
@@ -66,7 +66,7 @@ public class TomcatServerQuirksTest
* <li><a href="https://issues.apache.org/bugzilla/show_bug.cgi?id=54067">Apache Tomcat Bug #54067</a></li>
* </ul>
*
- * @throws IOException
+ * @throws Exception on test failure
*/
@Test
public void testTomcat7_0_32_WithTransferEncoding() throws Exception
@@ -91,7 +91,7 @@ public class TomcatServerQuirksTest
client.connect(websocket,wsURI);
// Accept incoming connection
- ServerConnection socket = server.accept();
+ IBlockheadServerConnection socket = server.accept();
socket.setSoTimeout(2000); // timeout
// Issue upgrade
@@ -113,8 +113,7 @@ public class TomcatServerQuirksTest
serverFrame.put((byte)(payload.length & 0xFF)); // second length byte
serverFrame.put(payload);
BufferUtil.flipToFlush(serverFrame,0);
- byte buf[] = BufferUtil.toArray(serverFrame);
- socket.write(buf,0,buf.length);
+ socket.write(serverFrame);
socket.flush();
Assert.assertTrue(websocket.dataLatch.await(1000,TimeUnit.SECONDS));
diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/WebSocketClientTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/WebSocketClientTest.java
index 56975a0192..c2653eda34 100644
--- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/WebSocketClientTest.java
+++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/WebSocketClientTest.java
@@ -18,9 +18,12 @@
package org.eclipse.jetty.websocket.client;
+import static org.hamcrest.Matchers.*;
+
import java.net.InetSocketAddress;
import java.net.URI;
import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Future;
@@ -32,21 +35,17 @@ import org.eclipse.jetty.websocket.api.BatchMode;
import org.eclipse.jetty.websocket.api.RemoteEndpoint;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.UpgradeRequest;
+import org.eclipse.jetty.websocket.common.WebSocketSession;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.io.FutureWriteCallback;
import org.eclipse.jetty.websocket.common.test.BlockheadServer;
-import org.eclipse.jetty.websocket.common.test.BlockheadServer.ServerConnection;
+import org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
-
@RunWith(AdvancedRunner.class)
public class WebSocketClientTest
{
@@ -106,7 +105,7 @@ public class WebSocketClientTest
request.setSubProtocols("echo");
Future<Session> future = client.connect(cliSock,wsUri,request);
- final ServerConnection srvSock = server.accept();
+ final IBlockheadServerConnection srvSock = server.accept();
srvSock.upgrade();
Session sess = future.get(500,TimeUnit.MILLISECONDS);
@@ -118,7 +117,8 @@ public class WebSocketClientTest
cliSock.assertWasOpened();
cliSock.assertNotClosed();
- Assert.assertThat("client.connectionManager.sessions.size",client.getConnectionManager().getSessions().size(),is(1));
+ Collection<WebSocketSession> sessions = client.getBeans(WebSocketSession.class);
+ Assert.assertThat("client.connectionManager.sessions.size",sessions.size(),is(1));
RemoteEndpoint remote = cliSock.getSession().getRemote();
remote.sendStringByFuture("Hello World!");
@@ -152,7 +152,7 @@ public class WebSocketClientTest
request.setSubProtocols("echo");
Future<Session> future = client.connect(cliSock,wsUri,request);
- final ServerConnection srvSock = server.accept();
+ final IBlockheadServerConnection srvSock = server.accept();
srvSock.upgrade();
Session sess = future.get(500,TimeUnit.MILLISECONDS);
@@ -164,7 +164,8 @@ public class WebSocketClientTest
cliSock.assertWasOpened();
cliSock.assertNotClosed();
- Assert.assertThat("client.connectionManager.sessions.size",client.getConnectionManager().getSessions().size(),is(1));
+ Collection<WebSocketSession> sessions = client.getBeans(WebSocketSession.class);
+ Assert.assertThat("client.connectionManager.sessions.size",sessions.size(),is(1));
FutureWriteCallback callback = new FutureWriteCallback();
@@ -188,7 +189,7 @@ public class WebSocketClientTest
Future<Session> future = client.connect(wsocket,server.getWsUri());
// Server
- final ServerConnection srvSock = server.accept();
+ final IBlockheadServerConnection srvSock = server.accept();
srvSock.upgrade();
// Validate connect
@@ -226,7 +227,7 @@ public class WebSocketClientTest
URI wsUri = server.getWsUri();
Future<Session> future = fact.connect(wsocket,wsUri);
- ServerConnection ssocket = server.accept();
+ IBlockheadServerConnection ssocket = server.accept();
ssocket.upgrade();
future.get(500,TimeUnit.MILLISECONDS);
@@ -266,7 +267,7 @@ public class WebSocketClientTest
URI wsUri = server.getWsUri();
Future<Session> future = factSmall.connect(wsocket,wsUri);
- ServerConnection ssocket = server.accept();
+ IBlockheadServerConnection ssocket = server.accept();
ssocket.upgrade();
future.get(500,TimeUnit.MILLISECONDS);
@@ -304,7 +305,7 @@ public class WebSocketClientTest
URI wsUri = server.getWsUri();
Future<Session> future = client.connect(wsocket,wsUri);
- ServerConnection ssocket = server.accept();
+ IBlockheadServerConnection ssocket = server.accept();
ssocket.upgrade();
wsocket.awaitConnect(1,TimeUnit.SECONDS);
@@ -346,7 +347,7 @@ public class WebSocketClientTest
URI wsUri = server.getWsUri().resolve("/test?snack=cashews&amount=handful&brand=off");
Future<Session> future = fact.connect(wsocket,wsUri);
- ServerConnection ssocket = server.accept();
+ IBlockheadServerConnection ssocket = server.accept();
ssocket.upgrade();
future.get(500,TimeUnit.MILLISECONDS);
diff --git a/jetty-websocket/websocket-common/pom.xml b/jetty-websocket/websocket-common/pom.xml
index 56c18599ff..e8bcacac26 100644
--- a/jetty-websocket/websocket-common/pom.xml
+++ b/jetty-websocket/websocket-common/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-parent</artifactId>
- <version>9.2.15-SNAPSHOT</version>
+ <version>9.3.7-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/BlockingWriteCallback.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/BlockingWriteCallback.java
index 0909a3fde9..7e0e320f66 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/BlockingWriteCallback.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/BlockingWriteCallback.java
@@ -24,9 +24,8 @@ import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.SharedBlockingCallback;
import org.eclipse.jetty.websocket.api.WriteCallback;
-
-/* ------------------------------------------------------------ */
-/** extend a SharedlBlockingCallback to an websocket WriteCallback
+/**
+ * Extends a {@link SharedBlockingCallback} to a WebSocket {@link WriteCallback}
*/
public class BlockingWriteCallback extends SharedBlockingCallback
{
@@ -39,11 +38,11 @@ public class BlockingWriteCallback extends SharedBlockingCallback
return new WriteBlocker(acquire());
}
- public static class WriteBlocker implements WriteCallback, Callback, AutoCloseable
+ public static class WriteBlocker implements WriteCallback, Callback.NonBlocking, AutoCloseable
{
- Blocker blocker;
+ private final Blocker blocker;
- WriteBlocker(Blocker blocker)
+ protected WriteBlocker(Blocker blocker)
{
this.blocker=blocker;
}
@@ -73,7 +72,7 @@ public class BlockingWriteCallback extends SharedBlockingCallback
}
@Override
- public void close() throws IOException
+ public void close()
{
blocker.close();
}
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/ConnectionState.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/ConnectionState.java
index ae94f7ea2e..95293ced83 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/ConnectionState.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/ConnectionState.java
@@ -18,6 +18,9 @@
package org.eclipse.jetty.websocket.common;
+import org.eclipse.jetty.websocket.common.io.IOState;
+import org.eclipse.jetty.websocket.common.io.IOState.ConnectionStateListener;
+
/**
* Connection states as outlined in <a href="https://tools.ietf.org/html/rfc6455">RFC6455</a>.
*/
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/LogicalConnection.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/LogicalConnection.java
index df0dfb3d96..ebbd2ca2da 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/LogicalConnection.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/LogicalConnection.java
@@ -22,6 +22,7 @@ import java.net.InetSocketAddress;
import java.util.concurrent.Executor;
import org.eclipse.jetty.io.ByteBufferPool;
+import org.eclipse.jetty.websocket.api.StatusCode;
import org.eclipse.jetty.websocket.api.SuspendToken;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
@@ -60,11 +61,13 @@ public interface LogicalConnection extends OutgoingFrames, SuspendToken
/**
* Get the ByteBufferPool in use by the connection
+ * @return the buffer pool
*/
ByteBufferPool getBufferPool();
/**
* Get the Executor used by this connection.
+ * @return the executor
*/
Executor getExecutor();
@@ -113,13 +116,6 @@ public interface LogicalConnection extends OutgoingFrames, SuspendToken
InetSocketAddress getRemoteAddress();
/**
- * Get the Session for this connection
- *
- * @return the Session for this connection
- */
- WebSocketSession getSession();
-
- /**
* Test if logical connection is still open
*
* @return true if connection is open
@@ -155,15 +151,8 @@ public interface LogicalConnection extends OutgoingFrames, SuspendToken
void setNextIncomingFrames(IncomingFrames incoming);
/**
- * Set the session associated with this connection
- *
- * @param session
- * the session
- */
- void setSession(WebSocketSession session);
-
- /**
* Suspend a the incoming read events on the connection.
+ * @return the suspend token
*/
SuspendToken suspend();
}
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/OpCode.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/OpCode.java
index a4f5018df1..19d5df5e04 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/OpCode.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/OpCode.java
@@ -99,7 +99,8 @@ public final class OpCode
return "CONTINUATION";
case TEXT:
return "TEXT";
- case BINARY: return "BINARY";
+ case BINARY:
+ return "BINARY";
case CLOSE:
return "CLOSE";
case PING:
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Parser.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Parser.java
index a9a2c18f7f..74d50d1d85 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Parser.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Parser.java
@@ -248,8 +248,6 @@ public class Parser
}
try
{
- // TODO: create DebugBuffer
-
// parse through all the frames in the buffer
while (parseFrame(buffer))
{
@@ -332,9 +330,9 @@ public class Parser
policy.getBehavior(),
OpCode.name(opcode),
fin,
- (isRsv1InUse()?'1':'.'),
- (isRsv2InUse()?'1':'.'),
- (isRsv3InUse()?'1':'.'));
+ (((b & 0x40) != 0)?'1':'.'),
+ (((b & 0x20) != 0)?'1':'.'),
+ (((b & 0x10) != 0)?'1':'.'));
// base framing flags
switch(opcode)
@@ -653,7 +651,7 @@ public class Parser
builder.append(",c=").append(cursor);
builder.append(",len=").append(payloadLength);
builder.append(",f=").append(frame);
- builder.append(",p=").append(policy);
+ // builder.append(",p=").append(policy);
builder.append("]");
return builder.toString();
}
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketFrame.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketFrame.java
index be64a68086..ad61202b1a 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketFrame.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketFrame.java
@@ -96,7 +96,6 @@ public abstract class WebSocketFrame implements Frame
/**
* Combined FIN + RSV1 + RSV2 + RSV3 + OpCode byte.
- * <p>
*
* <pre>
* 1000_0000 (0x80) = fin
@@ -119,6 +118,7 @@ public abstract class WebSocketFrame implements Frame
/**
* Construct form opcode
+ * @param opcode the opcode the frame is based on
*/
protected WebSocketFrame(byte opcode)
{
@@ -341,6 +341,7 @@ public abstract class WebSocketFrame implements Frame
*
* @param buf
* the bytebuffer to set
+ * @return the frame itself
*/
public WebSocketFrame setPayload(ByteBuffer buf)
{
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java
index e0e2c91d08..7e4bb330c4 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSession.java
@@ -24,16 +24,20 @@ import java.net.URI;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.Executor;
import org.eclipse.jetty.io.ByteBufferPool;
+import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
+import org.eclipse.jetty.util.thread.ThreadClassLoaderScope;
import org.eclipse.jetty.websocket.api.BatchMode;
+import org.eclipse.jetty.websocket.api.CloseException;
import org.eclipse.jetty.websocket.api.CloseStatus;
import org.eclipse.jetty.websocket.api.RemoteEndpoint;
import org.eclipse.jetty.websocket.api.Session;
@@ -51,14 +55,18 @@ import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
import org.eclipse.jetty.websocket.common.events.EventDriver;
import org.eclipse.jetty.websocket.common.io.IOState;
import org.eclipse.jetty.websocket.common.io.IOState.ConnectionStateListener;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketSessionScope;
@ManagedObject("A Jetty WebSocket Session")
-public class WebSocketSession extends ContainerLifeCycle implements Session, IncomingFrames, ConnectionStateListener
+public class WebSocketSession extends ContainerLifeCycle implements Session, WebSocketSessionScope, IncomingFrames, Connection.Listener, ConnectionStateListener
{
private static final Logger LOG = Log.getLogger(WebSocketSession.class);
+ private static final Logger LOG_OPEN = Log.getLogger(WebSocketSession.class.getName() + "_OPEN");
+ private final WebSocketContainerScope containerScope;
private final URI requestURI;
- private final EventDriver websocket;
private final LogicalConnection connection;
+ private final EventDriver websocket;
private final SessionListener[] sessionListeners;
private final Executor executor;
private ClassLoader classLoader;
@@ -71,16 +79,14 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
private WebSocketPolicy policy;
private UpgradeRequest upgradeRequest;
private UpgradeResponse upgradeResponse;
- private BatchMode batchMode = BatchMode.AUTO;
- public WebSocketSession(URI requestURI, EventDriver websocket, LogicalConnection connection, SessionListener... sessionListeners)
+ public WebSocketSession(WebSocketContainerScope containerScope, URI requestURI, EventDriver websocket, LogicalConnection connection, SessionListener... sessionListeners)
{
- if (requestURI == null)
- {
- throw new RuntimeException("Request URI cannot be null");
- }
+ Objects.requireNonNull(containerScope,"Container Scope cannot be null");
+ Objects.requireNonNull(requestURI,"Request URI cannot be null");
this.classLoader = Thread.currentThread().getContextClassLoader();
+ this.containerScope = containerScope;
this.requestURI = requestURI;
this.websocket = websocket;
this.connection = connection;
@@ -89,6 +95,9 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
this.outgoingHandler = connection;
this.incomingHandler = websocket;
this.connection.getIOState().addListener(this);
+
+ addBean(this.connection);
+ addBean(this.websocket);
}
@Override
@@ -125,7 +134,36 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
{
executor.execute(runnable);
}
+
+ @Override
+ protected void doStart() throws Exception
+ {
+ if(LOG.isDebugEnabled())
+ LOG.debug("starting - {}",this);
+ super.doStart();
+ }
+
+ @Override
+ protected void doStop() throws Exception
+ {
+ if(LOG.isDebugEnabled())
+ LOG.debug("stopping - {}",this);
+
+ if (getConnection() != null)
+ {
+ try
+ {
+ getConnection().close(StatusCode.SHUTDOWN,"Shutdown");
+ }
+ catch (Throwable t)
+ {
+ LOG.debug("During Connection Shutdown",t);
+ }
+ }
+ super.doStop();
+ }
+
@Override
public void dump(Appendable out, String indent) throws IOException
{
@@ -196,6 +234,12 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
return connection;
}
+ @Override
+ public WebSocketContainerScope getContainerScope()
+ {
+ return this.containerScope;
+ }
+
public ExtensionFactory getExtensionFactory()
{
return extensionFactory;
@@ -243,12 +287,16 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
@Override
public RemoteEndpoint getRemote()
{
- if (connection.getIOState().isOutputAvailable())
+ if(LOG_OPEN.isDebugEnabled())
+ LOG_OPEN.debug("[{}] {}.getRemote()",policy.getBehavior(),this.getClass().getSimpleName());
+ ConnectionState state = connection.getIOState().getConnectionState();
+
+ if ((state == ConnectionState.OPEN) || (state == ConnectionState.CONNECTED))
{
return remote;
}
- throw new WebSocketException("RemoteEndpoint unavailable, outgoing connection not open");
+ throw new WebSocketException("RemoteEndpoint unavailable, current state [" + state + "], expecting [OPEN or CONNECTED]");
}
@Override
@@ -273,6 +321,13 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
{
return this.upgradeResponse;
}
+
+
+ @Override
+ public WebSocketSession getWebSocketSession()
+ {
+ return this;
+ }
@Override
public int hashCode()
@@ -302,10 +357,19 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
@Override
public void incomingFrame(Frame frame)
{
- if (connection.getIOState().isInputAvailable())
+ ClassLoader old = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ if (connection.getIOState().isInputAvailable())
+ {
+ // Forward Frames Through Extension List
+ incomingHandler.incomingFrame(frame);
+ }
+ }
+ finally
{
- // Forward Frames Through Extension List
- incomingHandler.incomingFrame(frame);
+ Thread.currentThread().setContextClassLoader(old);
}
}
@@ -345,6 +409,19 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
{
incomingError(cause);
}
+
+ @Override
+ public void onClosed(Connection connection)
+ {
+ }
+
+ @Override
+ public void onOpened(Connection connection)
+ {
+ if(LOG_OPEN.isDebugEnabled())
+ LOG_OPEN.debug("[{}] {}.onOpened()",policy.getBehavior(),this.getClass().getSimpleName());
+ open();
+ }
@SuppressWarnings("incomplete-switch")
@Override
@@ -353,6 +430,11 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
switch (state)
{
case CLOSED:
+ IOState ioState = this.connection.getIOState();
+ CloseInfo close = ioState.getCloseInfo();
+ // confirmed close of local endpoint
+ notifyClose(close.getStatusCode(),close.getReason());
+
// notify session listeners
for (SessionListener listener : sessionListeners)
{
@@ -367,17 +449,15 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
LOG.ignore(t);
}
}
- IOState ioState = this.connection.getIOState();
- CloseInfo close = ioState.getCloseInfo();
- // confirmed close of local endpoint
- notifyClose(close.getStatusCode(),close.getReason());
break;
- case OPEN:
+ case CONNECTED:
// notify session listeners
for (SessionListener listener : sessionListeners)
{
try
{
+ if (LOG.isDebugEnabled())
+ LOG.debug("{}.onSessionOpen()", listener.getClass().getSimpleName());
listener.onSessionOpened(this);
}
catch (Throwable t)
@@ -388,34 +468,31 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
break;
}
}
-
+
/**
* Open/Activate the session
*/
public void open()
{
+ if(LOG_OPEN.isDebugEnabled())
+ LOG_OPEN.debug("[{}] {}.open()",policy.getBehavior(),this.getClass().getSimpleName());
+
if (remote != null)
{
// already opened
return;
}
- ClassLoader old = Thread.currentThread().getContextClassLoader();
- try
+ try(ThreadClassLoaderScope scope = new ThreadClassLoaderScope(classLoader))
{
- Thread.currentThread().setContextClassLoader(classLoader);
-
// Upgrade success
connection.getIOState().onConnected();
-
+
// Connect remote
- BatchMode endpointBatchMode = websocket.getBatchMode();
- if (endpointBatchMode == null)
- {
- endpointBatchMode = this.getBatchMode();
- }
- remote = new WebSocketRemoteEndpoint(connection,outgoingHandler,endpointBatchMode);
-
+ remote = new WebSocketRemoteEndpoint(connection,outgoingHandler,getBatchMode());
+ if(LOG_OPEN.isDebugEnabled())
+ LOG_OPEN.debug("[{}] {}.open() remote={}",policy.getBehavior(),this.getClass().getSimpleName(),remote);
+
// Open WebSocket
websocket.openSession(this);
@@ -427,8 +504,14 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
LOG.debug("open -> {}",dump());
}
}
+ catch (CloseException ce)
+ {
+ LOG.warn(ce);
+ close(ce.getStatusCode(),ce.getMessage());
+ }
catch (Throwable t)
{
+ LOG.warn(t);
// Exception on end-user WS-Endpoint.
// Fast-fail & close connection with reason.
int statusCode = StatusCode.SERVER_ERROR;
@@ -436,15 +519,10 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
{
statusCode = StatusCode.POLICY_VIOLATION;
}
-
close(statusCode,t.getMessage());
}
- finally
- {
- Thread.currentThread().setContextClassLoader(old);
- }
}
-
+
public void setExtensionFactory(ExtensionFactory extensionFactory)
{
this.extensionFactory = extensionFactory;
@@ -503,20 +581,11 @@ public class WebSocketSession extends ContainerLifeCycle implements Session, Inc
}
/**
- * @return the batching mode default for RemoteEndpoint behavior
+ * @return the default (initial) value for the batching mode.
*/
public BatchMode getBatchMode()
{
- return batchMode;
- }
-
- /**
- * Set the batch mode default for the RemoteEndpoint behavior.
- * @param mode the batching mode.
- */
- public void setBatchMode(BatchMode mode)
- {
- this.batchMode = mode;
+ return BatchMode.AUTO;
}
@Override
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSessionFactory.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSessionFactory.java
index 24887cfed4..1f9b026800 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSessionFactory.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketSessionFactory.java
@@ -23,18 +23,35 @@ import java.net.URI;
import org.eclipse.jetty.websocket.common.events.EventDriver;
import org.eclipse.jetty.websocket.common.events.JettyAnnotatedEventDriver;
import org.eclipse.jetty.websocket.common.events.JettyListenerEventDriver;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
/**
* Default Session factory, creating WebSocketSession objects.
*/
public class WebSocketSessionFactory implements SessionFactory
{
+ private final WebSocketContainerScope containerScope;
private final SessionListener[] listeners;
- public WebSocketSessionFactory(SessionListener... sessionListeners)
+ public WebSocketSessionFactory(WebSocketContainerScope containerScope, SessionListener... sessionListeners)
{
- listeners = sessionListeners;
- }
+ this.containerScope = containerScope;
+ if ((sessionListeners != null) && (sessionListeners.length > 0))
+ {
+ this.listeners = sessionListeners;
+ }
+ else
+ {
+ if (this.containerScope instanceof SessionListener)
+ {
+ this.listeners = new SessionListener[] { (SessionListener)containerScope };
+ }
+ else
+ {
+ this.listeners = new SessionListener[0];
+ }
+ }
+ }
@Override
public boolean supports(EventDriver websocket)
@@ -45,6 +62,6 @@ public class WebSocketSessionFactory implements SessionFactory
@Override
public WebSocketSession createSession(URI requestURI, EventDriver websocket, LogicalConnection connection)
{
- return new WebSocketSession(requestURI,websocket,connection,listeners);
+ return new WebSocketSession(containerScope, requestURI,websocket,connection,listeners);
}
}
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java
index df26e7e8f4..8ccce72d8f 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java
@@ -23,6 +23,7 @@ import java.nio.ByteBuffer;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.Utf8Appendable.NotUtf8Exception;
+import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.BatchMode;
@@ -40,11 +41,11 @@ import org.eclipse.jetty.websocket.common.message.MessageAppender;
/**
* EventDriver is the main interface between the User's WebSocket POJO and the internal jetty implementation of WebSocket.
*/
-public abstract class AbstractEventDriver implements IncomingFrames, EventDriver
+public abstract class AbstractEventDriver extends AbstractLifeCycle implements IncomingFrames, EventDriver
{
private static final Logger LOG = Log.getLogger(AbstractEventDriver.class);
protected final Logger TARGET_LOG;
- protected final WebSocketPolicy policy;
+ protected WebSocketPolicy policy;
protected final Object websocket;
protected WebSocketSession session;
protected MessageAppender activeMessage;
@@ -222,6 +223,7 @@ public abstract class AbstractEventDriver implements IncomingFrames, EventDriver
if (LOG.isDebugEnabled())
LOG.debug("openSession({})",session);
this.session = session;
+ this.session.getContainerScope().getObjectFactory().decorate(this.websocket);
try
{
this.onConnect();
@@ -232,6 +234,12 @@ public abstract class AbstractEventDriver implements IncomingFrames, EventDriver
throw t;
}
}
+
+ @Override
+ protected void doStop() throws Exception
+ {
+ session = null;
+ }
protected void terminateConnection(int statusCode, String rawreason)
{
@@ -244,6 +252,12 @@ public abstract class AbstractEventDriver implements IncomingFrames, EventDriver
{
TARGET_LOG.warn("Unhandled Error (closing connection)",t);
onError(t);
+
+ if (t instanceof CloseException)
+ {
+ terminateConnection(((CloseException)t).getStatusCode(),t.getClass().getSimpleName());
+ return;
+ }
// Unhandled Error, close the connection.
switch (policy.getBehavior())
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/EventDriverFactory.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/EventDriverFactory.java
index fa33843c80..352115e945 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/EventDriverFactory.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/EventDriverFactory.java
@@ -24,7 +24,9 @@ import java.util.List;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.InvalidWebSocketException;
+import org.eclipse.jetty.websocket.api.WebSocketListener;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
+import org.eclipse.jetty.websocket.api.annotations.WebSocket;
/**
* Create EventDriver implementations.
@@ -99,7 +101,7 @@ public class EventDriverFactory
* Wrap the given WebSocket object instance in a suitable EventDriver
*
* @param websocket
- * the websocket instance to wrap. Must either implement {@link WebSocketListener} or be annotated with {@link WebSocket &#064WebSocket}
+ * the websocket instance to wrap. Must either implement {@link WebSocketListener} or be annotated with {@link WebSocket &#064;WebSocket}
* @return appropriate EventDriver for this websocket instance.
*/
public EventDriver wrap(Object websocket)
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerEventDriver.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerEventDriver.java
index 376a1ce96b..9d5e8a534c 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerEventDriver.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerEventDriver.java
@@ -25,12 +25,19 @@ import java.nio.ByteBuffer;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
+import org.eclipse.jetty.websocket.api.WebSocketConnectionListener;
+import org.eclipse.jetty.websocket.api.WebSocketFrameListener;
import org.eclipse.jetty.websocket.api.WebSocketListener;
+import org.eclipse.jetty.websocket.api.WebSocketPartialListener;
+import org.eclipse.jetty.websocket.api.WebSocketPingPongListener;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.Frame;
+import org.eclipse.jetty.websocket.api.extensions.Frame.Type;
import org.eclipse.jetty.websocket.common.CloseInfo;
+import org.eclipse.jetty.websocket.common.frames.ReadOnlyDelegatedFrame;
import org.eclipse.jetty.websocket.common.message.SimpleBinaryMessage;
import org.eclipse.jetty.websocket.common.message.SimpleTextMessage;
+import org.eclipse.jetty.websocket.common.util.Utf8PartialBuilder;
/**
* Handler for {@link WebSocketListener} based User WebSocket implementations.
@@ -38,10 +45,11 @@ import org.eclipse.jetty.websocket.common.message.SimpleTextMessage;
public class JettyListenerEventDriver extends AbstractEventDriver
{
private static final Logger LOG = Log.getLogger(JettyListenerEventDriver.class);
- private final WebSocketListener listener;
+ private final WebSocketConnectionListener listener;
+ private Utf8PartialBuilder utf8Partial;
private boolean hasCloseBeenCalled = false;
- public JettyListenerEventDriver(WebSocketPolicy policy, WebSocketListener listener)
+ public JettyListenerEventDriver(WebSocketPolicy policy, WebSocketConnectionListener listener)
{
super(policy,listener);
this.listener = listener;
@@ -50,18 +58,29 @@ public class JettyListenerEventDriver extends AbstractEventDriver
@Override
public void onBinaryFrame(ByteBuffer buffer, boolean fin) throws IOException
{
- if (activeMessage == null)
+ if (listener instanceof WebSocketListener)
{
- activeMessage = new SimpleBinaryMessage(this);
+ if (activeMessage == null)
+ {
+ activeMessage = new SimpleBinaryMessage(this);
+ }
+
+ appendMessage(buffer,fin);
}
- appendMessage(buffer,fin);
+ if (listener instanceof WebSocketPartialListener)
+ {
+ ((WebSocketPartialListener)listener).onWebSocketPartialBinary(buffer.slice().asReadOnlyBuffer(),fin);
+ }
}
@Override
public void onBinaryMessage(byte[] data)
{
- listener.onWebSocketBinary(data,0,data.length);
+ if (listener instanceof WebSocketListener)
+ {
+ ((WebSocketListener)listener).onWebSocketBinary(data,0,data.length);
+ }
}
@Override
@@ -96,7 +115,22 @@ public class JettyListenerEventDriver extends AbstractEventDriver
@Override
public void onFrame(Frame frame)
{
- /* ignore, not supported by WebSocketListener */
+ if (listener instanceof WebSocketFrameListener)
+ {
+ ((WebSocketFrameListener)listener).onWebSocketFrame(new ReadOnlyDelegatedFrame(frame));
+ }
+
+ if (listener instanceof WebSocketPingPongListener)
+ {
+ if (frame.getType() == Type.PING)
+ {
+ ((WebSocketPingPongListener)listener).onWebSocketPing(frame.getPayload().asReadOnlyBuffer());
+ }
+ else if (frame.getType() == Type.PONG)
+ {
+ ((WebSocketPingPongListener)listener).onWebSocketPong(frame.getPayload().asReadOnlyBuffer());
+ }
+ }
}
@Override
@@ -114,18 +148,46 @@ public class JettyListenerEventDriver extends AbstractEventDriver
@Override
public void onTextFrame(ByteBuffer buffer, boolean fin) throws IOException
{
- if (activeMessage == null)
+ if (listener instanceof WebSocketListener)
{
- activeMessage = new SimpleTextMessage(this);
+ if (activeMessage == null)
+ {
+ activeMessage = new SimpleTextMessage(this);
+ }
+
+ appendMessage(buffer,fin);
}
- appendMessage(buffer,fin);
+ if (listener instanceof WebSocketPartialListener)
+ {
+ if (utf8Partial == null)
+ {
+ utf8Partial = new Utf8PartialBuilder();
+ }
+
+ String partial = utf8Partial.toPartialString(buffer);
+
+ ((WebSocketPartialListener)listener).onWebSocketPartialText(partial,fin);
+
+ if (fin)
+ {
+ partial = null;
+ }
+ }
}
+ /**
+ * Whole Message event.
+ *
+ * @param message the whole message
+ */
@Override
public void onTextMessage(String message)
{
- listener.onWebSocketText(message);
+ if (listener instanceof WebSocketListener)
+ {
+ ((WebSocketListener)listener).onWebSocketText(message);
+ }
}
@Override
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerImpl.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerImpl.java
index 720864a866..0da607523a 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerImpl.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/JettyListenerImpl.java
@@ -18,6 +18,7 @@
package org.eclipse.jetty.websocket.common.events;
+import org.eclipse.jetty.websocket.api.WebSocketConnectionListener;
import org.eclipse.jetty.websocket.api.WebSocketListener;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
@@ -26,7 +27,7 @@ public class JettyListenerImpl implements EventDriverImpl
@Override
public EventDriver create(Object websocket, WebSocketPolicy policy)
{
- WebSocketListener listener = (WebSocketListener)websocket;
+ WebSocketConnectionListener listener = (WebSocketConnectionListener)websocket;
return new JettyListenerEventDriver(policy,listener);
}
@@ -39,6 +40,6 @@ public class JettyListenerImpl implements EventDriverImpl
@Override
public boolean supports(Object websocket)
{
- return (websocket instanceof WebSocketListener);
+ return (websocket instanceof WebSocketConnectionListener);
}
}
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/AbstractMethodAnnotationScanner.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/AbstractMethodAnnotationScanner.java
index 480e10b353..18300b362c 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/AbstractMethodAnnotationScanner.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/AbstractMethodAnnotationScanner.java
@@ -27,6 +27,7 @@ import org.eclipse.jetty.websocket.common.events.ParamList;
/**
* Basic scanner for Annotated Methods
+ * @param <T> The type of metadata
*/
public abstract class AbstractMethodAnnotationScanner<T>
{
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/CallableMethod.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/CallableMethod.java
index 69b97c6e3f..c44496a5fd 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/CallableMethod.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/annotated/CallableMethod.java
@@ -55,7 +55,8 @@ public class CallableMethod
if (obj == null)
{
- LOG.warn("Cannot call {} on null object",this.method);
+ String err = String.format("Cannot call %s on null object", this.method);
+ LOG.warn(new RuntimeException(err));
return null;
}
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/AbstractExtension.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/AbstractExtension.java
index c35fe8f818..93519e6c6f 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/AbstractExtension.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/AbstractExtension.java
@@ -35,6 +35,7 @@ import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
import org.eclipse.jetty.websocket.common.LogicalConnection;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
@ManagedObject("Abstract Extension")
public abstract class AbstractExtension extends ContainerLifeCycle implements Extension
@@ -67,6 +68,12 @@ public abstract class AbstractExtension extends ContainerLifeCycle implements Ex
out.append(heading).append(" : ");
out.append(bean.toString());
}
+
+ public void init(WebSocketContainerScope container)
+ {
+ this.policy = container.getPolicy();
+ this.bufferPool = container.getBufferPool();
+ }
public ByteBufferPool getBufferPool()
{
@@ -183,7 +190,7 @@ public abstract class AbstractExtension extends ContainerLifeCycle implements Ex
{
this.connection = connection;
}
-
+
@Override
public void setNextIncomingFrames(IncomingFrames nextIncoming)
{
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/FrameDebugExtension.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/FrameCaptureExtension.java
index d9b540a99a..c4a43e4ce9 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/FrameDebugExtension.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/FrameCaptureExtension.java
@@ -18,53 +18,82 @@
package org.eclipse.jetty.websocket.common.extensions;
+import static java.nio.file.StandardOpenOption.*;
+
import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SeekableByteChannel;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.StandardOpenOption;
-import java.util.concurrent.atomic.AtomicLong;
+import java.util.Calendar;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.BatchMode;
+import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.WriteCallback;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.Generator;
+import org.eclipse.jetty.websocket.common.WebSocketFrame;
-public class FrameDebugExtension extends AbstractExtension
+public class FrameCaptureExtension extends AbstractExtension
{
- private static final Logger LOG = Log.getLogger(FrameDebugExtension.class);
+ private static final Logger LOG = Log.getLogger(FrameCaptureExtension.class);
private static final int BUFSIZE = 32768;
private Generator generator;
private Path outputDir;
private String prefix = "frame";
- private AtomicLong incomingId = new AtomicLong(0);
- private AtomicLong outgoingId = new AtomicLong(0);
+ private Path incomingFramesPath;
+ private Path outgoingFramesPath;
+
+ private AtomicInteger incomingCount = new AtomicInteger(0);
+ private AtomicInteger outgoingCount = new AtomicInteger(0);
+
+ private SeekableByteChannel incomingChannel;
+ private SeekableByteChannel outgoingChannel;
@Override
public String getName()
{
- return "@frame-debug";
+ return "@frame-capture";
}
@Override
public void incomingFrame(Frame frame)
{
saveFrame(frame,false);
- nextIncomingFrame(frame);
+ try
+ {
+ nextIncomingFrame(frame);
+ }
+ catch (Throwable t)
+ {
+ IO.close(incomingChannel);
+ incomingChannel = null;
+ throw t;
+ }
}
@Override
public void outgoingFrame(Frame frame, WriteCallback callback, BatchMode batchMode)
{
saveFrame(frame,true);
- nextOutgoingFrame(frame,callback,batchMode);
+ try
+ {
+ nextOutgoingFrame(frame,callback,batchMode);
+ }
+ catch (Throwable t)
+ {
+ IO.close(outgoingChannel);
+ outgoingChannel = null;
+ throw t;
+ }
}
private void saveFrame(Frame frame, boolean outgoing)
@@ -74,33 +103,33 @@ public class FrameDebugExtension extends AbstractExtension
return;
}
- StringBuilder filename = new StringBuilder();
- filename.append(prefix);
- if (outgoing)
+ @SuppressWarnings("resource")
+ SeekableByteChannel channel = (outgoing) ? outgoingChannel : incomingChannel;
+
+ if (channel == null)
{
- filename.append(String.format("-outgoing-%05d",outgoingId.getAndIncrement()));
- }
- else
- {
- filename.append(String.format("-incoming-%05d",incomingId.getAndIncrement()));
+ return;
}
- filename.append(".dat");
- Path outputFile = outputDir.resolve(filename.toString());
ByteBuffer buf = getBufferPool().acquire(BUFSIZE,false);
- try (SeekableByteChannel channel = Files.newByteChannel(outputFile,StandardOpenOption.CREATE,StandardOpenOption.WRITE))
+
+ try
{
- generator.generateHeaderBytes(frame,buf);
+ WebSocketFrame f = WebSocketFrame.copy(frame);
+ f.setMasked(false);
+ generator.generateHeaderBytes(f,buf);
channel.write(buf);
if (frame.hasPayload())
{
channel.write(frame.getPayload().slice());
}
- LOG.debug("Saved raw frame: {}",outputFile.toString());
+ if (LOG.isDebugEnabled())
+ LOG.debug("Saved {} frame #{}",(outgoing) ? "outgoing" : "incoming",
+ (outgoing) ? outgoingCount.incrementAndGet() : incomingCount.incrementAndGet());
}
catch (IOException e)
{
- LOG.warn("Unable to save frame: " + filename.toString(),e);
+ LOG.warn("Unable to save frame: " + frame,e);
}
finally
{
@@ -135,8 +164,24 @@ public class FrameDebugExtension extends AbstractExtension
if (this.outputDir != null)
{
- // create a non-validating, read-only generator
- this.generator = new Generator(getPolicy(),getBufferPool(),false,true);
+ try
+ {
+ Path dir = this.outputDir.toRealPath();
+
+ // create a non-validating, read-only generator
+ String tstamp = String.format("%1$tY%1$tm%1$td-%1$tH%1$tM%1$tS",Calendar.getInstance());
+ incomingFramesPath = dir.resolve(String.format("%s-%s-incoming.dat",this.prefix,tstamp));
+ outgoingFramesPath = dir.resolve(String.format("%s-%s-outgoing.dat",this.prefix,tstamp));
+
+ incomingChannel = Files.newByteChannel(incomingFramesPath,CREATE,WRITE);
+ outgoingChannel = Files.newByteChannel(outgoingFramesPath,CREATE,WRITE);
+
+ this.generator = new Generator(WebSocketPolicy.newServerPolicy(),getBufferPool(),false,true);
+ }
+ catch (IOException e)
+ {
+ LOG.warn("Unable to create capture file(s)",e);
+ }
}
}
}
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/WebSocketExtensionFactory.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/WebSocketExtensionFactory.java
index 8bec446d6d..0b2d8a8fe3 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/WebSocketExtensionFactory.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/WebSocketExtensionFactory.java
@@ -18,24 +18,21 @@
package org.eclipse.jetty.websocket.common.extensions;
-import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.websocket.api.WebSocketException;
-import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.Extension;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
import org.eclipse.jetty.websocket.api.extensions.ExtensionFactory;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
public class WebSocketExtensionFactory extends ExtensionFactory
{
- private WebSocketPolicy policy;
- private ByteBufferPool bufferPool;
+ private WebSocketContainerScope container;
- public WebSocketExtensionFactory(WebSocketPolicy policy, ByteBufferPool bufferPool)
+ public WebSocketExtensionFactory(WebSocketContainerScope container)
{
super();
- this.policy = policy;
- this.bufferPool = bufferPool;
+ this.container = container;
}
@Override
@@ -60,12 +57,11 @@ public class WebSocketExtensionFactory extends ExtensionFactory
try
{
- Extension ext = extClass.newInstance();
+ Extension ext = container.getObjectFactory().createInstance(extClass);
if (ext instanceof AbstractExtension)
{
AbstractExtension aext = (AbstractExtension)ext;
- aext.setPolicy(policy);
- aext.setBufferPool(bufferPool);
+ aext.init(container);
aext.setConfig(config);
}
return ext;
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/CompressExtension.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/CompressExtension.java
index 5c27104c59..ec73e3c384 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/CompressExtension.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/CompressExtension.java
@@ -154,30 +154,33 @@ public abstract class CompressExtension extends AbstractExtension
return;
}
byte[] output = new byte[DECOMPRESS_BUF_SIZE];
-
- if (inflater.needsInput() && !supplyInput(inflater,buf))
- {
- LOG.debug("Needed input, but no buffer could supply input");
- return;
- }
-
- int read = 0;
- while ((read = inflater.inflate(output)) >= 0)
+
+ while(buf.hasRemaining() && inflater.needsInput())
{
- if (read == 0)
+ if (!supplyInput(inflater,buf))
{
- LOG.debug("Decompress: read 0 {}",toDetail(inflater));
- break;
+ LOG.debug("Needed input, but no buffer could supply input");
+ return;
}
- else
+
+ int read = 0;
+ while ((read = inflater.inflate(output)) >= 0)
{
- // do something with output
- if (LOG.isDebugEnabled())
+ if (read == 0)
{
- LOG.debug("Decompressed {} bytes: {}",read,toDetail(inflater));
+ LOG.debug("Decompress: read 0 {}",toDetail(inflater));
+ break;
+ }
+ else
+ {
+ // do something with output
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Decompressed {} bytes: {}",read,toDetail(inflater));
+ }
+
+ accumulator.copyChunk(output,0,read);
}
-
- accumulator.copyChunk(output,0,read);
}
}
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageDeflateExtension.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageDeflateExtension.java
index fe97e57c69..9d73f1f72e 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageDeflateExtension.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageDeflateExtension.java
@@ -32,7 +32,7 @@ import org.eclipse.jetty.websocket.common.OpCode;
/**
* Per Message Deflate Compression extension for WebSocket.
- * <p/>
+ * <p>
* Attempts to follow <a href="https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-12">draft-ietf-hybi-permessage-compression-12</a>
*/
public class PerMessageDeflateExtension extends CompressExtension
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/DataFrame.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/DataFrame.java
index 0f6f79c93b..5fe357c20f 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/DataFrame.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/DataFrame.java
@@ -36,6 +36,7 @@ public class DataFrame extends WebSocketFrame
* Construct new DataFrame based on headers of provided frame.
* <p>
* Useful for when working in extensions and a new frame needs to be created.
+ * @param basedOn the frame this one is based on
*/
public DataFrame(Frame basedOn)
{
@@ -46,6 +47,8 @@ public class DataFrame extends WebSocketFrame
* Construct new DataFrame based on headers of provided frame, overriding for continuations if needed.
* <p>
* Useful for when working in extensions and a new frame needs to be created.
+ * @param basedOn the frame this one is based on
+ * @param continuation true if this is a continuation frame
*/
public DataFrame(Frame basedOn, boolean continuation)
{
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/ReadOnlyDelegatedFrame.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/ReadOnlyDelegatedFrame.java
new file mode 100644
index 0000000000..706e8cfda2
--- /dev/null
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/ReadOnlyDelegatedFrame.java
@@ -0,0 +1,112 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.websocket.common.frames;
+
+import java.nio.ByteBuffer;
+
+import org.eclipse.jetty.websocket.api.extensions.Frame;
+
+/**
+ * Immutable, Read-only, Frame implementation.
+ */
+public class ReadOnlyDelegatedFrame implements Frame
+{
+ private final Frame delegate;
+
+ public ReadOnlyDelegatedFrame(Frame frame)
+ {
+ this.delegate = frame;
+ }
+
+ @Override
+ public byte[] getMask()
+ {
+ return delegate.getMask();
+ }
+
+ @Override
+ public byte getOpCode()
+ {
+ return delegate.getOpCode();
+ }
+
+ @Override
+ public ByteBuffer getPayload()
+ {
+ if(!delegate.hasPayload()) {
+ return null;
+ }
+ return delegate.getPayload().asReadOnlyBuffer();
+ }
+
+ @Override
+ public int getPayloadLength()
+ {
+ return delegate.getPayloadLength();
+ }
+
+ @Override
+ public Type getType()
+ {
+ return delegate.getType();
+ }
+
+ @Override
+ public boolean hasPayload()
+ {
+ return delegate.hasPayload();
+ }
+
+ @Override
+ public boolean isFin()
+ {
+ return delegate.isFin();
+ }
+
+ @Override
+ @Deprecated
+ public boolean isLast()
+ {
+ return delegate.isLast();
+ }
+
+ @Override
+ public boolean isMasked()
+ {
+ return delegate.isMasked();
+ }
+
+ @Override
+ public boolean isRsv1()
+ {
+ return delegate.isRsv1();
+ }
+
+ @Override
+ public boolean isRsv2()
+ {
+ return delegate.isRsv2();
+ }
+
+ @Override
+ public boolean isRsv3()
+ {
+ return delegate.isRsv3();
+ }
+}
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java
index 4e51713338..7366457dc3 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/AbstractWebSocketConnection.java
@@ -32,6 +32,7 @@ import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.jetty.io.AbstractConnection;
import org.eclipse.jetty.io.ByteBufferPool;
+import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.component.ContainerLifeCycle;
@@ -52,13 +53,12 @@ import org.eclipse.jetty.websocket.common.ConnectionState;
import org.eclipse.jetty.websocket.common.Generator;
import org.eclipse.jetty.websocket.common.LogicalConnection;
import org.eclipse.jetty.websocket.common.Parser;
-import org.eclipse.jetty.websocket.common.WebSocketSession;
import org.eclipse.jetty.websocket.common.io.IOState.ConnectionStateListener;
/**
- * Provides the implementation of {@link LogicalConnection} within the framework of the new {@link Connection} framework of {@code jetty-io}.
+ * Provides the implementation of {@link LogicalConnection} within the framework of the new {@link org.eclipse.jetty.io.Connection} framework of {@code jetty-io}.
*/
-public abstract class AbstractWebSocketConnection extends AbstractConnection implements LogicalConnection, ConnectionStateListener, Dumpable
+public abstract class AbstractWebSocketConnection extends AbstractConnection implements LogicalConnection, Connection.UpgradeTo, ConnectionStateListener, Dumpable
{
private class Flusher extends FrameFlusher
{
@@ -70,7 +70,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
@Override
protected void onFailure(Throwable x)
{
- session.notifyError(x);
+ notifyError(x);
if (ioState.wasAbnormalClose())
{
@@ -156,8 +156,8 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
private void onLocalClose()
{
- if (LOG.isDebugEnabled())
- LOG.debug("Local Close Confirmed {}",close);
+ if (LOG_CLOSE.isDebugEnabled())
+ LOG_CLOSE.debug("Local Close Confirmed {}",close);
if (close.isAbnormal())
{
ioState.onAbnormalClose(close);
@@ -199,6 +199,8 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
}
private static final Logger LOG = Log.getLogger(AbstractWebSocketConnection.class);
+ private static final Logger LOG_OPEN = Log.getLogger(AbstractWebSocketConnection.class.getName() + "_OPEN");
+ private static final Logger LOG_CLOSE = Log.getLogger(AbstractWebSocketConnection.class.getName() + "_CLOSE");
/**
* Minimum size of a buffer is the determined to be what would be the maximum framing header size (not including payload)
@@ -212,17 +214,16 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
private final WebSocketPolicy policy;
private final AtomicBoolean suspendToken;
private final FrameFlusher flusher;
- private WebSocketSession session;
private List<ExtensionConfig> extensions;
private boolean isFilling;
- private ByteBuffer buffer;
+ private ByteBuffer prefillBuffer;
private ReadMode readMode = ReadMode.PARSE;
private IOState ioState;
private Stats stats = new Stats();
public AbstractWebSocketConnection(EndPoint endp, Executor executor, Scheduler scheduler, WebSocketPolicy policy, ByteBufferPool bufferPool)
{
- super(endp,executor,EXECUTE_ONFILLABLE); // TODO review if this is best. Specifically with MUX
+ super(endp,executor);
this.policy = policy;
this.bufferPool = bufferPool;
this.generator = new Generator(policy,bufferPool);
@@ -249,6 +250,8 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
@Override
public void close()
{
+ if(LOG_CLOSE.isDebugEnabled())
+ LOG_CLOSE.debug(".close()");
CloseInfo close = new CloseInfo();
this.outgoingFrame(close.asFrame(),new OnCloseLocalCallback(close),BatchMode.OFF);
}
@@ -268,8 +271,8 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
@Override
public void close(int statusCode, String reason)
{
- if (LOG.isDebugEnabled())
- LOG.debug("close({},{})",statusCode,reason);
+ if (LOG_CLOSE.isDebugEnabled())
+ LOG_CLOSE.debug("close({},{})",statusCode,reason);
CloseInfo close = new CloseInfo(statusCode,reason);
this.outgoingFrame(close.asFrame(),new OnCloseLocalCallback(close),BatchMode.OFF);
}
@@ -277,24 +280,27 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
@Override
public void disconnect()
{
+ if (LOG_CLOSE.isDebugEnabled())
+ LOG_CLOSE.debug("{} disconnect()",policy.getBehavior());
disconnect(false);
}
private void disconnect(boolean onlyOutput)
{
- if (LOG.isDebugEnabled())
- LOG.debug("{} disconnect({})",policy.getBehavior(),onlyOutput?"outputOnly":"both");
+ if (LOG_CLOSE.isDebugEnabled())
+ LOG_CLOSE.debug("{} disconnect({})",policy.getBehavior(),onlyOutput?"outputOnly":"both");
// close FrameFlusher, we cannot write anymore at this point.
flusher.close();
EndPoint endPoint = getEndPoint();
// We need to gently close first, to allow
// SSL close alerts to be sent by Jetty
- if (LOG.isDebugEnabled())
- LOG.debug("Shutting down output {}",endPoint);
+ if (LOG_CLOSE.isDebugEnabled())
+ LOG_CLOSE.debug("Shutting down output {}",endPoint);
endPoint.shutdownOutput();
if (!onlyOutput)
{
- LOG.debug("Closing {}",endPoint);
+ if (LOG_CLOSE.isDebugEnabled())
+ LOG_CLOSE.debug("Closing {}",endPoint);
endPoint.close();
}
}
@@ -382,12 +388,6 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
return scheduler;
}
- @Override
- public WebSocketSession getSession()
- {
- return session;
- }
-
public Stats getStats()
{
return stats;
@@ -423,21 +423,31 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
@Override
public void onConnectionStateChange(ConnectionState state)
{
- if (LOG.isDebugEnabled())
- LOG.debug("{} Connection State Change: {}",policy.getBehavior(),state);
+ if (LOG_CLOSE.isDebugEnabled())
+ LOG_CLOSE.debug("{} Connection State Change: {}",policy.getBehavior(),state);
+
switch (state)
{
case OPEN:
- if (BufferUtil.isEmpty(buffer))
+ if (BufferUtil.hasContent(prefillBuffer))
{
if (LOG.isDebugEnabled())
- LOG.debug("fillInterested");
- fillInterested();
+ {
+ LOG.debug("Parsing Upgrade prefill buffer ({} remaining)",prefillBuffer.remaining());
+ }
+ parser.parse(prefillBuffer);
}
- else
- onFillable();
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("OPEN: normal fillInterested");
+ }
+ // TODO: investigate what happens if a failure occurs during prefill, and an attempt to write close fails,
+ // should a fill interested occur? or just a quick disconnect?
+ fillInterested();
break;
case CLOSED:
+ if (LOG_CLOSE.isDebugEnabled())
+ LOG_CLOSE.debug("CLOSED - wasAbnormalClose: {}", ioState.wasAbnormalClose());
if (ioState.wasAbnormalClose())
{
// Fire out a close frame, indicating abnormal shutdown, then disconnect
@@ -451,6 +461,8 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
}
break;
case CLOSING:
+ if (LOG_CLOSE.isDebugEnabled())
+ LOG_CLOSE.debug("CLOSING - wasRemoteCloseInitiated: {}", ioState.wasRemoteCloseInitiated());
// First occurrence of .onCloseLocal or .onCloseRemote use
if (ioState.wasRemoteCloseInitiated())
{
@@ -469,8 +481,9 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
if (LOG.isDebugEnabled())
LOG.debug("{} onFillable()",policy.getBehavior());
stats.countOnFillableEvents.incrementAndGet();
- if (buffer==null)
- buffer = bufferPool.acquire(getInputBufferSize(),true);
+
+ ByteBuffer buffer = bufferPool.acquire(getInputBufferSize(),true);
+
try
{
isFilling = true;
@@ -487,7 +500,6 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
finally
{
bufferPool.release(buffer);
- buffer=null;
}
if ((readMode != ReadMode.EOF) && (suspendToken.get() == false))
@@ -510,14 +522,31 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
super.onFillInterestedFailed(cause);
}
- protected void prefill(ByteBuffer prefilled)
+ /**
+ * Extra bytes from the initial HTTP upgrade that need to
+ * be processed by the websocket parser before starting
+ * to read bytes from the connection
+ * @param prefilled the bytes of prefilled content encountered during upgrade
+ */
+ protected void setInitialBuffer(ByteBuffer prefilled)
+ {
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("set Initial Buffer - {}",BufferUtil.toDetailString(prefilled));
+ }
+ prefillBuffer = prefilled;
+ }
+
+ private void notifyError(Throwable t)
{
- buffer=prefilled;
+ getParser().getIncomingFramesHandler().incomingError(t);
}
@Override
public void onOpen()
{
+ if(LOG_OPEN.isDebugEnabled())
+ LOG_OPEN.debug("[{}] {}.onOpened()",policy.getBehavior(),this.getClass().getSimpleName());
super.onOpen();
this.ioState.onOpened();
}
@@ -530,11 +559,13 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
{
IOState state = getIOState();
ConnectionState cstate = state.getConnectionState();
- if (LOG.isDebugEnabled())
- LOG.debug("{} Read Timeout - {}",policy.getBehavior(),cstate);
+ if (LOG_CLOSE.isDebugEnabled())
+ LOG_CLOSE.debug("{} Read Timeout - {}",policy.getBehavior(),cstate);
if (cstate == ConnectionState.CLOSED)
{
+ if (LOG_CLOSE.isDebugEnabled())
+ LOG_CLOSE.debug("onReadTimeout - Connection Already CLOSED");
// close already completed, extra timeouts not relevant
// allow underlying connection and endpoint to disconnect on its own
return true;
@@ -542,7 +573,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
try
{
- session.notifyError(new SocketTimeoutException("Timeout on Read"));
+ notifyError(new SocketTimeoutException("Timeout on Read"));
}
finally
{
@@ -581,15 +612,14 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
}
else if (filled < 0)
{
- LOG.debug("read - EOF Reached (remote: {})",getRemoteAddress());
+ if (LOG_CLOSE.isDebugEnabled())
+ LOG_CLOSE.debug("read - EOF Reached (remote: {})",getRemoteAddress());
return ReadMode.EOF;
}
else
{
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Discarded {} bytes - {}",filled,BufferUtil.toDetailString(buffer));
- }
+ if (LOG_CLOSE.isDebugEnabled())
+ LOG_CLOSE.debug("Discarded {} bytes - {}",filled,BufferUtil.toDetailString(buffer));
}
}
}
@@ -610,27 +640,27 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
EndPoint endPoint = getEndPoint();
try
{
- while (true) // TODO: should this honor the LogicalConnection.suspend() ?
+ // Process the content from the Endpoint next
+ while(true) // TODO: should this honor the LogicalConnection.suspend() ?
{
int filled = endPoint.fill(buffer);
- if (filled == 0)
- {
- return ReadMode.PARSE;
- }
- else if (filled < 0)
+ if (filled < 0)
{
LOG.debug("read - EOF Reached (remote: {})",getRemoteAddress());
ioState.onReadFailure(new EOFException("Remote Read EOF"));
return ReadMode.EOF;
}
- else
+ else if (filled == 0)
{
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Filled {} bytes - {}",filled,BufferUtil.toDetailString(buffer));
- }
- parser.parse(buffer);
+ // Done reading, wait for next onFillable
+ return ReadMode.PARSE;
}
+
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Filled {} bytes - {}",filled,BufferUtil.toDetailString(buffer));
+ }
+ parser.parse(buffer);
}
}
catch (IOException e)
@@ -653,7 +683,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
return ReadMode.DISCARD;
}
}
-
+
@Override
public void resume()
{
@@ -693,12 +723,6 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
}
@Override
- public void setSession(WebSocketSession session)
- {
- this.session = session;
- }
-
- @Override
public SuspendToken suspend()
{
suspendToken.set(true);
@@ -720,7 +744,17 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
@Override
public String toString()
{
- return String.format("%s{f=%s,g=%s,p=%s}",super.toString(),flusher,generator,parser);
+ return String.format("%s@%X{endp=%s,ios=%s,f=%s,g=%s,p=%s}",getClass().getSimpleName(),hashCode(),getEndPoint(),ioState,flusher,generator,parser);
}
+ /**
+ * Extra bytes from the initial HTTP upgrade that need to
+ * be processed by the websocket parser before starting
+ * to read bytes from the connection
+ */
+ @Override
+ public void onUpgradeTo(ByteBuffer prefilled)
+ {
+ setInitialBuffer(prefilled);
+ }
}
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/FrameFlusher.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/FrameFlusher.java
index fb9d35fc94..8c4bc39520 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/FrameFlusher.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/FrameFlusher.java
@@ -40,7 +40,7 @@ import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.frames.BinaryFrame;
/**
- * Interface for working with bytes destined for {@link EndPoint#write(Callback, ByteBuffer...)}
+ * Interface for working with bytes destined for {@link EndPoint#write(org.eclipse.jetty.util.Callback, ByteBuffer...)}
*/
public class FrameFlusher
{
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/FutureWriteCallback.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/FutureWriteCallback.java
index d67e1fb684..a0509e50ce 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/FutureWriteCallback.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/FutureWriteCallback.java
@@ -18,6 +18,8 @@
package org.eclipse.jetty.websocket.common.io;
+import java.util.concurrent.Future;
+
import org.eclipse.jetty.util.FutureCallback;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/IOState.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/IOState.java
index 5ba0eb9f16..6c6de1066b 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/IOState.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/IOState.java
@@ -189,6 +189,7 @@ public class IOState
* A websocket connection has been disconnected for abnormal close reasons.
* <p>
* This is the low level disconnect of the socket. It could be the result of a normal close operation, from an IO error, or even from a timeout.
+ * @param close the close information
*/
public void onAbnormalClose(CloseInfo close)
{
@@ -220,6 +221,7 @@ public class IOState
/**
* A close handshake has been issued from the local endpoint
+ * @param close the close information
*/
public void onCloseLocal(CloseInfo close)
{
@@ -248,6 +250,9 @@ public class IOState
synchronized (this)
{
closeInfo = close;
+
+ // Turn off further output
+ outputAvailable = false;
boolean in = inputAvailable;
boolean out = outputAvailable;
@@ -255,9 +260,7 @@ public class IOState
{
closeHandshakeSource = CloseHandshakeSource.LOCAL;
}
- out = false;
- outputAvailable = false;
-
+
LOG.debug("onCloseLocal(), input={}, output={}",in,out);
if (!in && !out)
@@ -301,6 +304,7 @@ public class IOState
/**
* A close handshake has been received from the remote endpoint
+ * @param close the close information
*/
public void onCloseRemote(CloseInfo close)
{
@@ -316,6 +320,9 @@ public class IOState
}
closeInfo = close;
+
+ // turn off further input
+ inputAvailable = false;
boolean in = inputAvailable;
boolean out = outputAvailable;
@@ -323,8 +330,6 @@ public class IOState
{
closeHandshakeSource = CloseHandshakeSource.REMOTE;
}
- in = false;
- inputAvailable = false;
if (LOG.isDebugEnabled())
LOG.debug("onCloseRemote(), input={}, output={}",in,out);
@@ -399,6 +404,9 @@ public class IOState
*/
public void onOpened()
{
+ if(LOG.isDebugEnabled())
+ LOG.debug(" onOpened()");
+
ConnectionState event = null;
synchronized (this)
{
@@ -426,6 +434,7 @@ public class IOState
* The local endpoint has reached a read failure.
* <p>
* This could be a normal result after a proper close handshake, or even a premature close due to a connection disconnect.
+ * @param t the read failure
*/
public void onReadFailure(Throwable t)
{
@@ -476,6 +485,7 @@ public class IOState
* The local endpoint has reached a write failure.
* <p>
* A low level I/O failure, or even a jetty side EndPoint close (from idle timeout) are a few scenarios
+ * @param t the throwable that caused the write failure
*/
public void onWriteFailure(Throwable t)
{
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/http/HttpResponseHeaderParser.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/http/HttpResponseHeaderParser.java
index d7c78479c2..2b72738ba4 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/http/HttpResponseHeaderParser.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/http/HttpResponseHeaderParser.java
@@ -80,7 +80,9 @@ public class HttpResponseHeaderParser
{
if (parseHeader(line))
{
- // Finished parsing entire header
+ // Now finished with parsing the entire response header
+ // Save the remaining bytes for WebSocket to process.
+
ByteBuffer copy = ByteBuffer.allocate(buf.remaining());
BufferUtil.put(buf,copy);
BufferUtil.flipToFlush(copy,0);
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/payload/PayloadProcessor.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/payload/PayloadProcessor.java
index dc9cc95c29..67ade06a47 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/payload/PayloadProcessor.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/payload/PayloadProcessor.java
@@ -20,6 +20,7 @@ package org.eclipse.jetty.websocket.common.io.payload;
import java.nio.ByteBuffer;
+import org.eclipse.jetty.websocket.api.BadPayloadException;
import org.eclipse.jetty.websocket.api.extensions.Frame;
/**
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageInputStream.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageInputStream.java
index 7bd35a1050..2c5d5a7892 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageInputStream.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageInputStream.java
@@ -32,7 +32,7 @@ import org.eclipse.jetty.util.log.Logger;
/**
* Support class for reading a (single) WebSocket BINARY message via a InputStream.
- * <p/>
+ * <p>
* An InputStream that can access a queue of ByteBuffer payloads, along with expected InputStream blocking behavior.
*/
public class MessageInputStream extends InputStream implements MessageAppender
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageReader.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageReader.java
index 100152f702..b416301198 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageReader.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageReader.java
@@ -21,11 +21,12 @@ package org.eclipse.jetty.websocket.common.message;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
/**
* Support class for reading a (single) WebSocket TEXT message via a Reader.
- * <p/>
+ * <p>
* In compliance to the WebSocket spec, this reader always uses the UTF8 {@link Charset}.
*/
public class MessageReader extends InputStreamReader implements MessageAppender
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageWriter.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageWriter.java
index 8272cea303..44367edbf3 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageWriter.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/message/MessageWriter.java
@@ -36,7 +36,7 @@ import org.eclipse.jetty.websocket.common.frames.TextFrame;
/**
* Support for writing a single WebSocket TEXT message via a {@link Writer}
- * <p/>
+ * <p>
* Note: Per WebSocket spec, all WebSocket TEXT messages must be encoded in UTF-8
*/
public class MessageWriter extends Writer
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/package-info.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/package-info.java
index 197cadc2e9..f28f1e394c 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/package-info.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/package-info.java
@@ -21,7 +21,7 @@
* <p>
* A core set of internal implementation classes for the Jetty WebSocket API.
* <p>
- * Note: do not reference or use classes present in this package space in your code. <br />
+ * Note: do not reference or use classes present in this package space in your code. <br>
* Restrict your usage to the Jetty WebSocket API classes, the Jetty WebSocket Client API,
* or the Jetty WebSocket Servlet API.
*/
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/scopes/SimpleContainerScope.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/scopes/SimpleContainerScope.java
new file mode 100644
index 0000000000..f407f8bafd
--- /dev/null
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/scopes/SimpleContainerScope.java
@@ -0,0 +1,108 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.websocket.common.scopes;
+
+import java.util.concurrent.Executor;
+
+import org.eclipse.jetty.io.ByteBufferPool;
+import org.eclipse.jetty.io.MappedByteBufferPool;
+import org.eclipse.jetty.util.DecoratedObjectFactory;
+import org.eclipse.jetty.util.component.ContainerLifeCycle;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
+import org.eclipse.jetty.util.thread.QueuedThreadPool;
+import org.eclipse.jetty.websocket.api.WebSocketPolicy;
+
+public class SimpleContainerScope extends ContainerLifeCycle implements WebSocketContainerScope
+{
+ private final ByteBufferPool bufferPool;
+ private final DecoratedObjectFactory objectFactory;
+ private final WebSocketPolicy policy;
+ private Executor executor;
+ private SslContextFactory sslContextFactory;
+
+ public SimpleContainerScope(WebSocketPolicy policy)
+ {
+ this(policy,new MappedByteBufferPool(),new DecoratedObjectFactory());
+ }
+
+ public SimpleContainerScope(WebSocketPolicy policy, ByteBufferPool bufferPool)
+ {
+ this(policy,bufferPool,new DecoratedObjectFactory());
+ }
+
+ public SimpleContainerScope(WebSocketPolicy policy, ByteBufferPool bufferPool, DecoratedObjectFactory objectFactory)
+ {
+ this.policy = policy;
+ this.bufferPool = bufferPool;
+ this.objectFactory = objectFactory;
+
+ QueuedThreadPool threadPool = new QueuedThreadPool();
+ String name = "WebSocketSimpleContainer@" + hashCode();
+ threadPool.setName(name);
+ threadPool.setDaemon(true);
+ this.executor = threadPool;
+ }
+
+ @Override
+ protected void doStart() throws Exception
+ {
+ super.doStart();
+ }
+
+ @Override
+ protected void doStop() throws Exception
+ {
+ super.doStop();
+ }
+
+ @Override
+ public ByteBufferPool getBufferPool()
+ {
+ return this.bufferPool;
+ }
+
+ @Override
+ public Executor getExecutor()
+ {
+ return this.executor;
+ }
+
+ @Override
+ public DecoratedObjectFactory getObjectFactory()
+ {
+ return this.objectFactory;
+ }
+
+ @Override
+ public WebSocketPolicy getPolicy()
+ {
+ return this.policy;
+ }
+
+ @Override
+ public SslContextFactory getSslContextFactory()
+ {
+ return this.sslContextFactory;
+ }
+
+ public void setSslContextFactory(SslContextFactory sslContextFactory)
+ {
+ this.sslContextFactory = sslContextFactory;
+ }
+}
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/scopes/WebSocketContainerScope.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/scopes/WebSocketContainerScope.java
new file mode 100644
index 0000000000..acc611f778
--- /dev/null
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/scopes/WebSocketContainerScope.java
@@ -0,0 +1,67 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.websocket.common.scopes;
+
+import java.util.concurrent.Executor;
+
+import org.eclipse.jetty.io.ByteBufferPool;
+import org.eclipse.jetty.util.DecoratedObjectFactory;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
+import org.eclipse.jetty.websocket.api.WebSocketPolicy;
+
+/**
+ * Defined Scope for a WebSocketContainer.
+ */
+public interface WebSocketContainerScope
+{
+ /**
+ * The configured Container Buffer Pool.
+ *
+ * @return the buffer pool (never null)
+ */
+ public ByteBufferPool getBufferPool();
+
+ /**
+ * Executor in use by the container.
+ *
+ * @return the Executor in use by the container.
+ */
+ public Executor getExecutor();
+
+ /**
+ * Object Factory used to create objects.
+ *
+ * @return Object Factory used to create instances of objects.
+ */
+ public DecoratedObjectFactory getObjectFactory();
+
+ /**
+ * The policy the container is running on.
+ *
+ * @return the websocket policy
+ */
+ public WebSocketPolicy getPolicy();
+
+ /**
+ * The SslContextFactory in use by the container.
+ *
+ * @return the SslContextFactory in use by the container (can be null if no SSL context is defined)
+ */
+ public SslContextFactory getSslContextFactory();
+}
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/scopes/WebSocketSessionScope.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/scopes/WebSocketSessionScope.java
new file mode 100644
index 0000000000..1e59094ccf
--- /dev/null
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/scopes/WebSocketSessionScope.java
@@ -0,0 +1,39 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.websocket.common.scopes;
+
+import org.eclipse.jetty.websocket.common.WebSocketSession;
+
+/**
+ * Defined Scope for a WebSocketSession (active connection)
+ */
+public interface WebSocketSessionScope
+{
+ /**
+ * Active {@link WebSocketSession} associated with this scope.
+ * @return the websocket session
+ */
+ WebSocketSession getWebSocketSession();
+
+ /**
+ * The parent {@link WebSocketContainerScope} for this session scope.
+ * @return the websocket container scope
+ */
+ WebSocketContainerScope getContainerScope();
+}
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/util/TextUtil.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/util/TextUtil.java
index 414529ad3b..651c8c9329 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/util/TextUtil.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/util/TextUtil.java
@@ -43,7 +43,6 @@ public final class TextUtil
/**
* Smash a long string to fit within the max string length, by taking the middle section of the string and replacing them with an ellipsis "..."
- * <p>
*
* <pre>
* Examples:
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/util/Utf8PartialBuilder.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/util/Utf8PartialBuilder.java
new file mode 100644
index 0000000000..7245f5991d
--- /dev/null
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/util/Utf8PartialBuilder.java
@@ -0,0 +1,63 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.websocket.common.util;
+
+import java.nio.ByteBuffer;
+
+import org.eclipse.jetty.util.Utf8Appendable;
+import org.eclipse.jetty.util.Utf8StringBuilder;
+
+/**
+ * Similar in scope to the {@link Utf8StringBuilder}, but allowing partially constructed Strings without throwing
+ * Exceptions for incomplete UTF8 sequences.
+ * <p>
+ * A call to {@link #toPartialString(ByteBuffer)} will return the section of the String from the start to the last
+ * completed UTF8 sequence. Leaving incomplete sequences for a subsequent call to complete.
+ */
+public class Utf8PartialBuilder
+{
+ private final StringBuilder str;
+ private final Utf8Appendable utf8;
+
+ public Utf8PartialBuilder()
+ {
+ this.str = new StringBuilder();
+ this.utf8 = new Utf8Appendable(str)
+ {
+ @Override
+ public int length()
+ {
+ return str.length();
+ }
+ };
+ }
+
+ public String toPartialString(ByteBuffer buf)
+ {
+ if (buf == null)
+ {
+ // no change, return empty
+ return "";
+ }
+ utf8.append(buf);
+ String ret = str.toString();
+ str.setLength(0);
+ return ret;
+ }
+}
diff --git a/jetty-websocket/websocket-common/src/test/java/examples/ListenerFrameSocket.java b/jetty-websocket/websocket-common/src/test/java/examples/ListenerFrameSocket.java
new file mode 100644
index 0000000000..ca329d528a
--- /dev/null
+++ b/jetty-websocket/websocket-common/src/test/java/examples/ListenerFrameSocket.java
@@ -0,0 +1,53 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package examples;
+
+import org.eclipse.jetty.websocket.api.Session;
+import org.eclipse.jetty.websocket.api.WebSocketFrameListener;
+import org.eclipse.jetty.websocket.api.extensions.Frame;
+import org.eclipse.jetty.websocket.common.events.EventCapture;
+
+public class ListenerFrameSocket implements WebSocketFrameListener
+{
+ public EventCapture capture = new EventCapture();
+
+ @Override
+ public void onWebSocketClose(int statusCode, String reason)
+ {
+ capture.add("onWebSocketClose(%d, %s)",statusCode,capture.q(reason));
+ }
+
+ @Override
+ public void onWebSocketConnect(Session session)
+ {
+ capture.add("onWebSocketConnect(%s)",session);
+ }
+
+ @Override
+ public void onWebSocketError(Throwable cause)
+ {
+ capture.add("onWebSocketError((%s) %s)",cause.getClass().getSimpleName(),cause.getMessage());
+ }
+
+ @Override
+ public void onWebSocketFrame(Frame frame)
+ {
+ capture.add("onWebSocketFrame(%s, %d, %b)", frame.getType(), frame.getPayload().remaining(), frame.isFin());
+ }
+}
diff --git a/jetty-websocket/websocket-common/src/test/java/examples/ListenerPartialSocket.java b/jetty-websocket/websocket-common/src/test/java/examples/ListenerPartialSocket.java
new file mode 100644
index 0000000000..d48cca8c8b
--- /dev/null
+++ b/jetty-websocket/websocket-common/src/test/java/examples/ListenerPartialSocket.java
@@ -0,0 +1,60 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package examples;
+
+import java.nio.ByteBuffer;
+
+import org.eclipse.jetty.websocket.api.Session;
+import org.eclipse.jetty.websocket.api.WebSocketPartialListener;
+import org.eclipse.jetty.websocket.common.events.EventCapture;
+
+public class ListenerPartialSocket implements WebSocketPartialListener
+{
+ public EventCapture capture = new EventCapture();
+
+ @Override
+ public void onWebSocketClose(int statusCode, String reason)
+ {
+ capture.add("onWebSocketClose(%d, %s)",statusCode,capture.q(reason));
+ }
+
+ @Override
+ public void onWebSocketConnect(Session session)
+ {
+ capture.add("onWebSocketConnect(%s)",session);
+ }
+
+ @Override
+ public void onWebSocketError(Throwable cause)
+ {
+ capture.add("onWebSocketError((%s) %s)",cause.getClass().getSimpleName(),cause.getMessage());
+ }
+
+ @Override
+ public void onWebSocketPartialText(String payload, boolean fin)
+ {
+ capture.add("onWebSocketPartialText('%s', %b)",payload,fin);
+ }
+
+ @Override
+ public void onWebSocketPartialBinary(ByteBuffer payload, boolean fin)
+ {
+ capture.add("onWebSocketPartialBinary(%s [%d], %b)",payload,payload.remaining(),fin);
+ }
+}
diff --git a/jetty-websocket/websocket-common/src/test/java/examples/ListenerPingPongSocket.java b/jetty-websocket/websocket-common/src/test/java/examples/ListenerPingPongSocket.java
new file mode 100644
index 0000000000..e9481afaf0
--- /dev/null
+++ b/jetty-websocket/websocket-common/src/test/java/examples/ListenerPingPongSocket.java
@@ -0,0 +1,60 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package examples;
+
+import java.nio.ByteBuffer;
+
+import org.eclipse.jetty.websocket.api.Session;
+import org.eclipse.jetty.websocket.api.WebSocketPingPongListener;
+import org.eclipse.jetty.websocket.common.events.EventCapture;
+
+public class ListenerPingPongSocket implements WebSocketPingPongListener
+{
+ public EventCapture capture = new EventCapture();
+
+ @Override
+ public void onWebSocketClose(int statusCode, String reason)
+ {
+ capture.add("onWebSocketClose(%d, %s)",statusCode,capture.q(reason));
+ }
+
+ @Override
+ public void onWebSocketConnect(Session session)
+ {
+ capture.add("onWebSocketConnect(%s)",session);
+ }
+
+ @Override
+ public void onWebSocketError(Throwable cause)
+ {
+ capture.add("onWebSocketError((%s) %s)",cause.getClass().getSimpleName(),cause.getMessage());
+ }
+
+ @Override
+ public void onWebSocketPing(ByteBuffer payload)
+ {
+ capture.add("onWebSocketPing(%d)",payload.remaining());
+ }
+
+ @Override
+ public void onWebSocketPong(ByteBuffer payload)
+ {
+ capture.add("onWebSocketPong(%d)",payload.remaining());
+ }
+}
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/CloseInfoTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/CloseInfoTest.java
index eefe04c522..afdca526ab 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/CloseInfoTest.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/CloseInfoTest.java
@@ -18,9 +18,15 @@
package org.eclipse.jetty.websocket.common;
-import static org.eclipse.jetty.websocket.api.StatusCode.*;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.eclipse.jetty.websocket.api.StatusCode.FAILED_TLS_HANDSHAKE;
+import static org.eclipse.jetty.websocket.api.StatusCode.NORMAL;
+import static org.eclipse.jetty.websocket.api.StatusCode.NO_CLOSE;
+import static org.eclipse.jetty.websocket.api.StatusCode.NO_CODE;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
import java.nio.ByteBuffer;
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java
index e9ff59e8c7..9f9f30bd1b 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java
@@ -18,7 +18,7 @@
package org.eclipse.jetty.websocket.common;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.is;
import java.nio.ByteBuffer;
import java.util.Arrays;
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java
index a13b2ecabf..c38f753060 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java
@@ -18,6 +18,8 @@
package org.eclipse.jetty.websocket.common;
+import static org.hamcrest.Matchers.is;
+
import java.nio.ByteBuffer;
import java.util.Arrays;
@@ -39,8 +41,6 @@ import org.eclipse.jetty.websocket.common.util.Hex;
import org.junit.Assert;
import org.junit.Test;
-import static org.hamcrest.Matchers.is;
-
public class GeneratorTest
{
private static final Logger LOG = Log.getLogger(GeneratorTest.WindowHelper.class);
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/WebSocketFrameTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/WebSocketFrameTest.java
index 0240021dd8..863377feca 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/WebSocketFrameTest.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/WebSocketFrameTest.java
@@ -18,7 +18,7 @@
package org.eclipse.jetty.websocket.common;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.is;
import java.nio.ByteBuffer;
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/WebSocketRemoteEndpointTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/WebSocketRemoteEndpointTest.java
index 258c2b2b85..2c15025444 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/WebSocketRemoteEndpointTest.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/WebSocketRemoteEndpointTest.java
@@ -18,7 +18,7 @@
package org.eclipse.jetty.websocket.common;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsString;
import java.io.IOException;
import java.nio.ByteBuffer;
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java
index 580fd25953..6d300cd4d8 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java
@@ -18,7 +18,7 @@
package org.eclipse.jetty.websocket.common.ab;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.is;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
@@ -27,6 +27,7 @@ import java.util.Arrays;
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.Frame;
+import org.eclipse.jetty.websocket.common.Generator;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.Parser;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java
index 9440d8dac8..63ab2fbf4e 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java
@@ -18,7 +18,7 @@
package org.eclipse.jetty.websocket.common.ab;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.is;
import java.nio.ByteBuffer;
@@ -26,6 +26,7 @@ import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.websocket.api.WebSocketBehavior;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.Frame;
+import org.eclipse.jetty.websocket.common.Generator;
import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.Parser;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java
index 2bfdc66341..b9ce79df1a 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java
@@ -18,6 +18,8 @@
package org.eclipse.jetty.websocket.common.ab;
+import static org.hamcrest.Matchers.is;
+
import java.nio.ByteBuffer;
import java.util.Arrays;
@@ -39,8 +41,6 @@ import org.eclipse.jetty.websocket.common.test.UnitParser;
import org.junit.Assert;
import org.junit.Test;
-import static org.hamcrest.Matchers.is;
-
public class TestABCase2
{
WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.CLIENT);
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadBinarySignatureSocket.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadBinarySignatureSocket.java
index bc202e3104..d0633b8ec0 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadBinarySignatureSocket.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadBinarySignatureSocket.java
@@ -30,6 +30,11 @@ public class BadBinarySignatureSocket
{
/**
* Declaring a non-void return type
+ * @param session the session
+ * @param buf the buffer
+ * @param offset the offset
+ * @param len the length
+ * @return the response boolean
*/
@OnWebSocketMessage
public boolean onBinary(Session session, byte buf[], int offset, int len)
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadDuplicateBinarySocket.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadDuplicateBinarySocket.java
index 9de8780735..9441cb85a4 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadDuplicateBinarySocket.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadDuplicateBinarySocket.java
@@ -31,6 +31,9 @@ public class BadDuplicateBinarySocket
{
/**
* First method
+ * @param payload the payload
+ * @param offset the offset
+ * @param len the len
*/
@OnWebSocketMessage
public void binMe(byte[] payload, int offset, int len)
@@ -40,6 +43,7 @@ public class BadDuplicateBinarySocket
/**
* Second method
+ * @param stream the input stream
*/
@OnWebSocketMessage
public void streamMe(InputStream stream)
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadDuplicateFrameSocket.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadDuplicateFrameSocket.java
index 743ed6248c..991e9c5a27 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadDuplicateFrameSocket.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadDuplicateFrameSocket.java
@@ -27,6 +27,7 @@ public class BadDuplicateFrameSocket
{
/**
* The get a frame
+ * @param frame the frame
*/
@OnWebSocketFrame
public void frameMe(Frame frame)
@@ -36,6 +37,7 @@ public class BadDuplicateFrameSocket
/**
* This is a duplicate frame type (should throw an exception attempting to use)
+ * @param frame the frame
*/
@OnWebSocketFrame
public void watchMe(Frame frame)
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadTextSignatureSocket.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadTextSignatureSocket.java
index 43449cdad8..6e16f0d75a 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadTextSignatureSocket.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/BadTextSignatureSocket.java
@@ -30,6 +30,8 @@ public class BadTextSignatureSocket
{
/**
* Declaring a static method
+ * @param session the session
+ * @param text the text message
*/
@OnWebSocketMessage
public static void onText(Session session, String text)
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/FrameSocket.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/FrameSocket.java
index f0bb100ae4..006b04d50c 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/FrameSocket.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/annotations/FrameSocket.java
@@ -27,6 +27,7 @@ public class FrameSocket
{
/**
* A frame
+ * @param frame the frame
*/
@OnWebSocketFrame
public void frameMe(Frame frame)
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventCapture.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventCapture.java
index 4ddd6b9d9a..932d392509 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventCapture.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventCapture.java
@@ -18,6 +18,10 @@
package org.eclipse.jetty.websocket.common.events;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.startsWith;
+
import java.util.regex.Pattern;
import org.eclipse.jetty.toolchain.test.EventQueue;
@@ -25,10 +29,6 @@ import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
import org.junit.Assert;
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.startsWith;
-
@SuppressWarnings("serial")
public class EventCapture extends EventQueue<String>
{
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventDriverTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventDriverTest.java
index e027614469..006f2d6dbe 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventDriverTest.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventDriverTest.java
@@ -30,7 +30,10 @@ import org.eclipse.jetty.websocket.common.frames.BinaryFrame;
import org.eclipse.jetty.websocket.common.frames.PingFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
import org.eclipse.jetty.websocket.common.io.LocalWebSocketSession;
+import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
@@ -49,6 +52,14 @@ public class EventDriverTest
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
+
+ private WebSocketContainerScope container;
+
+ @Before
+ public void initContainer()
+ {
+ this.container = new SimpleContainerScope(WebSocketPolicy.newClientPolicy());
+ }
private Frame makeBinaryFrame(String content, boolean fin)
{
@@ -61,7 +72,7 @@ public class EventDriverTest
AdapterConnectCloseSocket socket = new AdapterConnectCloseSocket();
EventDriver driver = wrap(socket);
- try (LocalWebSocketSession conn = new LocalWebSocketSession(testname,driver,bufferPool))
+ try (LocalWebSocketSession conn = new LocalWebSocketSession(container,testname,driver))
{
conn.open();
driver.incomingFrame(new CloseInfo(StatusCode.NORMAL).asFrame());
@@ -78,7 +89,7 @@ public class EventDriverTest
AnnotatedBinaryArraySocket socket = new AnnotatedBinaryArraySocket();
EventDriver driver = wrap(socket);
- try (LocalWebSocketSession conn = new LocalWebSocketSession(testname,driver,bufferPool))
+ try (LocalWebSocketSession conn = new LocalWebSocketSession(container,testname,driver))
{
conn.open();
driver.incomingFrame(makeBinaryFrame("Hello World",true));
@@ -97,7 +108,7 @@ public class EventDriverTest
AnnotatedTextSocket socket = new AnnotatedTextSocket();
EventDriver driver = wrap(socket);
- try (LocalWebSocketSession conn = new LocalWebSocketSession(testname,driver,bufferPool))
+ try (LocalWebSocketSession conn = new LocalWebSocketSession(container,testname,driver))
{
conn.open();
driver.incomingError(new WebSocketException("oof"));
@@ -116,7 +127,7 @@ public class EventDriverTest
AnnotatedFramesSocket socket = new AnnotatedFramesSocket();
EventDriver driver = wrap(socket);
- try (LocalWebSocketSession conn = new LocalWebSocketSession(testname,driver,bufferPool))
+ try (LocalWebSocketSession conn = new LocalWebSocketSession(container,testname,driver))
{
conn.open();
driver.incomingFrame(new PingFrame().setPayload("PING"));
@@ -140,7 +151,7 @@ public class EventDriverTest
AnnotatedBinaryStreamSocket socket = new AnnotatedBinaryStreamSocket();
EventDriver driver = wrap(socket);
- try (LocalWebSocketSession conn = new LocalWebSocketSession(testname,driver,bufferPool))
+ try (LocalWebSocketSession conn = new LocalWebSocketSession(container,testname,driver))
{
conn.open();
driver.incomingFrame(makeBinaryFrame("Hello World",true));
@@ -154,12 +165,12 @@ public class EventDriverTest
}
@Test
- public void testListener_Text() throws Exception
+ public void testListenerBasic_Text() throws Exception
{
ListenerBasicSocket socket = new ListenerBasicSocket();
EventDriver driver = wrap(socket);
- try (LocalWebSocketSession conn = new LocalWebSocketSession(testname,driver,bufferPool))
+ try (LocalWebSocketSession conn = new LocalWebSocketSession(container,testname,driver))
{
conn.start();
conn.open();
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStackTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStackTest.java
index 18bdb4debb..3a69e83e7a 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStackTest.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/ExtensionStackTest.java
@@ -18,7 +18,7 @@
package org.eclipse.jetty.websocket.common.extensions;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.is;
import java.util.ArrayList;
import java.util.List;
@@ -28,8 +28,9 @@ import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.Extension;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
-import org.eclipse.jetty.websocket.api.extensions.ExtensionFactory;
import org.eclipse.jetty.websocket.common.extensions.identity.IdentityExtension;
+import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.junit.Assert;
import org.junit.Rule;
@@ -56,7 +57,9 @@ public class ExtensionStackTest
private ExtensionStack createExtensionStack()
{
WebSocketPolicy policy = WebSocketPolicy.newClientPolicy();
- ExtensionFactory factory = new WebSocketExtensionFactory(policy,bufferPool);
+ WebSocketContainerScope container = new SimpleContainerScope(policy,bufferPool);
+
+ WebSocketExtensionFactory factory = new WebSocketExtensionFactory(container);
return new ExtensionStack(factory);
}
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/ExtensionTool.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/ExtensionTool.java
index 4e17cc965a..082604a92b 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/ExtensionTool.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/ExtensionTool.java
@@ -18,7 +18,8 @@
package org.eclipse.jetty.websocket.common.extensions;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
import java.nio.ByteBuffer;
import java.util.Collections;
@@ -33,6 +34,8 @@ import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.common.Parser;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.eclipse.jetty.websocket.common.frames.TextFrame;
+import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.common.test.ByteBufferAssert;
import org.eclipse.jetty.websocket.common.test.IncomingFramesCapture;
import org.eclipse.jetty.websocket.common.test.UnitParser;
@@ -126,7 +129,9 @@ public class ExtensionTool
public ExtensionTool(WebSocketPolicy policy, ByteBufferPool bufferPool)
{
this.policy = policy;
- this.factory = new WebSocketExtensionFactory(policy,bufferPool);
+ WebSocketContainerScope container = new SimpleContainerScope(policy, bufferPool);
+ WebSocketExtensionFactory extFactory = new WebSocketExtensionFactory(container);
+ this.factory = extFactory;
}
public Tester newTester(String parameterizedExtension)
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/FragmentExtensionTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/FragmentExtensionTest.java
index 4274cb371b..b245c91f05 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/FragmentExtensionTest.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/FragmentExtensionTest.java
@@ -18,6 +18,8 @@
package org.eclipse.jetty.websocket.common.extensions;
+import static org.hamcrest.Matchers.is;
+
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
@@ -44,8 +46,6 @@ import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
-import static org.hamcrest.Matchers.is;
-
public class FragmentExtensionTest
{
@Rule
@@ -140,6 +140,7 @@ public class FragmentExtensionTest
/**
* Verify that outgoing text frames are fragmented by the maxLength configuration.
+ * @throws IOException on test failure
*/
@Test
public void testOutgoingFramesByMaxLength() throws IOException
@@ -212,6 +213,7 @@ public class FragmentExtensionTest
/**
* Verify that outgoing text frames are fragmented by default configuration
+ * @throws IOException on test failure
*/
@Test
public void testOutgoingFramesDefaultConfig() throws IOException
@@ -276,6 +278,7 @@ public class FragmentExtensionTest
/**
* Outgoing PING (Control Frame) should pass through extension unmodified
+ * @throws IOException on test failure
*/
@Test
public void testOutgoingPing() throws IOException
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/IdentityExtensionTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/IdentityExtensionTest.java
index df581b4120..7cdc07006c 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/IdentityExtensionTest.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/IdentityExtensionTest.java
@@ -18,6 +18,8 @@
package org.eclipse.jetty.websocket.common.extensions;
+import static org.hamcrest.Matchers.is;
+
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
@@ -36,8 +38,6 @@ import org.eclipse.jetty.websocket.common.test.OutgoingFramesCapture;
import org.junit.Assert;
import org.junit.Test;
-import static org.hamcrest.Matchers.is;
-
public class IdentityExtensionTest
{
/**
@@ -71,6 +71,7 @@ public class IdentityExtensionTest
/**
* Verify that outgoing frames are unmodified
+ * @throws IOException on test failure
*/
@Test
public void testOutgoingFrames() throws IOException
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageDeflateExtensionTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageDeflateExtensionTest.java
index b39d4c89e4..3d80f7e2c3 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageDeflateExtensionTest.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageDeflateExtensionTest.java
@@ -18,6 +18,9 @@
package org.eclipse.jetty.websocket.common.extensions.compress;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.*;
+
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
@@ -25,6 +28,7 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.jetty.util.BufferUtil;
+import org.eclipse.jetty.util.TypeUtil;
import org.eclipse.jetty.websocket.api.BatchMode;
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
@@ -44,83 +48,61 @@ import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
-import static org.hamcrest.Matchers.is;
-
/**
* Client side behavioral tests for permessage-deflate extension.
- * <p/>
+ * <p>
* See: http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-15
*/
public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
{
@Rule
public LeakTrackingBufferPoolRule bufferPool = new LeakTrackingBufferPoolRule("Test");
-
- /**
- * Decode payload example as seen in draft-ietf-hybi-permessage-compression-15.
- * <p/>
- * Section 8.2.3.4: Using a DEFLATE Block with BFINAL Set to 1
- */
- @Test
- public void testDraft15_DeflateBlockWithBFinal1()
+
+ private void assertEndsWithTail(String hexStr, boolean expectedResult)
{
- Tester tester = clientExtensions.newTester("permessage-deflate");
-
- tester.assertNegotiated("permessage-deflate");
-
- tester.parseIncomingHex(// 1 message
- "0xc1 0x08", // header
- "0xf3 0x48 0xcd 0xc9 0xc9 0x07 0x00 0x00" // example payload
- );
-
- tester.assertHasFrames("Hello");
+ ByteBuffer buf = ByteBuffer.wrap(TypeUtil.fromHexString(hexStr));
+ assertThat("endsWithTail([" + hexStr + "])",CompressExtension.endsWithTail(buf),is(expectedResult));
}
-
- /**
- * Decode payload example as seen in draft-ietf-hybi-permessage-compression-15.
- * <p/>
- * Section 8.2.3.3: Using a DEFLATE Block with No Compression
- */
+
@Test
- public void testDraft15_DeflateBlockWithNoCompression()
+ public void testEndsWithTailBytes()
{
- Tester tester = clientExtensions.newTester("permessage-deflate");
-
- tester.assertNegotiated("permessage-deflate");
-
- tester.parseIncomingHex(// 1 message / no compression
- "0xc1 0x0b 0x00 0x05 0x00 0xfa 0xff 0x48 0x65 0x6c 0x6c 0x6f 0x00" // example frame
- );
-
- tester.assertHasFrames("Hello");
+ assertEndsWithTail("11223344",false);
+ assertEndsWithTail("00",false);
+ assertEndsWithTail("0000",false);
+ assertEndsWithTail("FFFF0000",false);
+ assertEndsWithTail("880000FFFF",true);
+ assertEndsWithTail("0000FFFF",true);
}
/**
- * Decode payload example as seen in draft-ietf-hybi-permessage-compression-15.
- * <p/>
+ * Decode payload example as seen in draft-ietf-hybi-permessage-compression-21.
+ * <p>
* Section 8.2.3.1: A message compressed using 1 compressed DEFLATE block
*/
@Test
- public void testDraft15_Hello_UnCompressedBlock()
+ public void testDraft21_Hello_UnCompressedBlock()
{
Tester tester = clientExtensions.newTester("permessage-deflate");
tester.assertNegotiated("permessage-deflate");
- tester.parseIncomingHex(//basic, 1 block, compressed with 0 compression level (aka, uncompressed).
- "0xc1 0x07 0xf2 0x48 0xcd 0xc9 0xc9 0x07 0x00" // example frame
+ tester.parseIncomingHex(
+ // basic, 1 block, compressed with 0 compression level (aka, uncompressed).
+ "0xc1 0x07", // (HEADER added for this test)
+ "0xf2 0x48 0xcd 0xc9 0xc9 0x07 0x00" // example frame from RFC
);
tester.assertHasFrames("Hello");
}
/**
- * Decode payload example as seen in draft-ietf-hybi-permessage-compression-15.
- * <p/>
+ * Decode payload example as seen in draft-ietf-hybi-permessage-compression-21.
+ * <p>
* Section 8.2.3.1: A message compressed using 1 compressed DEFLATE block (with fragmentation)
*/
@Test
- public void testDraft15_Hello_UnCompressedBlock_Fragmented()
+ public void testDraft21_Hello_UnCompressedBlock_Fragmented()
{
Tester tester = clientExtensions.newTester("permessage-deflate");
@@ -138,12 +120,12 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
}
/**
- * Decode payload example as seen in draft-ietf-hybi-permessage-compression-15.
- * <p/>
+ * Decode payload example as seen in draft-ietf-hybi-permessage-compression-21.
+ * <p>
* Section 8.2.3.2: Sharing LZ77 Sliding Window
*/
@Test
- public void testDraft15_SharingL77SlidingWindow_ContextTakeover()
+ public void testDraft21_SharingL77SlidingWindow_ContextTakeover()
{
Tester tester = clientExtensions.newTester("permessage-deflate");
@@ -161,12 +143,12 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
}
/**
- * Decode payload example as seen in draft-ietf-hybi-permessage-compression-15.
- * <p/>
+ * Decode payload example as seen in draft-ietf-hybi-permessage-compression-21.
+ * <p>
* Section 8.2.3.2: Sharing LZ77 Sliding Window
*/
@Test
- public void testDraft15_SharingL77SlidingWindow_NoContextTakeover()
+ public void testDraft21_SharingL77SlidingWindow_NoContextTakeover()
{
Tester tester = clientExtensions.newTester("permessage-deflate");
@@ -185,12 +167,51 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
}
/**
- * Decode payload example as seen in draft-ietf-hybi-permessage-compression-15.
- * <p/>
+ * Decode payload example as seen in draft-ietf-hybi-permessage-compression-21.
+ * <p>
+ * Section 8.2.3.3: Using a DEFLATE Block with No Compression
+ */
+ @Test
+ public void testDraft21_DeflateBlockWithNoCompression()
+ {
+ Tester tester = clientExtensions.newTester("permessage-deflate");
+
+ tester.assertNegotiated("permessage-deflate");
+
+ tester.parseIncomingHex(// 1 message / no compression
+ "0xc1 0x0b 0x00 0x05 0x00 0xfa 0xff 0x48 0x65 0x6c 0x6c 0x6f 0x00" // example frame
+ );
+
+ tester.assertHasFrames("Hello");
+ }
+
+ /**
+ * Decode payload example as seen in draft-ietf-hybi-permessage-compression-21.
+ * <p>
+ * Section 8.2.3.4: Using a DEFLATE Block with BFINAL Set to 1
+ */
+ @Test
+ public void testDraft21_DeflateBlockWithBFinal1()
+ {
+ Tester tester = clientExtensions.newTester("permessage-deflate");
+
+ tester.assertNegotiated("permessage-deflate");
+
+ tester.parseIncomingHex(// 1 message
+ "0xc1 0x08", // header
+ "0xf3 0x48 0xcd 0xc9 0xc9 0x07 0x00 0x00" // example payload
+ );
+
+ tester.assertHasFrames("Hello");
+ }
+
+ /**
+ * Decode payload example as seen in draft-ietf-hybi-permessage-compression-21.
+ * <p>
* Section 8.2.3.5: Two DEFLATE Blocks in 1 Message
*/
@Test
- public void testDraft15_TwoDeflateBlocksOneMessage()
+ public void testDraft21_TwoDeflateBlocksOneMessage()
{
Tester tester = clientExtensions.newTester("permessage-deflate");
@@ -298,6 +319,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest
/**
* Outgoing PING (Control Frame) should pass through extension unmodified
+ * @throws IOException on test failure
*/
@Test
public void testOutgoingPing() throws IOException
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/LocalWebSocketConnection.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/LocalWebSocketConnection.java
index 5321d1acdd..3fa82c6a79 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/LocalWebSocketConnection.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/LocalWebSocketConnection.java
@@ -35,7 +35,6 @@ import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
import org.eclipse.jetty.websocket.common.CloseInfo;
import org.eclipse.jetty.websocket.common.ConnectionState;
import org.eclipse.jetty.websocket.common.LogicalConnection;
-import org.eclipse.jetty.websocket.common.WebSocketSession;
import org.eclipse.jetty.websocket.common.io.IOState.ConnectionStateListener;
import org.junit.rules.TestName;
@@ -150,12 +149,6 @@ public class LocalWebSocketConnection implements LogicalConnection, IncomingFram
}
@Override
- public WebSocketSession getSession()
- {
- return null;
- }
-
- @Override
public void incomingError(Throwable e)
{
incoming.incomingError(e);
@@ -236,11 +229,6 @@ public class LocalWebSocketConnection implements LogicalConnection, IncomingFram
}
@Override
- public void setSession(WebSocketSession session)
- {
- }
-
- @Override
public SuspendToken suspend()
{
return null;
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/LocalWebSocketSession.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/LocalWebSocketSession.java
index 843c64e6d5..18f49f3ee3 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/LocalWebSocketSession.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/LocalWebSocketSession.java
@@ -20,9 +20,9 @@ package org.eclipse.jetty.websocket.common.io;
import java.net.URI;
-import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.websocket.common.WebSocketSession;
import org.eclipse.jetty.websocket.common.events.EventDriver;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.common.test.OutgoingFramesCapture;
import org.junit.rules.TestName;
@@ -31,9 +31,10 @@ public class LocalWebSocketSession extends WebSocketSession
private String id;
private OutgoingFramesCapture outgoingCapture;
- public LocalWebSocketSession(TestName testname, EventDriver driver, ByteBufferPool bufferPool)
+ public LocalWebSocketSession(WebSocketContainerScope containerScope, TestName testname, EventDriver driver)
{
- super(URI.create("ws://localhost/LocalWebSocketSesssion/" + testname.getMethodName()),driver,new LocalWebSocketConnection(testname,bufferPool));
+ super(containerScope,URI.create("ws://localhost/LocalWebSocketSesssion/" + testname.getMethodName()),driver,
+ new LocalWebSocketConnection(testname,containerScope.getBufferPool()));
this.id = testname.getMethodName();
outgoingCapture = new OutgoingFramesCapture();
setOutgoingHandler(outgoingCapture);
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageInputStreamTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageInputStreamTest.java
index 54de967cdc..57e8db6f27 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageInputStreamTest.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageInputStreamTest.java
@@ -18,7 +18,7 @@
package org.eclipse.jetty.websocket.common.message;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.is;
import java.io.IOException;
import java.nio.ByteBuffer;
@@ -49,7 +49,6 @@ public class MessageInputStreamTest
{
// Append a single message (simple, short)
ByteBuffer payload = BufferUtil.toBuffer("Hello World",StandardCharsets.UTF_8);
- System.out.printf("payload = %s%n",BufferUtil.toDetailString(payload));
boolean fin = true;
stream.appendFrame(payload,fin);
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageOutputStreamTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageOutputStreamTest.java
index 868a20d9f4..2d49891cac 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageOutputStreamTest.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageOutputStreamTest.java
@@ -33,6 +33,8 @@ import org.eclipse.jetty.websocket.common.events.EventDriver;
import org.eclipse.jetty.websocket.common.events.EventDriverFactory;
import org.eclipse.jetty.websocket.common.io.FramePipes;
import org.eclipse.jetty.websocket.common.io.LocalWebSocketSession;
+import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.junit.After;
import org.junit.Assert;
@@ -73,6 +75,9 @@ public class MessageOutputStreamTest
// Event Driver factory
EventDriverFactory factory = new EventDriverFactory(policy);
+
+ // Container
+ WebSocketContainerScope containerScope = new SimpleContainerScope(policy,bufferPool);
// local socket
EventDriver driver = factory.wrap(new TrackingSocket("local"));
@@ -81,7 +86,7 @@ public class MessageOutputStreamTest
socket = new TrackingSocket("remote");
OutgoingFrames socketPipe = FramePipes.to(factory.wrap(socket));
- session = new LocalWebSocketSession(testname,driver,bufferPool);
+ session = new LocalWebSocketSession(containerScope,testname,driver);
session.setPolicy(policy);
// talk to our remote socket
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageWriterTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageWriterTest.java
index 7b0dac0a47..62ee15036f 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageWriterTest.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/MessageWriterTest.java
@@ -18,6 +18,8 @@
package org.eclipse.jetty.websocket.common.message;
+import static org.hamcrest.Matchers.is;
+
import java.util.Arrays;
import org.eclipse.jetty.toolchain.test.TestTracker;
@@ -29,6 +31,8 @@ import org.eclipse.jetty.websocket.common.events.EventDriver;
import org.eclipse.jetty.websocket.common.events.EventDriverFactory;
import org.eclipse.jetty.websocket.common.io.FramePipes;
import org.eclipse.jetty.websocket.common.io.LocalWebSocketSession;
+import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
+import org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope;
import org.eclipse.jetty.websocket.common.test.LeakTrackingBufferPoolRule;
import org.junit.After;
import org.junit.Assert;
@@ -37,8 +41,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
-import static org.hamcrest.Matchers.is;
-
public class MessageWriterTest
{
private static final Logger LOG = Log.getLogger(MessageWriterTest.class);
@@ -72,6 +74,9 @@ public class MessageWriterTest
// Event Driver factory
EventDriverFactory factory = new EventDriverFactory(policy);
+ // Container
+ WebSocketContainerScope containerScope = new SimpleContainerScope(policy,bufferPool);
+
// local socket
EventDriver driver = factory.wrap(new TrackingSocket("local"));
@@ -79,7 +84,7 @@ public class MessageWriterTest
socket = new TrackingSocket("remote");
OutgoingFrames socketPipe = FramePipes.to(factory.wrap(socket));
- session = new LocalWebSocketSession(testname,driver,bufferPool);
+ session = new LocalWebSocketSession(containerScope,testname,driver);
session.setPolicy(policy);
// talk to our remote socket
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/TrackingInputStreamSocket.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/TrackingInputStreamSocket.java
index ca1b5cd75e..561bfa3c12 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/TrackingInputStreamSocket.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/TrackingInputStreamSocket.java
@@ -18,6 +18,8 @@
package org.eclipse.jetty.websocket.common.message;
+import static org.hamcrest.Matchers.is;
+
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.CountDownLatch;
@@ -33,8 +35,6 @@ import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage;
import org.eclipse.jetty.websocket.api.annotations.WebSocket;
import org.junit.Assert;
-import static org.hamcrest.Matchers.is;
-
@WebSocket
public class TrackingInputStreamSocket
{
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/Utf8CharBufferTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/Utf8CharBufferTest.java
index 8fd4cccaa8..28d0e6be5e 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/Utf8CharBufferTest.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/message/Utf8CharBufferTest.java
@@ -18,7 +18,7 @@
package org.eclipse.jetty.websocket.common.message;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.is;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadClient.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadClient.java
index 65eea4c68e..6662421e9c 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadClient.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadClient.java
@@ -18,12 +18,15 @@
package org.eclipse.jetty.websocket.common.test;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.anyOf;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
@@ -40,6 +43,8 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
+import javax.net.ssl.HttpsURLConnection;
+
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.eclipse.jetty.toolchain.test.EventQueue;
@@ -68,6 +73,7 @@ import org.eclipse.jetty.websocket.common.extensions.WebSocketExtensionFactory;
import org.eclipse.jetty.websocket.common.io.IOState;
import org.eclipse.jetty.websocket.common.io.IOState.ConnectionStateListener;
import org.eclipse.jetty.websocket.common.io.http.HttpResponseHeaderParser;
+import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
import org.junit.Assert;
/**
@@ -82,7 +88,7 @@ import org.junit.Assert;
* with regards to basic IO behavior, a write should work as expected, a read should work as expected, but <u>what</u> byte it sends or reads is not within its
* scope.
*/
-public class BlockheadClient implements OutgoingFrames, ConnectionStateListener, AutoCloseable
+public class BlockheadClient implements OutgoingFrames, ConnectionStateListener, AutoCloseable, IBlockheadClient
{
private class FrameReadingThread extends Thread implements Runnable, IncomingFrames
{
@@ -227,21 +233,33 @@ public class BlockheadClient implements OutgoingFrames, ConnectionStateListener,
this.generator = new Generator(policy,bufferPool);
this.parser = new Parser(policy,bufferPool);
- this.extensionFactory = new WebSocketExtensionFactory(policy,bufferPool);
+ this.extensionFactory = new WebSocketExtensionFactory(new SimpleContainerScope(policy,bufferPool));
this.ioState = new IOState();
this.ioState.addListener(this);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#addExtensions(java.lang.String)
+ */
+ @Override
public void addExtensions(String xtension)
{
this.extensions.add(xtension);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#addHeader(java.lang.String)
+ */
+ @Override
public void addHeader(String header)
{
this.headers.add(header);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#awaitDisconnect(long, java.util.concurrent.TimeUnit)
+ */
+ @Override
public boolean awaitDisconnect(long timeout, TimeUnit unit) throws InterruptedException
{
return disconnectedLatch.await(timeout,unit);
@@ -257,6 +275,9 @@ public class BlockheadClient implements OutgoingFrames, ConnectionStateListener,
extensions.clear();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#close()
+ */
@Override
public void close()
{
@@ -264,6 +285,10 @@ public class BlockheadClient implements OutgoingFrames, ConnectionStateListener,
close(-1,null);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#close(int, java.lang.String)
+ */
+ @Override
public void close(int statusCode, String message)
{
LOG.debug("close({},{})",statusCode,message);
@@ -279,6 +304,10 @@ public class BlockheadClient implements OutgoingFrames, ConnectionStateListener,
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#connect()
+ */
+ @Override
public void connect() throws IOException
{
InetAddress destAddr = InetAddress.getByName(destHttpURI.getHost());
@@ -317,6 +346,10 @@ public class BlockheadClient implements OutgoingFrames, ConnectionStateListener,
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#expectServerDisconnect()
+ */
+ @Override
public void expectServerDisconnect()
{
if (eof)
@@ -347,6 +380,10 @@ public class BlockheadClient implements OutgoingFrames, ConnectionStateListener,
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#expectUpgradeResponse()
+ */
+ @Override
public HttpResponse expectUpgradeResponse() throws IOException
{
HttpResponse response = readResponseHeader();
@@ -460,6 +497,10 @@ public class BlockheadClient implements OutgoingFrames, ConnectionStateListener,
return ioState;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#getProtocols()
+ */
+ @Override
public String getProtocols()
{
return protocols;
@@ -591,6 +632,10 @@ public class BlockheadClient implements OutgoingFrames, ConnectionStateListener,
return frameReader.frames;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#readResponseHeader()
+ */
+ @Override
public HttpResponse readResponseHeader() throws IOException
{
HttpResponse response = new HttpResponse();
@@ -626,6 +671,10 @@ public class BlockheadClient implements OutgoingFrames, ConnectionStateListener,
return response;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#sendStandardRequest()
+ */
+ @Override
public void sendStandardRequest() throws IOException
{
StringBuilder req = generateUpgradeRequest();
@@ -670,11 +719,19 @@ public class BlockheadClient implements OutgoingFrames, ConnectionStateListener,
this.executor = executor;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#setProtocols(java.lang.String)
+ */
+ @Override
public void setProtocols(String protocols)
{
this.protocols = protocols;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#setTimeout(int, java.util.concurrent.TimeUnit)
+ */
+ @Override
public void setTimeout(int duration, TimeUnit unit)
{
this.timeout = (int)TimeUnit.MILLISECONDS.convert(duration,unit);
@@ -719,6 +776,10 @@ public class BlockheadClient implements OutgoingFrames, ConnectionStateListener,
LOG.info("Waking up from sleep");
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#write(org.eclipse.jetty.websocket.common.WebSocketFrame)
+ */
+ @Override
public void write(WebSocketFrame frame) throws IOException
{
if (!ioState.isOpen())
@@ -738,12 +799,20 @@ public class BlockheadClient implements OutgoingFrames, ConnectionStateListener,
extensionStack.outgoingFrame(frame,null,BatchMode.OFF);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#writeRaw(java.nio.ByteBuffer)
+ */
+ @Override
public void writeRaw(ByteBuffer buf) throws IOException
{
LOG.debug("write(ByteBuffer) {}",BufferUtil.toDetailString(buf));
BufferUtil.writeTo(buf,out);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#writeRaw(java.nio.ByteBuffer, int)
+ */
+ @Override
public void writeRaw(ByteBuffer buf, int numBytes) throws IOException
{
int len = Math.min(numBytes,buf.remaining());
@@ -752,12 +821,20 @@ public class BlockheadClient implements OutgoingFrames, ConnectionStateListener,
out.write(arr);
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#writeRaw(java.lang.String)
+ */
+ @Override
public void writeRaw(String str) throws IOException
{
LOG.debug("write((String)[{}]){}{})",str.length(),'\n',str);
out.write(str.getBytes(StandardCharsets.ISO_8859_1));
}
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#writeRawSlowly(java.nio.ByteBuffer, int)
+ */
+ @Override
public void writeRawSlowly(ByteBuffer buf, int segmentSize) throws IOException
{
while (buf.remaining() > 0)
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadServer.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadServer.java
index 7a2c32da35..8d4d614669 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadServer.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadServer.java
@@ -20,52 +20,15 @@ package org.eclipse.jetty.websocket.common.test;
import static org.hamcrest.Matchers.*;
-import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
-import java.net.SocketException;
import java.net.URI;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import org.eclipse.jetty.io.ByteBufferPool;
-import org.eclipse.jetty.io.MappedByteBufferPool;
-import org.eclipse.jetty.util.BufferUtil;
-import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
-import org.eclipse.jetty.websocket.api.BatchMode;
-import org.eclipse.jetty.websocket.api.WebSocketPolicy;
-import org.eclipse.jetty.websocket.api.WriteCallback;
-import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
-import org.eclipse.jetty.websocket.api.extensions.Frame;
-import org.eclipse.jetty.websocket.api.extensions.Frame.Type;
-import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
-import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
-import org.eclipse.jetty.websocket.common.AcceptHash;
-import org.eclipse.jetty.websocket.common.CloseInfo;
-import org.eclipse.jetty.websocket.common.Generator;
-import org.eclipse.jetty.websocket.common.OpCode;
-import org.eclipse.jetty.websocket.common.Parser;
-import org.eclipse.jetty.websocket.common.WebSocketFrame;
-import org.eclipse.jetty.websocket.common.extensions.ExtensionStack;
-import org.eclipse.jetty.websocket.common.extensions.WebSocketExtensionFactory;
-import org.eclipse.jetty.websocket.common.frames.CloseFrame;
import org.junit.Assert;
/**
@@ -75,548 +38,16 @@ import org.junit.Assert;
*/
public class BlockheadServer
{
- public static class ServerConnection implements IncomingFrames, OutgoingFrames, Runnable
- {
- private final int BUFFER_SIZE = 8192;
- private final Socket socket;
- private final ByteBufferPool bufferPool;
- private final WebSocketPolicy policy;
- private final IncomingFramesCapture incomingFrames;
- private final Parser parser;
- private final Generator generator;
- private final AtomicInteger parseCount;
- private final WebSocketExtensionFactory extensionRegistry;
- private final AtomicBoolean echoing = new AtomicBoolean(false);
- private Thread echoThread;
-
- /** Set to true to disable timeouts (for debugging reasons) */
- private boolean debug = false;
- private OutputStream out;
- private InputStream in;
-
- private Map<String, String> extraResponseHeaders = new HashMap<>();
- private OutgoingFrames outgoing = this;
-
- public ServerConnection(Socket socket)
- {
- this.socket = socket;
- this.incomingFrames = new IncomingFramesCapture();
- this.policy = WebSocketPolicy.newServerPolicy();
- this.policy.setMaxBinaryMessageSize(100000);
- this.policy.setMaxTextMessageSize(100000);
- // This is a blockhead server connection, no point tracking leaks on this object.
- this.bufferPool = new MappedByteBufferPool(BUFFER_SIZE);
- this.parser = new Parser(policy,bufferPool);
- this.parseCount = new AtomicInteger(0);
- this.generator = new Generator(policy,bufferPool,false);
- this.extensionRegistry = new WebSocketExtensionFactory(policy,bufferPool);
- }
-
- /**
- * Add an extra header for the upgrade response (from the server). No extra work is done to ensure the key and value are sane for http.
- */
- public void addResponseHeader(String rawkey, String rawvalue)
- {
- extraResponseHeaders.put(rawkey,rawvalue);
- }
-
- public void close() throws IOException
- {
- write(new CloseFrame());
- flush();
- }
-
- public void close(int statusCode) throws IOException
- {
- CloseInfo close = new CloseInfo(statusCode);
- write(close.asFrame());
- flush();
- }
-
- public void disconnect()
- {
- LOG.debug("disconnect");
- IO.close(in);
- IO.close(out);
- if (socket != null)
- {
- try
- {
- socket.close();
- }
- catch (IOException ignore)
- {
- /* ignore */
- }
- }
- }
-
- public void echoMessage(int expectedFrames, int timeoutDuration, TimeUnit timeoutUnit) throws IOException, TimeoutException
- {
- LOG.debug("Echo Frames [expecting {}]",expectedFrames);
- IncomingFramesCapture cap = readFrames(expectedFrames,timeoutDuration,timeoutUnit);
- // now echo them back.
- for (Frame frame : cap.getFrames())
- {
- write(WebSocketFrame.copy(frame).setMasked(false));
- }
- }
-
- public void flush() throws IOException
- {
- getOutputStream().flush();
- }
-
- public ByteBufferPool getBufferPool()
- {
- return bufferPool;
- }
-
- public IncomingFramesCapture getIncomingFrames()
- {
- return incomingFrames;
- }
-
- public InputStream getInputStream() throws IOException
- {
- if (in == null)
- {
- in = socket.getInputStream();
- }
- return in;
- }
-
- private OutputStream getOutputStream() throws IOException
- {
- if (out == null)
- {
- out = socket.getOutputStream();
- }
- return out;
- }
-
- public Parser getParser()
- {
- return parser;
- }
-
- public WebSocketPolicy getPolicy()
- {
- return policy;
- }
-
- @Override
- public void incomingError(Throwable e)
- {
- incomingFrames.incomingError(e);
- }
-
- @Override
- public void incomingFrame(Frame frame)
- {
- LOG.debug("incoming({})",frame);
- int count = parseCount.incrementAndGet();
- if ((count % 10) == 0)
- {
- LOG.info("Server parsed {} frames",count);
- }
- incomingFrames.incomingFrame(WebSocketFrame.copy(frame));
-
- if (frame.getOpCode() == OpCode.CLOSE)
- {
- CloseInfo close = new CloseInfo(frame);
- LOG.debug("Close frame: {}",close);
- }
-
- Type type = frame.getType();
- if (echoing.get() && (type.isData() || type.isContinuation()))
- {
- try
- {
- write(WebSocketFrame.copy(frame).setMasked(false));
- }
- catch (IOException e)
- {
- LOG.warn(e);
- }
- }
- }
-
- @Override
- public void outgoingFrame(Frame frame, WriteCallback callback, BatchMode batchMode)
- {
- ByteBuffer headerBuf = generator.generateHeaderBytes(frame);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("writing out: {}",BufferUtil.toDetailString(headerBuf));
- }
-
- try
- {
- BufferUtil.writeTo(headerBuf,out);
- if (frame.hasPayload())
- BufferUtil.writeTo(frame.getPayload(),out);
- out.flush();
- if (callback != null)
- {
- callback.writeSuccess();
- }
-
- if (frame.getOpCode() == OpCode.CLOSE)
- {
- disconnect();
- }
- }
- catch (Throwable t)
- {
- if (callback != null)
- {
- callback.writeFailed(t);
- }
- }
- }
-
- public List<ExtensionConfig> parseExtensions(List<String> requestLines)
- {
- List<ExtensionConfig> extensionConfigs = new ArrayList<>();
-
- List<String> hits = regexFind(requestLines, "^Sec-WebSocket-Extensions: (.*)$");
-
- for (String econf : hits)
- {
- // found extensions
- ExtensionConfig config = ExtensionConfig.parse(econf);
- extensionConfigs.add(config);
- }
-
- return extensionConfigs;
- }
-
- public String parseWebSocketKey(List<String> requestLines)
- {
- List<String> hits = regexFind(requestLines,"^Sec-WebSocket-Key: (.*)$");
- if (hits.size() <= 0)
- {
- return null;
- }
-
- Assert.assertThat("Number of Sec-WebSocket-Key headers", hits.size(), is(1));
-
- String key = hits.get(0);
- return key;
- }
-
- public int read(ByteBuffer buf) throws IOException
- {
- int len = 0;
- while ((in.available() > 0) && (buf.remaining() > 0))
- {
- buf.put((byte)in.read());
- len++;
- }
- return len;
- }
-
- public IncomingFramesCapture readFrames(int expectedCount, int timeoutDuration, TimeUnit timeoutUnit) throws IOException, TimeoutException
- {
- LOG.debug("Read: waiting for {} frame(s) from client",expectedCount);
- int startCount = incomingFrames.size();
-
- ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false);
- BufferUtil.clearToFill(buf);
- try
- {
- long msDur = TimeUnit.MILLISECONDS.convert(timeoutDuration,timeoutUnit);
- long now = System.currentTimeMillis();
- long expireOn = now + msDur;
- LOG.debug("Now: {} - expireOn: {} ({} ms)",now,expireOn,msDur);
-
- int len = 0;
- while (incomingFrames.size() < (startCount + expectedCount))
- {
- BufferUtil.clearToFill(buf);
- len = read(buf);
- if (len > 0)
- {
- LOG.debug("Read {} bytes",len);
- BufferUtil.flipToFlush(buf,0);
- parser.parse(buf);
- }
- try
- {
- TimeUnit.MILLISECONDS.sleep(20);
- }
- catch (InterruptedException gnore)
- {
- /* ignore */
- }
- if (!debug && (System.currentTimeMillis() > expireOn))
- {
- incomingFrames.dump();
- throw new TimeoutException(String.format("Timeout reading all %d expected frames. (managed to only read %d frame(s))",expectedCount,
- incomingFrames.size()));
- }
- }
- }
- finally
- {
- bufferPool.release(buf);
- }
-
- return incomingFrames;
- }
-
- public String readRequest() throws IOException
- {
- LOG.debug("Reading client request");
- StringBuilder request = new StringBuilder();
- BufferedReader in = new BufferedReader(new InputStreamReader(getInputStream()));
- for (String line = in.readLine(); line != null; line = in.readLine())
- {
- if (line.length() == 0)
- {
- break;
- }
- request.append(line).append("\r\n");
- LOG.debug("read line: {}",line);
- }
-
- LOG.debug("Client Request:{}{}","\n",request);
- return request.toString();
- }
-
- public List<String> readRequestLines() throws IOException
- {
- LOG.debug("Reading client request header");
- List<String> lines = new ArrayList<>();
-
- BufferedReader in = new BufferedReader(new InputStreamReader(getInputStream()));
- for (String line = in.readLine(); line != null; line = in.readLine())
- {
- if (line.length() == 0)
- {
- break;
- }
- lines.add(line);
- }
-
- return lines;
- }
-
- public List<String> regexFind(List<String> lines, String pattern)
- {
- List<String> hits = new ArrayList<>();
-
- Pattern patKey = Pattern.compile(pattern,Pattern.CASE_INSENSITIVE);
-
- Matcher mat;
- for (String line : lines)
- {
- mat = patKey.matcher(line);
- if (mat.matches())
- {
- if (mat.groupCount() >= 1)
- {
- hits.add(mat.group(1));
- }
- else
- {
- hits.add(mat.group(0));
- }
- }
- }
-
- return hits;
- }
-
- public void respond(String rawstr) throws IOException
- {
- LOG.debug("respond(){}{}","\n",rawstr);
- getOutputStream().write(rawstr.getBytes());
- flush();
- }
-
- @Override
- public void run()
- {
- LOG.debug("Entering echo thread");
-
- ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false);
- BufferUtil.clearToFill(buf);
- long readBytes = 0;
- try
- {
- while (echoing.get())
- {
- BufferUtil.clearToFill(buf);
- long len = read(buf);
- if (len > 0)
- {
- readBytes += len;
- LOG.debug("Read {} bytes",len);
- BufferUtil.flipToFlush(buf,0);
- parser.parse(buf);
- }
-
- try
- {
- TimeUnit.MILLISECONDS.sleep(20);
- }
- catch (InterruptedException gnore)
- {
- /* ignore */
- }
- }
- }
- catch (IOException e)
- {
- LOG.debug("Exception during echo loop",e);
- }
- finally
- {
- LOG.debug("Read {} bytes",readBytes);
- bufferPool.release(buf);
- }
- }
-
- public void setSoTimeout(int ms) throws SocketException
- {
- socket.setSoTimeout(ms);
- }
-
- public void startEcho()
- {
- if (echoThread != null)
- {
- throw new IllegalStateException("Echo thread already declared!");
- }
- echoThread = new Thread(this,"BlockheadServer/Echo");
- echoing.set(true);
- echoThread.start();
- }
-
- public void stopEcho()
- {
- echoing.set(false);
- }
-
- public List<String> upgrade() throws IOException
- {
- List<String> requestLines = readRequestLines();
- List<ExtensionConfig> extensionConfigs = parseExtensions(requestLines);
- String key = parseWebSocketKey(requestLines);
-
- LOG.debug("Client Request Extensions: {}",extensionConfigs);
- LOG.debug("Client Request Key: {}",key);
-
- Assert.assertThat("Request: Sec-WebSocket-Key",key,notNullValue());
-
- // collect extensions configured in response header
- ExtensionStack extensionStack = new ExtensionStack(extensionRegistry);
- extensionStack.negotiate(extensionConfigs);
-
- // Start with default routing
- extensionStack.setNextIncoming(this);
- extensionStack.setNextOutgoing(this);
-
- // Configure Parser / Generator
- extensionStack.configure(parser);
- extensionStack.configure(generator);
-
- // Start Stack
- try
- {
- extensionStack.start();
- }
- catch (Exception e)
- {
- throw new IOException("Unable to start Extension Stack");
- }
-
- // Configure Parser
- parser.setIncomingFramesHandler(extensionStack);
-
- // Setup Response
- StringBuilder resp = new StringBuilder();
- resp.append("HTTP/1.1 101 Upgrade\r\n");
- resp.append("Connection: upgrade\r\n");
- resp.append("Sec-WebSocket-Accept: ");
- resp.append(AcceptHash.hashKey(key)).append("\r\n");
- if (extensionStack.hasNegotiatedExtensions())
- {
- // Respond to used extensions
- resp.append("Sec-WebSocket-Extensions: ");
- boolean delim = false;
- for (ExtensionConfig ext : extensionStack.getNegotiatedExtensions())
- {
- if (delim)
- {
- resp.append(", ");
- }
- resp.append(ext.getParameterizedName());
- delim = true;
- }
- resp.append("\r\n");
- }
- if (extraResponseHeaders.size() > 0)
- {
- for (Map.Entry<String, String> xheader : extraResponseHeaders.entrySet())
- {
- resp.append(xheader.getKey());
- resp.append(": ");
- resp.append(xheader.getValue());
- resp.append("\r\n");
- }
- }
- resp.append("\r\n");
-
- // Write Response
- LOG.debug("Response: {}",resp.toString());
- write(resp.toString().getBytes());
- return requestLines;
- }
-
- private void write(byte[] bytes) throws IOException
- {
- getOutputStream().write(bytes);
- }
-
- public void write(byte[] buf, int offset, int length) throws IOException
- {
- getOutputStream().write(buf,offset,length);
- }
-
- public void write(Frame frame) throws IOException
- {
- LOG.debug("write(Frame->{}) to {}",frame,outgoing);
- outgoing.outgoingFrame(frame,null,BatchMode.OFF);
- }
-
- public void write(int b) throws IOException
- {
- getOutputStream().write(b);
- }
-
- public void write(ByteBuffer buf) throws IOException
- {
- byte arr[] = BufferUtil.toArray(buf);
- if ((arr != null) && (arr.length > 0))
- {
- getOutputStream().write(arr);
- }
- }
- }
-
private static final Logger LOG = Log.getLogger(BlockheadServer.class);
private ServerSocket serverSocket;
private URI wsUri;
- public ServerConnection accept() throws IOException
+ public IBlockheadServerConnection accept() throws IOException
{
LOG.debug(".accept()");
assertIsStarted();
Socket socket = serverSocket.accept();
- return new ServerConnection(socket);
+ return new BlockheadServerConnection(socket);
}
private void assertIsStarted()
@@ -633,42 +64,6 @@ public class BlockheadServer
return wsUri;
}
- public void respondToClient(Socket connection, String serverResponse) throws IOException
- {
- InputStream in = null;
- InputStreamReader isr = null;
- BufferedReader buf = null;
- OutputStream out = null;
- try
- {
- in = connection.getInputStream();
- isr = new InputStreamReader(in);
- buf = new BufferedReader(isr);
- String line;
- while ((line = buf.readLine()) != null)
- {
- // System.err.println(line);
- if (line.length() == 0)
- {
- // Got the "\r\n" line.
- break;
- }
- }
-
- // System.out.println("[Server-Out] " + serverResponse);
- out = connection.getOutputStream();
- out.write(serverResponse.getBytes());
- out.flush();
- }
- finally
- {
- IO.close(buf);
- IO.close(isr);
- IO.close(in);
- IO.close(out);
- }
- }
-
public void start() throws IOException
{
InetAddress addr = InetAddress.getByName("localhost");
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadServerConnection.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadServerConnection.java
new file mode 100644
index 0000000000..e54e66423d
--- /dev/null
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/BlockheadServerConnection.java
@@ -0,0 +1,614 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.websocket.common.test;
+
+import static org.hamcrest.Matchers.*;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.SocketException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.jetty.io.ByteBufferPool;
+import org.eclipse.jetty.io.MappedByteBufferPool;
+import org.eclipse.jetty.util.BufferUtil;
+import org.eclipse.jetty.util.IO;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
+import org.eclipse.jetty.websocket.api.BatchMode;
+import org.eclipse.jetty.websocket.api.WebSocketPolicy;
+import org.eclipse.jetty.websocket.api.WriteCallback;
+import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
+import org.eclipse.jetty.websocket.api.extensions.Frame;
+import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
+import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
+import org.eclipse.jetty.websocket.api.extensions.Frame.Type;
+import org.eclipse.jetty.websocket.common.AcceptHash;
+import org.eclipse.jetty.websocket.common.CloseInfo;
+import org.eclipse.jetty.websocket.common.Generator;
+import org.eclipse.jetty.websocket.common.OpCode;
+import org.eclipse.jetty.websocket.common.Parser;
+import org.eclipse.jetty.websocket.common.WebSocketFrame;
+import org.eclipse.jetty.websocket.common.extensions.ExtensionStack;
+import org.eclipse.jetty.websocket.common.extensions.WebSocketExtensionFactory;
+import org.eclipse.jetty.websocket.common.frames.CloseFrame;
+import org.eclipse.jetty.websocket.common.scopes.SimpleContainerScope;
+import org.junit.Assert;
+
+public class BlockheadServerConnection implements IncomingFrames, OutgoingFrames, Runnable, IBlockheadServerConnection
+{
+ private static final Logger LOG = Log.getLogger(BlockheadServerConnection.class);
+
+ private final int BUFFER_SIZE = 8192;
+ private final Socket socket;
+ private final ByteBufferPool bufferPool;
+ private final WebSocketPolicy policy;
+ private final IncomingFramesCapture incomingFrames;
+ private final Parser parser;
+ private final Generator generator;
+ private final AtomicInteger parseCount;
+ private final WebSocketExtensionFactory extensionRegistry;
+ private final AtomicBoolean echoing = new AtomicBoolean(false);
+ private Thread echoThread;
+
+ /** Set to true to disable timeouts (for debugging reasons) */
+ private boolean debug = false;
+ private OutputStream out;
+ private InputStream in;
+
+ private Map<String, String> extraResponseHeaders = new HashMap<>();
+ private OutgoingFrames outgoing = this;
+
+ public BlockheadServerConnection(Socket socket)
+ {
+ this.socket = socket;
+ this.incomingFrames = new IncomingFramesCapture();
+ this.policy = WebSocketPolicy.newServerPolicy();
+ this.policy.setMaxBinaryMessageSize(100000);
+ this.policy.setMaxTextMessageSize(100000);
+ // This is a blockhead server connection, no point tracking leaks on this object.
+ this.bufferPool = new MappedByteBufferPool(BUFFER_SIZE);
+ this.parser = new Parser(policy,bufferPool);
+ this.parseCount = new AtomicInteger(0);
+ this.generator = new Generator(policy,bufferPool,false);
+ this.extensionRegistry = new WebSocketExtensionFactory(new SimpleContainerScope(policy,bufferPool));
+ }
+
+ /**
+ * Add an extra header for the upgrade response (from the server). No extra work is done to ensure the key and value are sane for http.
+ * @param rawkey the raw key
+ * @param rawvalue the raw value
+ */
+ public void addResponseHeader(String rawkey, String rawvalue)
+ {
+ extraResponseHeaders.put(rawkey,rawvalue);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection#close()
+ */
+ @Override
+ public void close() throws IOException
+ {
+ write(new CloseFrame());
+ flush();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection#close(int)
+ */
+ @Override
+ public void close(int statusCode) throws IOException
+ {
+ CloseInfo close = new CloseInfo(statusCode);
+ write(close.asFrame());
+ flush();
+ }
+
+ public void disconnect()
+ {
+ LOG.debug("disconnect");
+ IO.close(in);
+ IO.close(out);
+ if (socket != null)
+ {
+ try
+ {
+ socket.close();
+ }
+ catch (IOException ignore)
+ {
+ /* ignore */
+ }
+ }
+ }
+
+ public void echoMessage(int expectedFrames, int timeoutDuration, TimeUnit timeoutUnit) throws IOException, TimeoutException
+ {
+ LOG.debug("Echo Frames [expecting {}]",expectedFrames);
+ IncomingFramesCapture cap = readFrames(expectedFrames,timeoutDuration,timeoutUnit);
+ // now echo them back.
+ for (Frame frame : cap.getFrames())
+ {
+ write(WebSocketFrame.copy(frame).setMasked(false));
+ }
+ }
+
+ public void flush() throws IOException
+ {
+ getOutputStream().flush();
+ }
+
+ public ByteBufferPool getBufferPool()
+ {
+ return bufferPool;
+ }
+
+ public IncomingFramesCapture getIncomingFrames()
+ {
+ return incomingFrames;
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ if (in == null)
+ {
+ in = socket.getInputStream();
+ }
+ return in;
+ }
+
+ private OutputStream getOutputStream() throws IOException
+ {
+ if (out == null)
+ {
+ out = socket.getOutputStream();
+ }
+ return out;
+ }
+
+ public Parser getParser()
+ {
+ return parser;
+ }
+
+ public WebSocketPolicy getPolicy()
+ {
+ return policy;
+ }
+
+ @Override
+ public void incomingError(Throwable e)
+ {
+ incomingFrames.incomingError(e);
+ }
+
+ @Override
+ public void incomingFrame(Frame frame)
+ {
+ LOG.debug("incoming({})",frame);
+ int count = parseCount.incrementAndGet();
+ if ((count % 10) == 0)
+ {
+ LOG.info("Server parsed {} frames",count);
+ }
+ incomingFrames.incomingFrame(WebSocketFrame.copy(frame));
+
+ if (frame.getOpCode() == OpCode.CLOSE)
+ {
+ CloseInfo close = new CloseInfo(frame);
+ LOG.debug("Close frame: {}",close);
+ }
+
+ Type type = frame.getType();
+ if (echoing.get() && (type.isData() || type.isContinuation()))
+ {
+ try
+ {
+ write(WebSocketFrame.copy(frame).setMasked(false));
+ }
+ catch (IOException e)
+ {
+ LOG.warn(e);
+ }
+ }
+ }
+
+ @Override
+ public void outgoingFrame(Frame frame, WriteCallback callback, BatchMode batchMode)
+ {
+ ByteBuffer headerBuf = generator.generateHeaderBytes(frame);
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("writing out: {}",BufferUtil.toDetailString(headerBuf));
+ }
+
+ try
+ {
+ BufferUtil.writeTo(headerBuf,out);
+ if (frame.hasPayload())
+ BufferUtil.writeTo(frame.getPayload(),out);
+ out.flush();
+ if (callback != null)
+ {
+ callback.writeSuccess();
+ }
+
+ if (frame.getOpCode() == OpCode.CLOSE)
+ {
+ disconnect();
+ }
+ }
+ catch (Throwable t)
+ {
+ if (callback != null)
+ {
+ callback.writeFailed(t);
+ }
+ }
+ }
+
+ public List<ExtensionConfig> parseExtensions(List<String> requestLines)
+ {
+ List<ExtensionConfig> extensionConfigs = new ArrayList<>();
+
+ List<String> hits = regexFind(requestLines, "^Sec-WebSocket-Extensions: (.*)$");
+
+ for (String econf : hits)
+ {
+ // found extensions
+ ExtensionConfig config = ExtensionConfig.parse(econf);
+ extensionConfigs.add(config);
+ }
+
+ return extensionConfigs;
+ }
+
+ public String parseWebSocketKey(List<String> requestLines)
+ {
+ List<String> hits = regexFind(requestLines,"^Sec-WebSocket-Key: (.*)$");
+ if (hits.size() <= 0)
+ {
+ return null;
+ }
+
+ Assert.assertThat("Number of Sec-WebSocket-Key headers", hits.size(), is(1));
+
+ String key = hits.get(0);
+ return key;
+ }
+
+ public int read(ByteBuffer buf) throws IOException
+ {
+ int len = 0;
+ while ((in.available() > 0) && (buf.remaining() > 0))
+ {
+ buf.put((byte)in.read());
+ len++;
+ }
+ return len;
+ }
+
+ public IncomingFramesCapture readFrames(int expectedCount, int timeoutDuration, TimeUnit timeoutUnit) throws IOException, TimeoutException
+ {
+ LOG.debug("Read: waiting for {} frame(s) from client",expectedCount);
+ int startCount = incomingFrames.size();
+
+ ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false);
+ BufferUtil.clearToFill(buf);
+ try
+ {
+ long msDur = TimeUnit.MILLISECONDS.convert(timeoutDuration,timeoutUnit);
+ long now = System.currentTimeMillis();
+ long expireOn = now + msDur;
+ LOG.debug("Now: {} - expireOn: {} ({} ms)",now,expireOn,msDur);
+
+ int len = 0;
+ while (incomingFrames.size() < (startCount + expectedCount))
+ {
+ BufferUtil.clearToFill(buf);
+ len = read(buf);
+ if (len > 0)
+ {
+ LOG.debug("Read {} bytes",len);
+ BufferUtil.flipToFlush(buf,0);
+ parser.parse(buf);
+ }
+ try
+ {
+ TimeUnit.MILLISECONDS.sleep(20);
+ }
+ catch (InterruptedException gnore)
+ {
+ /* ignore */
+ }
+ if (!debug && (System.currentTimeMillis() > expireOn))
+ {
+ incomingFrames.dump();
+ throw new TimeoutException(String.format("Timeout reading all %d expected frames. (managed to only read %d frame(s))",expectedCount,
+ incomingFrames.size()));
+ }
+ }
+ }
+ finally
+ {
+ bufferPool.release(buf);
+ }
+
+ return incomingFrames;
+ }
+
+ public String readRequest() throws IOException
+ {
+ LOG.debug("Reading client request");
+ StringBuilder request = new StringBuilder();
+ BufferedReader in = new BufferedReader(new InputStreamReader(getInputStream()));
+ for (String line = in.readLine(); line != null; line = in.readLine())
+ {
+ if (line.length() == 0)
+ {
+ break;
+ }
+ request.append(line).append("\r\n");
+ LOG.debug("read line: {}",line);
+ }
+
+ LOG.debug("Client Request:{}{}","\n",request);
+ return request.toString();
+ }
+
+ public List<String> readRequestLines() throws IOException
+ {
+ LOG.debug("Reading client request header");
+ List<String> lines = new ArrayList<>();
+
+ BufferedReader in = new BufferedReader(new InputStreamReader(getInputStream()));
+ for (String line = in.readLine(); line != null; line = in.readLine())
+ {
+ if (line.length() == 0)
+ {
+ break;
+ }
+ lines.add(line);
+ }
+
+ return lines;
+ }
+
+ public List<String> regexFind(List<String> lines, String pattern)
+ {
+ List<String> hits = new ArrayList<>();
+
+ Pattern patKey = Pattern.compile(pattern,Pattern.CASE_INSENSITIVE);
+
+ Matcher mat;
+ for (String line : lines)
+ {
+ mat = patKey.matcher(line);
+ if (mat.matches())
+ {
+ if (mat.groupCount() >= 1)
+ {
+ hits.add(mat.group(1));
+ }
+ else
+ {
+ hits.add(mat.group(0));
+ }
+ }
+ }
+
+ return hits;
+ }
+
+ public void respond(String rawstr) throws IOException
+ {
+ LOG.debug("respond(){}{}","\n",rawstr);
+ getOutputStream().write(rawstr.getBytes());
+ flush();
+ }
+
+ @Override
+ public void run()
+ {
+ LOG.debug("Entering echo thread");
+
+ ByteBuffer buf = bufferPool.acquire(BUFFER_SIZE,false);
+ BufferUtil.clearToFill(buf);
+ long readBytes = 0;
+ try
+ {
+ while (echoing.get())
+ {
+ BufferUtil.clearToFill(buf);
+ long len = read(buf);
+ if (len > 0)
+ {
+ readBytes += len;
+ LOG.debug("Read {} bytes",len);
+ BufferUtil.flipToFlush(buf,0);
+ parser.parse(buf);
+ }
+
+ try
+ {
+ TimeUnit.MILLISECONDS.sleep(20);
+ }
+ catch (InterruptedException gnore)
+ {
+ /* ignore */
+ }
+ }
+ }
+ catch (IOException e)
+ {
+ LOG.debug("Exception during echo loop",e);
+ }
+ finally
+ {
+ LOG.debug("Read {} bytes",readBytes);
+ bufferPool.release(buf);
+ }
+ }
+
+ public void setSoTimeout(int ms) throws SocketException
+ {
+ socket.setSoTimeout(ms);
+ }
+
+ public void startEcho()
+ {
+ if (echoThread != null)
+ {
+ throw new IllegalStateException("Echo thread already declared!");
+ }
+ echoThread = new Thread(this,"BlockheadServer/Echo");
+ echoing.set(true);
+ echoThread.start();
+ }
+
+ public void stopEcho()
+ {
+ echoing.set(false);
+ }
+
+ public List<String> upgrade() throws IOException
+ {
+ List<String> requestLines = readRequestLines();
+ List<ExtensionConfig> extensionConfigs = parseExtensions(requestLines);
+ String key = parseWebSocketKey(requestLines);
+
+ LOG.debug("Client Request Extensions: {}",extensionConfigs);
+ LOG.debug("Client Request Key: {}",key);
+
+ Assert.assertThat("Request: Sec-WebSocket-Key",key,notNullValue());
+
+ // collect extensions configured in response header
+ ExtensionStack extensionStack = new ExtensionStack(extensionRegistry);
+ extensionStack.negotiate(extensionConfigs);
+
+ // Start with default routing
+ extensionStack.setNextIncoming(this);
+ extensionStack.setNextOutgoing(this);
+
+ // Configure Parser / Generator
+ extensionStack.configure(parser);
+ extensionStack.configure(generator);
+
+ // Start Stack
+ try
+ {
+ extensionStack.start();
+ }
+ catch (Exception e)
+ {
+ throw new IOException("Unable to start Extension Stack");
+ }
+
+ // Configure Parser
+ parser.setIncomingFramesHandler(extensionStack);
+
+ // Setup Response
+ StringBuilder resp = new StringBuilder();
+ resp.append("HTTP/1.1 101 Upgrade\r\n");
+ resp.append("Connection: upgrade\r\n");
+ resp.append("Sec-WebSocket-Accept: ");
+ resp.append(AcceptHash.hashKey(key)).append("\r\n");
+ if (extensionStack.hasNegotiatedExtensions())
+ {
+ // Respond to used extensions
+ resp.append("Sec-WebSocket-Extensions: ");
+ boolean delim = false;
+ for (ExtensionConfig ext : extensionStack.getNegotiatedExtensions())
+ {
+ if (delim)
+ {
+ resp.append(", ");
+ }
+ resp.append(ext.getParameterizedName());
+ delim = true;
+ }
+ resp.append("\r\n");
+ }
+ if (extraResponseHeaders.size() > 0)
+ {
+ for (Map.Entry<String, String> xheader : extraResponseHeaders.entrySet())
+ {
+ resp.append(xheader.getKey());
+ resp.append(": ");
+ resp.append(xheader.getValue());
+ resp.append("\r\n");
+ }
+ }
+ resp.append("\r\n");
+
+ // Write Response
+ LOG.debug("Response: {}",resp.toString());
+ write(resp.toString().getBytes());
+ return requestLines;
+ }
+
+ private void write(byte[] bytes) throws IOException
+ {
+ getOutputStream().write(bytes);
+ }
+
+ public void write(byte[] buf, int offset, int length) throws IOException
+ {
+ getOutputStream().write(buf,offset,length);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jetty.websocket.common.test.IBlockheadServerConnection#write(org.eclipse.jetty.websocket.api.extensions.Frame)
+ */
+ @Override
+ public void write(Frame frame) throws IOException
+ {
+ LOG.debug("write(Frame->{}) to {}",frame,outgoing);
+ outgoing.outgoingFrame(frame,null,BatchMode.OFF);
+ }
+
+ public void write(int b) throws IOException
+ {
+ getOutputStream().write(b);
+ }
+
+ public void write(ByteBuffer buf) throws IOException
+ {
+ byte arr[] = BufferUtil.toArray(buf);
+ if ((arr != null) && (arr.length > 0))
+ {
+ getOutputStream().write(arr);
+ }
+ }
+} \ No newline at end of file
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/ByteBufferAssert.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/ByteBufferAssert.java
index 9c0e02fb73..4709069796 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/ByteBufferAssert.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/ByteBufferAssert.java
@@ -18,8 +18,9 @@
package org.eclipse.jetty.websocket.common.test;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertThat;
import java.nio.ByteBuffer;
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/DummyConnection.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/DummyConnection.java
index dc03d2abb6..012fd78ffc 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/DummyConnection.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/DummyConnection.java
@@ -16,7 +16,7 @@
// ========================================================================
//
-package org.eclipse.jetty.websocket.jsr356.server;
+package org.eclipse.jetty.websocket.common.test;
import java.net.InetSocketAddress;
import java.util.concurrent.Executor;
@@ -31,7 +31,6 @@ import org.eclipse.jetty.websocket.api.WriteCallback;
import org.eclipse.jetty.websocket.api.extensions.Frame;
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
import org.eclipse.jetty.websocket.common.LogicalConnection;
-import org.eclipse.jetty.websocket.common.WebSocketSession;
import org.eclipse.jetty.websocket.common.io.IOState;
public class DummyConnection implements LogicalConnection
@@ -104,13 +103,6 @@ public class DummyConnection implements LogicalConnection
@Override
public InetSocketAddress getRemoteAddress()
{
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public WebSocketSession getSession()
- {
return null;
}
@@ -150,11 +142,6 @@ public class DummyConnection implements LogicalConnection
}
@Override
- public void setSession(WebSocketSession session)
- {
- }
-
- @Override
public SuspendToken suspend()
{
return null;
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/Fuzzer.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/Fuzzer.java
index d1dcd3c76b..78f925ff12 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/Fuzzer.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/Fuzzer.java
@@ -18,7 +18,8 @@
package org.eclipse.jetty.websocket.common.test;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.is;
import java.io.IOException;
import java.net.SocketException;
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IBlockheadClient.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IBlockheadClient.java
new file mode 100644
index 0000000000..9afea76102
--- /dev/null
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IBlockheadClient.java
@@ -0,0 +1,79 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.websocket.common.test;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.nio.ByteBuffer;
+import java.util.concurrent.TimeUnit;
+
+import org.eclipse.jetty.toolchain.test.EventQueue;
+import org.eclipse.jetty.websocket.common.WebSocketFrame;
+
+/**
+ * Interface for BlockheadClient.
+ */
+public interface IBlockheadClient extends AutoCloseable
+{
+ public void addExtensions(String xtension);
+
+ public void addHeader(String header);
+
+ public boolean awaitDisconnect(long timeout, TimeUnit unit) throws InterruptedException;
+
+ public void close();
+
+ public void close(int statusCode, String message);
+
+ public void connect() throws IOException;
+
+ public void disconnect();
+
+ public void expectServerDisconnect();
+
+ public HttpResponse expectUpgradeResponse() throws IOException;
+
+ public InetSocketAddress getLocalSocketAddress();
+
+ public String getProtocols();
+
+ public InetSocketAddress getRemoteSocketAddress();
+
+ public EventQueue<WebSocketFrame> readFrames(int expectedFrameCount, int timeoutDuration, TimeUnit timeoutUnit) throws Exception;
+
+ public HttpResponse readResponseHeader() throws IOException;
+
+ public void sendStandardRequest() throws IOException;
+
+ public void setConnectionValue(String connectionValue);
+
+ public void setProtocols(String protocols);
+
+ public void setTimeout(int duration, TimeUnit unit);
+
+ public void write(WebSocketFrame frame) throws IOException;
+
+ public void writeRaw(ByteBuffer buf) throws IOException;
+
+ public void writeRaw(ByteBuffer buf, int numBytes) throws IOException;
+
+ public void writeRaw(String str) throws IOException;
+
+ public void writeRawSlowly(ByteBuffer buf, int segmentSize) throws IOException;
+} \ No newline at end of file
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IBlockheadServerConnection.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IBlockheadServerConnection.java
new file mode 100644
index 0000000000..dc3c5a7e5b
--- /dev/null
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IBlockheadServerConnection.java
@@ -0,0 +1,68 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ========================================================================
+//
+
+package org.eclipse.jetty.websocket.common.test;
+
+import java.io.IOException;
+import java.net.SocketException;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.eclipse.jetty.io.ByteBufferPool;
+import org.eclipse.jetty.websocket.api.extensions.Frame;
+import org.eclipse.jetty.websocket.common.Parser;
+
+public interface IBlockheadServerConnection
+{
+ public void close() throws IOException;
+
+ public void close(int statusCode) throws IOException;
+
+ public void write(Frame frame) throws IOException;
+
+ public List<String> upgrade() throws IOException;
+
+ public void disconnect();
+
+ public IncomingFramesCapture readFrames(int expectedCount, int timeoutDuration, TimeUnit timeoutUnit) throws IOException, TimeoutException;
+ public void write(ByteBuffer buf) throws IOException;
+ public List<String> readRequestLines() throws IOException;
+ public String parseWebSocketKey(List<String> requestLines);
+ public void respond(String rawstr) throws IOException;
+ public String readRequest() throws IOException;
+ public List<String> regexFind(List<String> lines, String pattern);
+ public void echoMessage(int expectedFrames, int timeoutDuration, TimeUnit timeoutUnit) throws IOException, TimeoutException;
+ public void setSoTimeout(int ms) throws SocketException;
+ public ByteBufferPool getBufferPool();
+ public int read(ByteBuffer buf) throws IOException;
+ public Parser getParser();
+ public IncomingFramesCapture getIncomingFrames();
+ public void flush() throws IOException;
+ public void write(int b) throws IOException;
+ public void startEcho();
+ public void stopEcho();
+
+ /**
+ * Add an extra header for the upgrade response (from the server). No extra work is done to ensure the key and value are sane for http.
+ * @param rawkey the raw key
+ * @param rawvalue the raw value
+ */
+ public void addResponseHeader(String rawkey, String rawvalue);
+} \ No newline at end of file
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IncomingFramesCapture.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IncomingFramesCapture.java
index 5fc94ac220..9d62aafc7e 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IncomingFramesCapture.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/IncomingFramesCapture.java
@@ -18,7 +18,8 @@
package org.eclipse.jetty.websocket.common.test;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.is;
import java.util.Queue;
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/LeakTrackingBufferPoolRule.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/LeakTrackingBufferPoolRule.java
index 49224edf52..fc982d88fc 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/LeakTrackingBufferPoolRule.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/LeakTrackingBufferPoolRule.java
@@ -18,15 +18,15 @@
package org.eclipse.jetty.websocket.common.test;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
import org.eclipse.jetty.io.LeakTrackingByteBufferPool;
import org.eclipse.jetty.io.MappedByteBufferPool;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
public class LeakTrackingBufferPoolRule extends LeakTrackingByteBufferPool implements TestRule
{
private final String id;
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/OutgoingFramesCapture.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/OutgoingFramesCapture.java
index 2ed9db7b37..1850882e60 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/OutgoingFramesCapture.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/OutgoingFramesCapture.java
@@ -18,6 +18,9 @@
package org.eclipse.jetty.websocket.common.test;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.is;
+
import java.util.LinkedList;
import org.eclipse.jetty.util.BufferUtil;
@@ -29,9 +32,6 @@ import org.eclipse.jetty.websocket.common.OpCode;
import org.eclipse.jetty.websocket.common.WebSocketFrame;
import org.junit.Assert;
-import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.hamcrest.Matchers.is;
-
public class OutgoingFramesCapture implements OutgoingFrames
{
private LinkedList<WebSocketFrame> frames = new LinkedList<>();
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/OutgoingNetworkBytesCapture.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/OutgoingNetworkBytesCapture.java
index ee7ae9fc48..b96518f8aa 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/OutgoingNetworkBytesCapture.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/OutgoingNetworkBytesCapture.java
@@ -18,6 +18,9 @@
package org.eclipse.jetty.websocket.common.test;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.lessThan;
+
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@@ -32,9 +35,6 @@ import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
import org.eclipse.jetty.websocket.common.Generator;
import org.junit.Assert;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.lessThan;
-
/**
* Capture outgoing network bytes.
*/
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/RawFrameBuilder.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/RawFrameBuilder.java
index 3f814b5f66..5e69fb6936 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/RawFrameBuilder.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/RawFrameBuilder.java
@@ -18,7 +18,7 @@
package org.eclipse.jetty.websocket.common.test;
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.Matchers.is;
import java.nio.ByteBuffer;
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/UnitGenerator.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/UnitGenerator.java
index df9f8414c9..f92d29e45c 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/UnitGenerator.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/UnitGenerator.java
@@ -83,6 +83,8 @@ public class UnitGenerator extends Generator
/**
* Generate a single giant buffer of all provided frames Not appropriate for production code, but useful for testing.
+ * @param frames the list of frames to generate from
+ * @return the bytebuffer representing all of the generated frames
*/
public static ByteBuffer generate(List<WebSocketFrame> frames)
{
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/UnitParser.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/UnitParser.java
index b93776cac3..9f924d264a 100644
--- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/UnitParser.java
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/test/UnitParser.java
@@ -50,6 +50,7 @@ public class UnitParser extends Parser
* Parse a buffer, but do so in a quiet fashion, squelching stacktraces if encountered.
* <p>
* Use if you know the parse will cause an exception and just don't wnat to make the test console all noisy.
+ * @param buf the buffer to parse
*/
public void parseQuietly(ByteBuffer buf)
{
diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/util/Sha1Sum.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/util/Sha1Sum.java
new file mode 100644
index 0000000000..f3771efb8a
--- /dev/null
+++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/util/Sha1Sum.java
@@ -0,0 +1,110 @@
+//
+// ========================================================================
+// Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// All rights reserved. This program and the accompanying materials
+// are made available under the terms of the Eclipse Public License v1.0
+// and Apache License v2.0 which accompanies this distribution.
+//
+// The Eclipse Public License is available at
+// http://www.eclipse.org/legal/epl-v10.html
+//
+// The Apache License v2.0 is available at
+// http://www.opensource.org/licenses/apache2.0.php
+//
+// You may elect to redistribute this code under either of these licenses.
+// ==========================================================