Class WebSocketUpgradeFilter

  • All Implemented Interfaces:
    javax.servlet.Filter, org.eclipse.jetty.util.component.Dumpable, MappedWebSocketCreator

    @ManagedObject("WebSocket Upgrade Filter")
    public class WebSocketUpgradeFilter
    extends java.lang.Object
    implements javax.servlet.Filter, MappedWebSocketCreator, org.eclipse.jetty.util.component.Dumpable
    Inline Servlet Filter to capture WebSocket upgrade requests and perform path mappings to WebSocketCreator objects.
    • Field Detail

      • CONTEXT_ATTRIBUTE_KEY

        public static final java.lang.String CONTEXT_ATTRIBUTE_KEY
        See Also:
        Constant Field Values
      • CONFIG_ATTRIBUTE_KEY

        public static final java.lang.String CONFIG_ATTRIBUTE_KEY
        See Also:
        Constant Field Values
      • ATTR_KEY

        public static final java.lang.String ATTR_KEY
    • Method Detail

      • configure

        public static WebSocketUpgradeFilter configure​(org.eclipse.jetty.servlet.ServletContextHandler context)
                                                throws javax.servlet.ServletException
        Configure the default WebSocketUpgradeFilter.

        This will return the default WebSocketUpgradeFilter on the provided ServletContextHandler, creating the filter if necessary.

        The default WebSocketUpgradeFilter is also available via the ServletContext attribute named org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter

        Parameters:
        context - the ServletContextHandler to use
        Returns:
        the configured default WebSocketUpgradeFilter instance
        Throws:
        javax.servlet.ServletException - if the filer cannot be configured
      • configureContext

        @Deprecated
        public static WebSocketUpgradeFilter configureContext​(org.eclipse.jetty.servlet.ServletContextHandler context)
                                                       throws javax.servlet.ServletException
        Deprecated.
        Parameters:
        context - the ServletContextHandler to use
        Returns:
        a configured WebSocketUpgradeFilter instance
        Throws:
        javax.servlet.ServletException - if the filer cannot be configured
      • addMapping

        public void addMapping​(java.lang.String spec,
                               WebSocketCreator creator)
        Description copied from interface: MappedWebSocketCreator
        Add a mapping, of a pathspec to a WebSocketCreator.

        Recognized Path Spec syntaxes

        /path/to or / or *.ext or servlet|{spec}
        Servlet Syntax
        ^{spec} or regex|{spec}
        Regex Syntax
        uri-template|{spec}
        URI Template (see JSR356 and RFC6570 level 1)
        Specified by:
        addMapping in interface MappedWebSocketCreator
        Parameters:
        spec - the path spec to use.
        creator - the websocket creator for this specific mapping
      • destroy

        public void destroy()
        Specified by:
        destroy in interface javax.servlet.Filter
      • doFilter

        public void doFilter​(javax.servlet.ServletRequest request,
                             javax.servlet.ServletResponse response,
                             javax.servlet.FilterChain chain)
                      throws java.io.IOException,
                             javax.servlet.ServletException
        Specified by:
        doFilter in interface javax.servlet.Filter
        Throws:
        java.io.IOException
        javax.servlet.ServletException
      • dump

        public java.lang.String dump()
        Specified by:
        dump in interface org.eclipse.jetty.util.component.Dumpable
      • dump

        public void dump​(java.lang.Appendable out,
                         java.lang.String indent)
                  throws java.io.IOException
        Specified by:
        dump in interface org.eclipse.jetty.util.component.Dumpable
        Throws:
        java.io.IOException
      • init

        public void init​(javax.servlet.FilterConfig config)
                  throws javax.servlet.ServletException
        Specified by:
        init in interface javax.servlet.Filter
        Throws:
        javax.servlet.ServletException
      • setToAttribute

        public void setToAttribute​(javax.servlet.ServletContext context,
                                   java.lang.String key)
                            throws javax.servlet.ServletException
        Throws:
        javax.servlet.ServletException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object