amyroh 02/04/04 12:17:47 Modified: catalina/src/share/org/apache/catalina/mbeans MBeanFactory.java mbeans-descriptors.xml Log: Add createAjp13Connector() and createCoyoteConnector() using relfection to avoid j-t-c compile-time circular dependencies. Revision Changes Path 1.22 +116 -4 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.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- MBeanFactory.java 26 Mar 2002 01:23:25 -0000 1.21 +++ MBeanFactory.java 4 Apr 2002 20:17:47 -0000 1.22 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v 1.21 2002/03/26 01:23:25 manveen Exp $ - * $Revision: 1.21 $ - * $Date: 2002/03/26 01:23:25 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v 1.22 2002/04/04 20:17:47 amyroh Exp $ + * $Revision: 1.22 $ + * $Date: 2002/04/04 20:17:47 $ * * ==================================================================== * @@ -63,6 +63,7 @@ package org.apache.catalina.mbeans; +import java.lang.reflect.*; import javax.management.MBeanException; import javax.management.MBeanServer; import javax.management.ObjectName; @@ -115,7 +116,7 @@ * <code>org.apache.catalina.core.StandardServer</code> component.</p> * * @author Amy Roh - * @version $Revision: 1.21 $ $Date: 2002/03/26 01:23:25 $ + * @version $Revision: 1.22 $ $Date: 2002/04/04 20:17:47 $ */ public class MBeanFactory extends BaseModelMBean { @@ -214,6 +215,117 @@ ManagedBean managed = registry.findManagedBean("AccessLogValve"); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), accessLogger); + return (oname.toString()); + + } + + /** + * Create a new Ajp13Connector + * + * @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 + * + * @exception Exception if an MBean cannot be created or registered + */ + public String createAjp13Connector(String parent, String address, int port) + throws Exception { + + Object retobj = null; + + try { + + // Create a new AjpConnector instance + // use reflection to avoid j-t-c compile-time circular dependencies + Class cls = Class.forName("org.apache.ajp.tomcat4.Ajp13Connector"); + Constructor ct = cls.getConstructor(null); + retobj = ct.newInstance(null); + Class partypes1 [] = new Class[1]; + // Set address + String str = new String(); + partypes1[0] = str.getClass(); + Method meth1 = cls.getMethod("setAddress", partypes1); + Object arglist1[] = new Object[1]; + arglist1[0] = address; + meth1.invoke(retobj, arglist1); + // Set port number + Class partypes2 [] = new Class[1]; + partypes2[0] = Integer.TYPE; + Method meth2 = cls.getMethod("setPort", partypes2); + Object arglist2[] = new Object[1]; + arglist2[0] = new Integer(port); + meth2.invoke(retobj, arglist2); + + } catch (Exception e) { + throw new MBeanException(e); + } + + // Add the new instance to its parent component + ObjectName pname = new ObjectName(parent); + Server server = ServerFactory.getServer(); + Service service = server.findService(pname.getKeyProperty("name")); + service.addConnector((Connector)retobj); + + // Return the corresponding MBean name + ManagedBean managed = registry.findManagedBean("Ajp13Connector"); + ObjectName oname = + MBeanUtils.createObjectName(managed.getDomain(), (Connector)retobj); + return (oname.toString()); + + } + + + /** + * Create a new CoyoteConnector + * + * @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 + * + * @exception Exception if an MBean cannot be created or registered + */ + public String createCoyoteConnector(String parent, String address, int port) + throws Exception { + + Object retobj = null; + + try { + + // Create a new CoyoteConnector instance + // use reflection to avoid j-t-c compile-time circular dependencies + Class cls = Class.forName("org.apache.coyote.tomcat4.CoyoteConnector"); + Constructor ct = cls.getConstructor(null); + retobj = ct.newInstance(null); + Class partypes1 [] = new Class[1]; + // Set address + String str = new String(); + partypes1[0] = str.getClass(); + Method meth1 = cls.getMethod("setAddress", partypes1); + Object arglist1[] = new Object[1]; + arglist1[0] = address; + meth1.invoke(retobj, arglist1); + // Set port number + Class partypes2 [] = new Class[1]; + partypes2[0] = Integer.TYPE; + Method meth2 = cls.getMethod("setPort", partypes2); + Object arglist2[] = new Object[1]; + arglist2[0] = new Integer(port); + meth2.invoke(retobj, arglist2); + + } catch (Exception e) { + throw new MBeanException(e); + } + + // Add the new instance to its parent component + ObjectName pname = new ObjectName(parent); + Server server = ServerFactory.getServer(); + Service service = server.findService(pname.getKeyProperty("name")); + service.addConnector((Connector)retobj); + + // Return the corresponding MBean name + ManagedBean managed = registry.findManagedBean("CoyoteConnector"); + ObjectName oname = + MBeanUtils.createObjectName(managed.getDomain(), (Connector)retobj); return (oname.toString()); } 1.44 +31 -1 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.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- mbeans-descriptors.xml 21 Mar 2002 21:19:10 -0000 1.43 +++ mbeans-descriptors.xml 4 Apr 2002 20:17:47 -0000 1.44 @@ -6,7 +6,7 @@ <!-- Descriptions of JMX MBeans for Catalina - $Id: mbeans-descriptors.xml,v 1.43 2002/03/21 21:19:10 amyroh Exp $ + $Id: mbeans-descriptors.xml,v 1.44 2002/04/04 20:17:47 amyroh Exp $ --> <mbeans-descriptors> @@ -1042,6 +1042,36 @@ type="java.lang.String"/> </operation> + <operation name="createAjp13Connector" + description="Create a new Ajp13Connector" + impact="ACTION" + returnType="java.lang.String"> + <parameter name="parent" + description="MBean Name of the associated parent component" + type="java.lang.String"/> + <parameter name="address" + description="The IP address on which to bind" + type="java.lang.String"/> + <parameter name="port" + description="TCP port number to listen on" + type="int"/> + </operation> + + <operation name="createCoyoteConnector" + description="Create a new CoyoteConnector" + impact="ACTION" + returnType="java.lang.String"> + <parameter name="parent" + description="MBean Name of the associated parent component" + type="java.lang.String"/> + <parameter name="address" + description="The IP address on which to bind" + type="java.lang.String"/> + <parameter name="port" + description="TCP port number to listen on" + type="int"/> + </operation> + <operation name="createDefaultContext" description="Create a new DefaultContext" impact="ACTION"
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>