use of org.apache.catalina.Service in project tomcat by apache.
the class MBeanFactory method getService.
private Service getService(ObjectName oname) throws Exception {
if (container instanceof Service) {
// Don't bother checking the domain - this is the only option
return (Service) container;
}
StandardService service = null;
String domain = oname.getDomain();
if (container instanceof Server) {
Service[] services = ((Server) container).findServices();
for (Service value : services) {
service = (StandardService) value;
if (domain.equals(service.getObjectName().getDomain())) {
break;
}
}
}
if (service == null || !service.getObjectName().getDomain().equals(domain)) {
throw new Exception(sm.getString("mBeanFactory.noService", domain));
}
return service;
}
use of org.apache.catalina.Service in project tomcat by apache.
the class MBeanFactory method getParentContainerFromParent.
/**
* Get Parent Container to add its child component
* from parent's ObjectName
*/
private Container getParentContainerFromParent(ObjectName pname) throws Exception {
String type = pname.getKeyProperty("type");
String j2eeType = pname.getKeyProperty("j2eeType");
Service service = getService(pname);
StandardEngine engine = (StandardEngine) service.getContainer();
if ((j2eeType != null) && (j2eeType.equals("WebModule"))) {
String name = pname.getKeyProperty("name");
name = name.substring(2);
int i = name.indexOf('/');
String hostName = name.substring(0, i);
String path = name.substring(i);
Container host = engine.findChild(hostName);
String pathStr = getPathStr(path);
Container context = host.findChild(pathStr);
return context;
} else if (type != null) {
if (type.equals("Engine")) {
return engine;
} else if (type.equals("Host")) {
String hostName = pname.getKeyProperty("host");
Container host = engine.findChild(hostName);
return host;
}
}
return null;
}
use of org.apache.catalina.Service 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.Service in project tomcat by apache.
the class ServiceMBean method findExecutors.
/**
* Retrieves all executors.
* @return an array of string representations of the executors
* @throws MBeanException error accessing the associated service
*/
public String[] findExecutors() throws MBeanException {
Service service = doGetManagedResource();
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 tomcat by apache.
the class ServiceMBean method addExecutor.
/**
* Adds a named executor to the service
* @param type Classname of the Executor to be added
* @throws MBeanException error creating the executor
*/
public void addExecutor(String type) throws MBeanException {
Service service = doGetManagedResource();
Executor executor = (Executor) newInstance(type);
service.addExecutor(executor);
}
Aggregations