Class WebSocketMappings

    • Field Detail

      • WEBSOCKET_MAPPING_ATTRIBUTE

        public static final java.lang.String WEBSOCKET_MAPPING_ATTRIBUTE
    • Constructor Detail

      • WebSocketMappings

        public WebSocketMappings()
    • Method Detail

      • getMappings

        public static WebSocketMappings getMappings​(javax.servlet.ServletContext servletContext)
      • ensureMappings

        public static WebSocketMappings ensureMappings​(javax.servlet.ServletContext servletContext)
      • parsePathSpec

        public static PathSpec parsePathSpec​(java.lang.String rawSpec)
        Parse a PathSpec string into a PathSpec instance.

        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)
        Parameters:
        rawSpec - the raw path spec as String to parse.
        Returns:
        the PathSpec implementation for the rawSpec
      • getHandshaker

        public Handshaker getHandshaker()
      • dump

        public java.lang.String dump()
        Specified by:
        dump in interface Dumpable
      • dump

        public void dump​(java.lang.Appendable out,
                         java.lang.String indent)
                  throws java.io.IOException
        Description copied from interface: Dumpable
        Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.
        Specified by:
        dump in interface Dumpable
        Parameters:
        out - The appendable to dump to
        indent - The indent to apply after any new lines.
        Throws:
        java.io.IOException - if unable to write to Appendable
      • addMapping

        public void addMapping​(PathSpec pathSpec,
                               WebSocketCreator creator,
                               FrameHandlerFactory factory,
                               Configuration.Customizer customizer)
                        throws WebSocketException
        Manually add a WebSocket mapping.

        If mapping is added before this configuration is started, then it is persisted through stop/start of this configuration's lifecycle. Otherwise it will be removed when this configuration is stopped.

        Parameters:
        pathSpec - the pathspec to respond on
        creator - the websocket creator to activate on the provided mapping.
        factory - the factory to use to create a FrameHandler for the websocket.
        customizer - the customizer to use to customize the WebSocket session.
        Throws:
        WebSocketException
      • addMapping

        public void addMapping​(PathSpec pathSpec,
                               WebSocketNegotiator negotiator)
                        throws WebSocketException
        Manually add a WebSocket mapping.

        If mapping is added before this configuration is started, then it is persisted through stop/start of this configuration's lifecycle. Otherwise it will be removed when this configuration is stopped.

        Parameters:
        pathSpec - the pathspec to respond on
        negotiator - the WebSocketNegotiator to use to create a FrameHandler for the websocket.
        Throws:
        WebSocketException
      • removeMapping

        public boolean removeMapping​(PathSpec pathSpec)
      • getMatchedNegotiator

        public WebSocketNegotiator getMatchedNegotiator​(java.lang.String target,
                                                        java.util.function.Consumer<PathSpec> pathSpecConsumer)
        Get the matching MappedResource for the provided target.
        Parameters:
        target - the target path
        pathSpecConsumer - the path
        Returns:
        the matching resource, or null if no match.
      • upgrade

        public boolean upgrade​(javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response,
                               Configuration.Customizer defaultCustomizer)
                        throws java.io.IOException
        Throws:
        java.io.IOException