use of org.apache.catalina.Service in project tomcat70 by apache.
the class ServiceMBean method findExecutors.
/**
* Retrieves all executors
* @throws MBeanException
*/
public String[] findExecutors() throws MBeanException {
Service service;
try {
service = (Service) getManagedResource();
} catch (InstanceNotFoundException e) {
throw new MBeanException(e);
} catch (RuntimeOperationsException e) {
throw new MBeanException(e);
} catch (InvalidTargetObjectTypeException e) {
throw new MBeanException(e);
}
Executor[] executors = service.findExecutors();
String[] str = new String[executors.length];
for (int i = 0; i < executors.length; i++) {
str[i] = executors[i].toString();
}
return str;
}
use of org.apache.catalina.Service in project tomcat70 by apache.
the class StandardServer method getDomainInternal.
/**
* Obtain the MBean domain for this server. The domain is obtained using
* the following search order:
* <ol>
* <li>Name of first {@link org.apache.catalina.Engine}.</li>
* <li>Name of first {@link Service}.</li>
* </ol>
*/
@Override
protected String getDomainInternal() {
String domain = null;
Service[] services = findServices();
if (services.length > 0) {
Service service = services[0];
if (service != null) {
domain = MBeanUtils.getDomain(service);
}
}
return domain;
}
use of org.apache.catalina.Service in project tomcat70 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.Service in project tomcat by apache.
the class ContextConfig method getServer.
private Server getServer() {
Container c = context;
while (c != null && !(c instanceof Engine)) {
c = c.getParent();
}
if (c == null) {
return null;
}
Service s = ((Engine) c).getService();
if (s == null) {
return null;
}
return s.getServer();
}
use of org.apache.catalina.Service in project tomcat by apache.
the class Tomcat method setConnector.
/**
* Set the specified connector in the service, if it is not already
* present.
* @param connector The connector instance to add
*/
public void setConnector(Connector connector) {
Service service = getService();
boolean found = false;
for (Connector serviceConnector : service.findConnectors()) {
if (connector == serviceConnector) {
found = true;
break;
}
}
if (!found) {
service.addConnector(connector);
}
}
Aggregations