Created
February 1, 2017 12:24
-
-
Save andreldm/7f89a3279438467a0bd41e6c1249d014 to your computer and use it in GitHub Desktop.
APR on Spring Boot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.catalina.LifecycleListener; | |
import org.apache.catalina.core.AprLifecycleListener; | |
import org.springframework.beans.factory.annotation.Value; | |
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; | |
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
/** | |
* NOTE: You also need to install APR on your system, on Arch Linux the package is called `tomcat-native`. | |
*/ | |
@Configuration | |
public class AprConfiguration { | |
@Value("${server.tomcat.apr.enabled:false}") | |
private boolean enabled; | |
@Bean | |
public EmbeddedServletContainerFactory servletContainer() { | |
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(); | |
if (enabled) { | |
LifecycleListener arpLifecycle = new AprLifecycleListener(); | |
container.setProtocol("org.apache.coyote.http11.Http11AprProtocol"); | |
container.addContextLifecycleListeners(arpLifecycle); | |
} | |
return container; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Consider to use: https://dirask.com/posts/Spring-Boot-2-example-APR-native-library-configuration-with-Tomcat-9-Http11AprProtocol-pq6xxj