Don't enforce the default WebSocketMapping.
If a user wants to use the WebSocketUpgradeFilter with a different WebSocketMapping, they can add the ServerContainer manually and put their own WebSocketMapping in. Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
5d9c81a511
commit
b327992f75
|
@ -91,6 +91,7 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements
|
||||||
|
|
||||||
private final ServletContextHandler contextHandler;
|
private final ServletContextHandler contextHandler;
|
||||||
private final WebSocketMapping webSocketMapping;
|
private final WebSocketMapping webSocketMapping;
|
||||||
|
private final WebSocketComponents components;
|
||||||
private final FrameHandlerFactory frameHandlerFactory;
|
private final FrameHandlerFactory frameHandlerFactory;
|
||||||
private final Executor executor;
|
private final Executor executor;
|
||||||
private final Configuration.ConfigurationCustomizer customizer = new Configuration.ConfigurationCustomizer();
|
private final Configuration.ConfigurationCustomizer customizer = new Configuration.ConfigurationCustomizer();
|
||||||
|
@ -102,14 +103,15 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements
|
||||||
* Main entry point for {@link JettyWebSocketServletContainerInitializer}.
|
* Main entry point for {@link JettyWebSocketServletContainerInitializer}.
|
||||||
*
|
*
|
||||||
* @param webSocketMapping the {@link WebSocketMapping} that this container belongs to
|
* @param webSocketMapping the {@link WebSocketMapping} that this container belongs to
|
||||||
* @param webSocketComponents the {@link WebSocketComponents} instance to use
|
* @param components the {@link WebSocketComponents} instance to use
|
||||||
* @param executor the {@link Executor} to use
|
* @param executor the {@link Executor} to use
|
||||||
*/
|
*/
|
||||||
JettyWebSocketServerContainer(ServletContextHandler contextHandler, WebSocketMapping webSocketMapping, WebSocketComponents webSocketComponents, Executor executor)
|
JettyWebSocketServerContainer(ServletContextHandler contextHandler, WebSocketMapping webSocketMapping, WebSocketComponents components, Executor executor)
|
||||||
{
|
{
|
||||||
this.contextHandler = contextHandler;
|
this.contextHandler = contextHandler;
|
||||||
this.webSocketMapping = webSocketMapping;
|
this.webSocketMapping = webSocketMapping;
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
|
this.components = components;
|
||||||
|
|
||||||
// Ensure there is a FrameHandlerFactory
|
// Ensure there is a FrameHandlerFactory
|
||||||
JettyServerFrameHandlerFactory factory = contextHandler.getBean(JettyServerFrameHandlerFactory.class);
|
JettyServerFrameHandlerFactory factory = contextHandler.getBean(JettyServerFrameHandlerFactory.class);
|
||||||
|
@ -155,6 +157,11 @@ public class JettyWebSocketServerContainer extends ContainerLifeCycle implements
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WebSocketComponents getWebSocketComponents()
|
||||||
|
{
|
||||||
|
return components;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Executor getExecutor()
|
public Executor getExecutor()
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,12 +88,9 @@ public class JettyWebSocketServletContainerInitializer implements ServletContain
|
||||||
*/
|
*/
|
||||||
private static JettyWebSocketServerContainer initialize(ServletContextHandler context)
|
private static JettyWebSocketServerContainer initialize(ServletContextHandler context)
|
||||||
{
|
{
|
||||||
WebSocketComponents components = WebSocketServerComponents.ensureWebSocketComponents(context.getServletContext());
|
|
||||||
WebSocketMapping mapping = WebSocketMapping.ensureMapping(context.getServletContext(), WebSocketMapping.DEFAULT_KEY);
|
|
||||||
JettyWebSocketServerContainer container = JettyWebSocketServerContainer.ensureContainer(context.getServletContext());
|
JettyWebSocketServerContainer container = JettyWebSocketServerContainer.ensureContainer(context.getServletContext());
|
||||||
|
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("configureContext {} {} {}", container, mapping, components);
|
LOG.debug("initialize {}", container);
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
@ -102,6 +99,8 @@ public class JettyWebSocketServletContainerInitializer implements ServletContain
|
||||||
public void onStartup(Set<Class<?>> c, ServletContext context)
|
public void onStartup(Set<Class<?>> c, ServletContext context)
|
||||||
{
|
{
|
||||||
ServletContextHandler contextHandler = ServletContextHandler.getServletContextHandler(context, "Jetty WebSocket SCI");
|
ServletContextHandler contextHandler = ServletContextHandler.getServletContextHandler(context, "Jetty WebSocket SCI");
|
||||||
JettyWebSocketServletContainerInitializer.initialize(contextHandler);
|
JettyWebSocketServerContainer container = JettyWebSocketServletContainerInitializer.initialize(contextHandler);
|
||||||
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("onStartup {}", container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue