use of org.apache.coyote.ajp.AbstractAjpProtocol in project cas by apereo.
the class CasTomcatServletWebServerFactoryCustomizer method configureAjp.
private void configureAjp(final TomcatServletWebServerFactory tomcat) {
val ajp = casProperties.getServer().getTomcat().getAjp();
if (ajp.isEnabled() && ajp.getPort() > 0) {
LOGGER.debug("Creating AJP configuration for the embedded tomcat container...");
val ajpConnector = new Connector(ajp.getProtocol());
ajpConnector.setPort(ajp.getPort());
ajpConnector.setSecure(ajp.isSecure());
ajpConnector.setAllowTrace(ajp.isAllowTrace());
ajpConnector.setScheme(ajp.getScheme());
ajpConnector.setAsyncTimeout(Beans.newDuration(ajp.getAsyncTimeout()).toMillis());
ajpConnector.setEnableLookups(ajp.isEnableLookups());
ajpConnector.setMaxPostSize(ajp.getMaxPostSize());
ajpConnector.addUpgradeProtocol(new Http2Protocol());
val handler = (AbstractAjpProtocol) ajpConnector.getProtocolHandler();
if (handler != null) {
handler.setSecretRequired(ajp.isSecure());
handler.setSecret(ajp.getSecret());
}
if (ajp.getProxyPort() > 0) {
LOGGER.debug("Set AJP proxy port to [{}]", ajp.getProxyPort());
ajpConnector.setProxyPort(ajp.getProxyPort());
}
if (ajp.getRedirectPort() > 0) {
LOGGER.debug("Set AJP redirect port to [{}]", ajp.getRedirectPort());
ajpConnector.setRedirectPort(ajp.getRedirectPort());
}
ajp.getAttributes().forEach(ajpConnector::setProperty);
tomcat.addAdditionalTomcatConnectors(ajpConnector);
}
}
use of org.apache.coyote.ajp.AbstractAjpProtocol in project midpoint by Evolveum.
the class MidPointTomcatServletWebServerFactory method getWebServer.
@Override
public WebServer getWebServer(ServletContextInitializer... initializers) {
Tomcat tomcat = new Tomcat();
File baseDir = (this.baseDirectory != null) ? this.baseDirectory : createTempDir("tomcat");
tomcat.setBaseDir(baseDir.getAbsolutePath());
Connector connector = new Connector(this.protocol) {
@Override
public Response createResponse() {
if (protocolHandler instanceof AbstractAjpProtocol<?>) {
int packetSize = ((AbstractAjpProtocol<?>) protocolHandler).getPacketSize();
return new MidpointResponse(packetSize - org.apache.coyote.ajp.Constants.SEND_HEAD_LEN, contextPath, systemObjectCache);
} else {
return new MidpointResponse(contextPath, systemObjectCache);
}
}
};
tomcat.getService().addConnector(connector);
customizeConnector(connector);
tomcat.setConnector(connector);
tomcat.getHost().setAutoDeploy(false);
Engine engine = tomcat.getEngine();
if (!Strings.isNullOrEmpty(jvmRoute)) {
engine.setJvmRoute(jvmRoute);
}
configureEngine(engine);
for (Connector additionalConnector : getAdditionalTomcatConnectors()) {
tomcat.getService().addConnector(additionalConnector);
}
prepareContext(tomcat.getHost(), initializers);
return getTomcatWebServer(tomcat);
}
Aggregations