org.springframework.boot.context.embedded.jetty.JettyServerCustomizer Java Examples

The following examples show how to use org.springframework.boot.context.embedded.jetty.JettyServerCustomizer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JettyConfig.java    From nakadi with MIT License 6 votes vote down vote up
@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.addIncludedMethods(HttpMethod.POST.asString());
        gzipHandler.setHandler(server.getHandler());
        gzipHandler.setSyncFlush(true);
        server.setHandler(gzipHandler);
    });
    return factory;
}
 
Example #2
Source File: MonetaSpringBootApplication.java    From moneta with Apache License 2.0 5 votes vote down vote up
@Bean
public EmbeddedServletContainerFactory servletContainer() {
	JettyEmbeddedServletContainerFactory factory = new JettyEmbeddedServletContainerFactory();

	factory.addServerCustomizers(new JettyServerCustomizer() {
		public void customize(final Server server) {
			// Tweak the connection pool used by Jetty to handle incoming
			// HTTP connections
			Integer localServerMaxThreads = deriveValue(serverMaxThreads,
					DEFAULT_SERVER_MAX_THREADS);
			Integer localServerMinThreads = deriveValue(serverMinThreads,
					DEFAULT_SERVER_MIN_THREADS);
			Integer localServerIdleTimeout = deriveValue(serverIdleTimeout,
					DEFAULT_SERVER_IDLE_TIMEOUT);

			logger.info("Container Max Threads={}", localServerMaxThreads);
			logger.info("Container Min Threads={}", localServerMinThreads);
			logger.info("Container Idle Timeout={}", localServerIdleTimeout);

			final QueuedThreadPool threadPool = server.getBean(QueuedThreadPool.class);
			threadPool.setMaxThreads(Integer.valueOf(localServerMaxThreads));
			threadPool.setMinThreads(Integer.valueOf(localServerMinThreads));
			threadPool.setIdleTimeout(Integer.valueOf(localServerIdleTimeout));
		}
	});
	return factory;
}
 
Example #3
Source File: KeycloakAutoConfiguration.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnClass(name = {"org.eclipse.jetty.webapp.WebAppContext"})
public JettyServerCustomizer jettyKeycloakServerCustomizer() {
    return new KeycloakJettyServerCustomizer(keycloakProperties);
}