amyroh 02/03/19 13:14:54 Modified: catalina/src/share/org/apache/catalina/mbeans MBeanFactory.java mbeans-descriptors.xml Log: Add removeManager() and removeRealm(). Revision Changes Path 1.15 +100 -6 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.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- MBeanFactory.java 18 Mar 2002 20:25:15 -0000 1.14 +++ MBeanFactory.java 19 Mar 2002 21:14:54 -0000 1.15 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v 1.14 2002/03/18 20:25:15 amyroh Exp $ - * $Revision: 1.14 $ - * $Date: 2002/03/18 20:25:15 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v 1.15 2002/03/19 21:14:54 amyroh Exp $ + * $Revision: 1.15 $ + * $Date: 2002/03/19 21:14:54 $ * * ==================================================================== * @@ -76,6 +76,8 @@ import org.apache.catalina.Engine; import org.apache.catalina.Host; import org.apache.catalina.Logger; +import org.apache.catalina.Manager; +import org.apache.catalina.Realm; import org.apache.catalina.Server; import org.apache.catalina.ServerFactory; import org.apache.catalina.Service; @@ -111,7 +113,7 @@ * <code>org.apache.catalina.core.StandardServer</code> component.</p> * * @author Amy Roh - * @version $Revision: 1.14 $ $Date: 2002/03/18 20:25:15 $ + * @version $Revision: 1.15 $ $Date: 2002/03/19 21:14:54 $ */ public class MBeanFactory extends BaseModelMBean { @@ -235,8 +237,13 @@ Server server = ServerFactory.getServer(); Service service = server.findService(pname.getKeyProperty("service")); Engine engine = (Engine) service.getContainer(); - Host host = (Host) engine.findChild(pname.getKeyProperty("host")); - host.addDefaultContext(context); + String hostName = pname.getKeyProperty("host"); + if (hostName == null) { //if DefaultContext is nested in Engine + engine.addDefaultContext(context); + } else { // if DefaultContext is nested in Host + Host host = (Host) engine.findChild(hostName); + host.addDefaultContext(context); + } // Return the corresponding MBean name ManagedBean managed = registry.findManagedBean("DefaultContext"); @@ -1053,6 +1060,93 @@ } + /** + * Remove an existing Manager. + * + * @param name MBean Name of the comonent to remove + * + * @exception Exception if a component cannot be removed + */ + public void removeManager(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 contextName = oname.getKeyProperty("path"); + Server server = ServerFactory.getServer(); + Service service = server.findService(serviceName); + Engine engine = (Engine) service.getContainer(); + Host host = (Host) engine.findChild(hostName); + Context context = (Context) host.findChild(contextName); + + // Remove this component from its parent component + context.setManager(null); + + } + + + /** + * Remove an existing Realm. + * + * @param name MBean Name of the comonent to remove + * + * @exception Exception if a component cannot be removed + */ + public void removeRealm(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"); + Server server = ServerFactory.getServer(); + Service service = server.findService(serviceName); + StandardEngine engine = (StandardEngine) service.getContainer(); + if (hostName == null) { // if realm's container is Engine + Realm realm = engine.getRealm(); + Container container = realm.getContainer(); + if (container instanceof StandardEngine) { + String sname = + ((StandardEngine)container).getService().getName(); + if (sname.equals(serviceName)) { + engine.setRealm(null); + } + } + } else if (path == null) { // if realm's container is Host + StandardHost host = (StandardHost) engine.findChild(hostName); + Realm realm = host.getRealm(); + Container container = realm.getContainer(); + if (container instanceof StandardHost) { + String hn = ((StandardHost)container).getName(); + StandardEngine se = + (StandardEngine) ((StandardHost)container).getParent(); + String sname = se.getService().getName(); + if (sname.equals(serviceName) && hn.equals(hostName)) { + host.setRealm(null); + } + } + } else { // realm's container is Context + StandardHost host = (StandardHost) engine.findChild(hostName); + StandardContext context = (StandardContext) host.findChild(path); + Realm realm = context.getRealm(); + Container container = realm.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(); + if ((sname.equals(serviceName) && hn.equals(hostName)) && + pathName.equals(path)) { + context.setRealm(null); + } + } + } + } + + /** * Remove an existing Service. * 1.41 +19 -209 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.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- mbeans-descriptors.xml 18 Mar 2002 20:25:15 -0000 1.40 +++ mbeans-descriptors.xml 19 Mar 2002 21:14:54 -0000 1.41 @@ -6,7 +6,7 @@ <!-- Descriptions of JMX MBeans for Catalina - $Id: mbeans-descriptors.xml,v 1.40 2002/03/18 20:25:15 amyroh Exp $ + $Id: mbeans-descriptors.xml,v 1.41 2002/03/19 21:14:54 amyroh Exp $ --> <mbeans-descriptors> @@ -1290,6 +1290,24 @@ type="java.lang.String"/> </operation> + <operation name="removeManager" + description="Remove an existing Manager" + impact="ACTION" + returnType="void"> + <parameter name="name" + description="MBean Name of the component to be removed" + type="java.lang.String"/> + </operation> + + <operation name="removeRealm" + description="Remove an existing Realm" + impact="ACTION" + returnType="void"> + <parameter name="name" + description="MBean Name of the component to be removed" + type="java.lang.String"/> + </operation> + <operation name="removeService" description="Remove an existing Service" impact="ACTION" @@ -1697,61 +1715,6 @@ description="The pathname to the work directory for this context" type="java.lang.String"/> - <operation name="addValve" - description="Add a new Valve to those associated with this Context" - impact="ACTION" - returnType="void"> - <parameter name="valve" - description="MBean Name of the Valve to be added" - type="java.lang.String"/> - </operation> - - <operation name="removeValve" - description="Remove the specified Valve from those associated with - this Context" - impact="ACTION" - returnType="void"> - <parameter name="valve" - description="MBean Name of the Valve to be removed" - type="java.lang.String"/> - </operation> - - <operation name="setLoader" - description="Associate the specified Loader with this Context" - impact="ACTION" - returnType="void"> - <parameter name="loader" - description="MBean Name of the Loader to be associated" - type="java.lang.String"/> - </operation> - - <operation name="setLogger" - description="Associate the specified Logger with this Context" - impact="ACTION" - returnType="void"> - <parameter name="logger" - description="MBean Name of the Logger to be associated" - type="java.lang.String"/> - </operation> - - <operation name="setManager" - description="Associate the specified Manager with this Context" - impact="ACTION" - returnType="void"> - <parameter name="manager" - description="MBean Name of the Manager to be associated" - type="java.lang.String"/> - </operation> - - <operation name="setRealm" - description="Associate the specified Realm with this Context" - impact="ACTION" - returnType="void"> - <parameter name="realm" - description="MBean Name of the Realm to be associated" - type="java.lang.String"/> - </operation> - </mbean> @@ -1798,62 +1761,6 @@ description="Unique name of this Engine" type="java.lang.String"/> - <operation name="addHost" - description="Add a new Host to those associated with this Engine" - impact="ACTION" - returnType="void"> - <parameter name="host" - description="MBean Name of the new Host to be added" - type="java.lang.String"/> - </operation> - - <operation name="addValve" - description="Add a new Valve to those associated with this Engine" - impact="ACTION" - returnType="void"> - <parameter name="valve" - description="MBean Name of the Valve to be added" - type="java.lang.String"/> - </operation> - - <operation name="removeValve" - description="Remove the specified Valve from those associated with - this Engine" - impact="ACTION" - returnType="void"> - <parameter name="valve" - description="MBean Name of the Valve to be removed" - type="java.lang.String"/> - </operation> - - <operation name="removeHost" - description="Remove the specified Host from those associated with - this Engine" - impact="ACTION" - returnType="void"> - <parameter name="host" - description="MBean Name of the Host to be removed" - type="java.lang.String"/> - </operation> - - <operation name="setLogger" - description="Associate the specified Logger with this Engine" - impact="ACTION" - returnType="void"> - <parameter name="logger" - description="MBean Name of the Logger to be associated" - type="java.lang.String"/> - </operation> - - <operation name="setRealm" - description="Associate the specified Realm with this Engine" - impact="ACTION" - returnType="void"> - <parameter name="realm" - description="MBean Name of the Realm to be associated" - type="java.lang.String"/> - </operation> - </mbean> @@ -1914,24 +1821,6 @@ type="java.lang.String"/> </operation> - <operation name="addContext" - description="Add a new Context to those associated with this Host" - impact="ACTION" - returnType="void"> - <parameter name="context" - description="MBean Name of the new Context to be added" - type="java.lang.String"/> - </operation> - - <operation name="addValve" - description="Add a new Valve to those associated with this Host" - impact="ACTION" - returnType="void"> - <parameter name="valve" - description="MBean Name of the Valve to be added" - type="java.lang.String"/> - </operation> - <operation name="findAliases" description="Return the set of alias names for this Host" impact="INFO" @@ -1953,44 +1842,6 @@ type="java.lang.String"/> </operation> - <operation name="removeContext" - description="Remove the specified Context from those associated with - this Host" - impact="ACTION" - returnType="void"> - <parameter name="context" - description="MBean Name of the Context to be removed" - type="java.lang.String"/> - </operation> - - <operation name="removeValve" - description="Remove the specified Valve from those associated with - this Host" - impact="ACTION" - returnType="void"> - <parameter name="valve" - description="MBean Name of the Valve to be removed" - type="java.lang.String"/> - </operation> - - <operation name="setLogger" - description="Associate the specified Logger with this Host" - impact="ACTION" - returnType="void"> - <parameter name="logger" - description="MBean Name of the Logger to be associated" - type="java.lang.String"/> - </operation> - - <operation name="setRealm" - description="Associate the specified Realm with this Host" - impact="ACTION" - returnType="void"> - <parameter name="realm" - description="MBean Name of the Realm to be associated" - type="java.lang.String"/> - </operation> - </mbean> @@ -2096,26 +1947,6 @@ description="Shutdown password" type="java.lang.String"/> -<!-- - <operation name="addService" - description="Add a new Service associated with this Server" - impact="ACTION" - returnType="void"> - <parameter name="service" - description="MBean Name of the Service to be added" - type="java.lang.String"/> - </operation> - - <operation name="removeService" - description="Remove an existing child Service" - impact="ACTION" - returnType="void"> - <parameter name="service" - description="MBean Name of the Service to be removed" - type="java.lang.String"/> - </operation> ---> - </mbean> @@ -2137,27 +1968,6 @@ <attribute name="name" description="Unique name of this Service" type="java.lang.String"/> - -<!-- - <operation name="addConnector" - description="Add a new Connector associated with this Service" - impact="ACTION" - returnType="void"> - <parameter name="connector" - description="MBean Name of the Connector to be added" - type="java.lang.String"/> - </operation> - - <operation name="removeConnector" - description="Remove an existing Connector associated with this - Service" - impact="ACTION" - returnType="void"> - <parameter name="connector" - description="MBean Name of the Connector to be removed" - type="java.lang.String"/> - </operation> ---> </mbean>
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>