amyroh 02/05/01 19:03:16 Modified: catalina/src/share/org/apache/catalina/mbeans ConnectorMBean.java MBeanFactory.java StandardServerMBean.java Log: SSL connector mbean fixes. Needs an error page in case if a user wants to create SSL connector before configuring with keytool. ResourceParams and other components are now written out to new server.xml Revision Changes Path 1.4 +16 -15 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/ConnectorMBean.java Index: ConnectorMBean.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/ConnectorMBean.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ConnectorMBean.java 1 May 2002 00:38:09 -0000 1.3 +++ ConnectorMBean.java 2 May 2002 02:03:15 -0000 1.4 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/ConnectorMBean.java,v 1.3 2002/05/01 00:38:09 amyroh Exp $ - * $Revision: 1.3 $ - * $Date: 2002/05/01 00:38:09 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/ConnectorMBean.java,v 1.4 2002/05/02 02:03:15 amyroh Exp $ + * $Revision: 1.4 $ + * $Date: 2002/05/02 02:03:15 $ * * ==================================================================== * @@ -76,10 +76,10 @@ * <code>org.apache.coyote.tomcat4.CoyoteConnector</code> component.</p> * * @author Amy Roh - * @version $Revision: 1.3 $ $Date: 2002/05/01 00:38:09 $ + * @version $Revision: 1.4 $ $Date: 2002/05/02 02:03:15 $ */ -public class ConnectorMBean extends BaseModelMBean { +public class ConnectorMBean extends ClassNameMBean { // ----------------------------------------------------------- Constructors @@ -127,13 +127,14 @@ if (coyoteServerSocketFactoryCls.isInstance(factory)) { // get clientAuth Method meth2 = coyoteServerSocketFactoryCls.getMethod("getClientAuth", null); - clientAuthObj = meth2.invoke(this.resource, null); + clientAuthObj = meth2.invoke(factory, null); } } - if (clientAuthObj instanceof Boolean) + if (clientAuthObj instanceof Boolean) { return ((Boolean)clientAuthObj).booleanValue(); - else return false; + } else return false; + } @@ -158,7 +159,7 @@ Method meth2 = coyoteServerSocketFactoryCls.getMethod("setClientAuth", partypes2); Object arglist2[] = new Object[1]; arglist2[0] = new Boolean(clientAuth); - meth2.invoke(this.resource, arglist2); + meth2.invoke(factory, arglist2); } } @@ -183,8 +184,8 @@ if (coyoteServerSocketFactoryCls.isInstance(factory)) { // get keystoreFile Method meth2 = coyoteServerSocketFactoryCls.getMethod("getKeystoreFile", null); - keystoreFileObj = meth2.invoke(this.resource, null); - } + keystoreFileObj = meth2.invoke(factory, null); + } } if (keystoreFileObj == null) { @@ -221,7 +222,7 @@ Method meth2 = coyoteServerSocketFactoryCls.getMethod("setKeystoreFile", partypes2); Object arglist2[] = new Object[1]; arglist2[0] = keystoreFile; - meth2.invoke(this.resource, arglist2); + meth2.invoke(factory, arglist2); } } @@ -246,7 +247,7 @@ if (coyoteServerSocketFactoryCls.isInstance(factory)) { // get keystorePass Method meth2 = coyoteServerSocketFactoryCls.getMethod("getKeystorePass", null); - keystorePassObj = meth2.invoke(this.resource, null); + keystorePassObj = meth2.invoke(factory, null); } } @@ -255,7 +256,7 @@ return null; } else { return keystorePassObj.toString(); - } + } } @@ -285,7 +286,7 @@ Method meth2 = coyoteServerSocketFactoryCls.getMethod("setKeystorePass", partypes2); Object arglist2[] = new Object[1]; arglist2[0] = keystorePass; - meth2.invoke(this.resource, arglist2); + meth2.invoke(factory, arglist2); } } } 1.29 +32 -10 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.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- MBeanFactory.java 1 May 2002 00:38:09 -0000 1.28 +++ MBeanFactory.java 2 May 2002 02:03:15 -0000 1.29 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v 1.28 2002/05/01 00:38:09 amyroh Exp $ - * $Revision: 1.28 $ - * $Date: 2002/05/01 00:38:09 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanFactory.java,v 1.29 2002/05/02 02:03:15 amyroh Exp $ + * $Revision: 1.29 $ + * $Date: 2002/05/02 02:03:15 $ * * ==================================================================== * @@ -117,7 +117,7 @@ * <code>org.apache.catalina.core.StandardServer</code> component.</p> * * @author Amy Roh - * @version $Revision: 1.28 $ $Date: 2002/05/01 00:38:09 $ + * @version $Revision: 1.29 $ $Date: 2002/05/02 02:03:15 $ */ public class MBeanFactory extends BaseModelMBean { @@ -463,16 +463,38 @@ Object arglist4[] = new Object[1]; arglist4[0] = new Boolean(true); meth4.invoke(retobj, arglist4); + // Set factory + Class serverSocketFactoryCls = + Class.forName("org.apache.catalina.net.ServerSocketFactory"); + Class coyoteServerSocketFactoryCls = + Class.forName("org.apache.coyote.tomcat4.CoyoteServerSocketFactory"); + Constructor factoryConst = + coyoteServerSocketFactoryCls.getConstructor(null); + Object factoryObj = factoryConst.newInstance(null); + Class partypes5 [] = new Class[1]; + partypes5[0] = serverSocketFactoryCls; + Method meth5 = cls.getMethod("setFactory", partypes5); + Object arglist5[] = new Object[1]; + arglist5[0] = factoryObj; + meth5.invoke(retobj, arglist5); } 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); - + try { + // 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); + } catch (Exception e) { + // FIXME + // disply error message + // the user needs to use keytool to configure SSL first + // addConnector will fail otherwise + return null; + } + // Return the corresponding MBean name ManagedBean managed = registry.findManagedBean("CoyoteConnector"); ObjectName oname = 1.13 +135 -20 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServerMBean.java Index: StandardServerMBean.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServerMBean.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- StandardServerMBean.java 30 Apr 2002 17:47:26 -0000 1.12 +++ StandardServerMBean.java 2 May 2002 02:03:15 -0000 1.13 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServerMBean.java,v 1.12 2002/04/30 17:47:26 amyroh Exp $ - * $Revision: 1.12 $ - * $Date: 2002/04/30 17:47:26 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServerMBean.java,v 1.13 2002/05/02 02:03:15 amyroh Exp $ + * $Revision: 1.13 $ + * $Date: 2002/05/02 02:03:15 $ * * ==================================================================== * @@ -70,6 +70,8 @@ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; +import java.util.Enumeration; +import java.util.Hashtable; import java.util.Iterator; import javax.management.InstanceNotFoundException; import javax.management.MBeanAttributeInfo; @@ -95,8 +97,10 @@ import org.apache.catalina.Service; import org.apache.catalina.Store; import org.apache.catalina.Valve; +import org.apache.catalina.deploy.ApplicationParameter; import org.apache.catalina.deploy.NamingResources; import org.apache.catalina.deploy.ContextResource; +import org.apache.catalina.deploy.ContextResourceLink; import org.apache.catalina.deploy.ContextEnvironment; import org.apache.catalina.deploy.ResourceParams; import org.apache.catalina.net.ServerSocketFactory; @@ -109,7 +113,7 @@ * <code>org.apache.catalina.core.StandardServer</code> component.</p> * * @author Amy Roh - * @version $Revision: 1.12 $ $Date: 2002/04/30 17:47:26 $ + * @version $Revision: 1.13 $ $Date: 2002/05/02 02:03:15 $ */ public class StandardServerMBean extends BaseModelMBean { @@ -547,8 +551,27 @@ storeManager(writer, indent + 2, manager); } + // Store neste <Environment> elements + ContextEnvironment[] envs = context.findEnvironments(); + for (int i = 0; i < envs.length; i++) { + for (int j = 0; j < indent + 2; j++) { + writer.print(' '); + } + writer.print("<Environment"); + storeAttributes(writer, false, envs[i]); + writer.println("/>"); + } + // Store nested <Parameter> elements - ; // FIXME + ApplicationParameter[] appParams = context.findApplicationParameters(); + for (int i = 0; i < appParams.length; i++) { + for (int j = 0; j < indent + 2; j++) { + writer.print(' '); + } + writer.print("<Parameter"); + storeAttributes(writer, false, appParams[i]); + writer.println("/>"); + } // Store nested <Realm> element Realm realm = context.getRealm(); @@ -561,12 +584,75 @@ storeRealm(writer, indent + 2, realm); } } - - // Store nested <ResourceLink> elements (and resource params?) - ; // FIXME - + // Store nested <Resources> element - ; // FIXME + ContextResource[] resources = context.findResources(); + for (int i = 0; i < resources.length; i++) { + for (int j = 0; j < indent + 2; j++) { + writer.print(' '); + } + writer.print("<Resource"); + storeAttributes(writer, false, resources[i]); + writer.println("/>"); + } + + // Store nested <ResourceParams> elements + NamingResources namingResources = context.getNamingResources(); + ResourceParams[] params = namingResources.findResourceParams(); + for (int i = 0; i < indent + 2; i++) { + writer.print(' '); + } + if (params.length > 0) { + writer.print("<ResourceParams "); + } + for (int i = 0; i < params.length; i++) { + storeAttributes(writer, false, params[i]); + } + writer.println(">"); + + for (int i = 0; i < params.length; i++) { + Hashtable resourceParams = params[i].getParameters(); + Enumeration nameEnum = resourceParams.keys(); + Enumeration valueEnum = resourceParams.elements(); + while ((nameEnum.hasMoreElements()) && (valueEnum.hasMoreElements())) { + for (int j = 0; j < indent + 4; j++) { + writer.print(' '); + } + writer.println("<parameter>"); + for (int j = 0; j < indent + 6; j++) { + writer.print(' '); + } + writer.print("<name>"); + writer.print(nameEnum.nextElement()); + writer.println("</name>"); + for (int j = 0; j < indent + 6; j++) { + writer.print(' '); + } + writer.print("<value>"); + writer.print(valueEnum.nextElement()); + writer.println("</value>"); + for (int j = 0; j < indent + 4; j++) { + writer.print(' '); + } + writer.println("</parameter>"); + } + } + + for (int i = 0; i < indent + 2; i++) { + writer.print(' '); + } + writer.println("</ResourceParams>"); + + // Store nested <ResourceLink> elements + ContextResourceLink[] resourceLinks = context.findResourceLinks(); + for (int i = 0; i < resourceLinks.length; i++) { + for (int j = 0; j < indent + 2; j++) { + writer.print(' '); + } + writer.print("<ResourceLink"); + storeAttributes(writer, false, resourceLinks[i]); + writer.println("/>"); + } // Store nested <Valve> elements if (context instanceof Pipeline) { @@ -752,14 +838,43 @@ writer.print(' '); } // Store nested <ResourceParams> elements - ResourceParams[] resourceParams = globalNamingResources.findResourceParams(); - if (resourceParams.length > 0) { + ResourceParams[] params = globalNamingResources.findResourceParams(); + if (params.length > 0) { writer.print("<ResourceParams "); } - for (int i = 0; i < resourceParams.length; i++) { - storeAttributes(writer, false, resourceParams[i]); + for (int i = 0; i < params.length; i++) { + storeAttributes(writer, false, params[i]); } writer.println(">"); + + for (int i = 0; i < params.length; i++) { + Hashtable resourceParams = params[i].getParameters(); + Enumeration nameEnum = resourceParams.keys(); + Enumeration valueEnum = resourceParams.elements(); + while ((nameEnum.hasMoreElements()) && (valueEnum.hasMoreElements())) { + for (int j = 0; j < indent + 4; j++) { + writer.print(' '); + } + writer.println("<parameter>"); + for (int j = 0; j < indent + 6; j++) { + writer.print(' '); + } + writer.print("<name>"); + writer.print(nameEnum.nextElement()); + writer.println("</name>"); + for (int j = 0; j < indent + 6; j++) { + writer.print(' '); + } + writer.print("<value>"); + writer.print(valueEnum.nextElement()); + writer.println("</value>"); + for (int j = 0; j < indent + 4; j++) { + writer.print(' '); + } + writer.println("</parameter>"); + } + } + for (int i = 0; i < indent + 2; i++) { writer.print(' '); } @@ -1012,12 +1127,6 @@ storeAttributes(writer, server); writer.println(">"); - // Store nested <GlobalNamingResources> element - NamingResources globalNamingResources = server.getGlobalNamingResources(); - if (globalNamingResources != null) { - storeGlobalNamingResources(writer, indent + 2, globalNamingResources); - } - // Store nested <Listener> elements if (server instanceof Lifecycle) { LifecycleListener listeners[] = @@ -1027,6 +1136,12 @@ } } + // Store nested <GlobalNamingResources> element + NamingResources globalNamingResources = server.getGlobalNamingResources(); + if (globalNamingResources != null) { + storeGlobalNamingResources(writer, indent + 2, globalNamingResources); + } + // Store nested <Service> elements Service services[] = server.findServices(); for (int i = 0; i < services.length; i++) {
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>