From 64d72abde60a910e9e9cc56daaa30a069bd9cb61 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Thu, 23 Jan 2020 10:20:40 +1100 Subject: [PATCH] Extension interface now uses CoreSession and not Configuration Signed-off-by: Lachlan Roberts --- .../jetty/websocket/core/AbstractExtension.java | 4 ++-- .../org/eclipse/jetty/websocket/core/Extension.java | 5 +++-- .../jetty/websocket/core/internal/ExtensionStack.java | 2 +- .../websocket/core/internal/ValidationExtension.java | 11 ++++++----- .../websocket/core/extensions/ExtensionTool.java | 2 +- .../extensions/PerMessageDeflateExtensionTest.java | 6 +++--- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java index ca8500453d8..bb9a9d2e849 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/AbstractExtension.java @@ -168,9 +168,9 @@ public class AbstractExtension implements Extension } @Override - public void setConfiguration(Configuration configuration) + public void setCoreSession(CoreSession coreSession) { - this.configuration = configuration; + this.configuration = coreSession; } protected Configuration getConfiguration() diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java index 2fdd345f543..9e67ffa51c5 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/Extension.java @@ -86,7 +86,8 @@ public interface Extension extends IncomingFrames, OutgoingFrames void setNextOutgoingFrames(OutgoingFrames nextOutgoing); /** - * Set the {@link Configuration} for this Extension. + * Set the {@link CoreSession} for this Extension. + * @param coreSession */ - void setConfiguration(Configuration configuration); + void setCoreSession(CoreSession coreSession); } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java index 8f661710a2f..c1e0cc448e9 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ExtensionStack.java @@ -254,7 +254,7 @@ public class ExtensionStack implements IncomingFrames, OutgoingFrames, Dumpable for (Extension extension : extensions) { - extension.setConfiguration(coreSession); + extension.setCoreSession(coreSession); } } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java index 2ece2f145e4..3cc5f0166ee 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/internal/ValidationExtension.java @@ -24,7 +24,7 @@ import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.AbstractExtension; -import org.eclipse.jetty.websocket.core.Configuration; +import org.eclipse.jetty.websocket.core.CoreSession; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.Frame; import org.eclipse.jetty.websocket.core.WebSocketComponents; @@ -55,13 +55,14 @@ public class ValidationExtension extends AbstractExtension } @Override - public void setConfiguration(Configuration configuration) + public void setCoreSession(CoreSession coreSession) { - super.setConfiguration(configuration); + super.setCoreSession(coreSession); - if (!(configuration instanceof WebSocketCoreSession)) + // TODO: change validation to use static methods instead of down casting CoreSession. + if (!(coreSession instanceof WebSocketCoreSession)) throw new IllegalArgumentException("ValidationExtension needs a CoreSession Configuration"); - coreSession = (WebSocketCoreSession)configuration; + this.coreSession = (WebSocketCoreSession)coreSession; } @Override diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java index 6b70e2b725c..c6ee2bf1083 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/ExtensionTool.java @@ -77,7 +77,7 @@ public class ExtensionTool { this.ext = components.getExtensionRegistry().newInstance(extConfig, components); this.ext.setNextIncomingFrames(capture); - this.ext.setConfiguration(newWebSocketCoreSession()); + this.ext.setCoreSession(newWebSocketCoreSession()); } public void parseIncomingHex(String... rawhex) diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java index aa12bca3d93..22d881d9996 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/core/extensions/PerMessageDeflateExtensionTest.java @@ -376,7 +376,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest PerMessageDeflateExtension ext = new PerMessageDeflateExtension(); ExtensionConfig config = ExtensionConfig.parse("permessage-deflate"); ext.init(config, components); - ext.setConfiguration(newSession()); + ext.setCoreSession(newSession()); // Setup capture of incoming frames IncomingFramesCapture capture = new IncomingFramesCapture(); @@ -450,7 +450,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest { PerMessageDeflateExtension ext = new PerMessageDeflateExtension(); ext.init(ExtensionConfig.parse("permessage-deflate"), components); - ext.setConfiguration(newSession()); + ext.setCoreSession(newSession()); // Setup capture of outgoing frames OutgoingFramesCapture capture = new OutgoingFramesCapture(); @@ -497,7 +497,7 @@ public class PerMessageDeflateExtensionTest extends AbstractExtensionTest PerMessageDeflateExtension ext = new PerMessageDeflateExtension(); ExtensionConfig config = ExtensionConfig.parse("permessage-deflate"); ext.init(config, components); - ext.setConfiguration(newSession()); + ext.setCoreSession(newSession()); // Setup capture of incoming frames OutgoingFramesCapture capture = new OutgoingFramesCapture();