manveen 02/01/26 14:39:45 Modified: webapps/admin/WEB-INF struts-config.xml webapps/admin/WEB-INF/classes/org/apache/webapp/admin ApplicationResources_en.properties ApplicationResources_es.properties TomcatTreeBuilder.java Added: webapps/admin logger.jsp webapps/admin/WEB-INF/classes/org/apache/webapp/admin LoggerAction.java LoggerForm.java SetUpLoggerAction.java Log: Added functionality for Logger properties to be viewed and edited through the admin tool. Properties read/written to corresponding mBeans. Revision Changes Path 1.1 jakarta-tomcat-4.0/webapps/admin/logger.jsp Index: logger.jsp =================================================================== <!-- Standard Struts Entries --> <%@ page language="java" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <%@ taglib uri="/WEB-INF/controls.tld" prefix="controls" %> <html:html locale="true"> <%@ include file="header.jsp" %> <!-- Body --> <body bgcolor="white"> <!--Form --> <html:errors/> <html:form method="POST" action="/logger"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr bgcolor="7171A5"> <td width="81%"> <html:hidden property="loggerName"/> <html:hidden property="loggerType"/> <div class="page-title-text" align="left"> <bean:write name="loggerForm" property="nodeLabel" scope="session"/> </div> </td> <td width="19%"> <div align="right"> <controls:actions> <controls:action selected="true"> ----<bean:message key="actions.available.actions"/>---- </controls:action> <controls:action> --------------------------------- </controls:action> <!-- will add the urls later once those screens get implemented --> <controls:action url=""> <bean:message key="actions.thislogger.delete"/> </controls:action> </controls:actions> </div> </td> </tr> </table> <%@ include file="buttons.jsp" %> <br> <table class="back-table" border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <td> <controls:table tableStyle="front-table" lineStyle="line-row"> <controls:row header="true" labelStyle="table-header-text" dataStyle="table-header-text"> <controls:label><bean:message key="service.property"/></controls:label> <controls:data><bean:message key="service.value"/></controls:data> </controls:row> <controls:row labelStyle="table-label-text" dataStyle="table-normal-text"> <controls:label><bean:message key="connector.type"/>:</controls:label> <controls:data> <bean:write name="loggerForm" property="loggerType" scope="session"/> </controls:data> </controls:row> <controls:row labelStyle="table-label-text" dataStyle="table-normal-text"> <controls:label><bean:message key="server.debuglevel"/>:</controls:label> <controls:data> <html:select property="debugLvl"> <bean:define id="debugLvlVals" name="loggerForm" property="debugLvlVals"/> <html:options collection="debugLvlVals" property="value" labelProperty="label"/> </html:select> </controls:data> </controls:row> <controls:row labelStyle="table-label-text" dataStyle="table-normal-text"> <controls:label>Verbosity Level:</controls:label> <controls:data> <html:select property="verbosityLvl"> <bean:define id="verbosityLvlVals" name="loggerForm" property="verbosityLvlVals"/> <html:options collection="verbosityLvlVals" property="value" labelProperty="label"/> </html:select> </controls:data> </controls:row> </controls:table> <%-- Display the following fileds only if it is a FileLogger --%> <logic:equal name="loggerForm" property="loggerType" scope="session" value="FileLogger"> <controls:table tableStyle="front-table" lineStyle="line-row"> <controls:row labelStyle="table-label-text" dataStyle="table-normal-text"> <controls:label><bean:message key="logger.directory"/>:</controls:label> <controls:data> <html:text property="directory" size="25"/> </controls:data> </controls:row> <controls:row labelStyle="table-label-text" dataStyle="table-normal-text"> <controls:label><bean:message key="logger.prefix"/>:</controls:label> <controls:data> <html:text property="prefix" size="25"/> </controls:data> </controls:row> <controls:row labelStyle="table-label-text" dataStyle="table-normal-text"> <controls:label><bean:message key="logger.suffix"/>:</controls:label> <controls:data> <html:text property="suffix" size="15"/> </controls:data> </controls:row> <controls:row labelStyle="table-label-text" dataStyle="table-normal-text"> <controls:label><bean:message key="logger.timestamp"/>:</controls:label> <controls:data> <html:select property="timestamp"> <bean:define id="booleanVals" name="loggerForm" property="booleanVals"/> <html:options collection="booleanVals" property="value" labelProperty="label"/> </html:select> </controls:data> </controls:row> </controls:table> </logic:equal> </td> </tr> </table> <%@ include file="buttons.jsp" %> <br> </html:form> <p> </p> </body> </html:html> 1.18 +26 -0 jakarta-tomcat-4.0/webapps/admin/WEB-INF/struts-config.xml Index: struts-config.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/struts-config.xml,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- struts-config.xml 23 Jan 2002 23:06:53 -0000 1.17 +++ struts-config.xml 26 Jan 2002 22:39:45 -0000 1.18 @@ -34,6 +34,10 @@ <!-- Context form bean --> <form-bean name="contextForm" type="org.apache.webapp.admin.ContextForm"/> + + <!-- Logger form bean --> + <form-bean name="loggerForm" + type="org.apache.webapp.admin.LoggerForm"/> <!-- Set Locale form bean --> <form-bean name="setLocaleForm" @@ -106,6 +110,10 @@ path="/listUsers.jsp" redirect="false"/> + <forward name="Logger" + path="/logger.jsp" + redirect="false"/> + </global-forwards> @@ -180,6 +188,16 @@ redirect="true"/> </action> + <!-- Set up Logger datastructure --> + <action path="/setUpLogger" + type="org.apache.webapp.admin.SetUpLoggerAction" + name="loggerForm" + scope="session"> + <forward name="SetUpLogger" + path="/logger.jsp" + redirect="true"/> + </action> + <!-- Log out of the application --> <action path="/logOut" type="org.apache.webapp.admin.LogOutAction"> @@ -226,6 +244,14 @@ name="contextForm" scope="session" input="/context.jsp"> + </action> + + <!-- Process a logger change --> + <action path="/logger" + type="org.apache.webapp.admin.LoggerAction" + name="loggerForm" + scope="session" + input="/logger.jsp"> </action> <!-- Process a set-locale action --> 1.15 +8 -1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationResources_en.properties Index: ApplicationResources_en.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationResources_en.properties,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- ApplicationResources_en.properties 23 Jan 2002 23:06:54 -0000 1.14 +++ ApplicationResources_en.properties 26 Jan 2002 22:39:45 -0000 1.15 @@ -45,7 +45,6 @@ error.redirectPortText.format=<li>Redirect Port Number not a valid integer!</li> error.redirectPortText.range=<li>Redirect Port Number seems out of range. Valid range is 1-65535. </li> error.minProcessorsText.required=<li>Minimum Processors cannot be empty</li> -b error.minProcessorsText.format=<li>Minimum Processors not a valid integer!</li> error.minProcessorsText.range=<li>Minimum Processors seems out of range. Valid range is 1-512. </li> error.maxProcessorsText.required=<li>Maximum Processors cannot be empty</li> @@ -90,6 +89,7 @@ actions.alias.delete=Delete Aliases actions.thishost.delete=Delete This Host actions.thiscontext.delete=Delete This Context +actions.thislogger.delete=Delete This Logger connector.type=Type connector.accept.count=Accept Count connector.connection.timeout=Connection Timeout @@ -145,3 +145,10 @@ listUsers.title=Users List listUsers.username=Username listUsers.fullName=Full Name +logger.directory=Directory +logger.prefix=Prefix +logger.suffix=Suffix +logger.timestamp=Timestamp +error.directory.required=<li>Directory cannot be empty.</li> +error.prefix.required=<li>Prefix cannot be empty.</li> +error.suffix.required=<li>Suffix cannot be empty.</li> 1.17 +21 -0 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationResources_es.properties Index: ApplicationResources_es.properties =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ApplicationResources_es.properties,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- ApplicationResources_es.properties 18 Jan 2002 05:53:26 -0000 1.16 +++ ApplicationResources_es.properties 26 Jan 2002 22:39:45 -0000 1.17 @@ -69,12 +69,16 @@ actions.accesslogger.delete=Eliminar (Access Logger) Registrador de Acceso actions.connector.create=Crear Nuevo Conector actions.connector.delete=Eliminar Conectores +actions.group.create=Crear Nuevo Grupo +actions.group.delete=Grupo Existente De la Cancelacion actions.host.create=Crear Nuevo Host actions.host.delete=Eliminar Hosts actions.logger.create=Crear Nuevo (Logger) Registrador actions.logger.delete=Eliminar (Logger) Registradores actions.requestfilter.create=Cree El Filtro Nuevo de la Petici\u00f3n actions.requestfilter.delete=Filtros de la Petici\u00f3n de la Cancelaci\u00f3n +actions.user.create=Crear Nuevo Utilizador +actions.user.delete=Utilizador existente de la cancelacion actions.userrealm.create=Cree El Nuevo Reino de Usuario actions.userrealm.delete=Eliminar Reinos de Usuario actions.valve.create=Crear Nueva V\u00e1lvula @@ -85,6 +89,7 @@ actions.alias.delete=Pseudonimos De la Cancelacion actions.thishost.delete=Suprima Este Ordenador principal actions.thiscontext.delete=Suprima Este Contexto +actions.thislogger.delete=Suprima Este Logger connector.type=Tipo connector.accept.count=Valide La Cuenta connector.connection.timeout=Descanso De la Conexi\u00f3n @@ -131,3 +136,19 @@ error.mgrMaxSessions.required=<li>Las sesiones maximas no pueden ser vacias</li> error.mgrMaxSessions.format=<li>Sesiones maximas no un numero entero valido!</li> error.mgrMaxSessions.range=<li>Las sesiones maximas se parecen fuera de rango. El rango valido es -1 a 100.</li> +usersTreeBuilder.groupsNode=Group Administration +usersTreeBuilder.subtreeNode=User and Group Administration +usersTreeBuilder.usersNode=User Administration +listGroups.title=Groups List +listGroups.groupname=Nombre De Grupo +listGroups.description=Descripcion +listUsers.title=Users List +listUsers.username=Username +listUsers.fullName=Completo Nombre +logger.directory=Directorio +logger.prefix=Prefijo +logger.suffix=Sufijo +logger.timestamp=Timestamp +error.directory.required=<li>El directorio no puede ser vacio.</li> +error.prefix.required=<li>El prefijo no puede ser vacio.</li> +error.suffix.required=<li>El sufijo no puede ser vacio.</li> 1.10 +81 -18 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java Index: TomcatTreeBuilder.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- TomcatTreeBuilder.java 23 Jan 2002 02:18:49 -0000 1.9 +++ TomcatTreeBuilder.java 26 Jan 2002 22:39:45 -0000 1.10 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v 1.9 2002/01/23 02:18:49 patrickl Exp $ - * $Revision: 1.9 $ - * $Date: 2002/01/23 02:18:49 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v 1.10 2002/01/26 22:39:45 manveen Exp $ + * $Revision: 1.10 $ + * $Date: 2002/01/26 22:39:45 $ * * ==================================================================== * @@ -65,6 +65,7 @@ import java.util.Iterator; import java.util.List; import java.util.Locale; +import java.util.StringTokenizer; import java.net.URLEncoder; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -91,7 +92,7 @@ * * @author Jazmin Jonson * @author Manveen Kaur - * @version $Revision: 1.9 $ $Date: 2002/01/23 02:18:49 $ + * @version $Revision: 1.10 $ $Date: 2002/01/26 22:39:45 $ */ @@ -108,6 +109,7 @@ public final static String CONTEXT_TYPE = "Catalina:type=Context"; public final static String LOADER_TYPE = "Catalina:type=WebappLoader"; public final static String MANAGER_TYPE = "Catalina:type=StandardManager"; + public final static String LOGGER_TYPE = "Catalina:type=Logger"; public final static String WILDCARD = ",*"; @@ -195,7 +197,7 @@ getConnectors(serviceNode, serviceName); getHosts(serviceNode, serviceName); - + getLoggers(serviceNode, serviceName, null, null, 0); } } @@ -269,23 +271,13 @@ serviceNode.addChild(hostNode); getContexts(hostNode, hostName, serviceName); + getLoggers(hostNode, serviceName, hostName, null, 1); } } public void getContexts(TreeControlNode hostNode, String hostName, String serviceName) throws JMException{ - - /* - System.out.println("** There are " + mBServer.getMBeanCount().intValue() + - " registered MBeans **"); - Iterator instances = mBServer.queryMBeans(null, null).iterator(); - while (instances.hasNext()) { - ObjectInstance instance = (ObjectInstance) instances.next(); - System.out.println(" objectName=" + instance.getObjectName() + - ", className=" + instance.getClassName()); - } - */ Iterator contextItr = (mBServer.queryMBeans(new ObjectName(CONTEXT_TYPE + WILDCARD + @@ -315,8 +307,79 @@ "content", true); hostNode.addChild(contextNode); - + //get all loggers for this context + if (contextName.length() > 0) + getLoggers(contextNode, serviceName, hostName, contextName, 2); + } + } + + + /** + * Add the required logger nodes to the specified node instance. + * + * @param node The <code>TreeControlNode</code> to which we should + * add our logger nodes. + * @param serviceName The service to which this logger belongs. + * @param hostName The host to which this logger belongs. + * @param contextName The context to which this logger belongs. + * @param type (0,1,2) Get all loggers for a particular service(0), + * host(1), context (2). + */ + public void getLoggers(TreeControlNode node, String serviceName, + String hostName, String contextName, int type) + throws JMException{ + + Iterator loggerItr = null; + + if (type == 0) { + loggerItr = + (mBServer.queryMBeans(new ObjectName(LOGGER_TYPE + + ",service=" + serviceName), null)).iterator(); + } else if (type == 1) { + loggerItr = + (mBServer.queryMBeans(new ObjectName(LOGGER_TYPE + + ",host=" + hostName + ",service=" + serviceName), null)).iterator(); + } else if (type == 2) { + loggerItr = + (mBServer.queryMBeans(new ObjectName(LOGGER_TYPE + + ",path=" + contextName + ",host=" + hostName + + ",service=" + serviceName), null)).iterator(); } - } + TreeControlNode loggerNode = null; + String encodedLoggerName; + + while(loggerItr.hasNext()){ + + ObjectInstance loggerObj = (ObjectInstance)loggerItr.next(); + ObjectName loggerObjName = loggerObj.getObjectName(); + encodedLoggerName = URLEncoder.encode(loggerObj.getObjectName().toString()); + + String className = + (String)mBServer.getAttribute(loggerObj.getObjectName(), + SetUpLoggerAction.CLASSNAME_PROP_NAME); + + String loggerType = null; + StringTokenizer st = new StringTokenizer(className, "."); + while (st.hasMoreTokens()) { + loggerType = st.nextToken().trim(); + } + + String encodedLoggerType = URLEncoder.encode(loggerType); + + String nodeLabel="Logger"; + String encodedNodeLabel = URLEncoder.encode(nodeLabel); + + loggerNode = + new TreeControlNode(loggerObj.getObjectName().toString(), + "folder_16_pad.gif", + nodeLabel, + "setUpLogger.do?select=" + encodedLoggerName + +"&nodeLabel="+ encodedNodeLabel + +"&type="+ encodedLoggerType, + "content", true); + + node.addChild(loggerNode); + } + } } 1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/LoggerAction.java Index: LoggerAction.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/LoggerAction.java,v 1.1 2002/01/26 22:39:45 manveen Exp $ * $Revision: 1.1 $ * $Date: 2002/01/26 22:39:45 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Struts", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.webapp.admin; import java.util.Iterator; import java.util.Locale; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.struts.action.Action; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import javax.management.Attribute; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.QueryExp; import javax.management.Query; import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.JMException; import javax.management.MBeanAttributeInfo; import javax.management.MBeanOperationInfo; import javax.management.MBeanInfo; import org.apache.struts.util.MessageResources; /** * Implementation of <strong>Action</strong> that validates * actions on a Logger. * * @author Manveen Kaur * @version $Revision: 1.1 $ $Date: 2002/01/26 22:39:45 $ */ public final class LoggerAction extends Action { private static MBeanServer mBServer = null; // --------------------------------------------------------- Public Methods /** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). * Return an <code>ActionForward</code> instance describing where and how * control should be forwarded, or <code>null</code> if the response has * already been completed. * * @param mapping The ActionMapping used to select this instance * @param actionForm The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet exception occurs */ public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try{ // front end validation and checking. // =================================================== MessageResources messages = getResources(); Locale locale = (Locale)request.getSession().getAttribute(Action.LOCALE_KEY); // Validate the request parameters specified by the user ActionErrors errors = new ActionErrors(); // Report any errors we have discovered back to the original form if (!errors.empty()) { saveErrors(request, errors); return (new ActionForward(mapping.getInput())); } if(mBServer == null) { ApplicationServlet servlet = (ApplicationServlet)getServlet(); mBServer = servlet.getServer(); } /** * Get the logger Name from the form. * This is used to lookup the MBeanServer and * retrieve this logger's MBean. */ String loggerName = request.getParameter("loggerName"); Iterator loggerItr = mBServer.queryMBeans(new ObjectName(loggerName), null).iterator(); ObjectInstance objInstance = (ObjectInstance)loggerItr.next(); ObjectName loggerObjName = (objInstance).getObjectName(); /** * Extracting the values from the form and * updating the MBean with the new values. */ String debugLvlText = request.getParameter("debugLvl"); if(debugLvlText != null) { Integer debugLvl = new Integer(debugLvlText); mBServer.setAttribute(loggerObjName, new Attribute(SetUpLoggerAction.DEBUG_PROP_NAME, debugLvl)); } String verbosityLvlText = request.getParameter("verbosityLvl"); if(verbosityLvlText != null) { Integer verbosityLvl = new Integer(verbosityLvlText); mBServer.setAttribute(loggerObjName, new Attribute(SetUpLoggerAction.VERBOSITY_PROP_NAME, verbosityLvl)); } String type = request.getParameter("loggerType"); // the following are specific to FileLogger if (type.equalsIgnoreCase(SetUpLoggerAction.FILE_LOGGER)) { String directory = request.getParameter("directory"); if(directory != null) { mBServer.setAttribute(loggerObjName, new Attribute(SetUpLoggerAction.DIR_PROP_NAME, directory)); } String prefix = request.getParameter("prefix"); if(prefix != null) { mBServer.setAttribute(loggerObjName, new Attribute(SetUpLoggerAction.PREFIX_PROP_NAME, prefix)); } String suffix = request.getParameter("suffix"); if(suffix != null) { mBServer.setAttribute(loggerObjName, new Attribute(SetUpLoggerAction.SUFFIX_PROP_NAME, suffix)); } String timestamp = request.getParameter("timestamp"); if(timestamp != null) { Boolean tstamp = Boolean.valueOf(timestamp); mBServer.setAttribute(loggerObjName, new Attribute(SetUpLoggerAction.TIMESTAMP_PROP_NAME, tstamp)); } } }catch(Throwable t){ t.printStackTrace(System.out); //forward to error page } if (servlet.getDebug() >= 1) servlet.log(" Forwarding to success page"); // Forward back to the test page return (mapping.findForward("Save Successful")); } } 1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/LoggerForm.java Index: LoggerForm.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/LoggerForm.java,v 1.1 2002/01/26 22:39:45 manveen Exp $ * $Revision: 1.1 $ * $Date: 2002/01/26 22:39:45 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Struts", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.webapp.admin; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; import java.net.InetAddress; import java.util.ArrayList; /** * Form bean for the logger page. * * @author Manveen Kaur * @version $Revision: 1.1 $ $Date: 2002/01/26 22:39:45 $ */ public final class LoggerForm extends ActionForm { // ----------------------------------------------------- Instance Variables /** * The text for the debug level. */ private String debugLvl = "0"; /** * The text for the logger name, used to retrieve * the corresponding logger mBean. */ private String loggerName = null; /** * The text for the logger type. * Specifies if it is a FileLogger, or SysErr or SysOut Logger. */ private String loggerType = null; /** * The text for the verbosity. */ private String verbosityLvl = null; /** * Set of valid values for debug level. */ private ArrayList debugLvlVals = null; /** * Set of valid values for verbosity level. */ private ArrayList verbosityLvlVals = null; /* * Represent boolean (true, false) values for timestamp. */ private ArrayList booleanVals = null; /** * The text for the directory. */ private String directory = null; /** * The text for the prefix. */ private String prefix = null; /** * The text for the timestamp. */ private String timestamp = null; /** * The text for the suffix. */ private String suffix = null; /** * The text for the node label. */ private String nodeLabel = null; // ------------------------------------------------------------- Properties /** * Return the Logger Name. */ public String getLoggerName() { return this.loggerName; } /** * Set the Logger Name. */ public void setLoggerName(String loggerName) { this.loggerName = loggerName; } /** * Return the Logger type. */ public String getLoggerType() { return this.loggerType; } /** * Set the Logger type. */ public void setLoggerType(String loggerType) { this.loggerType = loggerType; } /** * Return the verbosityLvl. */ public String getVerbosityLvl() { return this.verbosityLvl; } /** * Set the verbosityLvl. */ public void setVerbosityLvl(String verbosityLvl) { this.verbosityLvl = verbosityLvl; } /** * Return the debugVals. */ public ArrayList getDebugLvlVals() { return this.debugLvlVals; } /** * Set the debugVals. */ public void setDebugLvlVals(ArrayList debugLvlVals) { this.debugLvlVals = debugLvlVals; } /** * Return the verbosityLvl Vals. */ public ArrayList getVerbosityLvlVals() { return this.verbosityLvlVals; } /** * Set the verbosityLvl Vals. */ public void setVerbosityLvlVals(ArrayList verbosityLvlVals) { this.verbosityLvlVals = verbosityLvlVals; } /** * Return the Debug Level Text. */ public String getDebugLvl() { return this.debugLvl; } /** * Set the Debug Level Text. */ public void setDebugLvl(String debugLvl) { this.debugLvl = debugLvl; } /** * Return the booleanVals. */ public ArrayList getBooleanVals() { return this.booleanVals; } /** * Set the debugVals. */ public void setBooleanVals(ArrayList booleanVals) { this.booleanVals = booleanVals; } /** * Return the directory. */ public String getDirectory() { return this.directory; } /** * Set the directory. */ public void setDirectory(String directory) { this.directory = directory; } /** * Return the prefix. */ public String getPrefix() { return this.prefix; } /** * Set the prefix. */ public void setPrefix(String prefix) { this.prefix = prefix; } /** * Return the suffix. */ public String getSuffix() { return this.suffix; } /** * Set the suffix. */ public void setSuffix(String suffix) { this.suffix = suffix; } /** * Return the label of the node that was clicked. */ public String getNodeLabel() { return this.nodeLabel; } /** * Set the node label. */ public void setNodeLabel(String nodeLabel) { this.nodeLabel = nodeLabel; } /** * Return the timestamp. */ public String getTimestamp() { return this.timestamp; } /** * Set the timestamp. */ public void setTimestamp(String timestamp) { this.timestamp = timestamp; } // --------------------------------------------------------- Public Methods /** * Reset all properties to their default values. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing */ public void reset(ActionMapping mapping, HttpServletRequest request) { //FIX ME -- is this needed for debug and verbosity? this.debugLvl = "0"; this.verbosityLvl = "0"; this.directory = null; this.prefix = null; this.suffix = null; this.timestamp = "false"; } /** * Validate the properties that have been set from this HTTP request, * and return an <code>ActionErrors</code> object that encapsulates any * validation errors that have been found. If no errors are found, return * <code>null</code> or an <code>ActionErrors</code> object with no * recorded error messages. * * @param mapping The mapping used to select this instance * @param request The servlet request we are processing */ public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); String submit = request.getParameter("submit"); String type = request.getParameter("loggerType"); // front end validation when save is clicked. // these checks should be done only if it is FileLogger. // No checks needed otherwise if ((submit != null) && (SetUpLoggerAction.FILE_LOGGER).equalsIgnoreCase(type)) { if ((directory == null) || (directory.length() < 1)) { errors.add("directory", new ActionError("error.directory.required")); } if ((prefix == null) || (prefix.length() < 1)) { errors.add("prefix", new ActionError("error.prefix.required")); } if ((suffix == null) || (suffix.length() < 1)) { errors.add("suffix", new ActionError("error.suffix.required")); } } return errors; } } 1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/SetUpLoggerAction.java Index: SetUpLoggerAction.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/SetUpLoggerAction.java,v 1.1 2002/01/26 22:39:45 manveen Exp $ * $Revision: 1.1 $ * $Date: 2002/01/26 22:39:45 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR loggerS; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.webapp.admin; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.ArrayList; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.struts.action.Action; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.QueryExp; import javax.management.Query; import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.JMException; import javax.management.MBeanAttributeInfo; import javax.management.MBeanOperationInfo; import javax.management.MBeanInfo; import javax.management.modelmbean.ModelMBean; import javax.management.modelmbean.ModelMBeanInfo; import org.apache.struts.util.MessageResources; /** * Test <code>Action</code> that handles events from the tree control when * a logger is chosen. * * @author Manveen Kaur * @version $Revision: 1.1 $ $Date: 2002/01/26 22:39:45 $ */ public class SetUpLoggerAction extends Action { private static MBeanServer mBServer = null; public final static String CLASSNAME_PROP_NAME = "className"; public final static String DEBUG_PROP_NAME = "debug"; public final static String VERBOSITY_PROP_NAME = "verbosity"; // specific to FileLogger public final static String DIR_PROP_NAME = "directory"; public final static String PREFIX_PROP_NAME = "prefix"; public final static String SUFFIX_PROP_NAME = "suffix"; public final static String TIMESTAMP_PROP_NAME = "timestamp"; public final static String FILE_LOGGER = "FileLogger"; private ArrayList debugLvlList = null; private ArrayList verbosityLvlList = null; private ArrayList booleanList = null; // --------------------------------------------------------- Public Methods /** * Process the specified HTTP request, and create the corresponding HTTP * response (or forward to another web component that will create it). * Return an <code>ActionForward</code> instance describing where and how * control should be forwarded, or <code>null</code> if the response has * already been completed. * * @param mapping The ActionMapping used to select this instance * @param actionForm The optional ActionForm bean for this request (if any) * @param request The HTTP request we are processing * @param response The HTTP response we are creating * * @exception IOException if an input/output error occurs * @exception ServletException if a servlet exception occurs */ public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { HttpSession session = request.getSession(); if (form == null) { getServlet().log(" Creating new LoggerForm bean under key " + mapping.getAttribute()); form = new LoggerForm(); if ("request".equals(mapping.getScope())) request.setAttribute(mapping.getAttribute(), form); else session.setAttribute(mapping.getAttribute(), form); } String selectedName = request.getParameter("select"); String loggerType = request.getParameter("type"); // label of the node that was clicked on. String nodeLabel = request.getParameter("nodeLabel"); LoggerForm loggerFm = (LoggerForm) form; if(debugLvlList == null) { debugLvlList = new ArrayList(); debugLvlList.add(new LabelValueBean("0", "0")); debugLvlList.add(new LabelValueBean("1", "1")); debugLvlList.add(new LabelValueBean("2", "2")); debugLvlList.add(new LabelValueBean("3", "3")); debugLvlList.add(new LabelValueBean("4", "4")); debugLvlList.add(new LabelValueBean("5", "5")); debugLvlList.add(new LabelValueBean("6", "6")); debugLvlList.add(new LabelValueBean("7", "7")); debugLvlList.add(new LabelValueBean("8", "8")); debugLvlList.add(new LabelValueBean("9", "9")); } if(verbosityLvlList == null) { verbosityLvlList = new ArrayList(); verbosityLvlList.add(new LabelValueBean("0", "0")); verbosityLvlList.add(new LabelValueBean("1", "1")); verbosityLvlList.add(new LabelValueBean("2", "2")); verbosityLvlList.add(new LabelValueBean("3", "3")); verbosityLvlList.add(new LabelValueBean("4", "4")); } /* Boolean (true.false) list for enableLookups */ if(booleanList == null) { booleanList = new ArrayList(); booleanList.add(new LabelValueBean("True", "true")); booleanList.add(new LabelValueBean("False", "false")); } // common for all loggers Integer debug = null; Integer verbosity = null; // specific to FileLogger String directory = null; String prefix = null; String suffix = null; Boolean timestamp = null; try{ if(mBServer == null) { ApplicationServlet servlet = (ApplicationServlet)getServlet(); mBServer = servlet.getServer(); } Iterator loggerItr = mBServer.queryMBeans(new ObjectName(selectedName), null).iterator(); ObjectInstance objInstance = (ObjectInstance)loggerItr.next(); ObjectName loggerObjName = (objInstance).getObjectName(); // common attributes for all logger types. debug = (Integer) mBServer.getAttribute(loggerObjName, DEBUG_PROP_NAME); verbosity = (Integer) mBServer.getAttribute(loggerObjName, VERBOSITY_PROP_NAME); if (FILE_LOGGER.equalsIgnoreCase(loggerType)) { // Initialize rest of variables. directory = (String) mBServer.getAttribute(loggerObjName, DIR_PROP_NAME); prefix = (String) mBServer.getAttribute(loggerObjName, PREFIX_PROP_NAME); suffix = (String) mBServer.getAttribute(loggerObjName, SUFFIX_PROP_NAME); timestamp = (Boolean) mBServer.getAttribute(loggerObjName, TIMESTAMP_PROP_NAME); } } catch(Throwable t){ t.printStackTrace(System.out); //forward to error page } //setting values obtained from the mBean to be displayed in the form. loggerFm.setLoggerType(loggerType); loggerFm.setDebugLvl(debug.toString()); loggerFm.setDebugLvlVals(debugLvlList); loggerFm.setVerbosityLvl(verbosity.toString()); loggerFm.setVerbosityLvlVals(verbosityLvlList); loggerFm.setLoggerName(selectedName); loggerFm.setNodeLabel(nodeLabel); if (FILE_LOGGER.equalsIgnoreCase(loggerType)) { loggerFm.setDirectory(directory); loggerFm.setPrefix(prefix); loggerFm.setSuffix(suffix); loggerFm.setBooleanVals(booleanList); loggerFm.setTimestamp(timestamp.toString()); } // Forward back to the test page return (mapping.findForward("Logger")); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>