org.apache.catalina.manager

Class ManagerServlet

public class ManagerServlet extends HttpServlet implements ContainerServlet

Servlet that enables remote management of the web applications installed within the same virtual host as this web application is. Normally, this functionality will be protected by a security constraint in the web application deployment descriptor. However, this requirement can be relaxed during testing.

This servlet examines the value returned by getPathInfo() and related query parameters to determine what action is being requested. The following actions and parameters (starting after the servlet path) are supported:

Use path=/ for the ROOT context.

The syntax of the URL for a web application archive must conform to one of the following patterns to be successfully deployed:

NOTE - Attempting to reload or remove the application containing this servlet itself will not succeed. Therefore, this servlet should generally be deployed as a separate web application within the virtual host to be managed.

NOTE - 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.

The following servlet initialization parameters are recognized:

Version: $Revision: 812174 $ $Date: 2009-09-07 16:57:59 +0200 (Mon, 07 Sep 2009) $

Author: Craig R. McClanahan Remy Maucherat

Field Summary
protected FileappBase
The host appBase.
protected FileconfigBase
Path where context descriptors should be deployed.
protected Contextcontext
The Context container associated with our web application.
protected FilecontextDescriptors
Path used to store context descriptors.
protected intdebug
The debugging detail level for this servlet.
protected Filedeployed
File object representing the directory into which the deploy() command will store the WAR and context configuration files that have been uploaded.
protected Contextglobal
The global JNDI NamingContext for this server, if available.
protected Hosthost
The associated host.
protected MBeanServermBeanServer
MBean server.
protected ObjectNameoname
The associated deployer ObjectName.
protected static StringManagersm
The string manager for this package.
protected Fileversioned
Path used to store revisions of webapps.
protected Wrapperwrapper
The Wrapper container associated with this servlet.
Method Summary
protected voidaddServiced(String name)
Invoke the addServiced method on the deployer.
protected voidcheck(String name)
Invoke the check method on the deployer.
static booleancopy(File src, File dest)
Copy the specified file or directory to the destination.
static booleancopyInternal(File src, File dest, byte[] buf)
Copy the specified file or directory to the destination.
protected voiddeploy(PrintWriter writer, String path, String tag, boolean update, HttpServletRequest request)
Deploy a web application archive (included in the current request) at the specified context path.
protected voiddeploy(PrintWriter writer, String path, String tag)
Install an application for the specified path from the specified web application archive.
protected voiddeploy(PrintWriter writer, String config, String path, String war, boolean update)
Install an application for the specified path from the specified web application archive.
voiddestroy()
Finalize this servlet.
voiddoGet(HttpServletRequest request, HttpServletResponse response)
Process a GET request for the specified resource.
voiddoPut(HttpServletRequest request, HttpServletResponse response)
Process a PUT request for the specified resource.
protected voidexpireSessions(PrintWriter writer, String path, HttpServletRequest req)
Extract the expiration request parameter
protected FilegetAppBase()
Return a File object representing the "application root" directory for our associated Host.
protected StringgetConfigFile(String path)
Given a context path, get the config file name.
protected StringgetDocBase(String path)
Given a context path, get the doc base.
WrappergetWrapper()
Return the Wrapper with which we are associated.
voidinit()
Initialize this servlet.
protected booleanisDeployed(String name)
Invoke the isDeployed method on the deployer.
protected booleanisServiced(String name)
Invoke the isServiced method on the deployer.
protected voidlist(PrintWriter writer)
Render a list of the currently active Contexts in our virtual host.
protected voidprintResources(PrintWriter writer, String prefix, Context namingContext, String type, Class clazz)
List the resources of the given context.
protected voidreload(PrintWriter writer, String path)
Reload the web application at the specified context path.
protected voidremoveServiced(String name)
Invoke the removeServiced method on the deployer.
protected voidresources(PrintWriter writer, String type)
Render a list of available global JNDI resources.
protected voidroles(PrintWriter writer)
Render a list of security role names (and corresponding descriptions) from the org.apache.catalina.UserDatabase resource that is connected to the users resource reference.
protected voidsave(PrintWriter writer, String path)
Store server configuration.
protected voidserverinfo(PrintWriter writer)
Writes System OS and JVM properties.
protected voidsessions(PrintWriter writer, String path, int idle)
Session information for the web application at the specified context path.
protected voidsessions(PrintWriter writer, String path)
Session information for the web application at the specified context path.
voidsetWrapper(Wrapper wrapper)
Set the Wrapper with which we are associated.
protected voidstart(PrintWriter writer, String path)
Start the web application at the specified context path.
protected voidstop(PrintWriter writer, String path)
Stop the web application at the specified context path.
protected voidundeploy(PrintWriter writer, String path)
Undeploy the web application at the specified context path.
protected voidundeployDir(File dir)
Delete the specified directory, including all of its contents and subdirectories recursively.
protected voiduploadWar(HttpServletRequest request, File war)
Upload the WAR file included in this request, and store it at the specified file location.

Field Detail

appBase

protected File appBase
The host appBase.

configBase

protected File configBase
Path where context descriptors should be deployed.

context

protected Context context
The Context container associated with our web application.

contextDescriptors

protected File contextDescriptors
Path used to store context descriptors.

debug

protected int debug
The debugging detail level for this servlet.

deployed

protected File deployed
File object representing the directory into which the deploy() command will store the WAR and context configuration files that have been uploaded.

global

protected Context global
The global JNDI NamingContext for this server, if available.

host

protected Host host
The associated host.

mBeanServer

protected MBeanServer mBeanServer
MBean server.

oname

protected ObjectName oname
The associated deployer ObjectName.

