public class ManagerServlet extends HttpServlet implements ContainerServlet
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:
docBase
attribute
of the context configuration file is used to locate the actual
WAR or directory containing the application.{config-url}
, overriding the
docBase
attribute with the contents of the web
application archive found at {war-url}
./xxx
, based
on the contents of the web application archive found at the
specified URL.path:status:sessions
.
Where path is the context path. Status is either running or stopped.
Sessions is the number of active Sessions./xxx
for this
virtual host./xxx
which were idle for at
least mm minutes./xxx
for this virtual host./xxx
for this virtual host./xxx
for this virtual host,
and remove the underlying WAR file or document base directory.
(NOTE - This is only allowed if the WAR file or document
base is stored in the appBase
directory of this host,
typically as a result of being placed there via the /deploy
command./xxx
to an appropriately
named context.xml file in the xmlBase
for the associated
Host.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.
The following servlet initialization parameters are recognized:
Modifier and Type | Field and Description |
---|---|
protected File |
configBase
Path where context descriptors should be deployed.
|
protected Context |
context
The Context container associated with our web application.
|
protected int |
debug
The debugging detail level for this servlet.
|
protected Context |
global
The global JNDI
NamingContext for this server,
if available. |
protected Host |
host
The associated host.
|
protected MBeanServer |
mBeanServer
MBean server.
|
protected ObjectName |
oname
The associated deployer ObjectName.
|
protected static StringManager |
sm
The string manager for this package.
|
protected File |
versioned
Path used to store revisions of webapps.
|
protected Wrapper |
wrapper
The Wrapper container associated with this servlet.
|
Constructor and Description |
---|
ManagerServlet() |
Modifier and Type | Method and Description |
---|---|
protected void |
addServiced(String name)
Invoke the addServiced method on the deployer.
|
protected void |
check(String name)
Invoke the check method on the deployer.
|
static boolean |
copy(File src,
File dest)
Copy the specified file or directory to the destination.
|
static boolean |
copyInternal(File src,
File dest,
byte[] buf)
Copy the specified file or directory to the destination.
|
protected void |
deploy(PrintWriter writer,
ContextName cn,
String tag,
boolean update,
HttpServletRequest request,
StringManager smClient)
Deploy a web application archive (included in the current request)
at the specified context path.
|
protected void |
deploy(PrintWriter writer,
ContextName cn,
String tag,
StringManager smClient)
Install an application for the specified path from the specified
web application archive.
|
protected void |
deploy(PrintWriter writer,
String config,
ContextName cn,
String war,
boolean update,
StringManager smClient)
Install an application for the specified path from the specified
web application archive.
|
void |
destroy()
Finalize this servlet.
|
void |
doGet(HttpServletRequest request,
HttpServletResponse response)
Process a GET request for the specified resource.
|
void |
doPut(HttpServletRequest request,
HttpServletResponse response)
Process a PUT request for the specified resource.
|
protected void |
expireSessions(PrintWriter writer,
ContextName cn,
HttpServletRequest req,
StringManager smClient)
Extract the expiration request parameter
|
protected void |
findleaks(boolean statusLine,
PrintWriter writer,
StringManager smClient)
Find potential memory leaks caused by web application reload.
|
protected Map<String,Set<String>> |
getConnectorCiphers() |
Wrapper |
getWrapper()
Return the Wrapper with which we are associated.
|
void |
init()
Initialize this servlet.
|
protected boolean |
isDeployed(String name)
Invoke the isDeployed method on the deployer.
|
protected boolean |
isServiced(String name)
Invoke the isServiced method on the deployer.
|
protected void |
list(PrintWriter writer,
StringManager smClient)
Render a list of the currently active Contexts in our virtual host.
|
protected void |
printResources(PrintWriter writer,
String prefix,
Context namingContext,
String type,
Class<?> clazz,
StringManager smClient)
List the resources of the given context.
|
protected void |
reload(PrintWriter writer,
ContextName cn,
StringManager smClient)
Reload the web application at the specified context path.
|
protected void |
removeServiced(String name)
Invoke the removeServiced method on the deployer.
|
protected void |
resources(PrintWriter writer,
String type,
StringManager smClient)
Render a list of available global JNDI resources.
|
protected void |
save(PrintWriter writer,
String path,
StringManager smClient)
Store server configuration.
|
protected void |
serverinfo(PrintWriter writer,
StringManager smClient)
Writes System OS and JVM properties.
|
protected void |
sessions(PrintWriter writer,
ContextName cn,
int idle,
StringManager smClient)
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 |
sslConnectorCiphers(PrintWriter writer,
StringManager smClient) |
protected void |
start(PrintWriter writer,
ContextName cn,
StringManager smClient)
Start the web application at the specified context path.
|
protected void |
stop(PrintWriter writer,
ContextName cn,
StringManager smClient)
Stop the web application at the specified context path.
|
protected void |
threadDump(PrintWriter writer,
StringManager smClient,
Enumeration<Locale> requestedLocales)
Write a JVM thread dump.
|
protected void |
undeploy(PrintWriter writer,
ContextName cn,
StringManager smClient)
Undeploy the web application at the specified context path.
|
protected boolean |
undeployDir(File dir)
Delete the specified directory, including all of its contents and
subdirectories recursively.
|
protected void |
uploadWar(PrintWriter writer,
HttpServletRequest request,
File war,
StringManager smClient)
Upload the WAR file included in this request, and store it at the
specified file location.
|
protected static boolean |
validateContextName(ContextName cn,
PrintWriter writer,
StringManager sm) |
protected void |
vmInfo(PrintWriter writer,
StringManager smClient,
Enumeration<Locale> requestedLocales)
Write some VM info.
|
doDelete, doHead, doOptions, doPost, doTrace, getLastModified, service, service
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
protected File configBase
protected transient Context context
protected int debug
protected File versioned
protected transient Host host
protected transient MBeanServer mBeanServer
protected ObjectName oname
protected transient Context global
NamingContext
for this server,
if available.protected static final StringManager sm
protected transient Wrapper wrapper
public Wrapper getWrapper()
getWrapper
in interface ContainerServlet
public void setWrapper(Wrapper wrapper)
setWrapper
in interface ContainerServlet
wrapper
- The new wrapperpublic void destroy()
destroy
in interface Servlet
destroy
in class GenericServlet
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
doGet
in class HttpServlet
request
- The servlet request we are processingresponse
- The servlet response we are creatingIOException
- if an input/output error occursServletException
- if a servlet-specified error occursServletResponse.setContentType(java.lang.String)
public void doPut(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
doPut
in class HttpServlet
request
- The servlet request we are processingresponse
- The servlet response we are creatingIOException
- if an input/output error occursServletException
- if a servlet-specified error occurspublic void init() throws ServletException
init
in class GenericServlet
ServletException
- if an exception occurs that interrupts the servlet's
normal operationprotected void findleaks(boolean statusLine, PrintWriter writer, StringManager smClient)
statusLine
- Print a status linewriter
- The output writersmClient
- StringManager for the client's localeprotected void vmInfo(PrintWriter writer, StringManager smClient, Enumeration<Locale> requestedLocales)
writer
- The output writersmClient
- StringManager for the client's localerequestedLocales
- the client's localesprotected void threadDump(PrintWriter writer, StringManager smClient, Enumeration<Locale> requestedLocales)
writer
- The output writersmClient
- StringManager for the client's localerequestedLocales
- the client's localesprotected void sslConnectorCiphers(PrintWriter writer, StringManager smClient)
protected void save(PrintWriter writer, String path, StringManager smClient)
writer
- Destination for any user message(s) during this operationpath
- Optional context path to savesmClient
- i18n support for current client's localeprotected void deploy(PrintWriter writer, ContextName cn, String tag, boolean update, HttpServletRequest request, StringManager smClient)
writer
- Writer to render results tocn
- Name of the application to be installedtag
- Tag to be associated with the webappupdate
- Flag that indicates that any existing app should be
replacedrequest
- Servlet request we are processingsmClient
- i18n messages using the locale of the clientprotected void deploy(PrintWriter writer, ContextName cn, String tag, StringManager smClient)
writer
- Writer to render results totag
- Revision tag to deploy fromcn
- Name of the application to be installedsmClient
- i18n messages using the locale of the clientprotected void deploy(PrintWriter writer, String config, ContextName cn, String war, boolean update, StringManager smClient)
writer
- Writer to render results toconfig
- URL of the context configuration file to be installedcn
- Name of the application to be installedwar
- URL of the web application archive to be installedupdate
- true to override any existing webapp on the pathsmClient
- i18n messages using the locale of the clientprotected void list(PrintWriter writer, StringManager smClient)
writer
- Writer to render tosmClient
- i18n support for current client's localeprotected void reload(PrintWriter writer, ContextName cn, StringManager smClient)
writer
- Writer to render tocn
- Name of the application to be restartedsmClient
- i18n support for current client's localeprotected void resources(PrintWriter writer, String type, StringManager smClient)
writer
- Writer to render totype
- Fully qualified class name of the resource type of interest,
or null
to list resources of all typessmClient
- i18n support for current client's localeprotected void printResources(PrintWriter writer, String prefix, Context namingContext, String type, Class<?> clazz, StringManager smClient)
writer
- Writer to render toprefix
- Path for recursionnamingContext
- The naming context for lookupstype
- Fully qualified class name of the resource type of interest,
or null
to list resources of all typesclazz
- The resource class or null
to list
resources of all typessmClient
- i18n support for current client's localeprotected void serverinfo(PrintWriter writer, StringManager smClient)
writer
- Writer to render tosmClient
- i18n support for current client's localeprotected void sessions(PrintWriter writer, ContextName cn, int idle, StringManager smClient)
writer
- Writer to render tocn
- Name of the application to list session information foridle
- Expire all sessions with idle time > idle for this contextsmClient
- i18n support for current client's localeprotected void expireSessions(PrintWriter writer, ContextName cn, HttpServletRequest req, StringManager smClient)
writer
- Writer to render tocn
- Name of the application to list session information forreq
- The Servlet requestsmClient
- i18n support for current client's localeprotected void start(PrintWriter writer, ContextName cn, StringManager smClient)
writer
- Writer to render tocn
- Name of the application to be startedsmClient
- i18n support for current client's localeprotected void stop(PrintWriter writer, ContextName cn, StringManager smClient)
writer
- Writer to render tocn
- Name of the application to be stoppedsmClient
- i18n support for current client's localeprotected void undeploy(PrintWriter writer, ContextName cn, StringManager smClient)
writer
- Writer to render tocn
- Name of the application to be removedsmClient
- i18n support for current client's localeprotected boolean isDeployed(String name) throws Exception
name
- The webapp nametrue
if a webapp with that name is deployedException
- Propagate JMX invocation errorprotected void check(String name) throws Exception
name
- The webapp nameException
- Propagate JMX invocation errorprotected boolean isServiced(String name) throws Exception
name
- The webapp nametrue
if a webapp with that name is being servicedException
- Propagate JMX invocation errorprotected void addServiced(String name) throws Exception
name
- The webapp nameException
- Propagate JMX invocation errorprotected void removeServiced(String name) throws Exception
name
- The webapp nameException
- Propagate JMX invocation errorprotected boolean undeployDir(File dir)
dir
- File object representing the directory to be deleted.true
if the deletion was successfulprotected void uploadWar(PrintWriter writer, HttpServletRequest request, File war, StringManager smClient) throws IOException
writer
- Writer to render torequest
- The servlet request we are processingwar
- The file into which we should store the uploaded WARsmClient
- The StringManager used to construct i18n messages based
on the Locale of the clientIOException
- if an I/O error occurs during processingprotected static boolean validateContextName(ContextName cn, PrintWriter writer, StringManager sm)
public static boolean copy(File src, File dest)
src
- File object representing the sourcedest
- File object representing the destinationtrue
if the copy was successfulpublic static boolean copyInternal(File src, File dest, byte[] buf)
src
- File object representing the sourcedest
- File object representing the destinationbuf
- Temp byte buffertrue
if the copy was successfulCopyright © 2000-2016 Apache Software Foundation. All Rights Reserved.