Class WebSocketUpgradeFilter
- java.lang.Object
-
- org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter
-
- All Implemented Interfaces:
Filter,org.eclipse.jetty.util.component.Dumpable,MappedWebSocketCreator
@ManagedObject("WebSocket Upgrade Filter") public class WebSocketUpgradeFilter extends Object implements Filter, MappedWebSocketCreator, org.eclipse.jetty.util.component.DumpableInline Servlet Filter to capture WebSocket upgrade requests and perform path mappings toWebSocketCreatorobjects.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCONFIG_ATTRIBUTE_KEYstatic StringCONTEXT_ATTRIBUTE_KEY
-
Constructor Summary
Constructors Constructor Description WebSocketUpgradeFilter()WebSocketUpgradeFilter(NativeWebSocketConfiguration configuration)WebSocketUpgradeFilter(WebSocketServerFactory factory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddMapping(String spec, org.eclipse.jetty.websocket.servlet.WebSocketCreator creator)Add a mapping, of a pathspec to a WebSocketCreator.voidaddMapping(org.eclipse.jetty.http.pathmap.PathSpec spec, org.eclipse.jetty.websocket.servlet.WebSocketCreator creator)Add a mapping.voidaddMapping(PathSpec spec, org.eclipse.jetty.websocket.servlet.WebSocketCreator creator)Deprecated.static WebSocketUpgradeFilterconfigureContext(ServletContext context)Deprecated.useconfigureContext(ServletContextHandler)insteadstatic WebSocketUpgradeFilterconfigureContext(org.eclipse.jetty.servlet.ServletContextHandler context)voiddestroy()voiddoFilter(ServletRequest request, ServletResponse response, FilterChain chain)Stringdump()voiddump(Appendable out, String indent)NativeWebSocketConfigurationgetConfiguration()org.eclipse.jetty.websocket.servlet.WebSocketServletFactorygetFactory()org.eclipse.jetty.websocket.servlet.WebSocketCreatorgetMapping(String target)/** Returns the creator for the given path spec.voidinit(FilterConfig config)booleanremoveMapping(String spec)Removes the mapping based on the given path spec.voidsetToAttribute(ServletContext context, String key)StringtoString()
-
-
-
Field Detail
-
CONTEXT_ATTRIBUTE_KEY
public static final String CONTEXT_ATTRIBUTE_KEY
- See Also:
- Constant Field Values
-
CONFIG_ATTRIBUTE_KEY
public static final String CONFIG_ATTRIBUTE_KEY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
WebSocketUpgradeFilter
public WebSocketUpgradeFilter()
-
WebSocketUpgradeFilter
public WebSocketUpgradeFilter(WebSocketServerFactory factory)
-
WebSocketUpgradeFilter
public WebSocketUpgradeFilter(NativeWebSocketConfiguration configuration)
-
-
Method Detail
-
configureContext
public static WebSocketUpgradeFilter configureContext(org.eclipse.jetty.servlet.ServletContextHandler context) throws ServletException
- Parameters:
context- theServletContextHandlerto use- Returns:
- a configured
WebSocketUpgradeFilterinstance - Throws:
ServletException- if the filer cannot be configured
-
configureContext
@Deprecated public static WebSocketUpgradeFilter configureContext(ServletContext context) throws ServletException
Deprecated.useconfigureContext(ServletContextHandler)instead- Parameters:
context- the ServletContext to use- Returns:
- a configured
WebSocketUpgradeFilterinstance - Throws:
ServletException- if the filer cannot be configured
-
addMapping
public void addMapping(org.eclipse.jetty.http.pathmap.PathSpec spec, org.eclipse.jetty.websocket.servlet.WebSocketCreator creator)Description copied from interface:MappedWebSocketCreatorAdd a mapping.- Specified by:
addMappingin interfaceMappedWebSocketCreator- Parameters:
spec- the path spec to usecreator- the creator for the mapping
-
addMapping
@Deprecated public void addMapping(PathSpec spec, org.eclipse.jetty.websocket.servlet.WebSocketCreator creator)
Deprecated.Description copied from interface:MappedWebSocketCreatorAdd a mapping.- Specified by:
addMappingin interfaceMappedWebSocketCreator- Parameters:
spec- the path spec to usecreator- the creator for the mapping
-
addMapping
public void addMapping(String spec, org.eclipse.jetty.websocket.servlet.WebSocketCreator creator)
Description copied from interface:MappedWebSocketCreatorAdd a mapping, of a pathspec to a WebSocketCreator.Recognized Path Spec syntaxes
/path/toor/or*.extorservlet|{spec}- Servlet Syntax
^{spec}orregex|{spec}- Regex Syntax
uri-template|{spec}- URI Template (see JSR356 and RFC6570 level 1)
- Specified by:
addMappingin interfaceMappedWebSocketCreator- Parameters:
spec- the path spec to use.creator- the websocket creator for this specific mapping
-
removeMapping
public boolean removeMapping(String spec)
Description copied from interface:MappedWebSocketCreatorRemoves the mapping based on the given path spec.- Specified by:
removeMappingin interfaceMappedWebSocketCreator- Parameters:
spec- the path spec to remove (using the same spec syntax as seen inMappedWebSocketCreator.addMapping(String, WebSocketCreator))- Returns:
- true if underlying mapping were altered, false otherwise
-
doFilter
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
- Specified by:
doFilterin interfaceFilter- Throws:
IOExceptionServletException
-
dump
public String dump()
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable
-
dump
public void dump(Appendable out, String indent) throws IOException
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Throws:
IOException
-
getFactory
public org.eclipse.jetty.websocket.servlet.WebSocketServletFactory getFactory()
-
getConfiguration
@ManagedAttribute(value="configuration", readonly=true) public NativeWebSocketConfiguration getConfiguration()
-
getMapping
public org.eclipse.jetty.websocket.servlet.WebSocketCreator getMapping(String target)
Description copied from interface:MappedWebSocketCreator/** Returns the creator for the given path spec.- Specified by:
getMappingin interfaceMappedWebSocketCreator- Parameters:
target- the spec to test for (using the same spec syntax as seen inMappedWebSocketCreator.addMapping(String, WebSocketCreator))- Returns:
- the websocket creator if path spec exists, or null
-
init
public void init(FilterConfig config) throws ServletException
- Specified by:
initin interfaceFilter- Throws:
ServletException
-
setToAttribute
public void setToAttribute(ServletContext context, String key) throws ServletException
- Throws:
ServletException
-
-