Search in sources :

Example 1 with JettyServerCustomizer

use of org.springframework.boot.context.embedded.jetty.JettyServerCustomizer in project nakadi by zalando.

the class JettyConfig method jettyEmbeddedServletContainerFactory.

@Bean
public JettyEmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory(@Value("${server.port:8080}") final String port, @Value("${jetty.threadPool.maxThreads:200}") final String maxThreads, @Value("${jetty.threadPool.minThreads:8}") final String minThreads, @Value("${jetty.threadPool.idleTimeout:60000}") final String idleTimeout) {
    final JettyEmbeddedServletContainerFactory factory = new JettyEmbeddedServletContainerFactory(Integer.valueOf(port));
    factory.addServerCustomizers((JettyServerCustomizer) server -> {
        final QueuedThreadPool threadPool = server.getBean(QueuedThreadPool.class);
        threadPool.setMaxThreads(Integer.valueOf(maxThreads));
        threadPool.setMinThreads(Integer.valueOf(minThreads));
        threadPool.setIdleTimeout(Integer.valueOf(idleTimeout));
        final GzipHandler gzipHandler = new GzipHandler();
        gzipHandler.setHandler(server.getHandler());
        gzipHandler.setSyncFlush(true);
        server.setHandler(gzipHandler);
    });
    return factory;
}
Also used : Value(org.springframework.beans.factory.annotation.Value) Configuration(org.springframework.context.annotation.Configuration) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) JettyEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory) JettyServerCustomizer(org.springframework.boot.context.embedded.jetty.JettyServerCustomizer) Bean(org.springframework.context.annotation.Bean) GzipHandler(org.eclipse.jetty.server.handler.gzip.GzipHandler) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) GzipHandler(org.eclipse.jetty.server.handler.gzip.GzipHandler) JettyEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory) Bean(org.springframework.context.annotation.Bean)

Aggregations

GzipHandler (org.eclipse.jetty.server.handler.gzip.GzipHandler)1 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)1 Value (org.springframework.beans.factory.annotation.Value)1 JettyEmbeddedServletContainerFactory (org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory)1 JettyServerCustomizer (org.springframework.boot.context.embedded.jetty.JettyServerCustomizer)1 Bean (org.springframework.context.annotation.Bean)1 Configuration (org.springframework.context.annotation.Configuration)1