sm

protected static StringManager sm
The string manager for this package.

versioned

protected File versioned
Path used to store revisions of webapps.

wrapper

protected Wrapper wrapper
The Wrapper container associated with this servlet.

Method Detail

addServiced

protected void addServiced(String name)
Invoke the addServiced method on the deployer.

check

protected void check(String name)
Invoke the check method on the deployer.

copy

public static boolean copy(File src, File dest)
Copy the specified file or directory to the destination.

Parameters: src File object representing the source dest File object representing the destination

copyInternal

public static boolean copyInternal(File src, File dest, byte[] buf)
Copy the specified file or directory to the destination.

Parameters: src File object representing the source dest File object representing the destination

deploy

protected void deploy(PrintWriter writer, String path, String tag, boolean update, HttpServletRequest request)
Deploy a web application archive (included in the current request) at the specified context path.

Parameters: writer Writer to render results to path Context path of the application to be installed tag Tag to be associated with the webapp request Servlet request we are processing

deploy

protected void deploy(PrintWriter writer, String path, String tag)
Install an application for the specified path from the specified web application archive.

Parameters: writer Writer to render results to tag Revision tag to deploy from path Context path of the application to be installed

deploy

protected void deploy(PrintWriter writer, String config, String path, String war, boolean update)
Install an application for the specified path from the specified web application archive.

Parameters: writer Writer to render results to config URL of the context configuration file to be installed path Context path of the application to be installed war URL of the web application archive to be installed update true to override any existing webapp on the path

destroy

public void destroy()
Finalize this servlet.

doGet

public void doGet(HttpServletRequest request, HttpServletResponse response)
Process a GET request for the specified resource.

Parameters: request The servlet request we are processing response The servlet response we are creating

Throws: IOException if an input/output error occurs ServletException if a servlet-specified error occurs

doPut

public void doPut(HttpServletRequest request, HttpServletResponse response)
Process a PUT request for the specified resource.

Parameters: request The servlet request we are processing response The servlet response we are creating

Throws: IOException if an input/output error occurs ServletException if a servlet-specified error occurs

expireSessions

protected void expireSessions(PrintWriter writer, String path, HttpServletRequest req)
Extract the expiration request parameter

Parameters: path req

getAppBase

protected File getAppBase()
Return a File object representing the "application root" directory for our associated Host.

getConfigFile

protected String getConfigFile(String path)
Given a context path, get the config file name.

getDocBase

protected String getDocBase(String path)
Given a context path, get the doc base.

getWrapper

public Wrapper getWrapper()
Return the Wrapper with which we are associated.

init

public void init()
Initialize this servlet.

isDeployed

protected boolean isDeployed(String name)
Invoke the isDeployed method on the deployer.

isServiced

protected boolean isServiced(String name)
Invoke the isServiced method on the deployer.

list

protected void list(PrintWriter writer)
Render a list of the currently active Contexts in our virtual host.

Parameters: writer Writer to render to

printResources

protected void printResources(PrintWriter writer, String prefix, Context namingContext, String type, Class clazz)
List the resources of the given context.

reload

protected void reload(PrintWriter writer, String path)
Reload the web application at the specified context path.

Parameters: writer Writer to render to path Context path of the application to be restarted

removeServiced

protected void removeServiced(String name)
Invoke the removeServiced method on the deployer.

resources

protected void resources(PrintWriter writer, String type)
Render a list of available global JNDI resources.

Parameters: type Fully qualified class name of the resource type of interest, or null to list resources of all types

roles

protected void roles(PrintWriter writer)
Render a list of security role names (and corresponding descriptions) from the org.apache.catalina.UserDatabase resource that is connected to the users resource reference. Typically, this will be the global user database, but can be adjusted if you have different user databases for different virtual hosts.

Parameters: writer Writer to render to

save

protected void save(PrintWriter writer, String path)
Store server configuration.

Parameters: path Optional context path to save

serverinfo

protected void serverinfo(PrintWriter writer)
Writes System OS and JVM properties.

Parameters: writer Writer to render to

sessions

protected void sessions(PrintWriter writer, String path, int idle)
Session information for the web application at the specified context path. Displays a profile of session lastAccessedTime listing number of sessions for each 10 minute interval up to 10 hours.

Parameters: writer Writer to render to path Context path of the application to list session information for idle Expire all sessions with idle time ≥ idle for this context

sessions

protected void sessions(PrintWriter writer, String path)
Session information for the web application at the specified context path. Displays a profile of session lastAccessedTime listing number of sessions for each 10 minute interval up to 10 hours.

Parameters: writer Writer to render to path Context path of the application to list session information for

setWrapper

public void setWrapper(Wrapper wrapper)
Set the Wrapper with which we are associated.

Parameters: wrapper The new wrapper

start

protected void start(PrintWriter writer, String path)
Start the web application at the specified context path.

Parameters: writer Writer to render to path Context path of the application to be started

stop

protected void stop(PrintWriter writer, String path)
Stop the web application at the specified context path.

Parameters: writer Writer to render to path Context path of the application to be stopped

undeploy

protected void undeploy(PrintWriter writer, String path)
Undeploy the web application at the specified context path.

Parameters: writer Writer to render to path Context path of the application to be removed

undeployDir

protected void undeployDir(File dir)
Delete the specified directory, including all of its contents and subdirectories recursively.

Parameters: dir File object representing the directory to be deleted

uploadWar

protected void uploadWar(HttpServletRequest request, File war)
Upload the WAR file included in this request, and store it at the specified file location.

Parameters: request The servlet request we are processing war The file into which we should store the uploaded WAR

Throws: IOException if an I/O error occurs during processing

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.