Class EmbeddedJettyServer

  • All Implemented Interfaces:
    EmbeddedServer

    public class EmbeddedJettyServer
    extends java.lang.Object
    implements EmbeddedServer
    Spark server implementation
    • Field Detail

      • handler

        private final org.eclipse.jetty.server.Handler handler
      • server

        private org.eclipse.jetty.server.Server server
      • logger

        private final org.slf4j.Logger logger
      • webSocketIdleTimeoutMillis

        private java.util.Optional<java.lang.Integer> webSocketIdleTimeoutMillis
      • threadPool

        private org.eclipse.jetty.util.thread.ThreadPool threadPool
    • Constructor Detail

      • EmbeddedJettyServer

        public EmbeddedJettyServer​(JettyServerFactory serverFactory,
                                   org.eclipse.jetty.server.Handler handler)
    • Method Detail

      • configureWebSockets

        public void configureWebSockets​(java.util.Map<java.lang.String,​WebSocketHandlerWrapper> webSocketHandlers,
                                        java.util.Optional<java.lang.Integer> webSocketIdleTimeoutMillis)
        Description copied from interface: EmbeddedServer
        Configures the web sockets for the embedded server.
        Specified by:
        configureWebSockets in interface EmbeddedServer
        Parameters:
        webSocketHandlers - - web socket handlers.
        webSocketIdleTimeoutMillis - - Optional WebSocket idle timeout (ms).
      • ignite

        public int ignite​(java.lang.String host,
                          int port,
                          SslStores sslStores,
                          int maxThreads,
                          int minThreads,
                          int threadIdleTimeoutMillis)
                   throws java.lang.Exception
        Ignites the embedded server, listening on the specified port, running SSL secured with the specified keystore and truststore. If truststore is null, keystore is reused.
        Specified by:
        ignite in interface EmbeddedServer
        Parameters:
        host - The address to listen on
        port - - the port
        sslStores - - The SSL sslStores.
        maxThreads - - max nbr of threads.
        minThreads - - min nbr of threads.
        threadIdleTimeoutMillis - - idle timeout (ms).
        Returns:
        The port number the server was launched on.
        Throws:
        java.lang.Exception
      • join

        public void join()
                  throws java.lang.InterruptedException
        Joins the embedded server thread(s).
        Specified by:
        join in interface EmbeddedServer
        Throws:
        java.lang.InterruptedException
      • extinguish

        public void extinguish()
        Extinguish the embedded server.
        Specified by:
        extinguish in interface EmbeddedServer
      • activeThreadCount

        public int activeThreadCount()
        Specified by:
        activeThreadCount in interface EmbeddedServer
        Returns:
        The approximate number of currently active threads
      • withThreadPool

        public EmbeddedJettyServer withThreadPool​(org.eclipse.jetty.util.thread.ThreadPool threadPool)
        Sets optional thread pool for jetty server. This is useful for overriding the default thread pool behaviour for example io.dropwizard.metrics.jetty9.InstrumentedQueuedThreadPool.
        Parameters:
        threadPool - thread pool
        Returns:
        Builder pattern - returns this instance