Search in sources :

Example 1 with JettyEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory in project scoold by Erudika.

the class ScooldServer method jettyConfigBean.

/**
	 * @return Jetty config bean
	 */
@Bean
public EmbeddedServletContainerFactory jettyConfigBean() {
    JettyEmbeddedServletContainerFactory jef = new JettyEmbeddedServletContainerFactory();
    jef.setPort(getServerPort());
    logger.info("Listening on port {}...", jef.getPort());
    return jef;
}
Also used : JettyEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with JettyEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory in project PublicCMS-preview by sanluan.

the class SprintBootApplication method servletContainer.

/**
 * @return servlet container
 */
@Bean
public EmbeddedServletContainerFactory servletContainer() {
    String server = System.getProperty("cms.server");
    AbstractEmbeddedServletContainerFactory factory = null;
    if ("jetty".equalsIgnoreCase(server)) {
        factory = new JettyEmbeddedServletContainerFactory();
    } else if ("undertow".equalsIgnoreCase(server)) {
        factory = new UndertowEmbeddedServletContainerFactory();
    } else {
        factory = new TomcatEmbeddedServletContainerFactory();
    }
    factory.setPort(Integer.valueOf(System.getProperty("cms.port", "8080")));
    factory.setContextPath(System.getProperty("cms.contextPath", ""));
    factory.setDisplayName("PublicCMS");
    factory.setSessionTimeout(20, TimeUnit.MINUTES);
    return factory;
}
Also used : AbstractEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory) UndertowEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory) JettyEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory) TomcatEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory) Bean(org.springframework.context.annotation.Bean)

Example 3 with JettyEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory 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

JettyEmbeddedServletContainerFactory (org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory)3 Bean (org.springframework.context.annotation.Bean)3 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 AbstractEmbeddedServletContainerFactory (org.springframework.boot.context.embedded.AbstractEmbeddedServletContainerFactory)1 JettyServerCustomizer (org.springframework.boot.context.embedded.jetty.JettyServerCustomizer)1 TomcatEmbeddedServletContainerFactory (org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory)1 UndertowEmbeddedServletContainerFactory (org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory)1 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)1 Configuration (org.springframework.context.annotation.Configuration)1