You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by pa...@apache.org on 2001/12/15 00:22:34 UTC
cvs commit: jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin ServiceAction.java ServiceForm.java SetUpServiceAction.java ApplicationResources_en.properties ApplicationResources_es.properties ServerAction.java ServerForm.java TomcatTreeBuilder.java
patrickl 01/12/14 15:22:33
Modified: webapps/admin/WEB-INF struts-config.xml
webapps/admin/WEB-INF/classes/org/apache/webapp/admin
ApplicationResources_en.properties
ApplicationResources_es.properties
ServerAction.java ServerForm.java
TomcatTreeBuilder.java
Added: webapps/admin service.jsp
webapps/admin/WEB-INF/classes/org/apache/webapp/admin
ServiceAction.java ServiceForm.java
SetUpServiceAction.java
Log:
Implementaton of Service screen
Revision Changes Path
1.1 jakarta-tomcat-4.0/webapps/admin/service.jsp
Index: service.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" %>
<html:html locale="true">
<%@ include file="header.jsp" %>
<!-- Body -->
<body bgcolor="white">
<!--Form -->
<html:errors/>
<html:form method="POST" action="/service">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="page-title-row">
<td width="81%">
<div class="page-title-text" align="left">
<bean:message key="service.service"/> (
<bean:write name="serviceForm" property="serviceName"
scope="session"/>
) </div>
</td>
<td width="19%">
<div align="right">
<html:select property="action">
<bean:define id="actionVals" name="serviceForm" property="actionVals"/>
<html:options collection="actionVals"
property="value" labelProperty="label"/>
</html:select>
</div>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td colspan="2" align="right" nowrap>
<html:submit styleClass="button">
<bean:message key="button.save"/>
</html:submit>
<html:reset styleClass="button">
<bean:message key="button.cancel"/>
</html:reset>
</td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td>
<div class="table-title-text">
<bean:message key="service.properties"/>
</div>
</td>
</tr>
</table>
<table class="back-table" border="0" cellspacing="0" cellpadding="1" width="100%">
<tr>
<td>
<table class="front-table" border="0" cellspacing="0" cellpadding="0" width="100%">
<tr class="header-row">
<td width="27%">
<div class="table-header-text" align="left"><bean:message key="service.property"/></div>
</td>
<td width="73%">
<div class="table-header-text" align="left"><bean:message key="service.value"/></div>
</td>
</tr>
<tr height="1">
<td class="line-row" colspan="2"><img src="../images/dot.gif" alt="" width="1" height="1" border="0"></td>
</tr>
<tr>
<td width="27%" valign="top">
<div class="table-label-text"> <bean:message key="service.name"/>:
</div>
</td>
<td valign="bottom" width="73%">
<div class="table-normal-text">
<html:hidden property="serviceName"/>
<bean:write name="serviceForm" property="serviceName"
scope="session"/>
</div>
</td>
</tr></table>
</td>
</tr>
</table>
<br>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td>
<div class="table-title-text">
<bean:message key="service.engine.props"/>
</div>
</td>
</tr>
</table>
<table class="back-table" border="0" cellspacing="0" cellpadding="1" width="100%">
<tr>
<td>
<table class="front-table" border="0" cellspacing="0" cellpadding="0" width="100%">
<tr class="header-row">
<td width="27%">
<div class="table-header-text" align="left"> <bean:message key="service.property"/></div>
</td>
<td width="73%">
<div class="table-header-text" align="left"> <bean:message key="service.value"/></div>
</td>
</tr>
<tr height="1">
<td class="line-row" colspan="2"><img src="../images/dot.gif" alt="" width="1" height="1" border="0"></td>
</tr>
<tr>
<td width="27%" valign="top">
<div class="table-label-text">
<bean:message key="service.name"/>:
</div>
</td>
<td width="73%" valign="bottom">
<div class="table-normal-text">
<html:text property="engineName" size="24" maxlength="24"/>
</div>
</td>
</tr>
<tr height="1">
<td class="line-row" colspan="2"><img src="../images/dot.gif" alt="" width="1" height="1" border="0"></td>
</tr>
<tr>
<td width="27%" valign="top">
<div class="table-label-text">
<bean:message key="server.debuglevel"/>:
</div>
</td>
<td valign="bottom" width="73%">
<div class="table-normal-text">
<html:select property="debugLvl">
<bean:define id="debugLvlVals" name="serviceForm" property="debugLvlVals"/>
<html:options collection="debugLvlVals" property="value"
labelProperty="label"/>
</html:select>
</div>
</td>
</tr>
<tr height="1">
<td class="line-row" colspan="2"><img src="../images/dot.gif" alt="" width="1" height="1" border="0"></td>
</tr>
<tr>
<td width="27%" valign="top">
<div class="table-label-text">
<bean:message key="service.defaulthostname"/>:
</div>
</td>
<td width="73%" valign="bottom">
<div class="table-normal-text">
<html:select property="defaultHost">
<bean:define id="hostNameVals"
name="serviceForm" property="hostNameVals"/>
<html:options collection="hostNameVals" property="value"
labelProperty="label"/>
</html:select>
</div>
</td>
</tr></table>
</td>
</tr>
</table>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td colspan="2" align="right" nowrap>
<html:submit styleClass="button">
<bean:message key="button.save"/>
</html:submit>
<html:reset styleClass="button">
<bean:message key="button.cancel"/>
</html:reset>
</td>
</tr>
</table>
</html:form>
<!-- Standard Footer -->
<%@ include file="footer.jsp" %>
</body>
</html:html>
1.11 +27 -1 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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- struts-config.xml 2001/12/06 23:49:19 1.10
+++ struts-config.xml 2001/12/14 23:22:33 1.11
@@ -19,6 +19,10 @@
<form-bean name="serverForm"
type="org.apache.webapp.admin.ServerForm"/>
+ <!-- Service form bean -->
+ <form-bean name="serviceForm"
+ type="org.apache.webapp.admin.ServiceForm"/>
+
<!-- Set Locale form bean -->
<form-bean name="setLocaleForm"
type="org.apache.webapp.admin.SetLocaleForm"/>
@@ -50,6 +54,10 @@
path="/server.jsp"
redirect="false"/>
+ <forward name="Service"
+ path="/service.jsp"
+ redirect="false"/>
+
<forward name="Save Successful"
path="/saved.jsp"
redirect="false"/>
@@ -77,7 +85,7 @@
redirect="true"/>
</action>
- <!-- Set up Tree datastructure -->
+ <!-- Set up Server -->
<action path="/setUpServer"
type="org.apache.webapp.admin.SetUpServerAction"
name="serverForm"
@@ -87,6 +95,16 @@
redirect="true"/>
</action>
+ <!-- Set up Service datastructure -->
+ <action path="/setUpService"
+ type="org.apache.webapp.admin.SetUpServiceAction"
+ name="serviceForm"
+ scope="session">
+ <forward name="SetUpService"
+ path="/service.jsp"
+ redirect="true"/>
+ </action>
+
<!-- Log out of the application -->
<action path="/logOut"
type="org.apache.webapp.admin.LogOutAction">
@@ -101,6 +119,14 @@
name="serverForm"
scope="session"
input="/server.jsp">
+ </action>
+
+ <!-- Process a user server change -->
+ <action path="/service"
+ type="org.apache.webapp.admin.ServiceAction"
+ name="serviceForm"
+ scope="session"
+ input="/service.jsp">
</action>
<!-- Process a set-locale action -->
1.7 +8 -0 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ApplicationResources_en.properties 2001/12/11 22:54:12 1.6
+++ ApplicationResources_en.properties 2001/12/14 23:22:33 1.7
@@ -30,3 +30,11 @@
error.shutdownText.length=<li>Shutdown Text must be atleast 6 characters</li>
error.portNumber.format=<li>PortNumber not a valid integer!</li>
error.portNumber.range=<li>PortNumber seems out of range. Valid range is 1-65535. </li>
+error.engineName.required=<li>Engine name is required</li>
+service.service=Service
+service.name=Name
+service.engine.props=Engine properties
+service.defaulthostname=Default Hostname
+service.properties=Service Properties
+service.property=Property
+service.value=Value
1.9 +8 -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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- ApplicationResources_es.properties 2001/12/12 18:25:43 1.8
+++ ApplicationResources_es.properties 2001/12/14 23:22:33 1.9
@@ -30,3 +30,11 @@
error.shutdownText.length=<li>El texto de la para Detener debe ser de al menos 6 caracteres!</li>
error.portNumber.format=<li>El numero de puerto es un entero no valido! </li>
error.portNumber.range=<li>El numero de puerto esta fuera del rango. El rango valido es 1-65535.</li>
+error.engineName.required=<li>Se requiere el nombre del motor</li>
+service.service=Mantienen
+service.name=Nombre
+service.engine.props=Caracteristicas del motor
+service.defaulthostname=Hostname del valor por defecto
+service.properties=Mantenga Las Caracteristicas
+service.property=Caracteristica
+service.value=Valor
1.3 +4 -6 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ServerAction.java
Index: ServerAction.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ServerAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ServerAction.java 2001/12/11 22:54:12 1.2
+++ ServerAction.java 2001/12/14 23:22:33 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ServerAction.java,v 1.2 2001/12/11 22:54:12 patrickl Exp $
- * $Revision: 1.2 $
- * $Date: 2001/12/11 22:54:12 $
+ * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ServerAction.java,v 1.3 2001/12/14 23:22:33 patrickl Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/12/14 23:22:33 $
*
* ====================================================================
*
@@ -90,7 +90,7 @@
*
* @author Jazmin Jonson
* @author Manveen Kaur
- * @version $Revision: 1.2 $ $Date: 2001/12/11 22:54:12 $
+ * @version $Revision: 1.3 $ $Date: 2001/12/14 23:22:33 $
*/
public final class ServerAction extends Action {
@@ -120,8 +120,6 @@
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
-
- System.out.println(mapping.getInput());
try{
1.3 +5 -6 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ServerForm.java
Index: ServerForm.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ServerForm.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ServerForm.java 2001/12/11 22:54:12 1.2
+++ ServerForm.java 2001/12/14 23:22:33 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ServerForm.java,v 1.2 2001/12/11 22:54:12 patrickl Exp $
- * $Revision: 1.2 $
- * $Date: 2001/12/11 22:54:12 $
+ * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ServerForm.java,v 1.3 2001/12/14 23:22:33 patrickl Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/12/14 23:22:33 $
*
* ====================================================================
*
@@ -59,7 +59,6 @@
*
*/
-
package org.apache.webapp.admin;
@@ -75,7 +74,7 @@
* Form bean for the server form page.
* @author Patrick Luby
* @author Manveen Kaur
- * @version $Revision: 1.2 $ $Date: 2001/12/11 22:54:12 $
+ * @version $Revision: 1.3 $ $Date: 2001/12/14 23:22:33 $
*/
public final class ServerForm extends ActionForm {
@@ -134,7 +133,7 @@
}
/**
- * Set the portNumberText.
+ * Set the ActionVals.
*/
public void setActionVals(ArrayList actionVals) {
1.3 +96 -94 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TomcatTreeBuilder.java 2001/12/06 22:57:54 1.2
+++ TomcatTreeBuilder.java 2001/12/14 23:22:33 1.3
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v 1.2 2001/12/06 22:57:54 patrickl Exp $
- * $Revision: 1.2 $
- * $Date: 2001/12/06 22:57:54 $
+ * $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/TomcatTreeBuilder.java,v 1.3 2001/12/14 23:22:33 patrickl Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/12/14 23:22:33 $
*
* ====================================================================
*
@@ -84,34 +84,36 @@
import javax.management.JMException;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanInfo;
-
+
/**
- * <p> Implementation of TreeBuilder interface for Tomcat Tree Controller
+ * <p> Implementation of TreeBuilder interface for Tomcat Tree Controller
* to build plugin components into the tree
*
* @author Jazmin Jonson
- * @version
+ * @author Manveen Kaur
+ * @version
*/
public class TomcatTreeBuilder implements TreeBuilder{
-
+
// This SERVER_LABEL needs to be localized
private final static String SERVER_LABEL = "Tomcat Server";
-
+
public final static String SERVER_TYPE = "Catalina:type=Server";
- private final static String SERVICE_TYPE = "Catalina:type=Service";
- private final static String ENGINE_TYPE = "Engine";
+ public final static String SERVICE_TYPE = "Catalina:type=Service";
+ public final static String ENGINE_TYPE = "Catalina:type=Engine";
private final static String CONNECTOR_TYPE = "Catalina:type=Connector";
+ public final static String HOST_TYPE = "Catalina:type=Host";
public final static String WILDCARD = ",*";
-
+
private static MBeanServer mBServer = null;
-
+
public void buildTree(TreeControl treeControl,
- ApplicationServlet servlet,
- HttpServletRequest request) {
-
+ ApplicationServlet servlet,
+ HttpServletRequest request) {
+
try {
mBServer = servlet.getServer();
TreeControlNode root = treeControl.getRoot();
@@ -120,113 +122,113 @@
getServices(server);
}catch(Throwable t){
t.printStackTrace(System.out);
- }
+ }
}
-
- public TreeControlNode getServer()
- throws JMException, ServletException {
-
- Iterator serverItr =
- mBServer.queryMBeans(new ObjectName(SERVER_TYPE + WILDCARD),
- null).iterator();
- String serverObjName =
- (((ObjectInstance)serverItr.next()).getObjectName()).toString();
-
+
+ public TreeControlNode getServer()
+ throws JMException, ServletException {
+
+ Iterator serverItr =
+ mBServer.queryMBeans(new ObjectName(SERVER_TYPE + WILDCARD),
+ null).iterator();
+ String serverObjName =
+ (((ObjectInstance)serverItr.next()).getObjectName()).toString();
+
// HACK to take into account special characters like = and &
// in the node name, could remove this code if encode URL
// and later request.getParameter() could deal with = and &
// character in parameter values. Decoding name not needed
// because Tomcat does this automatically
-
- String encodedServerName = URLEncoder.encode(serverObjName);
+
+ String encodedServerName = URLEncoder.encode(serverObjName);
TreeControlNode serverNode =
- new TreeControlNode(serverObjName,
- "folder_16_pad.gif", SERVER_LABEL,
- "setUpServer.do?select=" + encodedServerName,
- "content", true);
-
+ new TreeControlNode(serverObjName,
+ "folder_16_pad.gif", SERVER_LABEL,
+ "setUpServer.do?select=" + encodedServerName,
+ "content", true);
+
return serverNode;
-
+
}
-
-
- public void getServices(TreeControlNode serverNode)
- throws JMException, ServletException {
-
- Iterator serviceItr =
- mBServer.queryMBeans(new ObjectName(SERVICE_TYPE + WILDCARD) ,
- null).iterator();
-
+
+
+ public void getServices(TreeControlNode serverNode)
+ throws JMException, ServletException {
+
+ Iterator serviceItr =
+ mBServer.queryMBeans(new ObjectName(SERVICE_TYPE + WILDCARD) ,
+ null).iterator();
+
String encodedServiceName;
-
+
while(serviceItr.hasNext()){
ObjectInstance service = (ObjectInstance)serviceItr.next();
-
- String serviceName =
- (String)mBServer.getAttribute(service.getObjectName(),"name");
-
+
+ String serviceName =
+ (String)mBServer.getAttribute(service.getObjectName(),"name");
+
// HACK to take into account special characters like = and &
// in the node name, could remove this code if encode URL
// and later request.getParameter() could deal with = and &
// character in parameter values. Decoding name not needed
- // because Tomcat does this automatically
-
+ // because Tomcat does this automatically
+
encodedServiceName = URLEncoder.encode(service.getObjectName().toString());
-
- TreeControlNode serviceNode =
- new TreeControlNode(service.getObjectName().toString(),
- "folder_16_pad.gif",
- "Service(" + serviceName + ")",
- "treeControlTest.do?select=" + encodedServiceName,
- null, true);
-
+
+ TreeControlNode serviceNode =
+ new TreeControlNode(service.getObjectName().toString(),
+ "folder_16_pad.gif",
+ "Service(" + serviceName + ")",
+ "setUpService.do?select=" + encodedServiceName,
+ "content", true);
+
serverNode.addChild(serviceNode);
-
+
getConnectors(serviceNode, serviceName);
}
}
-
- public void getConnectors(TreeControlNode serviceNode,
- String serviceName)
-
- throws JMException{
-
-
- Iterator ConnectorItr =
- (mBServer.queryMBeans(new ObjectName(CONNECTOR_TYPE + WILDCARD +
- ",service=" + serviceName),
- null)).iterator();
-
+
+ public void getConnectors(TreeControlNode serviceNode,
+ String serviceName)
+
+ throws JMException{
+
+
+ Iterator ConnectorItr =
+ (mBServer.queryMBeans(new ObjectName(CONNECTOR_TYPE + WILDCARD +
+ ",service=" + serviceName),
+ null)).iterator();
+
TreeControlNode connectorNode = null;
String encodedConnectorName;
-
- while(ConnectorItr.hasNext()){
-
+
+ while(ConnectorItr.hasNext()){
+
ObjectInstance connectorObj = (ObjectInstance)ConnectorItr.next();
-
- String connectorName =
- (String)mBServer.getAttribute(connectorObj.getObjectName(),
- "scheme");
-
+
+ String connectorName =
+ (String)mBServer.getAttribute(connectorObj.getObjectName(),
+ "scheme");
+
// HACK to take into account special characters like = and &
// in the node name, could remove this code if encode URL
// and later request.getParameter() could deal with = and &
// character in parameter values. Decoding name not needed
- // because Tomcat does this automatically
-
+ // because Tomcat does this automatically
+
encodedConnectorName = URLEncoder.encode(connectorObj.getObjectName().toString());
-
- connectorNode =
- new TreeControlNode(connectorObj.getObjectName().toString(),
- "folder_16_pad.gif",
- "Connector(" + connectorName + ")",
- "treeControlTest.do?select=" +
- encodedConnectorName,
- null, true);
-
+
+ connectorNode =
+ new TreeControlNode(connectorObj.getObjectName().toString(),
+ "folder_16_pad.gif",
+ "Connector(" + connectorName + ")",
+ "treeControlTest.do?select=" +
+ encodedConnectorName,
+ null, true);
+
serviceNode.addChild(connectorNode);
}
-
- }
-
-}
+
+ }
+
+}
1.1 jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ServiceAction.java
Index: ServiceAction.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ServiceAction.java,v 1.1 2001/12/14 23:22:33 patrickl Exp $
* $Revision: 1.1 $
* $Date: 2001/12/14 23:22:33 $
*
* ====================================================================
*
* 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 apache@apache.org.
*
* 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.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 Service.
*
* @author Manveen Kaur
* @version $Revision: 1.1 $ $Date: 2001/12/14 23:22:33 $
*/
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/ServiceForm.java
Index: ServiceForm.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/ServiceForm.java,v 1.1 2001/12/14 23:22:33 patrickl Exp $
* $Revision: 1.1 $
* $Date: 2001/12/14 23:22:33 $
*
* ====================================================================
*
* 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 apache@apache.org.
*
* 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.util.ArrayList;
/**
* Form bean for the service page.
*
* @author Manveen Kaur
* @version $Revision: 1.1 $ $Date: 2001/12/14 23:22:33 $
*/
public final class ServiceForm extends ActionForm {
// ----------------------------------------------------- Instance Variables
/**
* The text for the serviceName.
*/
private String serviceName = null;
/**
* The text for the engine Name.
*/
private String engineName = null;
/**
* The text for the debug level.
*/
private String debugLvl = "0";
/**
* The action chosen.
*/
private String action = null;
/**
* The text for the defaultHost Name.
*/
private String defaultHost = " ";
private ArrayList debugLvlVals = null;
private ArrayList hostNameVals = null;
private ArrayList actionVals = null;
// ------------------------------------------------------------- Properties
/**
* 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;
}
/**
* Return the ActionVals.
*/
public ArrayList getActionVals() {
return this.actionVals;
}
/**
* Set the ActionVals.
*/
public void setActionVals(ArrayList actionVals) {
this.actionVals = actionVals;
}
/**
* Return the Action.
*/
public String getAction() {
return this.action;
}
/**
* Set the action.
*/
public void setAction(String action) {
this.action = action;
}
/**
* 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.action = null;
//this.debugLvlVals = null;
//this.hostNameVals = null;
//this.actionVals = 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/SetUpServiceAction.java
Index: SetUpServiceAction.java
===================================================================
/*
* $Header: /home/cvs/jakarta-tomcat-4.0/webapps/admin/WEB-INF/classes/org/apache/webapp/admin/SetUpServiceAction.java,v 1.1 2001/12/14 23:22:33 patrickl Exp $
* $Revision: 1.1 $
* $Date: 2001/12/14 23:22:33 $
*
* ====================================================================
*
* 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 apache@apache.org.
*
* 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.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;
/**
* Test <code>Action</code> that handles events from the tree control test
* page.
*
* @author Manveen Kaur
* @version $Revision: 1.1 $ $Date: 2001/12/14 23:22:33 $
*/
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";
// list of available actions on this service.
private ArrayList actionList = null;
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 {
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
request.getSession().setAttribute(mapping.getAttribute(), form);
}
String selectedName = request.getParameter("select");
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"));
}
if(actionList == null) {
actionList = new ArrayList();
// You can get this from the Mbean
actionList.add(new LabelValueBean("Available Actions",
"Available Actions"));
actionList.add(new LabelValueBean("Create New Access Logger...",
"Create New Access Logger..."));
actionList.add(new LabelValueBean("Delete Access Logger...",
"Delete Access Logger..."));
actionList.add(new LabelValueBean("Create New Connector...",
"Create New Connector..."));
actionList.add(new LabelValueBean("Delete Connectors...",
"Delete Connectors..."));
actionList.add(new LabelValueBean("Create New Host...",
"Create New Host..."));
actionList.add(new LabelValueBean("Delete Hosts... ",
"Delete Hosts... "));
actionList.add(new LabelValueBean("Create New Logger...",
"Create New Logger..."));
actionList.add(new LabelValueBean("Delete Logger...",
"Delete Logger..."));
actionList.add(new LabelValueBean("Create New Request Filter...",
"Create New Request Filter..."));
actionList.add(new LabelValueBean("Delete Request Filters...",
"Delete Request Filters..."));
actionList.add(new LabelValueBean("Create New User Realm...",
"Create New User Realm..."));
actionList.add(new LabelValueBean("Delete User Realm...",
"Delete User Realm..."));
actionList.add(new LabelValueBean("Create New Valve...",
"Create New Valve..."));
actionList.add(new LabelValueBean("Delete Valves...",
"Delete Valves..."));
actionList.add(new LabelValueBean("Delete This Service...",
"Delete This Service..."));
// I18N these.
}
String serviceName = null;
String engineName = null;
Integer debug = null;
String defaultHost = null;
try{
if(mBServer == null) {
ApplicationServlet servlet = (ApplicationServlet)getServlet();
mBServer = servlet.getServer();
}
Iterator serviceItr =
mBServer.queryMBeans(new
ObjectName(selectedName), null).iterator();
ObjectInstance objInstance = (ObjectInstance)serviceItr.next();
ObjectName serviceObjName = (objInstance).getObjectName();
/*
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());
}
*/
serviceName = (String) mBServer.getAttribute(serviceObjName,
NAME_PROP_NAME);
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.setServiceName(serviceName);
serviceFm.setDefaultHost(defaultHost);
serviceFm.setDebugLvl(debug.toString());
serviceFm.setEngineName(engineName);
serviceFm.setDebugLvlVals(debugLvlList);
serviceFm.setActionVals(actionList);
serviceFm.setHostNameVals(hostNameList);
// Forward back to the test page
return (mapping.findForward("Service"));
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>