manveen 02/01/31 11:35:58 Modified: webapps/admin service.jsp webapps/admin/WEB-INF struts-config.xml Added: webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service ServiceAction.java ServiceForm.java SetUpServiceAction.java Removed: webapps/admin/WEB-INF/classes/org/apache/webapp/admin ServiceAction.java ServiceForm.java SetUpServiceAction.java Log: * Moved all service related files to admin.service, appropriate changes to struts-config.xml Revision Changes Path 1.6 +1 -0 jakarta-tomcat-4.0/webapps/admin/service.jsp Index: service.jsp =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/service.jsp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- service.jsp 31 Jan 2002 06:58:03 -0000 1.5 +++ service.jsp 31 Jan 2002 19:35:57 -0000 1.6 @@ -85,6 +85,7 @@ <controls:row labelStyle="table-label-text" dataStyle="table-normal-text"> <controls:label><bean:message key="service.name"/>:</controls:label> <controls:data> + <html:hidden property="serviceName"/> <bean:write name="serviceForm" property="serviceName" scope="session"/> </controls:data> 1.21 +3 -3 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.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- struts-config.xml 31 Jan 2002 05:25:25 -0000 1.20 +++ struts-config.xml 31 Jan 2002 19:35:57 -0000 1.21 @@ -21,7 +21,7 @@ <!-- Service form bean --> <form-bean name="serviceForm" - type="org.apache.webapp.admin.ServiceForm"/> + type="org.apache.webapp.admin.service.ServiceForm"/> <!-- Service form bean --> <form-bean name="deleteServiceForm" @@ -169,7 +169,7 @@ <!-- Set up Service datastructure --> <action path="/setUpService" - type="org.apache.webapp.admin.SetUpServiceAction" + type="org.apache.webapp.admin.service.SetUpServiceAction" name="serviceForm" scope="session"> <forward name="SetUpService" @@ -245,7 +245,7 @@ <!-- Process a user server change --> <action path="/service" - type="org.apache.webapp.admin.ServiceAction" + type="org.apache.webapp.admin.service.ServiceAction" name="serviceForm" scope="session" input="/service.jsp"> 1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service/ServiceAction.java Index: ServiceAction.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service/ServiceAction.java,v 1.1 2002/01/31 19:35:58 manveen Exp $ * $Revision: 1.1 $ * $Date: 2002/01/31 19:35:58 $ * * ==================================================================== * * 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.service; import java.util.Iterator; 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 org.apache.struts.util.MessageResources; import org.apache.webapp.admin.ApplicationServlet; import org.apache.webapp.admin.TomcatTreeBuilder; /** * Implementation of <strong>Action</strong> that validates * actions on a Service. * * @author Manveen Kaur * @version $Revision: 1.1 $ $Date: 2002/01/31 19:35:58 $ */ public final class ServiceAction 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(); // 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(); } String serviceName = request.getParameter("serviceName"); Iterator serviceItr = mBServer.queryMBeans(new ObjectName( TomcatTreeBuilder.ENGINE_TYPE + ",service=" + serviceName), null).iterator(); ObjectName serviceObjName = ((ObjectInstance)serviceItr.next()).getObjectName(); String engineName = request.getParameter("engineName"); String debugLvlText = request.getParameter("debugLvl"); String defaultHost = request.getParameter("defaultHost"); if (engineName != null) { mBServer.setAttribute(serviceObjName, new Attribute(SetUpServiceAction.NAME_PROP_NAME, engineName)); } if(debugLvlText != null) { Integer debugLvl = new Integer(debugLvlText); mBServer.setAttribute(serviceObjName, new Attribute(SetUpServiceAction.DEBUG_PROP_NAME, debugLvl)); } if(defaultHost != null) { /* if ((" ").equals(defaultHost)) { // no default host value set. // remove this attribute. TBD: FIX ME - if needed. } */ mBServer.setAttribute(serviceObjName, new Attribute(SetUpServiceAction.HOST_PROP_NAME, defaultHost)); } }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/service/ServiceForm.java Index: ServiceForm.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service/ServiceForm.java,v 1.1 2002/01/31 19:35:58 manveen Exp $ * $Revision: 1.1 $ * $Date: 2002/01/31 19:35:58 $ * * ==================================================================== * * 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.service; 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.util.ArrayList; /** * Form bean for the service page. * * @author Manveen Kaur * @version $Revision: 1.1 $ $Date: 2002/01/31 19:35:58 $ */ public final class ServiceForm extends ActionForm { // ----------------------------------------------------- Instance Variables /** * The text for the serviceName. */ private String serviceName = null; /** * The text for the node label. */ private String nodeLabel = null; /** * The text for the engine Name. */ private String engineName = null; /** * The text for the debug level. */ private String debugLvl = "0"; /** * The text for the defaultHost Name. */ private String defaultHost = " "; private ArrayList debugLvlVals = null; private ArrayList hostNameVals = null; // ------------------------------------------------------------- Properties /** * 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 debugVals. */ public ArrayList getDebugLvlVals() { return this.debugLvlVals; } /** * Set the debugVals. */ public void setDebugLvlVals(ArrayList debugLvlVals) { this.debugLvlVals = debugLvlVals; } /** * Return the host name values. */ public ArrayList getHostNameVals() { return this.hostNameVals; } /** * Set the hostName values. */ public void setHostNameVals(ArrayList hostNameVals) { this.hostNameVals = hostNameVals; } /** * Set the engineName. */ public void setEngineName(String engineName) { this.engineName = engineName; } /** * Return the engineName. */ public String getEngineName() { return this.engineName; } /** * 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 Service Name. */ public String getServiceName() { return this.serviceName; } /** * Set the Service Name. */ public void setServiceName(String serviceName) { this.serviceName = serviceName; } /** * Return the default Host. */ public String getDefaultHost() { return this.defaultHost; } /** * Set the default Host. */ public void setDefaultHost(String defaultHost) { this.defaultHost = defaultHost; } // --------------------------------------------------------- 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) { this.serviceName = null; this.engineName = null; this.debugLvl = "0"; this.defaultHost = " "; //this.debugLvlVals = null; //this.hostNameVals = null; } /** * 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"); if (submit != null) { if ((engineName == null) || (engineName.length() < 1)) errors.add("engineName", new ActionError("error.engineName.required")); } return errors; } } 1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service/SetUpServiceAction.java Index: SetUpServiceAction.java =================================================================== /* * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/service/SetUpServiceAction.java,v 1.1 2002/01/31 19:35:58 manveen Exp $ * $Revision: 1.1 $ * $Date: 2002/01/31 19:35:58 $ * * ==================================================================== * * 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 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.service; 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.ObjectInstance; import javax.management.ObjectName; import javax.management.JMException; import org.apache.struts.util.MessageResources; import org.apache.webapp.admin.LabelValueBean; import org.apache.webapp.admin.ApplicationServlet; import org.apache.webapp.admin.TomcatTreeBuilder; /** * Test <code>Action</code> that handles events from the tree control test * page. * * @author Manveen Kaur * @version $Revision: 1.1 $ $Date: 2002/01/31 19:35:58 $ */ public class SetUpServiceAction extends Action { private static MBeanServer mBServer = null; public final static String NAME_PROP_NAME = "name"; public final static String HOST_PROP_NAME = "defaultHost"; public final static String DEBUG_PROP_NAME = "debug"; private ArrayList debugLvlList = null; private ArrayList hostNameList = 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(); // Acquire a reference to the MBeanServer containing our MBeans try { mBServer = ((ApplicationServlet) getServlet()).getServer(); } catch (Throwable t) { throw new ServletException ("Cannot acquire MBeanServer reference", t); } // fill in the form values for display and editing if (form == null) { getServlet().log(" Creating new ServiceForm bean under key " + mapping.getAttribute()); form = new ServiceForm(); if ("request".equals(mapping.getScope())) request.setAttribute(mapping.getAttribute(), form); else session.setAttribute(mapping.getAttribute(), form); } String selectedName = request.getParameter("select"); // label of the node that was clicked on. String nodeLabel = request.getParameter("nodeLabel"); ServiceForm serviceFm = (ServiceForm) 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")); } String serviceName = null; String engineName = null; Integer debug = null; String defaultHost = null; try{ Iterator serviceItr = mBServer.queryMBeans(new ObjectName(selectedName), null).iterator(); ObjectInstance objInstance = (ObjectInstance)serviceItr.next(); ObjectName serviceObjName = (objInstance).getObjectName(); serviceName = (String) mBServer.getAttribute(serviceObjName, NAME_PROP_NAME); // FIX-ME // nodelabel might be null in case of returning from delete screen if (nodeLabel == null) nodeLabel = "Service (" + serviceName + ")"; String search = TomcatTreeBuilder.ENGINE_TYPE + ",service=" + serviceName; Iterator engineItr = mBServer.queryMBeans(new ObjectName(search), null).iterator(); ObjectName engineObjName = ((ObjectInstance)engineItr.next()).getObjectName(); /*set values from engine mBean*/ engineName = (String) mBServer.getAttribute(engineObjName, NAME_PROP_NAME); debug = (Integer) mBServer.getAttribute(engineObjName, DEBUG_PROP_NAME); defaultHost = (String) mBServer.getAttribute(engineObjName, HOST_PROP_NAME); // defaultHost is an optional attribute of Engine, // display blank if this value was not set. if (defaultHost == null) defaultHost =" "; /* Now Extracting all Hostnames configured for this engine */ search = TomcatTreeBuilder.HOST_TYPE + TomcatTreeBuilder.WILDCARD + ",service=" + serviceName; Iterator hostItr = mBServer.queryMBeans(new ObjectName(search), null).iterator(); hostNameList = new ArrayList(); //add a blank entry here for this attribute not set hostNameList.add(new LabelValueBean("(none)", " ")); while(hostItr.hasNext()) { ObjectName hostObjName = ((ObjectInstance)hostItr.next()).getObjectName(); String hostName = (String) mBServer.getAttribute(hostObjName, NAME_PROP_NAME); // add this to the list that will be displayed in // the pulldown menu.. hostNameList.add(new LabelValueBean(hostName, hostName)); } }catch(Throwable t){ t.printStackTrace(System.out); //forward to error page } serviceFm.setNodeLabel(nodeLabel); serviceFm.setServiceName(serviceName); serviceFm.setDefaultHost(defaultHost); serviceFm.setDebugLvl(debug.toString()); serviceFm.setEngineName(engineName); serviceFm.setDebugLvlVals(debugLvlList); serviceFm.setHostNameVals(hostNameList); // Forward back to the test page return (mapping.findForward("Service")); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>