Set the javax ws upgrade request in constructor.

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2021-01-12 11:47:35 +11:00
parent 02963baae3
commit 2d43661fe3
2 changed files with 5 additions and 11 deletions

View File

@ -68,7 +68,7 @@ public class JavaxWebSocketFrameHandler implements FrameHandler
private MethodHandle pongHandle;
private JavaxWebSocketMessageMetadata textMetadata;
private JavaxWebSocketMessageMetadata binaryMetadata;
private UpgradeRequest upgradeRequest;
private final UpgradeRequest upgradeRequest;
private EndpointConfig endpointConfig;
private final Map<Byte, RegisteredMessageHandler> messageHandlerMap = new HashMap<>();
private MessageSink textSink;
@ -79,6 +79,7 @@ public class JavaxWebSocketFrameHandler implements FrameHandler
protected byte dataType = OpCode.UNDEFINED;
public JavaxWebSocketFrameHandler(JavaxWebSocketContainer container,
UpgradeRequest upgradeRequest,
Object endpointInstance,
MethodHandle openHandle, MethodHandle closeHandle, MethodHandle errorHandle,
JavaxWebSocketMessageMetadata textMetadata,
@ -89,6 +90,7 @@ public class JavaxWebSocketFrameHandler implements FrameHandler
this.logger = LoggerFactory.getLogger(endpointInstance.getClass());
this.container = container;
this.upgradeRequest = upgradeRequest;
if (endpointInstance instanceof ConfiguredEndpoint)
{
RuntimeException oops = new RuntimeException("ConfiguredEndpoint needs to be unwrapped");
@ -96,7 +98,6 @@ public class JavaxWebSocketFrameHandler implements FrameHandler
throw oops;
}
this.endpointInstance = endpointInstance;
this.openHandle = openHandle;
this.closeHandle = closeHandle;
this.errorHandle = errorHandle;
@ -636,11 +637,6 @@ public class JavaxWebSocketFrameHandler implements FrameHandler
}
}
public void setUpgradeRequest(UpgradeRequest upgradeRequest)
{
this.upgradeRequest = upgradeRequest;
}
public UpgradeRequest getUpgradeRequest()
{
return upgradeRequest;

View File

@ -165,16 +165,14 @@ public abstract class JavaxWebSocketFrameHandlerFactory
errorHandle = InvokerUtils.bindTo(errorHandle, endpoint);
pongHandle = InvokerUtils.bindTo(pongHandle, endpoint);
JavaxWebSocketFrameHandler frameHandler = new JavaxWebSocketFrameHandler(
return new JavaxWebSocketFrameHandler(
container,
upgradeRequest,
endpoint,
openHandle, closeHandle, errorHandle,
textMetadata, binaryMetadata,
pongHandle,
config);
frameHandler.setUpgradeRequest(upgradeRequest);
return frameHandler;
}
public static MessageSink createMessageSink(JavaxWebSocketSession session, JavaxWebSocketMessageMetadata msgMetadata)