Class WebSocketServerFactory

    • Field Detail

      • LOG

        private static final org.eclipse.jetty.util.log.Logger LOG
      • WEBSOCKET_INFLATER_POOL_ATTRIBUTE

        private static final java.lang.String WEBSOCKET_INFLATER_POOL_ATTRIBUTE
        See Also:
        Constant Field Values
      • WEBSOCKET_DEFLATER_POOL_ATTRIBUTE

        private static final java.lang.String WEBSOCKET_DEFLATER_POOL_ATTRIBUTE
        See Also:
        Constant Field Values
      • contextClassloader

        private final java.lang.ClassLoader contextClassloader
      • handshakes

        private final java.util.Map<java.lang.Integer,​WebSocketHandshake> handshakes
      • scheduler

        private final org.eclipse.jetty.util.thread.Scheduler scheduler
      • supportedVersions

        private final java.lang.String supportedVersions
      • bufferPool

        private final org.eclipse.jetty.io.ByteBufferPool bufferPool
      • context

        private final javax.servlet.ServletContext context
      • sessionFactories

        private final java.util.List<SessionFactory> sessionFactories
      • registeredSocketClasses

        private final java.util.List<java.lang.Class<?>> registeredSocketClasses
      • executor

        private java.util.concurrent.Executor executor
      • objectFactory

        private org.eclipse.jetty.util.DecoratedObjectFactory objectFactory
    • Constructor Detail

      • WebSocketServerFactory

        public WebSocketServerFactory()
        Entry point for Spring Boot's MockMVC framework
      • WebSocketServerFactory

        public WebSocketServerFactory​(javax.servlet.ServletContext context)
      • WebSocketServerFactory

        public WebSocketServerFactory​(javax.servlet.ServletContext context,
                                      org.eclipse.jetty.io.ByteBufferPool bufferPool)
      • WebSocketServerFactory

        public WebSocketServerFactory​(javax.servlet.ServletContext context,
                                      WebSocketPolicy policy)
        Parameters:
        context - the servlet context
        policy - the policy to use
      • WebSocketServerFactory

        public WebSocketServerFactory​(javax.servlet.ServletContext context,
                                      WebSocketPolicy policy,
                                      org.eclipse.jetty.io.ByteBufferPool bufferPool)
      • WebSocketServerFactory

        protected WebSocketServerFactory​(WebSocketPolicy policy,
                                         java.util.concurrent.Executor executor,
                                         org.eclipse.jetty.io.ByteBufferPool bufferPool)
        Protected entry point for WebSocketHandler
        Parameters:
        policy - the policy to use
        executor - the executor to use
        bufferPool - the buffer pool to use
      • WebSocketServerFactory

        private WebSocketServerFactory​(javax.servlet.ServletContext context,
                                       WebSocketPolicy policy,
                                       org.eclipse.jetty.util.DecoratedObjectFactory objectFactory,
                                       java.util.concurrent.Executor executor,
                                       org.eclipse.jetty.io.ByteBufferPool bufferPool)
    • Method Detail

      • acceptWebSocket

        public boolean acceptWebSocket​(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response)
                                throws java.io.IOException
        Specified by:
        acceptWebSocket in interface WebSocketServletFactory
        Throws:
        java.io.IOException
      • acceptWebSocket

        public boolean acceptWebSocket​(WebSocketCreator creator,
                                       javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response)
                                throws java.io.IOException
        Specified by:
        acceptWebSocket in interface WebSocketServletFactory
        Throws:
        java.io.IOException
      • addSessionFactory

        public void addSessionFactory​(SessionFactory sessionFactory)
      • doStart

        protected void doStart()
                        throws java.lang.Exception
        Overrides:
        doStart in class org.eclipse.jetty.util.component.ContainerLifeCycle
        Throws:
        java.lang.Exception
      • doStop

        protected void doStop()
                       throws java.lang.Exception
        Overrides:
        doStop in class org.eclipse.jetty.util.component.ContainerLifeCycle
        Throws:
        java.lang.Exception
      • findDecoratedObjectFactory

        private org.eclipse.jetty.util.DecoratedObjectFactory findDecoratedObjectFactory()
        Attempt to find the DecoratedObjectFactory that should be used.
        Returns:
        the DecoratedObjectFactory that should be used. (never null)
      • findExecutor

        private java.util.concurrent.Executor findExecutor()
        Attempt to find the Executor that should be used.
        Returns:
        the Executor that should be used. (never null)
      • getObjectFactory

        public org.eclipse.jetty.util.DecoratedObjectFactory getObjectFactory()
        Description copied from interface: WebSocketContainerScope
        Object Factory used to create objects.
        Specified by:
        getObjectFactory in interface WebSocketContainerScope
        Returns:
        Object Factory used to create instances of objects.
      • getOpenSessions

        public java.util.Collection<WebSocketSession> getOpenSessions()
      • getSslContextFactory

        public org.eclipse.jetty.util.ssl.SslContextFactory getSslContextFactory()
        Description copied from interface: WebSocketContainerScope
        The SslContextFactory in use by the container.
        Specified by:
        getSslContextFactory in interface WebSocketContainerScope
        Returns:
        the SslContextFactory in use by the container (can be null if no SSL context is defined)
      • isUpgradeRequest

        public boolean isUpgradeRequest​(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response)
        Specified by:
        isUpgradeRequest in interface WebSocketServletFactory
      • register

        public void register​(java.lang.Class<?> websocketPojo)
        Description copied from interface: WebSocketServletFactory
        Register a websocket class pojo with the default WebSocketCreator.

        Note: only required if using the default WebSocketCreator provided by this factory.

        Specified by:
        register in interface WebSocketServletFactory
        Parameters:
        websocketPojo - the class to instantiate for each incoming websocket upgrade request.
      • upgrade

        private boolean upgrade​(org.eclipse.jetty.server.HttpConnection http,
                                ServletUpgradeRequest request,
                                ServletUpgradeResponse response,
                                EventDriver driver)
                         throws java.io.IOException
        Upgrade the request/response to a WebSocket Connection.

        This method will not normally return, but will instead throw a UpgradeConnectionException, to exit HTTP handling and initiate WebSocket handling of the connection.

        Parameters:
        http - the raw http connection
        request - The request to upgrade
        response - The response to upgrade
        driver - The websocket handler implementation to use
        Throws:
        java.io.IOException
      • getSendServerVersion

        private boolean getSendServerVersion​(org.eclipse.jetty.server.Connector connector)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class org.eclipse.jetty.util.component.AbstractLifeCycle