use of org.apache.catalina.connector.Connector in project tomcat by apache.
the class ThreadLocalLeakPreventionListener method stopIdleThreads.
/**
* Updates each ThreadPoolExecutor with the current time, which is the time
* when a context is being stopped.
*
* @param context
* the context being stopped, used to discover all the Connectors
* of its parent Service.
*/
private void stopIdleThreads(Context context) {
if (serverStopping)
return;
if (!(context instanceof StandardContext) || !((StandardContext) context).getRenewThreadsWhenStoppingContext()) {
log.debug("Not renewing threads when the context is stopping. " + "It is not configured to do it.");
return;
}
Engine engine = (Engine) context.getParent().getParent();
Service service = engine.getService();
Connector[] connectors = service.findConnectors();
if (connectors != null) {
for (Connector connector : connectors) {
ProtocolHandler handler = connector.getProtocolHandler();
Executor executor = null;
if (handler != null) {
executor = handler.getExecutor();
}
if (executor instanceof ThreadPoolExecutor) {
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) executor;
threadPoolExecutor.contextStopping();
} else if (executor instanceof StandardThreadExecutor) {
StandardThreadExecutor stdThreadExecutor = (StandardThreadExecutor) executor;
stdThreadExecutor.contextStopping();
}
}
}
}
use of org.apache.catalina.connector.Connector in project tomcat by apache.
the class ServiceMBean method findConnectors.
/**
* Find and return the set of Connectors associated with this Service.
* @return an array of string representations of the connectors
* @throws MBeanException error accessing the associated service
*/
public String[] findConnectors() throws MBeanException {
Service service = doGetManagedResource();
Connector[] connectors = service.findConnectors();
String[] str = new String[connectors.length];
for (int i = 0; i < connectors.length; i++) {
str[i] = connectors[i].toString();
}
return str;
}
use of org.apache.catalina.connector.Connector in project tomcat by apache.
the class ServiceMBean method addConnector.
/**
* Add a new Connector to the set of defined Connectors, and associate it
* with this Service's Container.
*
* @param address The IP address on which to bind
* @param port TCP port number to listen on
* @param isAjp Create a AJP/1.3 Connector
* @param isSSL Create a secure Connector
*
* @throws MBeanException error creating the connector
*/
public void addConnector(String address, int port, boolean isAjp, boolean isSSL) throws MBeanException {
Service service = doGetManagedResource();
String protocol = isAjp ? "AJP/1.3" : "HTTP/1.1";
Connector connector = new Connector(protocol);
if ((address != null) && (address.length() > 0)) {
connector.setProperty("address", address);
}
connector.setPort(port);
connector.setSecure(isSSL);
connector.setScheme(isSSL ? "https" : "http");
service.addConnector(connector);
}
use of org.apache.catalina.connector.Connector in project tomcat by apache.
the class ConnectorSF method storeChildren.
@Override
public void storeChildren(PrintWriter aWriter, int indent, Object aConnector, StoreDescription parentDesc) throws Exception {
if (aConnector instanceof Connector) {
Connector connector = (Connector) aConnector;
// Store nested <Listener> elements
LifecycleListener[] listeners = connector.findLifecycleListeners();
storeElementArray(aWriter, indent, listeners);
// Store nested <UpgradeProtocol> elements
UpgradeProtocol[] upgradeProtocols = connector.findUpgradeProtocols();
storeElementArray(aWriter, indent, upgradeProtocols);
// Store nested <SSLHostConfig> elements
SSLHostConfig[] hostConfigs = connector.findSslHostConfigs();
storeElementArray(aWriter, indent, hostConfigs);
}
}
use of org.apache.catalina.connector.Connector in project tomcat by apache.
the class ConnectorStoreAppender method printAttributes.
@Override
public void printAttributes(PrintWriter writer, int indent, boolean include, Object bean, StoreDescription desc) throws Exception {
// Render a className attribute if requested
if (include && desc != null && !desc.isStandard()) {
writer.print(" className=\"");
writer.print(bean.getClass().getName());
writer.print("\"");
}
Connector connector = (Connector) bean;
String protocol = connector.getProtocol();
List<String> propertyKeys = getPropertyKeys(connector);
// Create blank instance
//defaultInstance(bean);
Object bean2 = new Connector(protocol);
Iterator<String> propertyIterator = propertyKeys.iterator();
while (propertyIterator.hasNext()) {
String key = propertyIterator.next();
Object value = IntrospectionUtils.getProperty(bean, key);
if (desc.isTransientAttribute(key)) {
// Skip the specified exceptions
continue;
}
if (value == null) {
// Null values are not persisted
continue;
}
if (!isPersistable(value.getClass())) {
continue;
}
Object value2 = IntrospectionUtils.getProperty(bean2, key);
if (value.equals(value2)) {
// The property has its default value
continue;
}
if (isPrintValue(bean, bean2, key, desc)) {
printValue(writer, indent, key, value);
}
}
if (protocol != null && !"HTTP/1.1".equals(protocol)) {
super.printValue(writer, indent, "protocol", protocol);
}
String executorName = connector.getExecutorName();
if (!Connector.INTERNAL_EXECUTOR_NAME.equals(executorName)) {
super.printValue(writer, indent, "executor", executorName);
}
}
Aggregations