You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2005/03/11 23:39:26 UTC
cvs commit: jakarta-tomcat-catalina/webapps/host-manager/WEB-INF web.xml
remm 2005/03/11 14:39:26
Modified: . build.xml
webapps build.xml
resources logging.properties
webapps/manager/WEB-INF/classes/org/apache/catalina/manager
Constants.java
Added: webapps/host-manager host-manager.xml build.xml manager.xml
webapps/host-manager/WEB-INF/classes/org/apache/catalina/hostmanager
HTMLHostManagerServlet.java Constants.java
HostManagerServlet.java LocalStrings.properties
webapps/host-manager/WEB-INF web.xml
Log:
- Add simple host manager webapp.
Revision Changes Path
1.1 jakarta-tomcat-catalina/webapps/host-manager/host-manager.xml
Index: host-manager.xml
===================================================================
<!--
Context configuration file for the Tomcat Host Manager Web App
$Id: host-manager.xml,v 1.1 2005/03/11 22:39:26 remm Exp $
-->
<Context docBase="${catalina.home}/server/webapps/host-manager"
privileged="true" antiResourceLocking="false" antiJARLocking="false">
</Context>
1.1 jakarta-tomcat-catalina/webapps/host-manager/build.xml
Index: build.xml
===================================================================
<project name="host-manager" default="build-main" basedir=".">
<!-- ===================== Initialize Property Values =================== -->
<!-- See "build.properties.sample" in the top level directory for all -->
<!-- property values you must customize for successful building!!! -->
<property file="build.properties"/>
<property file="../build.properties"/>
<property file="../../build.properties"/>
<property file="${user.home}/build.properties"/>
<property name="build.compiler" value="modern"/>
<property name="webapps.build" value="../build"/>
<property name="webapps.dist" value="../dist"/>
<property name="webapp.name" value="host-manager"/>
<!-- Dependent JARs and files -->
<property name="servlet-api.jar" value="${api.home}/jsr154/dist/lib/servlet-api.jar"/>
<property name="jsp-api.jar" value="${api.home}/jsr152/dist/lib/jsp-api.jar"/>
<!-- Construct Admin classpath -->
<path id="host-manager.classpath">
<pathelement location="${catalina.deploy}/classes"/>
<pathelement location="${commons-fileupload.jar}"/>
<pathelement location="${commons-modeler.jar}"/>
<pathelement location="${jmx.jar}"/>
<pathelement location="${servlet-api.jar}"/>
<pathelement location="${jsp-api.jar}"/>
</path>
<!-- ======================== BUILD: Copy JARs ========================== -->
<!-- =================== BUILD: Create Directories ====================== -->
<target name="build-prepare">
<mkdir dir="${webapps.build}"/>
<mkdir dir="${webapps.build}/${webapp.name}"/>
<mkdir dir="${webapps.build}/${webapp.name}/images"/>
<mkdir dir="${webapps.build}/${webapp.name}/WEB-INF"/>
<mkdir dir="${webapps.build}/${webapp.name}/WEB-INF/classes"/>
</target>
<!-- ================ BUILD: Copy Static Files ========================== -->
<target name="build-static" depends="build-prepare">
<copy todir="${webapps.build}/${webapp.name}">
<fileset dir=".">
<exclude name="build.*"/>
</fileset>
</copy>
</target>
<!-- ================= BUILD: Compile Server Components ================= -->
<target name="build-main" depends="build-static">
<!-- Top Level Directory -->
<style basedir="../docs"
destdir="${webapps.build}/${webapp.name}"
extension=".html"
style="tomcat-docs.xsl"
excludes="build.xml project.xml"
includes="host-manager-howto.xml,host-html-manager-howto.xml">
<param name="relative-path" expression="."/>
<param name="project-menu" expression="nomenu"/>
<param name="standalone" expression="standalone"/>
</style>
<!-- Images Subdirectory -->
<copy todir="${webapps.build}/${webapp.name}/images">
<fileset dir="../docs/images">
<exclude name="printer.gif"/>
</fileset>
</copy>
<javac srcdir="WEB-INF/classes"
destdir="${webapps.build}/${webapp.name}/WEB-INF/classes"
debug="${compile.debug}" deprecation="${compile.deprecation}"
optimize="${compile.optimize}"
excludes="**/CVS/**">
<classpath refid="host-manager.classpath" />
</javac>
</target>
<!-- ==================== BUILD: Rebuild Everything ===================== -->
<target name="all" depends="build-clean,build-main"
description="Clean and build host manager webapp"/>
<!-- ======================= BUILD: Clean Directory ===================== -->
<target name="build-clean">
<delete dir="${webapps.build}/${webapp.name}"/>
</target>
<!-- ======================= DIST: Create Directories =================== -->
<target name="dist-prepare">
<mkdir dir="${webapps.dist}"/>
</target>
<!-- ======================= DIST: Create Distribution Files ============ -->
<target name="dist" depends="build-main,dist-prepare"
description="Create host manager webapp binary distribution">
<jar jarfile="${webapps.dist}/${webapp.name}.war"
basedir="${webapps.build}/${webapp.name}" includes="**"/>
</target>
<!-- ======================= DIST: Clean Directory ====================== -->
<target name="dist-clean">
<deltree dir="${dist.dir}/${webapp.name}"/>
</target>
<!-- ====================== Convenient Synonyms ========================= -->
<target name="clean" depends="build-clean,dist-clean"
description="Clean build and dist directories"/>
</project>
1.1 jakarta-tomcat-catalina/webapps/host-manager/manager.xml
Index: manager.xml
===================================================================
<!--
Context configuration file for the Tomcat Manager Web App
$Id: manager.xml,v 1.1 2005/03/11 22:39:26 remm Exp $
-->
<Context docBase="${catalina.home}/server/webapps/manager"
privileged="true" antiResourceLocking="false" antiJARLocking="false">
</Context>
1.227 +20 -1 jakarta-tomcat-5/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-tomcat-5/build.xml,v
retrieving revision 1.226
retrieving revision 1.227
diff -u -r1.226 -r1.227
--- build.xml 3 Mar 2005 15:13:39 -0000 1.226
+++ build.xml 11 Mar 2005 22:39:26 -0000 1.227
@@ -12,7 +12,7 @@
<!-- Project Properties -->
<property name="name" value="Apache Tomcat" />
- <property name="year" value="2004" />
+ <property name="year" value="2005" />
<property name="version.major" value="5" />
<property name="version.minor" value="5" />
<property name="version.build" value="0" />
@@ -777,6 +777,14 @@
<property name="flags.hide" value="true" />
</ant>
+ <ant dir="${catalina.home}/webapps/host-manager" target="build-main">
+ <property name="webapps.build" value="${tomcat.build}/server/webapps" />
+ <property name="classes.dir" value="${tomcat.build}/classes" />
+ <property name="tomcat-util.jar" value="${tomcat.build}/server/lib/tomcat-util.jar"/>
+ <property name="catalina.deploy" value="${tomcat.build}" />
+ <property name="flags.hide" value="true" />
+ </ant>
+
<ant dir="${catalina.home}/webapps/balancer" target="build-main">
<property name="webapps.build" value="${tomcat.build}/webapps" />
<property name="classes.dir" value="${tomcat.build}/classes" />
@@ -829,6 +837,14 @@
<include name="**/*.properties" />
</fileset>
</jar>
+ <mkdir dir="${tomcat.build}/server/webapps/host-manager/WEB-INF/lib" />
+ <jar jarfile="${tomcat.build}/server/webapps/host-manager/WEB-INF/lib/catalina-host-manager.jar"
+ index="true">
+ <fileset dir="${tomcat.build}/server/webapps/host-manager/WEB-INF/classes">
+ <include name="**/*.class" />
+ <include name="**/*.properties" />
+ </fileset>
+ </jar>
<mkdir dir="${tomcat.build}/webapps/balancer/WEB-INF/lib" />
<jar jarfile="${tomcat.build}/webapps/balancer/WEB-INF/lib/catalina-balancer.jar"
index="true">
@@ -849,6 +865,8 @@
<!-- Add XML declarations for admin, manager and balancer -->
<copy file="${tomcat.build}/server/webapps/manager/manager.xml"
todir="${tomcat.build}/conf/Catalina/localhost" />
+ <copy file="${tomcat.build}/server/webapps/host-manager/host-manager.xml"
+ todir="${tomcat.build}/conf/Catalina/localhost" />
<copy file="${tomcat.build}/server/webapps/admin/admin.xml"
todir="${tomcat.build}/conf/Catalina/localhost" />
@@ -1258,6 +1276,7 @@
<exclude name="admin/WEB-INF/classes/**" />
<exclude name="admin/WEB-INF/src/**" />
<exclude name="manager/WEB-INF/classes/**" />
+ <exclude name="host-manager/WEB-INF/classes/**" />
</fileset>
</copy>
<!--
1.1 jakarta-tomcat-catalina/webapps/host-manager/WEB-INF/classes/org/apache/catalina/hostmanager/HTMLHostManagerServlet.java
Index: HTMLHostManagerServlet.java
===================================================================
/*
* Copyright 1999,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.catalina.hostmanager;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.MessageFormat;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.Container;
import org.apache.catalina.Host;
import org.apache.catalina.util.ServerInfo;
/**
* Servlet that enables remote management of the virtual hosts deployed
* on the server. Normally, this functionality will be protected by a security
* constraint in the web application deployment descriptor. However,
* this requirement can be relaxed during testing.
* <p>
* The difference between the <code>HostManagerServlet</code> and this
* Servlet is that this Servlet prints out a HTML interface which
* makes it easier to administrate.
* <p>
* However if you use a software that parses the output of
* <code>HostManagerServlet</code you won't be able to upgrade
* to this Servlet since the output are not in the
* same format as from <code>HostManagerServlet</code>
*
* @author Bip Thelin
* @author Malcolm Edgar
* @author Glenn L. Nielsen
* @version $Revision: 1.1 $, $Date: 2005/03/11 22:39:26 $
* @see ManagerServlet
*/
public final class HTMLHostManagerServlet extends HostManagerServlet {
// --------------------------------------------------------- Public Methods
/**
* Process a GET request for the specified resource.
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet-specified error occurs
*/
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Identify the request parameters that we need
String command = request.getPathInfo();
String name = request.getParameter("name");
String aliases = request.getParameter("aliases");
String appBase = request.getParameter("appBase");
boolean manager = true;
if ((request.getParameter("manager") != null)
&& (request.getParameter("manager").equals("false"))) {
manager = false;
}
// Prepare our output writer to generate the response message
response.setContentType("text/html; charset=" + Constants.CHARSET);
String message = "";
// Process the requested command
if (command == null) {
} else if (command.equals("/add")) {
message = add(name, aliases, appBase, manager);
} else if (command.equals("/remove")) {
message = remove(name);
} else if (command.equals("/list")) {
} else if (command.equals("/start")) {
message = start(name);
} else if (command.equals("/stop")) {
message = stop(name);
} else {
message =
sm.getString("hostManagerServlet.unknownCommand", command);
}
list(request, response, message);
}
/**
* Add a host using the specified parameters.
*
* @param name host name
* @param aliases comma separated alias list
* @param appBase application base for the host
* @param manager should the manager webapp be deployed to the new host ?
*/
protected String add(String name, String aliases, String appBase,
boolean manager) {
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
super.add(printWriter, name, aliases, appBase, manager);
return stringWriter.toString();
}
/**
* Remove the specified host.
*
* @param writer Writer to render results to
* @param name host name
*/
protected String remove(String name) {
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
super.remove(printWriter, name);
return stringWriter.toString();
}
/**
* Start the host with the specified name.
*
* @param name Host name
*/
protected String start(String name) {
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
super.start(printWriter, name);
return stringWriter.toString();
}
/**
* Stop the host with the specified name.
*
* @param name Host name
*/
protected String stop(String name) {
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
super.stop(printWriter, name);
return stringWriter.toString();
}
/**
* Render a HTML list of the currently active Contexts in our virtual host,
* and memory and server status information.
*
* @param request The request
* @param response The response
* @param message a message to display
*/
public void list(HttpServletRequest request,
HttpServletResponse response,
String message) throws IOException {
PrintWriter writer = response.getWriter();
// HTML Header Section
writer.print(Constants.HTML_HEADER_SECTION);
// Body Header Section
Object[] args = new Object[2];
args[0] = request.getContextPath();
args[1] = sm.getString("htmlHostManagerServlet.title");
writer.print(MessageFormat.format
(Constants.BODY_HEADER_SECTION, args));
// Message Section
args = new Object[3];
args[0] = sm.getString("htmlHostManagerServlet.messageLabel");
args[1] = (message == null || message.length() == 0) ? "OK" : message;
writer.print(MessageFormat.format(Constants.MESSAGE_SECTION, args));
// Manager Section
args = new Object[9];
args[0] = sm.getString("htmlHostManagerServlet.manager");
args[1] = response.encodeURL(request.getContextPath() + "/html/list");
args[2] = sm.getString("htmlHostManagerServlet.list");
args[3] = response.encodeURL
(request.getContextPath() + "/" +
sm.getString("htmlHostManagerServlet.helpHtmlManagerFile"));
args[4] = sm.getString("htmlHostManagerServlet.helpHtmlManager");
args[5] = response.encodeURL
(request.getContextPath() + "/" +
sm.getString("htmlHostManagerServlet.helpManagerFile"));
args[6] = sm.getString("htmlHostManagerServlet.helpManager");
args[7] = response.encodeURL("/manager/status");
args[8] = sm.getString("statusServlet.title");
writer.print(MessageFormat.format(Constants.MANAGER_SECTION, args));
// Hosts Header Section
args = new Object[3];
args[0] = sm.getString("htmlHostManagerServlet.hostName");
args[1] = sm.getString("htmlHostManagerServlet.hostAliases");
args[2] = sm.getString("htmlHostManagerServlet.hostTasks");
writer.print(MessageFormat.format(HOSTS_HEADER_SECTION, args));
// Hosts Row Section
// Create sorted map of host names.
Container[] children = engine.findChildren();
String hostNames[] = new String[children.length];
for (int i = 0; i < children.length; i++)
hostNames[i] = children[i].getName();
TreeMap sortedHostNamesMap = new TreeMap();
for (int i = 0; i < hostNames.length; i++) {
String displayPath = hostNames[i];
sortedHostNamesMap.put(displayPath, hostNames[i]);
}
String hostsStart = sm.getString("htmlHostManagerServlet.hostsStart");
String hostsStop = sm.getString("htmlHostManagerServlet.hostsStop");
String hostsRemove = sm.getString("htmlHostManagerServlet.hostsRemove");
Iterator iterator = sortedHostNamesMap.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry) iterator.next();
String hostName = (String) entry.getKey();
Host host = (Host) engine.findChild(hostName);
if (host != null ) {
args = new Object[2];
args[0] = hostName;
String[] aliases = host.findAliases();
StringBuffer buf = new StringBuffer();
if (aliases.length > 0) {
buf.append(aliases[0]);
for (int j = 1; j < aliases.length; j++) {
buf.append(", ").append(aliases[j]);
}
}
args[1] = buf.toString();
writer.print
(MessageFormat.format(HOSTS_ROW_DETAILS_SECTION, args));
args = new Object[6];
args[0] = response.encodeURL
(request.getContextPath() +
"/html/start?name=" + hostName);
args[1] = hostsStart;
args[2] = response.encodeURL
(request.getContextPath() +
"/html/stop?name=" + hostName);
args[3] = hostsStop;
args[4] = response.encodeURL
(request.getContextPath() +
"/html/remove?name=" + hostName);
args[5] = hostsRemove;
if (host == this.host) {
writer.print(MessageFormat.format(
MANAGER_HOST_ROW_BUTTON_SECTION, args));
} else {
writer.print(MessageFormat.format(
HOSTS_ROW_BUTTON_SECTION, args));
}
}
}
// Add Section
args = new Object[10];
args[0] = sm.getString("htmlHostManagerServlet.addTitle");
args[1] = sm.getString("htmlHostManagerServlet.addHost");
args[2] = response.encodeURL(request.getContextPath() + "/html/add");
args[3] = sm.getString("htmlHostManagerServlet.addName");
args[4] = sm.getString("htmlHostManagerServlet.addAliases");
args[5] = sm.getString("htmlHostManagerServlet.addAppBase");
args[6] = sm.getString("htmlHostManagerServlet.addManager");
args[7] = sm.getString("htmlHostManagerServlet.addManagerTrue");
args[8] = sm.getString("htmlHostManagerServlet.addManagerFalse");
args[9] = sm.getString("htmlHostManagerServlet.addButton");
writer.print(MessageFormat.format(ADD_SECTION, args));
// Server Header Section
args = new Object[7];
args[0] = sm.getString("htmlHostManagerServlet.serverTitle");
args[1] = sm.getString("htmlHostManagerServlet.serverVersion");
args[2] = sm.getString("htmlHostManagerServlet.serverJVMVersion");
args[3] = sm.getString("htmlHostManagerServlet.serverJVMVendor");
args[4] = sm.getString("htmlHostManagerServlet.serverOSName");
args[5] = sm.getString("htmlHostManagerServlet.serverOSVersion");
args[6] = sm.getString("htmlHostManagerServlet.serverOSArch");
writer.print(MessageFormat.format
(Constants.SERVER_HEADER_SECTION, args));
// Server Row Section
args = new Object[6];
args[0] = ServerInfo.getServerInfo();
args[1] = System.getProperty("java.runtime.version");
args[2] = System.getProperty("java.vm.vendor");
args[3] = System.getProperty("os.name");
args[4] = System.getProperty("os.version");
args[5] = System.getProperty("os.arch");
writer.print(MessageFormat.format(Constants.SERVER_ROW_SECTION, args));
// HTML Tail Section
writer.print(Constants.HTML_TAIL_SECTION);
// Finish up the response
writer.flush();
writer.close();
}
// ------------------------------------------------------ Private Constants
// These HTML sections are broken in relatively small sections, because of
// limited number of subsitutions MessageFormat can process
// (maximium of 10).
private static final String HOSTS_HEADER_SECTION =
"<table border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n" +
"<tr>\n" +
" <td colspan=\"5\" class=\"title\">{0}</td>\n" +
"</tr>\n" +
"<tr>\n" +
" <td class=\"header-left\"><small>{0}</small></td>\n" +
" <td class=\"header-center\"><small>{1}</small></td>\n" +
" <td class=\"header-center\"><small>{2}</small></td>\n" +
"</tr>\n";
private static final String HOSTS_ROW_DETAILS_SECTION =
"<tr>\n" +
" <td class=\"row-left\"><small><a href=\"{0}\">{0}</a>" +
"</small></td>\n" +
" <td class=\"row-center\"><small>{1}</small></td>\n";
private static final String MANAGER_HOST_ROW_BUTTON_SECTION =
" <td class=\"row-left\">\n" +
" <small>\n" +
" {1} \n" +
" {3} \n" +
" {5} \n" +
" </small>\n" +
" </td>\n" +
"</tr>\n";
private static final String HOSTS_ROW_BUTTON_SECTION =
" <td class=\"row-left\">\n" +
" <small>\n" +
" <a href=\"{0}\" onclick=\"return(confirm('Are you sure?'))\">{1}</a> \n" +
" <a href=\"{2}\" onclick=\"return(confirm('Are you sure?'))\">{3}</a> \n" +
" <a href=\"{4}\" onclick=\"return(confirm('Are you sure?'))\">{5}</a> \n" +
" </small>\n" +
" </td>\n" +
"</tr>\n";
private static final String ADD_SECTION =
"</table>\n" +
"<br>\n" +
"<table border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n" +
"<tr>\n" +
" <td colspan=\"2\" class=\"title\">{0}</td>\n" +
"</tr>\n" +
"<tr>\n" +
" <td colspan=\"2\" class=\"header-left\"><small>{1}</small></td>\n" +
"</tr>\n" +
"<tr>\n" +
" <td colspan=\"2\">\n" +
"<form method=\"get\" action=\"{2}\">\n" +
"<table cellspacing=\"0\" cellpadding=\"3\">\n" +
"<tr>\n" +
" <td class=\"row-right\">\n" +
" <small>{3}</small>\n" +
" </td>\n" +
" <td class=\"row-left\">\n" +
" <input type=\"text\" name=\"name\" size=\"20\">\n" +
" </td>\n" +
"</tr>\n" +
"<tr>\n" +
" <td class=\"row-right\">\n" +
" <small>{4}</small>\n" +
" </td>\n" +
" <td class=\"row-left\">\n" +
" <input type=\"text\" name=\"aliases\" size=\"64\">\n" +
" </td>\n" +
"</tr>\n" +
"<tr>\n" +
" <td class=\"row-right\">\n" +
" <small>{5}</small>\n" +
" </td>\n" +
" <td class=\"row-left\">\n" +
" <input type=\"text\" name=\"appBase\" size=\"64\">\n" +
" </td>\n" +
"</tr>\n" +
"<tr>\n" +
" <td class=\"row-right\">\n" +
" \n" +
" </td>\n" +
" <td class=\"row-left\">\n" +
" <input type=\"hidden\" name=\"manager\" value=\"true\">\n" +
" <input type=\"submit\" value=\"{9}\">\n" +
" </td>\n" +
"</tr>\n" +
"</table>\n" +
"</form>\n" +
"</td>\n" +
"</tr>\n" +
"</table>\n" +
"<br>\n" +
"\n";
}
1.1 jakarta-tomcat-catalina/webapps/host-manager/WEB-INF/classes/org/apache/catalina/hostmanager/Constants.java
Index: Constants.java
===================================================================
/*
* Copyright 1999,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.catalina.hostmanager;
public class Constants {
public static final String Package = "org.apache.catalina.hostmanager";
public static final String HTML_HEADER_SECTION =
"<html>\n" +
"<head>\n" +
"<style>\n" +
org.apache.catalina.util.TomcatCSS.TOMCAT_CSS +
" table {\n" +
" width: 100%;\n" +
" }\n" +
" td.page-title {\n" +
" text-align: center;\n" +
" vertical-align: top;\n" +
" font-family:sans-serif,Tahoma,Arial;\n" +
" font-weight: bold;\n" +
" background: white;\n" +
" color: black;\n" +
" }\n" +
" td.title {\n" +
" text-align: left;\n" +
" vertical-align: top;\n" +
" font-family:sans-serif,Tahoma,Arial;\n" +
" font-style:italic;\n" +
" font-weight: bold;\n" +
" background: #D2A41C;\n" +
" }\n" +
" td.header-left {\n" +
" text-align: left;\n" +
" vertical-align: top;\n" +
" font-family:sans-serif,Tahoma,Arial;\n" +
" font-weight: bold;\n" +
" background: #FFDC75;\n" +
" }\n" +
" td.header-center {\n" +
" text-align: center;\n" +
" vertical-align: top;\n" +
" font-family:sans-serif,Tahoma,Arial;\n" +
" font-weight: bold;\n" +
" background: #FFDC75;\n" +
" }\n" +
" td.row-left {\n" +
" text-align: left;\n" +
" vertical-align: middle;\n" +
" font-family:sans-serif,Tahoma,Arial;\n" +
" color: black;\n" +
" background: white;\n" +
" }\n" +
" td.row-center {\n" +
" text-align: center;\n" +
" vertical-align: middle;\n" +
" font-family:sans-serif,Tahoma,Arial;\n" +
" color: black;\n" +
" background: white;\n" +
" }\n" +
" td.row-right {\n" +
" text-align: right;\n" +
" vertical-align: middle;\n" +
" font-family:sans-serif,Tahoma,Arial;\n" +
" color: black;\n" +
" background: white;\n" +
" }\n" +
" TH {\n" +
" text-align: center;\n" +
" vertical-align: top;\n" +
" font-family:sans-serif,Tahoma,Arial;\n" +
" font-weight: bold;\n" +
" background: #FFDC75;\n" +
" }\n" +
" TD {\n" +
" text-align: center;\n" +
" vertical-align: middle;\n" +
" font-family:sans-serif,Tahoma,Arial;\n" +
" color: black;\n" +
" background: white;\n" +
" }\n" +
"</style>\n";
public static final String BODY_HEADER_SECTION =
"<title>{0}</title>\n" +
"</head>\n" +
"\n" +
"<body bgcolor=\"#FFFFFF\">\n" +
"\n" +
"<table cellspacing=\"4\" width=\"100%\" border=\"0\">\n" +
" <tr>\n" +
" <td colspan=\"2\">\n" +
" <a href=\"http://jakarta.apache.org/\">\n" +
" <img border=\"0\" alt=\"The Jakarta Project\" align=\"left\"\n" +
" src=\"{0}/images/jakarta-logo.gif\">\n" +
" </a>\n" +
" <a href=\"http://jakarta.apache.org/tomcat/\">\n" +
" <img border=\"0\" alt=\"The Tomcat Servlet/JSP Container\"\n" +
" align=\"right\" src=\"{0}/images/tomcat.gif\">\n" +
" </a>\n" +
" </td>\n" +
" </tr>\n" +
"</table>\n" +
"<hr size=\"1\" noshade=\"noshade\">\n" +
"<table cellspacing=\"4\" width=\"100%\" border=\"0\">\n" +
" <tr>\n" +
" <td class=\"page-title\" bordercolor=\"#000000\" " +
"align=\"left\" nowrap>\n" +
" <font size=\"+2\">{1}</font>\n" +
" </td>\n" +
" </tr>\n" +
"</table>\n" +
"<br>\n" +
"\n";
public static final String MESSAGE_SECTION =
"<table border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n" +
" <tr>\n" +
" <td class=\"row-left\" width=\"10%\">" +
"<small><strong>{0}</strong></small> </td>\n" +
" <td class=\"row-left\"><pre>{1}</pre></td>\n" +
" </tr>\n" +
"</table>\n" +
"<br>\n" +
"\n";
public static final String MANAGER_SECTION =
"<table border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n" +
"<tr>\n" +
" <td colspan=\"4\" class=\"title\">{0}</td>\n" +
"</tr>\n" +
" <tr>\n" +
" <td class=\"row-left\"><a href=\"{1}\">{2}</a></td>\n" +
" <td class=\"row-center\"><a href=\"{3}\">{4}</a></td>\n" +
" <td class=\"row-center\"><a href=\"{5}\">{6}</a></td>\n" +
" <td class=\"row-right\"><a href=\"{7}\">{8}</a></td>\n" +
" </tr>\n" +
"</table>\n" +
"<br>\n" +
"\n";
public static final String SERVER_HEADER_SECTION =
"<table border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n" +
"<tr>\n" +
" <td colspan=\"6\" class=\"title\">{0}</td>\n" +
"</tr>\n" +
"<tr>\n" +
" <td class=\"header-center\"><small>{1}</small></td>\n" +
" <td class=\"header-center\"><small>{2}</small></td>\n" +
" <td class=\"header-center\"><small>{3}</small></td>\n" +
" <td class=\"header-center\"><small>{4}</small></td>\n" +
" <td class=\"header-center\"><small>{5}</small></td>\n" +
" <td class=\"header-center\"><small>{6}</small></td>\n" +
"</tr>\n";
public static final String SERVER_ROW_SECTION =
"<tr>\n" +
" <td class=\"row-center\"><small>{0}</small></td>\n" +
" <td class=\"row-center\"><small>{1}</small></td>\n" +
" <td class=\"row-center\"><small>{2}</small></td>\n" +
" <td class=\"row-center\"><small>{3}</small></td>\n" +
" <td class=\"row-center\"><small>{4}</small></td>\n" +
" <td class=\"row-center\"><small>{5}</small></td>\n" +
"</tr>\n" +
"</table>\n" +
"<br>\n" +
"\n";
public static final String HTML_TAIL_SECTION =
"<hr size=\"1\" noshade=\"noshade\">\n" +
"<center><font size=\"-1\" color=\"#525D76\">\n" +
" <em>Copyright © 1999-2005, Apache Software Foundation</em>" +
"</font></center>\n" +
"\n" +
"</body>\n" +
"</html>";
public static final String CHARSET="utf-8";
public static final String XML_DECLARATION =
"<?xml version=\"1.0\" encoding=\""+CHARSET+"\"?>";
public static final String XML_STYLE =
"<?xml-stylesheet type=\"text/xsl\" href=\"/manager/xform.xsl\" ?>";
}
1.1 jakarta-tomcat-catalina/webapps/host-manager/WEB-INF/classes/org/apache/catalina/hostmanager/HostManagerServlet.java
Index: HostManagerServlet.java
===================================================================
/*
* Copyright 1999,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.catalina.hostmanager;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import javax.management.MBeanServer;
import javax.servlet.ServletException;
import javax.servlet.UnavailableException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.catalina.Container;
import org.apache.catalina.ContainerServlet;
import org.apache.catalina.Context;
import org.apache.catalina.Engine;
import org.apache.catalina.Globals;
import org.apache.catalina.Host;
import org.apache.catalina.Lifecycle;
import org.apache.catalina.Wrapper;
import org.apache.catalina.core.StandardHost;
import org.apache.catalina.startup.HostConfig;
import org.apache.catalina.util.StringManager;
import org.apache.commons.modeler.Registry;
/**
* Servlet that enables remote management of the virtual hosts installed
* on the server. Normally, this functionality will be protected by
* a security constraint in the web application deployment descriptor.
* However, this requirement can be relaxed during testing.
* <p>
* This servlet examines the value returned by <code>getPathInfo()</code>
* and related query parameters to determine what action is being requested.
* The following actions and parameters (starting after the servlet path)
* are supported:
* <ul>
* <li><b>/add?name={host-name}&aliases={host-aliases}&manager={manager}</b> -
* Create and add a new virtual host. The <code>host-name</code> attribute
* indicates the name of the new host. The <code>host-aliases</code>
* attribute is a comma separated list of the host alias names.
* The <code>manager</code> attribute is a boolean value indicating if the
* webapp manager will be installed in the newly created host (optional,
* true by default).</li>
* <li><b>/remove?name={host-name}</b> - Remove a virtual host.
* The <code>host-name</code> attribute indicates the name of the host.
* </li>
* <li><b>/list</b> - List the virtual hosts installed on the server.
* Each host will be listed with the following format
* <code>host-name#host-aliases</code>.</li>
* <li><b>/start?name={host-name}</b> - Start the virtual host.</li>
* <li><b>/stop?name={host-name}</b> - Stop the virtual host.</li>
* </ul>
* <p>
* <b>NOTE</b> - Attempting to stop or remove the host containing
* this servlet itself will not succeed. Therefore, this servlet should
* generally be deployed in a separate virtual host.
* <p>
* <b>NOTE</b> - For security reasons, this application will not operate
* when accessed via the invoker servlet. You must explicitly map this servlet
* with a servlet mapping, and you will always want to protect it with
* appropriate security constraints as well.
* <p>
* The following servlet initialization parameters are recognized:
* <ul>
* <li><b>debug</b> - The debugging detail level that controls the amount
* of information that is logged by this servlet. Default is zero.
* </ul>
*
* @author Craig R. McClanahan
* @author Remy Maucherat
* @version $Revision: 1.1 $ $Date: 2005/03/11 22:39:26 $
*/
public class HostManagerServlet
extends HttpServlet implements ContainerServlet {
// ----------------------------------------------------- Instance Variables
/**
* Path where context descriptors should be deployed.
*/
protected File configBase = null;
/**
* The Context container associated with our web application.
*/
protected Context context = null;
/**
* The debugging detail level for this servlet.
*/
protected int debug = 1;
/**
* The associated host.
*/
protected Host host = null;
/**
* The associated engine.
*/
protected Engine engine = null;
/**
* MBean server.
*/
protected MBeanServer mBeanServer = null;
/**
* The string manager for this package.
*/
protected static StringManager sm =
StringManager.getManager(Constants.Package);
/**
* The Wrapper container associated with this servlet.
*/
protected Wrapper wrapper = null;
// ----------------------------------------------- ContainerServlet Methods
/**
* Return the Wrapper with which we are associated.
*/
public Wrapper getWrapper() {
return (this.wrapper);
}
/**
* Set the Wrapper with which we are associated.
*
* @param wrapper The new wrapper
*/
public void setWrapper(Wrapper wrapper) {
this.wrapper = wrapper;
if (wrapper == null) {
context = null;
host = null;
engine = null;
} else {
context = (Context) wrapper.getParent();
host = (Host) context.getParent();
engine = (Engine) host.getParent();
}
// Retrieve the MBean server
mBeanServer = Registry.getRegistry(null, null).getMBeanServer();
}
// --------------------------------------------------------- Public Methods
/**
* Finalize this servlet.
*/
public void destroy() {
; // No actions necessary
}
/**
* Process a GET request for the specified resource.
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
*
* @exception IOException if an input/output error occurs
* @exception ServletException if a servlet-specified error occurs
*/
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
// Verify that we were not accessed using the invoker servlet
if (request.getAttribute(Globals.INVOKED_ATTR) != null)
throw new UnavailableException
(sm.getString("hostManagerServlet.cannotInvoke"));
// Identify the request parameters that we need
String command = request.getPathInfo();
if (command == null)
command = request.getServletPath();
String name = request.getParameter("name");
String aliases = request.getParameter("aliases");
String appBase = request.getParameter("appBase");
boolean manager = true;
if ((request.getParameter("manager") != null)
&& (request.getParameter("manager").equals("false"))) {
manager = false;
}
// Prepare our output writer to generate the response message
response.setContentType("text/plain; charset=" + Constants.CHARSET);
PrintWriter writer = response.getWriter();
// Process the requested command
if (command == null) {
writer.println(sm.getString("hostManagerServlet.noCommand"));
} else if (command.equals("/add")) {
add(writer, name, aliases, appBase, manager);
} else if (command.equals("/remove")) {
remove(writer, name);
} else if (command.equals("/list")) {
list(writer);
} else if (command.equals("/start")) {
start(writer, name);
} else if (command.equals("/stop")) {
stop(writer, name);
} else {
writer.println(sm.getString("hostManagerServlet.unknownCommand",
command));
}
// Finish up the response
writer.flush();
writer.close();
}
/**
* Initialize this servlet.
*/
public void init() throws ServletException {
// Ensure that our ContainerServlet properties have been set
if ((wrapper == null) || (context == null))
throw new UnavailableException
(sm.getString("hostManagerServlet.noWrapper"));
// Verify that we were not accessed using the invoker servlet
String servletName = getServletConfig().getServletName();
if (servletName == null)
servletName = "";
if (servletName.startsWith("org.apache.catalina.INVOKER."))
throw new UnavailableException
(sm.getString("hostManagerServlet.cannotInvoke"));
// Set our properties from the initialization parameters
String value = null;
try {
value = getServletConfig().getInitParameter("debug");
debug = Integer.parseInt(value);
} catch (Throwable t) {
;
}
}
// -------------------------------------------------------- Private Methods
/**
* Add a host using the specified parameters.
*
* @param writer Writer to render results to
* @param name host name
* @param aliases comma separated alias list
* @param appBase application base for the host
* @param manager should the manager webapp be deployed to the new host ?
*/
protected synchronized void add
(PrintWriter writer, String name, String aliases, String appBase,
boolean manager) {
if (debug >= 1) {
log("add: Adding host '" + name + "'");
}
// Validate the requested host name
if ((name == null) || name.length() == 0) {
writer.println(sm.getString("hostManagerServlet.invalidHostName", name));
return;
}
// Check if host already exists
if (engine.findChild(name) != null) {
writer.println
(sm.getString("hostManagerServlet.alreadyHost", name));
return;
}
// Validate and create appBase
File appBaseFile = null;
if (appBase == null || appBase.length() == 0) {
appBase = name;
}
File file = new File(appBase);
if (!file.isAbsolute())
file = new File(System.getProperty("catalina.base"), appBase);
try {
appBaseFile = file.getCanonicalFile();
} catch (IOException e) {
appBaseFile = file;
}
if (!appBaseFile.exists()) {
appBaseFile.mkdirs();
}
// Create base for config files
File configBaseFile = getConfigBase(name);
// Copy manager.xml if requested
if (manager) {
InputStream is = null;
OutputStream os = null;
try {
is = getServletContext().getResourceAsStream("/manager.xml");
os = new FileOutputStream(new File(configBaseFile, "manager.xml"));
byte buffer[] = new byte[512];
int len = buffer.length;
while (true) {
len = is.read(buffer);
if (len == -1)
break;
os.write(buffer, 0, len);
}
} catch (IOException e) {
writer.println
(sm.getString("hostManagerServlet.managerXml"));
return;
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
}
}
if (os != null) {
try {
os.close();
} catch (IOException e) {
}
}
}
}
StandardHost host = new StandardHost();
host.setAppBase(appBase);
host.setName(name);
host.addLifecycleListener(new HostConfig());
// Add host aliases
if ((aliases != null) && !("".equals(aliases))) {
StringTokenizer tok = new StringTokenizer(aliases, ",");
while (tok.hasMoreTokens()) {
host.addAlias(tok.nextToken());
}
}
// Add new host
try {
engine.addChild(host);
} catch (Exception e) {
writer.println(sm.getString("hostManagerServlet.exception",
e.toString()));
return;
}
host = (StandardHost) engine.findChild(name);
if (host != null) {
writer.println(sm.getString("hostManagerServlet.add", name));
} else {
// Something failed
writer.println(sm.getString("hostManagerServlet.addFailed", name));
}
}
/**
* Remove the specified host.
*
* @param writer Writer to render results to
* @param name host name
*/
protected synchronized void remove(PrintWriter writer, String name) {
if (debug >= 1) {
log("remove: Removing host '" + name + "'");
}
// Validate the requested host name
if ((name == null) || name.length() == 0) {
writer.println(sm.getString("hostManagerServlet.invalidHostName", name));
return;
}
// Check if host exists
if (engine.findChild(name) == null) {
writer.println
(sm.getString("hostManagerServlet.noHost", name));
return;
}
// Prevent removing our own host
if (engine.findChild(name) == host) {
writer.println
(sm.getString("hostManagerServlet.cannotRemoveOwnHost", name));
return;
}
// Remove host
// Note that the host will not get physically removed
try {
engine.removeChild(engine.findChild(name));
} catch (Exception e) {
writer.println(sm.getString("hostManagerServlet.exception",
e.toString()));
return;
}
Host host = (StandardHost) engine.findChild(name);
if (host == null) {
writer.println(sm.getString("hostManagerServlet.remove", name));
} else {
// Something failed
writer.println(sm.getString("hostManagerServlet.removeFailed", name));
}
}
/**
* Render a list of the currently active Contexts in our virtual host.
*
* @param writer Writer to render to
*/
protected void list(PrintWriter writer) {
if (debug >= 1)
log("list: Listing hosts for engine '"
+ engine.getName() + "'");
writer.println(sm.getString("hostManagerServlet.listed",
engine.getName()));
Container[] hosts = engine.findChildren();
for (int i = 0; i < hosts.length; i++) {
Host host = (Host) hosts[i];
String name = host.getName();
String[] aliases = host.findAliases();
StringBuffer buf = new StringBuffer();
if (aliases.length > 0) {
buf.append(aliases[0]);
for (int j = 1; j < aliases.length; j++) {
buf.append(',').append(aliases[j]);
}
}
writer.println(sm.getString("hostManagerServlet.listitem",
name, buf.toString()));
}
}
/**
* Start the host with the specified name.
*
* @param writer Writer to render to
* @param name Host name
*/
protected void start(PrintWriter writer, String name) {
if (debug >= 1)
log("start: Starting host with name '" + name + "'");
// Validate the requested host name
if ((name == null) || name.length() == 0) {
writer.println(sm.getString("hostManagerServlet.invalidHostName", name));
return;
}
// Check if host exists
if (engine.findChild(name) == null) {
writer.println
(sm.getString("hostManagerServlet.noHost", name));
return;
}
// Prevent starting our own host
if (engine.findChild(name) == host) {
writer.println
(sm.getString("hostManagerServlet.cannotStartOwnHost", name));
return;
}
// Start host
try {
((Lifecycle) engine.findChild(name)).start();
writer.println
(sm.getString("hostManagerServlet.started", name));
} catch (Throwable t) {
getServletContext().log
(sm.getString("hostManagerServlet.startFailed", name), t);
writer.println
(sm.getString("hostManagerServlet.startFailed", name));
writer.println(sm.getString("hostManagerServlet.exception",
t.toString()));
return;
}
}
/**
* Start the host with the specified name.
*
* @param writer Writer to render to
* @param name Host name
*/
protected void stop(PrintWriter writer, String name) {
if (debug >= 1)
log("stop: Stopping host with name '" + name + "'");
// Validate the requested host name
if ((name == null) || name.length() == 0) {
writer.println(sm.getString("hostManagerServlet.invalidHostName", name));
return;
}
// Check if host exists
if (engine.findChild(name) == null) {
writer.println
(sm.getString("hostManagerServlet.noHost", name));
return;
}
// Prevent starting our own host
if (engine.findChild(name) == host) {
writer.println
(sm.getString("hostManagerServlet.cannotStopOwnHost", name));
return;
}
// Start host
try {
((Lifecycle) engine.findChild(name)).stop();
writer.println
(sm.getString("hostManagerServlet.stopped", name));
} catch (Throwable t) {
getServletContext().log
(sm.getString("hostManagerServlet.stopFailed", name), t);
writer.println
(sm.getString("hostManagerServlet.stopFailed", name));
writer.println(sm.getString("hostManagerServlet.exception",
t.toString()));
return;
}
}
// -------------------------------------------------------- Support Methods
/**
* Get config base.
*/
protected File getConfigBase(String hostName) {
File configBase =
new File(System.getProperty("catalina.base"), "conf");
if (!configBase.exists()) {
return null;
}
if (engine != null) {
configBase = new File(configBase, engine.getName());
}
if (host != null) {
configBase = new File(configBase, hostName);
}
configBase.mkdirs();
return configBase;
}
}
1.1 jakarta-tomcat-catalina/webapps/host-manager/WEB-INF/classes/org/apache/catalina/hostmanager/LocalStrings.properties
Index: LocalStrings.properties
===================================================================
hostManagerServlet.cannotInvoke=Cannot invoke host manager servlet through invoker
hostManagerServlet.noCommand=FAIL - No command was specified
hostManagerServlet.unknownCommand=FAIL - Unknown command {0}
hostManagerServlet.noWrapper=Container has not called setWrapper() for this servlet
hostManagerServlet.invalidHostName=FAIL - Invalid host name {0} was specified
hostManagerServlet.alreadyHost=FAIL - Host already exists with host name {0}
hostManagerServlet.managerXml=FAIL - Couldn't install manager.xml
hostManagerServlet.exception=FAIL - Encountered exception {0}
hostManagerServlet.add=OK - Host {0} added
hostManagerServlet.addFailed=FAIL - Failed to add host {0}
hostManagerServlet.cannotRemoveOwnHost=FAIL - Cannot remove own host {0}
hostManagerServlet.remove=OK - Removed host {0}
hostManagerServlet.removeFailed=FAIL - Failed to remove host {0}
hostManagerServlet.listed=OK - Listed hosts
hostManagerServlet.listitem={0}:{1}
hostManagerServlet.cannotStartOwnHost=FAIL - Cannot start own host {0}
hostManagerServlet.started=OK - Host {0} started
hostManagerServlet.startFailed=FAIL - Failed to start host {0}
hostManagerServlet.cannotStopOwnHost=FAIL - Cannot stop own host {0}
hostManagerServlet.stopped=OK - Host {0} stopped
hostManagerServlet.stopFailed=FAIL - Failed to stop host {0}
htmlHostManagerServlet.title=Tomcat Virtual Host Manager
htmlHostManagerServlet.messageLabel=Message:
htmlHostManagerServlet.manager=Host Manager
htmlHostManagerServlet.list=List Virtual Hosts
htmlHostManagerServlet.helpHtmlManagerFile=html-host-manager-howto.html
htmlHostManagerServlet.helpHtmlManager=HTML Host Manager Help
htmlHostManagerServlet.helpManagerFile=host-manager-howto.html
htmlHostManagerServlet.helpManager=Host Manager Help
htmlHostManagerServlet.hostName=Host name
htmlHostManagerServlet.hostAliases=Host aliases
htmlHostManagerServlet.hostTasks=Commands
htmlHostManagerServlet.hostsStart=Start
htmlHostManagerServlet.hostsStop=Stop
htmlHostManagerServlet.hostsRemove=Remove
htmlHostManagerServlet.addTitle=Add Virtual Host
htmlHostManagerServlet.addHost=Host
htmlHostManagerServlet.addName=Name:
htmlHostManagerServlet.addAliases=Aliases:
htmlHostManagerServlet.addAppBase=App base:
htmlHostManagerServlet.addManager=Manager:
htmlHostManagerServlet.addManagerTrue=True
htmlHostManagerServlet.addManagerFalse=False
htmlHostManagerServlet.addButton=Add
htmlHostManagerServlet.serverTitle=Server Information
htmlHostManagerServlet.serverVersion=Tomcat Version
htmlHostManagerServlet.serverJVMVersion=JVM Version
htmlHostManagerServlet.serverJVMVendor=JVM Vendor
htmlHostManagerServlet.serverOSName=OS Name
htmlHostManagerServlet.serverOSVersion=OS Version
htmlHostManagerServlet.serverOSArch=OS Architecture
statusServlet.title=Server Status
statusServlet.complete=Complete Server Status
1.6 +12 -1 jakarta-tomcat-catalina/webapps/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/webapps/build.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- build.xml 5 Aug 2004 20:17:23 -0000 1.5
+++ build.xml 11 Mar 2005 22:39:26 -0000 1.6
@@ -41,6 +41,10 @@
<ant dir="${basedir}/manager" target="dist"/>
</target>
+ <target name="host-manager">
+ <ant dir="${basedir}/host-manager" target="dist"/>
+ </target>
+
<target name="docs">
<ant dir="${basedir}/docs" target="dist"/>
</target>
@@ -56,7 +60,7 @@
<!-- ================= BUILD: Compile Server Components ================= -->
<!-- Update the depends list for each subproject -->
- <target name="build" depends="build-prepare,ROOT,admin,manager,docs,balancer,webdav" />
+ <target name="build" depends="build-prepare,ROOT,admin,manager,host-manager,docs,balancer,webdav" />
<!-- ======================= BUILD: Clean Directory ===================== -->
@@ -96,6 +100,13 @@
<fileset dir="${webapps.build}/manager" excludes="manager.xml"/>
</copy>
+ <copy todir="${webapps.deploy}/webapps"
+ file="${webapps.build}/host-manager/host-manager.xml"/>
+ <mkdir dir="${webapps.deploy}/server/webapps/host-manager"/>
+ <copy todir="${webapps.deploy}/server/webapps/host-manager">
+ <fileset dir="${webapps.build}/host-manager" excludes="host-manager.xml"/>
+ </copy>
+
</target>
1.3 +8 -1 jakarta-tomcat-5/resources/logging.properties
Index: logging.properties
===================================================================
RCS file: /home/cvs/jakarta-tomcat-5/resources/logging.properties,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- logging.properties 3 Mar 2005 15:26:07 -0000 1.2
+++ logging.properties 11 Mar 2005 22:39:26 -0000 1.3
@@ -1,4 +1,4 @@
-handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4admin.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
+handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4admin.org.apache.juli.FileHandler, 5host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
@@ -23,6 +23,10 @@
4admin.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
4admin.org.apache.juli.FileHandler.prefix = admin.
+5host-manager.org.apache.juli.FileHandler.level = FINE
+5host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
+5host-manager.org.apache.juli.FileHandler.prefix = host-manager.
+
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
@@ -41,6 +45,9 @@
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/admin].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/admin].handlers = 4admin.org.apache.juli.FileHandler
+org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
+org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 5host-manager.org.apache.juli.FileHandler
+
# For example, set the com.xyz.foo logger to only log SEVERE
# messages:
#org.apache.catalina.startup.ContextConfig.level = FINE
1.12 +1 -1 jakarta-tomcat-catalina/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/webapps/manager/WEB-INF/classes/org/apache/catalina/manager/Constants.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Constants.java 8 May 2004 22:33:22 -0000 1.11
+++ Constants.java 11 Mar 2005 22:39:26 -0000 1.12
@@ -185,7 +185,7 @@
public static final String HTML_TAIL_SECTION =
"<hr size=\"1\" noshade=\"noshade\">\n" +
"<center><font size=\"-1\" color=\"#525D76\">\n" +
- " <em>Copyright © 1999-2003, Apache Software Foundation</em>" +
+ " <em>Copyright © 1999-2005, Apache Software Foundation</em>" +
"</font></center>\n" +
"\n" +
"</body>\n" +
1.1 jakarta-tomcat-catalina/webapps/host-manager/WEB-INF/web.xml
Index: web.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Tomcat Manager Application</display-name>
<description>
A scriptable management web application for the Tomcat Web Server;
Manager lets you view, load/unload/etc particular web applications.
</description>
<!-- Define the Manager Servlet
Change servlet-class to: org.apache.catalina.servlets.HTMLManagerServlet
to get a Servlet with a more intuitive HTML interface, don't change if you
have software that is expected to parse the output from ManagerServlet
since they're not compatible.
-->
<servlet>
<servlet-name>HostManager</servlet-name>
<servlet-class>org.apache.catalina.hostmanager.HostManagerServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>HTMLHostManager</servlet-name>
<servlet-class>org.apache.catalina.hostmanager.HTMLHostManagerServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
</servlet>
<!-- Define the Manager Servlet Mapping -->
<servlet-mapping>
<servlet-name>HostManager</servlet-name>
<url-pattern>/list</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HostManager</servlet-name>
<url-pattern>/add</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HostManager</servlet-name>
<url-pattern>/remove</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HostManager</servlet-name>
<url-pattern>/start</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HostManager</servlet-name>
<url-pattern>/stop</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HTMLHostManager</servlet-name>
<url-pattern>/html/*</url-pattern>
</servlet-mapping>
<!-- Define a Security Constraint on this Application -->
<security-constraint>
<web-resource-collection>
<web-resource-name>HTMLHostManager and HostManager commands</web-resource-name>
<url-pattern>/html/*</url-pattern>
<url-pattern>/list</url-pattern>
<url-pattern>/add</url-pattern>
<url-pattern>/remove</url-pattern>
<url-pattern>/start</url-pattern>
<url-pattern>/stop</url-pattern>
</web-resource-collection>
<auth-constraint>
<!-- NOTE: This role is not present in the default users file -->
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<!-- Define the Login Configuration for this Application -->
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Tomcat Host Manager Application</realm-name>
</login-config>
<!-- Security roles referenced by this web application -->
<security-role>
<description>
The role that is required to log in to the Manager Application
</description>
<role-name>admin</role-name>
</security-role>
</web-app>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org