use of org.apache.catalina.Service in project tomcat70 by apache.
the class MBeanFactory method getParentContainerFromParent.
/**
* Get Parent ContainerBase to add its child component
* from parent's ObjectName
*/
private ContainerBase 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);
Host host = (Host) engine.findChild(hostName);
String pathStr = getPathStr(path);
StandardContext context = (StandardContext) 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");
StandardHost host = (StandardHost) engine.findChild(hostName);
return host;
}
}
return null;
}
use of org.apache.catalina.Service in project tomcat70 by apache.
the class MBeanFactory method createStandardHost.
/**
* Create a new StandardHost.
*
* @param parent MBean Name of the associated parent component
* @param name Unique name of this Host
* @param appBase Application base directory name
* @param autoDeploy Should we auto deploy?
* @param deployOnStartup Deploy on server startup?
* @param deployXML Should we deploy Context XML config files property?
* @param unpackWARs Should we unpack WARs when auto deploying?
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createStandardHost(String parent, String name, String appBase, boolean autoDeploy, boolean deployOnStartup, boolean deployXML, boolean unpackWARs) throws Exception {
// Create a new StandardHost instance
StandardHost host = new StandardHost();
host.setName(name);
host.setAppBase(appBase);
host.setAutoDeploy(autoDeploy);
host.setDeployOnStartup(deployOnStartup);
host.setDeployXML(deployXML);
host.setUnpackWARs(unpackWARs);
// add HostConfig for active reloading
HostConfig hostConfig = new HostConfig();
host.addLifecycleListener(hostConfig);
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
Service service = getService(pname);
Engine engine = (Engine) service.getContainer();
engine.addChild(host);
// Return the corresponding MBean name
return (host.getObjectName().toString());
}
use of org.apache.catalina.Service in project tomcat70 by apache.
the class MBeanFactory method createStandardServiceEngine.
/**
* Creates a new StandardService and StandardEngine.
*
* @param domain Domain name for the container instance
* @param defaultHost Name of the default host to be used in the Engine
* @param baseDir Base directory value for Engine
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createStandardServiceEngine(String domain, String defaultHost, String baseDir) throws Exception {
if (!(container instanceof Server)) {
throw new Exception("Container not Server");
}
StandardEngine engine = new StandardEngine();
engine.setDomain(domain);
engine.setName(domain);
engine.setDefaultHost(defaultHost);
engine.setBaseDir(baseDir);
Service service = new StandardService();
service.setContainer(engine);
service.setName(domain);
((Server) container).addService(service);
return engine.getObjectName().toString();
}
use of org.apache.catalina.Service in project tomcat70 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
*/
public void addExecutor(String type) 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 executor;
try {
executor = (Executor) Class.forName(type).newInstance();
} catch (InstantiationException e) {
throw new MBeanException(e);
} catch (IllegalAccessException e) {
throw new MBeanException(e);
} catch (ClassNotFoundException e) {
throw new MBeanException(e);
}
service.addExecutor(executor);
}
use of org.apache.catalina.Service in project tomcat70 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
*/
public void addConnector(String address, int port, boolean isAjp, boolean isSSL) 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);
}
Connector connector = new Connector();
if ((address != null) && (address.length() > 0)) {
connector.setProperty("address", address);
}
connector.setPort(port);
connector.setProtocol(isAjp ? "AJP/1.3" : "HTTP/1.1");
connector.setSecure(isSSL);
connector.setScheme(isSSL ? "https" : "http");
service.addConnector(connector);
}
Aggregations