421189 - WebSocket / AbstractExtension's WebSocketPolicy is not Session-specific

+ Ensuring that the EventDriver managed policy is used by the
  ExtensionStack
This commit is contained in:
Joakim Erdfelt 2013-12-12 13:51:01 -07:00
parent bc7afdc172
commit ecf3b8a68f
3 changed files with 17 additions and 1 deletions

View File

@ -28,6 +28,7 @@ import org.eclipse.jetty.util.annotation.ManagedObject;
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.WebSocketPolicy;
import org.eclipse.jetty.websocket.api.WriteCallback;
import org.eclipse.jetty.websocket.api.extensions.Extension;
import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig;
@ -245,6 +246,17 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames
this.nextOutgoing = nextOutgoing;
}
public void setPolicy(WebSocketPolicy policy)
{
for (Extension extension : extensions)
{
if (extension instanceof AbstractExtension)
{
((AbstractExtension)extension).setPolicy(policy);
}
}
}
@Override
public String toString()
{
@ -283,4 +295,3 @@ public class ExtensionStack extends ContainerLifeCycle implements IncomingFrames
return s.toString();
}
}

View File

@ -533,6 +533,7 @@ public class WebSocketServerFactory extends ContainerLifeCycle implements WebSoc
WebSocketServerConnection wsConnection = new WebSocketServerConnection(endp,executor,scheduler,driver.getPolicy(),bufferPool,this);
connection = wsConnection;
extensionStack.setPolicy(driver.getPolicy());
extensionStack.configure(wsConnection.getParser());
extensionStack.configure(wsConnection.getGenerator());

View File

@ -38,5 +38,9 @@ public class EchoServlet extends WebSocketServlet
// Setup the desired Socket to use for all incoming upgrade requests
factory.register(EchoSocket.class);
// Some alternate sizes
factory.getPolicy().setMaxBinaryMessageSize(2222);
factory.getPolicy().setMaxTextMessageSize(4444);
}
}