From a7968c07be1b7e5c94fe643d59f8be3393ffaf1f Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 6 Nov 2012 15:51:23 -0700 Subject: [PATCH] Rolling Extension and ExtensionConfig change into rest of websocket-common --- .../common/extensions/WebSocketExtensionRegistry.java | 4 ++-- .../websocket/common/extensions/mux/MuxChannel.java | 3 ++- .../common/io/AbstractWebSocketConnection.java | 8 ++++---- .../jetty/websocket/common/io/InternalConnection.java | 5 +++-- .../common/extensions/FragmentExtensionTest.java | 11 +++++------ .../common/extensions/IdentityExtensionTest.java | 2 +- .../compress/PerMessageCompressionExtensionTest.java | 11 +++++------ .../compress/WebkitDeflateFrameExtensionTest.java | 5 ++--- 8 files changed, 24 insertions(+), 25 deletions(-) diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/WebSocketExtensionRegistry.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/WebSocketExtensionRegistry.java index 7c1d144aec9..3a2e2cffe09 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/WebSocketExtensionRegistry.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/WebSocketExtensionRegistry.java @@ -24,9 +24,9 @@ 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.ExtensionRegistry; +import org.eclipse.jetty.websocket.api.extensions.ExtensionFactory; -public class WebSocketExtensionRegistry extends ExtensionRegistry +public class WebSocketExtensionRegistry extends ExtensionFactory { private WebSocketPolicy policy; private ByteBufferPool bufferPool; diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxChannel.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxChannel.java index 7b5a2982312..f964e3912af 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxChannel.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/mux/MuxChannel.java @@ -35,6 +35,7 @@ import org.eclipse.jetty.websocket.api.SuspendToken; import org.eclipse.jetty.websocket.api.WebSocketConnection; 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.common.CloseInfo; import org.eclipse.jetty.websocket.common.ConnectionState; import org.eclipse.jetty.websocket.common.WebSocketFrame; @@ -97,7 +98,7 @@ public class MuxChannel implements WebSocketConnection, InternalConnection, Inco } @Override - public void configureFromExtensions(List extensions) + public void configureFromExtensions(List extensions) { /* ignore */ } 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 ec0329d4463..db58910ab58 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 @@ -43,12 +43,12 @@ import org.eclipse.jetty.websocket.api.StatusCode; import org.eclipse.jetty.websocket.api.SuspendToken; import org.eclipse.jetty.websocket.api.WebSocketConnection; import org.eclipse.jetty.websocket.api.WebSocketPolicy; +import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig; import org.eclipse.jetty.websocket.common.CloseInfo; import org.eclipse.jetty.websocket.common.ConnectionState; 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.RequestedExtensionConfig; import org.eclipse.jetty.websocket.common.WebSocketFrame; /** @@ -67,7 +67,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp private final FrameQueue queue; private final AtomicBoolean suspendToken; private WebSocketSession session; - private List extensions; + private List extensions; private boolean flushing; private boolean isFilling; private ConnectionState connectionState; @@ -217,7 +217,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp * * @return the list of negotiated extensions in use. */ - public List getExtensions() + public List getExtensions() { return extensions; } @@ -484,7 +484,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp * @param extensions * the list of negotiated extensions in use. */ - public void setExtensions(List extensions) + public void setExtensions(List extensions) { this.extensions = extensions; } diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/InternalConnection.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/InternalConnection.java index 9b918a1fa5a..e03d1839dbf 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/InternalConnection.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/InternalConnection.java @@ -20,12 +20,13 @@ package org.eclipse.jetty.websocket.common.io; import java.util.List; +import org.eclipse.jetty.websocket.api.extensions.Extension; import org.eclipse.jetty.websocket.common.LogicalConnection; -import org.eclipse.jetty.websocket.common.extensions.AbstractExtension; public interface InternalConnection extends LogicalConnection { - void configureFromExtensions(List extensions); + // TODO: find way to remove + void configureFromExtensions(List extensions); void setIncoming(IncomingFrames incoming); 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 5a96afc6e0f..4366b7f6498 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 @@ -37,7 +37,6 @@ import org.eclipse.jetty.websocket.common.ByteBufferAssert; import org.eclipse.jetty.websocket.common.IncomingFramesCapture; import org.eclipse.jetty.websocket.common.OpCode; import org.eclipse.jetty.websocket.common.OutgoingFramesCapture; -import org.eclipse.jetty.websocket.common.RequestedExtensionConfig; import org.eclipse.jetty.websocket.common.WebSocketFrame; import org.eclipse.jetty.websocket.common.extensions.fragment.FragmentExtension; import org.junit.Assert; @@ -56,7 +55,7 @@ public class FragmentExtensionTest FragmentExtension ext = new FragmentExtension(); ext.setBufferPool(new MappedByteBufferPool()); ext.setPolicy(WebSocketPolicy.newServerPolicy()); - ExtensionConfig config = RequestedExtensionConfig.parse("fragment;maxLength=4"); + ExtensionConfig config = ExtensionConfig.parse("fragment;maxLength=4"); ext.setConfig(config); FrameHandler incomingHandler = ext.createIncomingFrameHandler(capture); @@ -108,7 +107,7 @@ public class FragmentExtensionTest FragmentExtension ext = new FragmentExtension(); ext.setBufferPool(new MappedByteBufferPool()); ext.setPolicy(WebSocketPolicy.newServerPolicy()); - ExtensionConfig config = RequestedExtensionConfig.parse("fragment;maxLength=4"); + ExtensionConfig config = ExtensionConfig.parse("fragment;maxLength=4"); ext.setConfig(config); FrameHandler incomingHandler = ext.createIncomingFrameHandler(capture); @@ -143,7 +142,7 @@ public class FragmentExtensionTest FragmentExtension ext = new FragmentExtension(); ext.setBufferPool(new MappedByteBufferPool()); ext.setPolicy(WebSocketPolicy.newServerPolicy()); - ExtensionConfig config = RequestedExtensionConfig.parse("fragment;maxLength=20"); + ExtensionConfig config = ExtensionConfig.parse("fragment;maxLength=20"); ext.setConfig(config); FrameHandler outgoingHandler = ext.createOutgoingFrameHandler(capture); @@ -212,7 +211,7 @@ public class FragmentExtensionTest FragmentExtension ext = new FragmentExtension(); ext.setBufferPool(new MappedByteBufferPool()); ext.setPolicy(WebSocketPolicy.newServerPolicy()); - ExtensionConfig config = RequestedExtensionConfig.parse("fragment"); + ExtensionConfig config = ExtensionConfig.parse("fragment"); ext.setConfig(config); FrameHandler outgoingHandler = ext.createOutgoingFrameHandler(capture); @@ -276,7 +275,7 @@ public class FragmentExtensionTest FragmentExtension ext = new FragmentExtension(); ext.setBufferPool(new MappedByteBufferPool()); ext.setPolicy(WebSocketPolicy.newServerPolicy()); - ExtensionConfig config = RequestedExtensionConfig.parse("fragment;maxLength=4"); + ExtensionConfig config = ExtensionConfig.parse("fragment;maxLength=4"); ext.setConfig(config); FrameHandler outgoingHandler = ext.createOutgoingFrameHandler(capture); 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 d53e5f51d6e..9ad26c88160 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 @@ -47,7 +47,7 @@ public class IdentityExtensionTest { IncomingFramesCapture capture = new IncomingFramesCapture(); - AbstractExtension ext = new IdentityExtension(); + Extension ext = new IdentityExtension(); FrameHandler incomingHandler = ext.createIncomingFrameHandler(capture); WebSocketFrame frame = WebSocketFrame.text("hello"); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageCompressionExtensionTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageCompressionExtensionTest.java index 085404638f1..a5b58d55195 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageCompressionExtensionTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/PerMessageCompressionExtensionTest.java @@ -38,7 +38,6 @@ import org.eclipse.jetty.websocket.common.ByteBufferAssert; import org.eclipse.jetty.websocket.common.IncomingFramesCapture; import org.eclipse.jetty.websocket.common.OpCode; import org.eclipse.jetty.websocket.common.OutgoingFramesCapture; -import org.eclipse.jetty.websocket.common.RequestedExtensionConfig; import org.eclipse.jetty.websocket.common.WebSocketFrame; import org.junit.Assert; import org.junit.Test; @@ -53,7 +52,7 @@ public class PerMessageCompressionExtensionTest PerMessageCompressionExtension ext = new PerMessageCompressionExtension(); ext.setBufferPool(new MappedByteBufferPool()); ext.setPolicy(policy); - ExtensionConfig config = RequestedExtensionConfig.parse("permessage-compress"); + ExtensionConfig config = ExtensionConfig.parse("permessage-compress"); ext.setConfig(config); // Setup capture of incoming frames @@ -166,7 +165,7 @@ public class PerMessageCompressionExtensionTest PerMessageCompressionExtension ext = new PerMessageCompressionExtension(); ext.setBufferPool(new MappedByteBufferPool()); ext.setPolicy(WebSocketPolicy.newServerPolicy()); - ExtensionConfig config = RequestedExtensionConfig.parse("permessage-compress"); + ExtensionConfig config = ExtensionConfig.parse("permessage-compress"); ext.setConfig(config); // Setup capture of incoming frames @@ -203,7 +202,7 @@ public class PerMessageCompressionExtensionTest PerMessageCompressionExtension ext = new PerMessageCompressionExtension(); ext.setBufferPool(new MappedByteBufferPool()); ext.setPolicy(WebSocketPolicy.newServerPolicy()); - ExtensionConfig config = RequestedExtensionConfig.parse("permessage-compress"); + ExtensionConfig config = ExtensionConfig.parse("permessage-compress"); ext.setConfig(config); // Setup capture of incoming frames @@ -258,7 +257,7 @@ public class PerMessageCompressionExtensionTest PerMessageCompressionExtension ext = new PerMessageCompressionExtension(); ext.setBufferPool(new MappedByteBufferPool()); ext.setPolicy(WebSocketPolicy.newServerPolicy()); - ExtensionConfig config = RequestedExtensionConfig.parse("permessage-compress"); + ExtensionConfig config = ExtensionConfig.parse("permessage-compress"); ext.setConfig(config); // Setup capture of outgoing frames @@ -318,7 +317,7 @@ public class PerMessageCompressionExtensionTest PerMessageCompressionExtension ext = new PerMessageCompressionExtension(); ext.setBufferPool(new MappedByteBufferPool()); ext.setPolicy(WebSocketPolicy.newServerPolicy()); - ExtensionConfig config = RequestedExtensionConfig.parse("permessage-compress"); + ExtensionConfig config = ExtensionConfig.parse("permessage-compress"); ext.setConfig(config); // Setup capture of outgoing frames diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/WebkitDeflateFrameExtensionTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/WebkitDeflateFrameExtensionTest.java index 02b0bf0c056..b04fd8a5e9e 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/WebkitDeflateFrameExtensionTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/WebkitDeflateFrameExtensionTest.java @@ -41,7 +41,6 @@ import org.eclipse.jetty.websocket.common.IncomingFramesCapture; import org.eclipse.jetty.websocket.common.OpCode; import org.eclipse.jetty.websocket.common.OutgoingNetworkBytesCapture; import org.eclipse.jetty.websocket.common.Parser; -import org.eclipse.jetty.websocket.common.RequestedExtensionConfig; import org.eclipse.jetty.websocket.common.WebSocketFrame; import org.eclipse.jetty.websocket.common.extensions.IncomingFrameHandler; import org.eclipse.jetty.websocket.common.io.IncomingFrames; @@ -58,7 +57,7 @@ public class WebkitDeflateFrameExtensionTest ext.setBufferPool(new MappedByteBufferPool()); ext.setPolicy(policy); - ExtensionConfig config = RequestedExtensionConfig.parse("x-webkit-deflate-frame"); + ExtensionConfig config = ExtensionConfig.parse("x-webkit-deflate-frame"); ext.setConfig(config); // Setup capture of incoming frames @@ -102,7 +101,7 @@ public class WebkitDeflateFrameExtensionTest ext.setBufferPool(new MappedByteBufferPool()); ext.setPolicy(policy); - ExtensionConfig config = RequestedExtensionConfig.parse("x-webkit-deflate-frame"); + ExtensionConfig config = ExtensionConfig.parse("x-webkit-deflate-frame"); ext.setConfig(config); ByteBufferPool bufferPool = new MappedByteBufferPool();