public void removeConnector(String name) throws Exception {
// Acquire a reference to the component to be removed
ObjectName oname = new ObjectName(name);
Server server = ServerFactory.getServer();
Service service = getService(oname);
String port = oname.getKeyProperty("port");
//String address = oname.getKeyProperty("address");
Connector conns[] = (Connector[]) service.findConnectors();
for (int i = 0; i < conns.length; i++) {
Class cls = conns[i].getClass();
Method getAddrMeth = cls.getMethod("getAddress", null);
Object addrObj = getAddrMeth.invoke(conns[i], null);
String connAddress = null;
if (addrObj != null) {
connAddress = addrObj.toString();
}
Method getPortMeth = cls.getMethod("getPort", null);
Object portObj = getPortMeth.invoke(conns[i], null);
String connPort = new String();
if (portObj != null) {
connPort = portObj.toString();
}
// if (((address.equals("null")) &&
if ((connAddress==null) && port.equals(connPort)) {
service.removeConnector(conns[i]);
((CoyoteConnector)conns[i]).destroy();
break;
}
// } else if (address.equals(connAddress))
if (port.equals(connPort)) {
// Remove this component from its parent component
service.removeConnector(conns[i]);
((CoyoteConnector)conns[i]).destroy();
break;
}
}