Author: markt Date: Wed Apr 14 12:07:04 2010 New Revision: 933921 URL: http://svn.apache.org/viewvc?rev=933921&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49045 Add support for adding Services and Engines via JMX Based on a patch by Chamith Buddhika
Modified: tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java tomcat/trunk/java/org/apache/catalina/mbeans/mbeans-descriptors.xml Modified: tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java?rev=933921&r1=933920&r2=933921&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java (original) +++ tomcat/trunk/java/org/apache/catalina/mbeans/MBeanFactory.java Wed Apr 14 12:07:04 2010 @@ -50,7 +50,6 @@ import org.apache.catalina.valves.Access import org.apache.catalina.valves.RemoteAddrValve; import org.apache.catalina.valves.RemoteHostValve; import org.apache.catalina.valves.ValveBase; -import org.apache.tomcat.util.modeler.BaseModelMBean; /** @@ -61,7 +60,7 @@ import org.apache.tomcat.util.modeler.Ba * @version $Revision$ $Date$ */ -public class MBeanFactory extends BaseModelMBean { +public class MBeanFactory { private static final org.apache.juli.logging.Log log = org.apache.juli.logging.LogFactory.getLog(MBeanFactory.class); @@ -548,9 +547,8 @@ public class MBeanFactory extends BaseMo String docBase) throws Exception { - // XXX for backward compatibility. Remove it once supported by the admin - return - createStandardContext(parent,path,docBase,false,false,false,false); + return createStandardContext(parent, path, docBase, false, false, + false, false); } /** @@ -687,6 +685,38 @@ public class MBeanFactory extends BaseMo /** + * 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(); + } + + 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.getJmxName().toString(); + } + + + /** * Create a new StandardManager. * * @param parent MBean Name of the associated parent component @@ -946,6 +976,26 @@ public class MBeanFactory extends BaseMo /** + * Remove an existing Service. + * + * @param name MBean Name of the component to remove + * + * @exception Exception if a component cannot be removed + */ + public void removeService(String name) throws Exception { + + if (!(container instanceof Server)) { + throw new Exception(); + } + + // Acquire a reference to the component to be removed + ObjectName oname = new ObjectName(name); + Service service = getService(oname); + ((Server) container).removeService(service); + } + + + /** * Remove an existing Valve. * * @param name MBean Name of the component to remove Modified: tomcat/trunk/java/org/apache/catalina/mbeans/mbeans-descriptors.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/mbeans/mbeans-descriptors.xml?rev=933921&r1=933920&r2=933921&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/mbeans/mbeans-descriptors.xml (original) +++ tomcat/trunk/java/org/apache/catalina/mbeans/mbeans-descriptors.xml Wed Apr 14 12:07:04 2010 @@ -18,7 +18,7 @@ <mbeans-descriptors> <mbean name="MBeanFactory" - className="org.apache.catalina.mbeans.MBeanFactory" + type="org.apache.catalina.mbeans.MBeanFactory" description="Factory for MBeans and corresponding components" domain="Catalina"> @@ -81,15 +81,6 @@ type="java.lang.String"/> </operation> - <operation name="createFileLogger" - description="Create a new FileLogger" - impact="ACTION" - returnType="java.lang.String"> - <parameter name="parent" - description="MBean Name of the associated parent component" - type="java.lang.String"/> - </operation> - <operation name="createHttpConnector" description="Create a new HttpConnector" impact="ACTION" @@ -198,36 +189,18 @@ type="java.lang.String"/> </operation> - <operation name="createStandardEngine" - description="Create a new StandardEngine" + <operation name="createStandardServiceEngine" + description="Create a new StandardService and StandardEngine" impact="ACTION" returnType="java.lang.String"> - <parameter name="parent" - description="MBean Name of the associated parent component" - type="java.lang.String"/> - <parameter name="name" - description="Unique name of this Engine" - type="java.lang.String"/> - <parameter name="defaultHost" - description="Default host name for this Engine" - type="java.lang.String"/> - </operation> - - <operation name="createStandardEngineService" - description="Create a new StandardEngine and StandardService" - impact="ACTION" - returnType="java.lang.String"> - <parameter name="parent" - description="MBean Name of the associated parent Service" - type="java.lang.String"/> - <parameter name="engineName" - description="Unique name of this Engine" + <parameter name="domain" + description="Domain used for MBeans associated with the new Service" type="java.lang.String"/> <parameter name="defaultHost" - description="Default host name for this Engine" + description="Default host name for the new Engine" type="java.lang.String"/> - <parameter name="serviceName" - description="Unique name of this Service" + <parameter name="baseDir" + description="Base directory value for the new Engine" type="java.lang.String"/> </operation> @@ -276,39 +249,6 @@ type="java.lang.String"/> </operation> - <operation name="createStandardService" - description="Create a new StandardService" - impact="ACTION" - returnType="java.lang.String"> - <parameter name="parent" - description="MBean Name of the associated parent component" - type="java.lang.String"/> - <parameter name="name" - description="Unique name of this Service" - type="java.lang.String"/> - <parameter name="domain" - description="The domain of this Service" - type="java.lang.String"/> - </operation> - - <operation name="createSystemErrLogger" - description="Create a new System Error Logger" - impact="ACTION" - returnType="java.lang.String"> - <parameter name="parent" - description="MBean Name of the associated parent component" - type="java.lang.String"/> - </operation> - - <operation name="createSystemOutLogger" - description="Create a new System Output Logger" - impact="ACTION" - returnType="java.lang.String"> - <parameter name="parent" - description="MBean Name of the associated parent component" - type="java.lang.String"/> - </operation> - <operation name="createUserDatabaseRealm" description="Create a new UserDatabase Realm" impact="ACTION" @@ -371,15 +311,6 @@ type="java.lang.String"/> </operation> - <operation name="removeLogger" - description="Remove an existing Logger" - impact="ACTION" - returnType="void"> - <parameter name="name" - description="MBean Name of the component to be removed" - type="java.lang.String"/> - </operation> - <operation name="removeManager" description="Remove an existing Manager" impact="ACTION" --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org