Apache Tomcat 6.0.43

org.apache.catalina.manager
Class ManagerServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.apache.catalina.manager.ManagerServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig, ContainerServlet
Direct Known Subclasses:
HTMLManagerServlet

public class ManagerServlet
extends javax.servlet.http.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:

Author:
Craig R. McClanahan, Remy Maucherat
See Also:
Serialized Form

Field Summary
protected  java.io.File appBase
          The host appBase.
protected  java.io.File configBase
          Path where context descriptors should be deployed.
protected  Context context
          The Context container associated with our web application.
protected  java.io.File contextDescriptors
          Path used to store context descriptors.
protected  int debug
          The debugging detail level for this servlet.
protected  java.io.File deployed
          File object representing the directory into which the deploy() command will store the WAR and context configuration files that have been uploaded.
protected  javax.naming.Context global
          The global JNDI NamingContext for this server, if available.
protected  Host host
          The associated host.
protected  javax.management.MBeanServer mBeanServer
          MBean server.
protected  javax.management.ObjectName oname
          The associated deployer ObjectName.
protected static StringManager sm
          The string manager for this package.
protected  java.io.File versioned
          Path used to store revisions of webapps.
protected  Wrapper wrapper
          The Wrapper container associated with this servlet.
 
Constructor Summary
ManagerServlet()
           
 
Method Summary
protected  void addServiced(java.lang.String name)
          Invoke the addServiced method on the deployer.
protected  void check(java.lang.String name)
          Invoke the check method on the deployer.
static boolean copy(java.io.File src, java.io.File dest)
          Copy the specified file or directory to the destination.
static boolean copyInternal(java.io.File src, java.io.File dest, byte[] buf)
          Copy the specified file or directory to the destination.
protected  void deploy(java.io.PrintWriter writer, java.lang.String path, java.lang.String tag)
          Install an application for the specified path from the specified web application archive.
protected  void deploy(java.io.PrintWriter writer, java.lang.String path, java.lang.String tag, boolean update, javax.servlet.http.HttpServletRequest request)
          Deploy a web application archive (included in the current request) at the specified context path.
protected  void deploy(java.io.PrintWriter writer, java.lang.String config, java.lang.String path, java.lang.String war, boolean update)
          Install an application for the specified path from the specified web application archive.
 void destroy()
          Finalize this servlet.
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Process a GET request for the specified resource.
 void doPut(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Process a PUT request for the specified resource.
protected  void expireSessions(java.io.PrintWriter writer, java.lang.String path, javax.servlet.http.HttpServletRequest req)
          Extract the expiration request parameter
protected  void findleaks(java.io.PrintWriter writer)
          Find potential memory leaks caused by web application reload.
protected  java.io.File getAppBase()
          Return a File object representing the "application root" directory for our associated Host.
protected  java.lang.String getConfigFile(java.lang.String path)
          Given a context path, get the config file name.
protected  java.lang.String getDocBase(java.lang.String path)
          Given a context path, get the doc base.
 Wrapper getWrapper()
          Return the Wrapper with which we are associated.
 void init()
          Initialize this servlet.
protected  boolean isDeployed(java.lang.String name)
          Invoke the isDeployed method on the deployer.
protected  boolean isServiced(java.lang.String name)
          Invoke the isServiced method on the deployer.
protected  void list(java.io.PrintWriter writer)
          Render a list of the currently active Contexts in our virtual host.
protected  void printResources(java.io.PrintWriter writer, java.lang.String prefix, javax.naming.Context namingContext, java.lang.String type, java.lang.Class clazz)
          List the resources of the given context.
protected  void reload(java.io.PrintWriter writer, java.lang.String path)
          Reload the web application at the specified context path.
protected  void removeServiced(java.lang.String name)
          Invoke the removeServiced method on the deployer.
protected  void resources(java.io.PrintWriter writer, java.lang.String type)
          Render a list of available global JNDI resources.
protected  void roles(java.io.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  void save(java.io.PrintWriter writer, java.lang.String path)
          Store server configuration.
protected  void serverinfo(java.io.PrintWriter writer)
          Writes System OS and JVM properties.
protected  void sessions(java.io.PrintWriter writer, java.lang.String path)
          Session information for the web application at the specified context path.
protected  void sessions(java.io.PrintWriter writer, java.lang.String path, int idle)
          Session information for the web application at the specified context path.
 void setWrapper(Wrapper wrapper)
          Set the Wrapper with which we are associated.
protected  void start(java.io.PrintWriter writer, java.lang.String path)
          Start the web application at the specified context path.
protected  void stop(java.io.PrintWriter writer, java.lang.String path)
          Stop the web application at the specified context path.
protected  void undeploy(java.io.PrintWriter writer, java.lang.String path)
          Undeploy the web application at the specified context path.
protected  void undeployDir(java.io.File dir)
          Delete the specified directory, including all of its contents and subdirectories recursively.
protected  void uploadWar(javax.servlet.http.HttpServletRequest request, java.io.File war)
          Upload the WAR file included in this request, and store it at the specified file location.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configBase

protected java.io.File configBase
Path where context descriptors should be deployed.


context

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


debug

protected int debug
The debugging detail level for this servlet.


deployed

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


versioned

protected java.io.File versioned
Path used to store revisions of webapps.


contextDescriptors

protected java.io.File contextDescriptors
Path used to store context descriptors.


host

protected Host host
The associated host.


appBase

protected java.io.File appBase
The host appBase.


mBeanServer

protected javax.management.MBeanServer mBeanServer
MBean server.


oname

protected javax.management.ObjectName oname
The associated deployer ObjectName.


global

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


sm

protected static StringManager sm
The string manager for this package.


wrapper

protected Wrapper wrapper
The Wrapper container associated with this servlet.

Constructor Detail

ManagerServlet

public ManagerServlet()
Method Detail

getWrapper

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

Specified by:
getWrapper in interface ContainerServlet

setWrapper

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

Specified by:
setWrapper in interface ContainerServlet
Parameters:
wrapper - The new wrapper

destroy

public void destroy()
Finalize this servlet.

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws java.io.IOException,
                  javax.servlet.ServletException
Process a GET request for the specified resource.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
request - The servlet request we are processing
response - The servlet response we are creating
Throws:
java.io.IOException - if an input/output error occurs
javax.servlet.ServletException - if a servlet-specified error occurs
See Also:
ServletResponse.setContentType(java.lang.String)

doPut

public void doPut(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws java.io.IOException,
                  javax.servlet.ServletException
Process a PUT request for the specified resource.

Overrides:
doPut in class javax.servlet.http.HttpServlet
Parameters:
request - The servlet request we are processing
response - The servlet response we are creating
Throws:
java.io.IOException - if an input/output error occurs
javax.servlet.ServletException - if a servlet-specified error occurs

init

public void init()
          throws javax.servlet.ServletException
Initialize this servlet.

Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException - if an exception occurs that interrupts the servlet's normal operation

findleaks

protected void findleaks(java.io.PrintWriter writer)
Find potential memory leaks caused by web application reload.


save

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

Parameters:
path - Optional context path to save

deploy

protected void deploy(java.io.PrintWriter writer,
                      java.lang.String path,
                      java.lang.String tag,
                      boolean update,
                      javax.servlet.http.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(java.io.PrintWriter writer,
                      java.lang.String path,
                      java.lang.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(java.io.PrintWriter writer,
                      java.lang.String config,
                      java.lang.String path,
                      java.lang.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

list

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

Parameters:
writer - Writer to render to

reload

protected void reload(java.io.PrintWriter writer,
                      java.lang.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

resources

protected void resources(java.io.PrintWriter writer,
                         java.lang.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

printResources

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


roles

protected void roles(java.io.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

serverinfo

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

Parameters:
writer - Writer to render to

sessions

protected void sessions(java.io.PrintWriter writer,
                        java.lang.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(java.io.PrintWriter writer,
                        java.lang.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

expireSessions

protected void expireSessions(java.io.PrintWriter writer,
                              java.lang.String path,
                              javax.servlet.http.HttpServletRequest req)
Extract the expiration request parameter

Parameters:
path -
req -

start

protected void start(java.io.PrintWriter writer,
                     java.lang.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(java.io.PrintWriter writer,
                    java.lang.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(java.io.PrintWriter writer,
                        java.lang.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

getConfigFile

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


getDocBase

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


getAppBase

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


isDeployed

protected boolean isDeployed(java.lang.String name)
                      throws java.lang.Exception
Invoke the isDeployed method on the deployer.

Throws:
java.lang.Exception

check

protected void check(java.lang.String name)
              throws java.lang.Exception
Invoke the check method on the deployer.

Throws:
java.lang.Exception

isServiced

protected boolean isServiced(java.lang.String name)
                      throws java.lang.Exception
Invoke the isServiced method on the deployer.

Throws:
java.lang.Exception

addServiced

protected void addServiced(java.lang.String name)
                    throws java.lang.Exception
Invoke the addServiced method on the deployer.

Throws:
java.lang.Exception

removeServiced

protected void removeServiced(java.lang.String name)
                       throws java.lang.Exception
Invoke the removeServiced method on the deployer.

Throws:
java.lang.Exception

undeployDir

protected void undeployDir(java.io.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(javax.servlet.http.HttpServletRequest request,
                         java.io.File war)
                  throws java.io.IOException
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:
java.io.IOException - if an I/O error occurs during processing

copy

public static boolean copy(java.io.File src,
                           java.io.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(java.io.File src,
                                   java.io.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

Apache Tomcat 6.0.43

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