JSR-356 - Making WebSocketUpgradeFilter an attribute in the ServletContext

This commit is contained in:
Joakim Erdfelt 2013-07-25 09:43:47 -07:00
parent 9c41f57b7c
commit b549410932
2 changed files with 10 additions and 1 deletions

View File

@ -49,7 +49,11 @@ public class WebSocketConfiguration extends AbstractConfiguration
String pathSpec = "/*"; String pathSpec = "/*";
context.addFilter(fholder,pathSpec,EnumSet.of(DispatcherType.REQUEST)); context.addFilter(fholder,pathSpec,EnumSet.of(DispatcherType.REQUEST));
LOG.debug("Adding {} mapped to {} to {}",filter,pathSpec,context); LOG.debug("Adding {} mapped to {} to {}",filter,pathSpec,context);
// Store reference to the WebSocketUpgradeFilter
context.setAttribute(WebSocketUpgradeFilter.class.getName(),filter);
// Store reference to the ServerContainer
ServerContainer container = new ServerContainer(filter); ServerContainer container = new ServerContainer(filter);
filter.setWebSocketServerFactoryListener(container); filter.setWebSocketServerFactoryListener(container);
context.setAttribute(JAVAX_WEBSOCKET_SERVER_CONTAINER,container); context.setAttribute(JAVAX_WEBSOCKET_SERVER_CONTAINER,container);

View File

@ -64,7 +64,7 @@ public class WebSocketUpgradeFilter implements Filter, MappedWebSocketCreator, D
{ {
factory.cleanup(); factory.cleanup();
} }
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{ {
@ -138,6 +138,11 @@ public class WebSocketUpgradeFilter implements Filter, MappedWebSocketCreator, D
pathmap.dump(out,indent + " "); pathmap.dump(out,indent + " ");
} }
public WebSocketServerFactory getFactory()
{
return factory;
}
@ManagedAttribute(value = "mappings", readonly = true) @ManagedAttribute(value = "mappings", readonly = true)
@Override @Override
public PathMappings<WebSocketCreator> getMappings() public PathMappings<WebSocketCreator> getMappings()