Extension interface now uses CoreSession and not Configuration

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2020-01-23 10:20:40 +11:00
parent bc88224f19
commit 64d72abde6
6 changed files with 16 additions and 14 deletions

View File

@ -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()

View File

@ -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);
}

View File

@ -254,7 +254,7 @@ public class ExtensionStack implements IncomingFrames, OutgoingFrames, Dumpable
for (Extension extension : extensions)
{
extension.setConfiguration(coreSession);
extension.setCoreSession(coreSession);
}
}

View File

@ -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

View File

@ -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)

View File

@ -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();