use of org.apache.catalina.connector.Connector in project meecrowave by apache.
the class Meecrowave method createConnector.
protected Connector createConnector() {
final Connector connector;
final Properties properties = configuration.properties;
if (properties != null) {
final Map<String, String> attributes = new HashMap<>();
final ObjectRecipe recipe = new ObjectRecipe(Connector.class);
for (final String key : properties.stringPropertyNames()) {
if (!key.startsWith("connector.")) {
continue;
}
final String substring = key.substring("connector.".length());
if (substring.startsWith("sslhostconfig.")) {
continue;
}
if (!substring.startsWith("attributes.")) {
recipe.setProperty(substring, properties.getProperty(key));
} else {
attributes.put(substring.substring("attributes.".length()), properties.getProperty(key));
}
}
connector = recipe.getProperties().isEmpty() ? new Connector() : Connector.class.cast(recipe.create());
for (final Map.Entry<String, String> attr : attributes.entrySet()) {
connector.setAttribute(attr.getKey(), attr.getValue());
}
} else {
connector = new Connector();
}
return connector;
}
use of org.apache.catalina.connector.Connector in project cas by apereo.
the class CasEmbeddedContainerTomcatConfiguration method configureHttp.
private void configureHttp(final TomcatEmbeddedServletContainerFactory tomcat) {
final CasEmbeddedApacheTomcatHttpProperties http = casProperties.getServer().getHttp();
if (http.isEnabled()) {
LOGGER.debug("Creating HTTP configuration for the embedded tomcat container...");
final Connector connector = new Connector(http.getProtocol());
int port = http.getPort();
if (port <= 0) {
LOGGER.warn("No explicit port configuration is provided to CAS. Scanning for available ports...");
port = SocketUtils.findAvailableTcpPort();
}
LOGGER.info("Activated embedded tomcat container HTTP port on [{}]", port);
connector.setPort(port);
LOGGER.debug("Configuring embedded tomcat container for HTTP2 protocol support");
connector.addUpgradeProtocol(new Http2Protocol());
http.getAttributes().forEach(connector::setAttribute);
tomcat.addAdditionalTomcatConnectors(connector);
}
}
use of org.apache.catalina.connector.Connector in project cas by apereo.
the class CasEmbeddedContainerTomcatConfiguration method configureAjp.
private void configureAjp(final TomcatEmbeddedServletContainerFactory tomcat) {
final CasEmbeddedApacheTomcatAjpProperties ajp = casProperties.getServer().getAjp();
if (ajp.isEnabled() && ajp.getPort() > 0) {
LOGGER.debug("Creating AJP configuration for the embedded tomcat container...");
final Connector ajpConnector = new Connector(ajp.getProtocol());
ajpConnector.setProtocol(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());
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::setAttribute);
tomcat.addAdditionalTomcatConnectors(ajpConnector);
}
}
use of org.apache.catalina.connector.Connector in project Payara by payara.
the class PwcCoyoteRequest method getPostDataEncoding.
private String getPostDataEncoding(String formHintField) {
if (!getMethod().equalsIgnoreCase("POST")) {
return null;
}
String contentType = getContentType();
if (contentType == null)
contentType = "";
int semicolon = contentType.indexOf(';');
if (semicolon >= 0) {
contentType = contentType.substring(0, semicolon).trim();
} else {
contentType = contentType.trim();
}
if (!("application/x-www-form-urlencoded".equals(contentType))) {
return null;
}
int len = getContentLength();
if (len <= 0) {
return null;
}
int maxPostSize = ((Connector) connector).getMaxPostSize();
if ((maxPostSize > 0) && (len > maxPostSize)) {
throw new IllegalStateException(rb.getString(LogFacade.POST_TOO_LARGE));
}
String encoding = null;
try {
formData = null;
if (len < CACHED_POST_LEN) {
if (postData == null)
postData = new byte[CACHED_POST_LEN];
formData = postData;
} else {
formData = new byte[len];
}
int actualLen = readPostBody(formData, len);
if (actualLen == len) {
// START SJSAS 6346738
formDataLen = actualLen;
// END SJSAS 6346738
String formDataString = new String(formData, Charset.defaultCharset()).substring(0, len);
encoding = parseFormHintField(formDataString, formHintField);
}
} catch (Throwable t) {
// Ignore
;
}
return encoding;
}
use of org.apache.catalina.connector.Connector in project tomee by apache.
the class Container method stop.
public void stop() throws Exception {
final Connector connector = tomcat.getConnector();
if (null != connector) {
connector.stop();
}
try {
tomcat.stop();
} catch (final LifecycleException e) {
e.printStackTrace();
}
try {
tomcat.destroy();
} catch (final LifecycleException e) {
e.printStackTrace();
}
if (configuration.isDeleteBaseOnStartup()) {
try {
deleteTree(base);
} catch (final Exception e) {
e.printStackTrace();
}
}
OpenEJB.destroy();
// don't set base = null here to be able to use base after to clean up from outside of this class
}
Aggregations