use of org.apache.catalina.Service in project tomcat by apache.
the class FrameworkListener method registerListenersForServer.
protected void registerListenersForServer(Server server) {
for (Service service : server.findServices()) {
Engine engine = service.getContainer();
if (engine != null) {
engine.addContainerListener(this);
registerListenersForEngine(engine);
}
}
}
use of org.apache.catalina.Service in project tomcat by apache.
the class MBeanFactory method removeConnector.
/**
* Remove an existing Connector.
*
* @param name MBean Name of the component to remove
*
* @exception Exception if a component cannot be removed
*/
public void removeConnector(String name) throws Exception {
// Acquire a reference to the component to be removed
ObjectName oname = new ObjectName(name);
Service service = getService(oname);
String port = oname.getKeyProperty("port");
String address = oname.getKeyProperty("address");
if (address != null) {
address = ObjectName.unquote(address);
}
Connector[] conns = service.findConnectors();
for (Connector conn : conns) {
String connAddress = null;
Object objConnAddress = conn.getProperty("address");
if (objConnAddress != null) {
connAddress = ((InetAddress) objConnAddress).getHostAddress();
}
String connPort = "" + conn.getPortWithOffset();
if (address == null) {
// 'else if' below
if (connAddress == null && port.equals(connPort)) {
service.removeConnector(conn);
conn.destroy();
break;
}
} else if (address.equals(connAddress) && port.equals(connPort)) {
service.removeConnector(conn);
conn.destroy();
break;
}
}
}
use of org.apache.catalina.Service in project tomcat by apache.
the class MBeanFactory method createConnector.
/**
* Create a new Connector
*
* @param parent MBean Name of the associated parent component
* @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
*
* @exception Exception if an MBean cannot be created or registered
*/
private String createConnector(String parent, String address, int port, boolean isAjp, boolean isSSL) throws Exception {
// Set the protocol in the constructor
String protocol = isAjp ? "AJP/1.3" : "HTTP/1.1";
Connector retobj = new Connector(protocol);
if ((address != null) && (address.length() > 0)) {
retobj.setProperty("address", address);
}
// Set port number
retobj.setPort(port);
// Set SSL
retobj.setSecure(isSSL);
retobj.setScheme(isSSL ? "https" : "http");
// Add the new instance to its parent component
// FIX ME - addConnector will fail
ObjectName pname = new ObjectName(parent);
Service service = getService(pname);
service.addConnector(retobj);
// Return the corresponding MBean name
ObjectName coname = retobj.getObjectName();
return coname.toString();
}
use of org.apache.catalina.Service in project tomcat by apache.
the class MBeanFactory method removeHost.
/**
* Remove an existing Host.
*
* @param name MBean Name of the component to remove
*
* @exception Exception if a component cannot be removed
*/
public void removeHost(String name) throws Exception {
// Acquire a reference to the component to be removed
ObjectName oname = new ObjectName(name);
String hostName = oname.getKeyProperty("host");
Service service = getService(oname);
Engine engine = service.getContainer();
Host host = (Host) engine.findChild(hostName);
// Remove this component from its parent component
if (host != null) {
engine.removeChild(host);
}
}
Aggregations