amyroh 02/03/08 14:01:08 Modified: catalina/src/share/org/apache/catalina/mbeans MBeanFactory.java StandardContextMBean.java StandardEngineMBean.java StandardHostMBean.java StandardServiceMBean.java mbeans-descriptors.xml Log: Add removeConnector and removeValve. Revision Changes Path 1.11 +128 -5 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java Index: MBeanFactory.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- MBeanFactory.java 8 Mar 2002 06:58:17 -0000 1.10 +++ MBeanFactory.java 8 Mar 2002 22:01:07 -0000 1.11 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v 1.10 2002/03/08 06:58:17 amyroh Exp $ - * $Revision: 1.10 $ - * $Date: 2002/03/08 06:58:17 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v 1.11 2002/03/08 22:01:07 amyroh Exp $ + * $Revision: 1.11 $ + * $Date: 2002/03/08 22:01:07 $ * * ==================================================================== * @@ -78,6 +78,7 @@ import org.apache.catalina.Server; import org.apache.catalina.ServerFactory; import org.apache.catalina.Service; +import org.apache.catalina.Valve; import org.apache.catalina.authenticator.SingleSignOn; import org.apache.catalina.core.StandardContext; import org.apache.catalina.core.StandardServer; @@ -98,6 +99,7 @@ import org.apache.catalina.valves.RemoteAddrValve; import org.apache.catalina.valves.RemoteHostValve; import org.apache.catalina.valves.RequestDumperValve; +import org.apache.catalina.valves.ValveBase; import org.apache.commons.modeler.BaseModelMBean; import org.apache.commons.modeler.ManagedBean; import org.apache.commons.modeler.Registry; @@ -108,7 +110,7 @@ * <code>org.apache.catalina.core.StandardServer</code> component.</p> * * @author Amy Roh - * @version $Revision: 1.10 $ $Date: 2002/03/08 06:58:17 $ + * @version $Revision: 1.11 $ $Date: 2002/03/08 22:01:07 $ */ public class MBeanFactory extends BaseModelMBean { @@ -885,6 +887,54 @@ /** + * Remove an existing Connector. + * + * @param name MBean Name of the comonent to remove + * + * @param serviceName Service name of the connector to remove + * + * @exception Exception if a component cannot be removed + */ + public void removeConnector(String name, String serviceName) throws Exception { + + // Acquire a reference to the component to be removed + ObjectName oname = new ObjectName(name); + Server server = ServerFactory.getServer(); + Service service = server.findService(serviceName); + String port = oname.getKeyProperty("port"); + String address = oname.getKeyProperty("address"); + Connector conns[] = (Connector[]) service.findConnectors(); + + for (int i = 0; i < conns.length; i++) { + if (conns[i] instanceof + org.apache.catalina.connector.http10.HttpConnector) { + String addr = + ((org.apache.catalina.connector.http10.HttpConnector)conns[i]).getAddress(); + int p = ((org.apache.catalina.connector.http10.HttpConnector)conns[i]).getPort(); + Integer portInt = new Integer(p); + if (address.equals(addr) && + port.equals(portInt.toString())) { + // Remove this component from its parent component + service.removeConnector(conns[i]); + } + } else if (conns[i] instanceof + org.apache.catalina.connector.http.HttpConnector) { + String addr = + ((org.apache.catalina.connector.http.HttpConnector)conns[i]).getAddress(); + int p = ((org.apache.catalina.connector.http.HttpConnector)conns[i]).getPort(); + Integer portInt = new Integer(p); + if (address.equals(addr) && + port.equals(portInt.toString())) { + // Remove this component from its parent component + service.removeConnector(conns[i]); + } + } + } + + } + + + /** * Remove an existing Context. * * @param name MBean Name of the comonent to remove @@ -897,7 +947,7 @@ ObjectName oname = new ObjectName(name); String serviceName = oname.getKeyProperty("service"); String hostName = oname.getKeyProperty("host"); - String contextName = oname.getKeyProperty("context"); + String contextName = oname.getKeyProperty("path"); Server server = ServerFactory.getServer(); Service service = server.findService(serviceName); Engine engine = (Engine) service.getContainer(); @@ -954,5 +1004,78 @@ } + + /** + * Remove an existing Valve. + * + * @param name MBean Name of the comonent to remove + * + * @exception Exception if a component cannot be removed + */ + public void removeValve(String name) throws Exception { + + // Acquire a reference to the component to be removed + ObjectName oname = new ObjectName(name); + String serviceName = oname.getKeyProperty("service"); + String hostName = oname.getKeyProperty("host"); + String path = oname.getKeyProperty("path"); + String sequence = oname.getKeyProperty("sequence"); + Server server = ServerFactory.getServer(); + Service service = server.findService(serviceName); + StandardEngine engine = (StandardEngine) service.getContainer(); + if (hostName == null) { // if valve's container is Engine + Valve [] valves = engine.getValves(); + for (int i = 0; i < valves.length; i++) { + Container container = ((ValveBase)valves[i]).getContainer(); + if (container instanceof StandardEngine) { + String sname = + ((StandardEngine)container).getService().getName(); + Integer sequenceInt = new Integer(valves[i].hashCode()); + if (sname.equals(serviceName) && + sequence.equals(sequenceInt.toString())){ + engine.removeValve(valves[i]); + } + } + } + } else if (path == null) { // if valve's container is Host + StandardHost host = (StandardHost) engine.findChild(hostName); + Valve [] valves = host.getValves(); + for (int i = 0; i < valves.length; i++) { + Container container = ((ValveBase)valves[i]).getContainer(); + if (container instanceof StandardHost) { + String hn = ((StandardHost)container).getName(); + StandardEngine se = + (StandardEngine) ((StandardHost)container).getParent(); + String sname = se.getService().getName(); + Integer sequenceInt = new Integer(valves[i].hashCode()); + if ((sname.equals(serviceName) && hn.equals(hostName)) && + sequence.equals(sequenceInt.toString())){ + host.removeValve(valves[i]); + } + } + } + } else { // valve's container is Context + StandardHost host = (StandardHost) engine.findChild(hostName); + StandardContext context = (StandardContext) host.findChild(path); + Valve [] valves = context.getValves(); + for (int i = 0; i < valves.length; i++) { + Container container = ((ValveBase)valves[i]).getContainer(); + if (container instanceof StandardContext) { + String pathName = ((StandardContext)container).getName(); + StandardHost sh = + (StandardHost)((StandardContext)container).getParent(); + String hn = sh.getName();; + StandardEngine se = (StandardEngine)sh.getParent(); + String sname = se.getService().getName(); + Integer sequenceInt = new Integer(valves[i].hashCode()); + if (((sname.equals(serviceName) && hn.equals(hostName)) && + pathName.equals(path)) && + sequence.equals(sequenceInt.toString())){ + context.removeValve(valves[i]); + } + } + } + } + } } 1.5 +5 -26 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardContextMBean.java Index: StandardContextMBean.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardContextMBean.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- StandardContextMBean.java 8 Mar 2002 06:58:17 -0000 1.4 +++ StandardContextMBean.java 8 Mar 2002 22:01:07 -0000 1.5 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardContextMBean.java,v 1.4 2002/03/08 06:58:17 amyroh Exp $ - * $Revision: 1.4 $ - * $Date: 2002/03/08 06:58:17 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardContextMBean.java,v 1.5 2002/03/08 22:01:07 amyroh Exp $ + * $Revision: 1.5 $ + * $Date: 2002/03/08 22:01:07 $ * * ==================================================================== * @@ -82,7 +82,7 @@ * <code>org.apache.catalina.core.StandardContext</code> component.</p> * * @author Amy Roh - * @version $Revision: 1.4 $ $Date: 2002/03/08 06:58:17 $ + * @version $Revision: 1.5 $ $Date: 2002/03/08 22:01:07 $ */ public class StandardContextMBean extends BaseModelMBean { @@ -118,26 +118,5 @@ // ------------------------------------------------------------- Operations - - /** - * Remove the specified Valve from those associated this Context - * - * @param valve MBean Name of the Valve to be removed - * - * @exception Exception if an MBean cannot be created or registered - */ - public void removeValve(String valve) - throws Exception { - - StandardContext context = (StandardContext) this.resource; - ObjectName oname = new ObjectName(valve); - Object obj = mserver.getAttribute(oname, "managedResource"); - Valve valveObj = null; - if (obj instanceof Valve) { - valveObj = (Valve) obj; - } - context.removeValve(valveObj); - - } - + } 1.8 +4 -26 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardEngineMBean.java Index: StandardEngineMBean.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardEngineMBean.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- StandardEngineMBean.java 8 Mar 2002 06:58:17 -0000 1.7 +++ StandardEngineMBean.java 8 Mar 2002 22:01:08 -0000 1.8 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardEngineMBean.java,v 1.7 2002/03/08 06:58:17 amyroh Exp $ - * $Revision: 1.7 $ - * $Date: 2002/03/08 06:58:17 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardEngineMBean.java,v 1.8 2002/03/08 22:01:08 amyroh Exp $ + * $Revision: 1.8 $ + * $Date: 2002/03/08 22:01:08 $ * * ==================================================================== * @@ -85,7 +85,7 @@ * <code>org.apache.catalina.core.StandardEngine</code> component.</p> * * @author Craig R. McClanahan - * @version $Revision: 1.7 $ $Date: 2002/03/08 06:58:17 $ + * @version $Revision: 1.8 $ $Date: 2002/03/08 22:01:08 $ */ public class StandardEngineMBean extends BaseModelMBean { @@ -120,28 +120,6 @@ // ------------------------------------------------------------- Operations - - - /** - * Remove the specified Valve from those assoicated with this Engine - * - * @param valve MBean Name of the Valve to be removed - * - * @exception Exception if an MBean cannot be created or registered - */ - public void removeValve(String valve) - throws Exception { - - StandardEngine engine = (StandardEngine) this.resource; - ObjectName oname = new ObjectName(valve); - Object obj = mserver.getAttribute(oname, "managedResource"); - Valve valveObj = null; - if (obj instanceof Valve) { - valveObj = (Valve) obj; - } - engine.removeValve(valveObj); - - } } 1.5 +4 -26 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardHostMBean.java Index: StandardHostMBean.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardHostMBean.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- StandardHostMBean.java 8 Mar 2002 06:58:17 -0000 1.4 +++ StandardHostMBean.java 8 Mar 2002 22:01:08 -0000 1.5 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardHostMBean.java,v 1.4 2002/03/08 06:58:17 amyroh Exp $ - * $Revision: 1.4 $ - * $Date: 2002/03/08 06:58:17 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardHostMBean.java,v 1.5 2002/03/08 22:01:08 amyroh Exp $ + * $Revision: 1.5 $ + * $Date: 2002/03/08 22:01:08 $ * * ==================================================================== * @@ -85,7 +85,7 @@ * <code>org.apache.catalina.core.StandardHost</code> component.</p> * * @author Amy Roh - * @version $Revision: 1.4 $ $Date: 2002/03/08 06:58:17 $ + * @version $Revision: 1.5 $ $Date: 2002/03/08 22:01:08 $ */ public class StandardHostMBean extends BaseModelMBean { @@ -194,28 +194,6 @@ StandardHost host = (StandardHost) this.resource; host.removeAlias(alias); - - } - - - /** - * Remove the specified Valve from those associated this Host - * - * @param valve MBean Name of the Valve to be removed - * - * @exception Exception if an MBean cannot be created or registered - */ - public void removeValve(String valve) - throws Exception { - - StandardHost host = (StandardHost) this.resource; - ObjectName oname = new ObjectName(valve); - Object obj = mserver.getAttribute(oname, "managedResource"); - Valve valveObj = null; - if (obj instanceof Valve) { - valveObj = (Valve) obj; - } - host.removeValve(valveObj); } 1.9 +4 -26 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServiceMBean.java Index: StandardServiceMBean.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServiceMBean.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- StandardServiceMBean.java 8 Mar 2002 00:42:14 -0000 1.8 +++ StandardServiceMBean.java 8 Mar 2002 22:01:08 -0000 1.9 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServiceMBean.java,v 1.8 2002/03/08 00:42:14 amyroh Exp $ - * $Revision: 1.8 $ - * $Date: 2002/03/08 00:42:14 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServiceMBean.java,v 1.9 2002/03/08 22:01:08 amyroh Exp $ + * $Revision: 1.9 $ + * $Date: 2002/03/08 22:01:08 $ * * ==================================================================== * @@ -78,7 +78,7 @@ * <code>org.apache.catalina.core.StandardService</code> component.</p> * * @author Amy Roh - * @version $Revision: 1.8 $ $Date: 2002/03/08 00:42:14 $ + * @version $Revision: 1.9 $ $Date: 2002/03/08 22:01:08 $ */ public class StandardServiceMBean extends BaseModelMBean { @@ -113,28 +113,6 @@ // ------------------------------------------------------------- Operations - - - /** - * Remove an existing Connector associated with this Service - * - * @param connector MBean Name of the Connector to be removed - * - * @exception Exception if an MBean cannot be created or registered - */ - public void removeConnector(String connector) - throws Exception { - - Service service = (Service) this.resource; - ObjectName oname = new ObjectName(connector); - Object obj = mserver.getAttribute(oname, "managedResource"); - Connector connectorObj = null; - if (obj instanceof Connector) { - connectorObj = (Connector) obj; - } - service.removeConnector(connectorObj); - - } } 1.37 +23 -2 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/mbeans-descriptors.xml Index: mbeans-descriptors.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/mbeans-descriptors.xml,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- mbeans-descriptors.xml 8 Mar 2002 19:01:32 -0000 1.36 +++ mbeans-descriptors.xml 8 Mar 2002 22:01:08 -0000 1.37 @@ -6,7 +6,7 @@ <!-- Descriptions of JMX MBeans for Catalina - $Id: mbeans-descriptors.xml,v 1.36 2002/03/08 19:01:32 craigmcc Exp $ + $Id: mbeans-descriptors.xml,v 1.37 2002/03/08 22:01:08 amyroh Exp $ --> <mbeans-descriptors> @@ -832,7 +832,7 @@ username" type="java.lang.String"/> - <attribute name="userRoleTable" + <attribute name="userRoleTable"remove description="The table that holds the relation between user's and roles" type="java.lang.String"/> @@ -1254,6 +1254,18 @@ <!-- components to be stopped (if necessary) and removed, and the --> <!-- corresponding MBeans to be destroyed. --> + <operation name="removeConnector" + description="Remove an existing Connector" + impact="ACTION" + returnType="void"> + <parameter name="name" + description="MBean Name of the component to be removed" + type="java.lang.String"/> + <parameter name="serviceName" + description="Service name of the connector to remove" + type="java.lang.String"/> + </operation> + <operation name="removeContext" description="Remove an existing Context" impact="ACTION" @@ -1274,6 +1286,15 @@ <operation name="removeService" description="Remove an existing Service" + impact="ACTION" + returnType="void"> + <parameter name="name" + description="MBean Name of the component to be removed" + type="java.lang.String"/> + </operation> + + <operation name="removeValve" + description="Remove an existing Valve" impact="ACTION" returnType="void"> <parameter name="name"
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>