org.apache.tomcat.core
Class ContextManager

java.lang.Object
  |
  +--org.apache.tomcat.core.ContextManager

public class ContextManager
extends java.lang.Object

A collection class representing the Contexts associated with a particular Server. The managed Contexts can be accessed by path. It also store global default properties - the server name and port ( returned by getServerName(), etc) and workdir.

Author:
James Duncan Davidson [duncan@eng.sun.com], James Todd [gonzo@eng.sun.com], Harish Prabandham

Field Summary
static java.lang.String DEFAULT_HOSTNAME
           
static int DEFAULT_PORT
           
static java.lang.String DEFAULT_WORK_DIR
           
 
Constructor Summary
ContextManager()
          Construct a new ContextManager instance with default values.
 
Method Summary
 void addContainer(Container container)
           
 void addContext(Context ctx)
          Adds a new Context to the set managed by this ContextManager.
 void addContextInterceptor(ContextInterceptor ci)
           
 void addLogger(org.apache.tomcat.logging.Logger logger)
           
 void addRequestInterceptor(RequestInterceptor ri)
           
 void addServerConnector(ServerConnector con)
          Add the specified server connector to the those attached to this server.
 void doLog(java.lang.String msg)
           
 void doLog(java.lang.String msg, java.lang.Throwable t)
           
 java.util.Enumeration getConnectors()
           
 Context getContext(java.lang.String name)
          Gets a context by it's name, or null if there is no such context.
 ContextInterceptor[] getContextInterceptors()
          Return the context interceptors as an array.
 java.util.Enumeration getContextNames()
          Get the names of all the contexts in this server.
 int getDebug()
           
 java.lang.String getHome()
          The root directory of tomcat
 java.lang.String getHostName()
          Deprecated.  
 int getPort()
          Deprecated.  
 RequestInterceptor[] getRequestInterceptors()
          Return the context interceptors as an array.
 java.lang.String getTomcatHome()
          Tomcat installation directory, where libraries and default files are located
 java.lang.String getWorkDir()
           
 void init()
          Init() is called after the context manager is set up and configured.
 void initContext(Context ctx)
          Initializes this context to take on requests.
 void log(java.lang.String msg)
           
 void removeContainer(Container container)
           
 void removeContext(java.lang.String name)
          Shut down and removes a context from service.
 void service(Request rrequest, Response rresponse)
          Common for all connectors, needs to be shared in order to avoid code duplication
 void setDebug(int level)
           
 void setDefaults()
          Set default settings ( interceptors, connectors, loader, manager ) It is called from init if no connector is set up - note that we try to avoid any "magic" - you either set up everything ( using server.xml or alternatives) or you don't set up and then defaults will be used.
 void setHome(java.lang.String home)
          Set installation directory.
 void setHostName(java.lang.String host)
          Deprecated.  
 void setPort(int port)
          Deprecated.  
 void setTomcatHome(java.lang.String tH)
           
 void setWorkDir(java.lang.String wd)
          WorkDir property - where all temporary files will be created
 void shutdownContext(Context ctx)
           
 void start()
          Will start the connectors and begin serving requests
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_HOSTNAME

public static final java.lang.String DEFAULT_HOSTNAME

DEFAULT_PORT

public static final int DEFAULT_PORT

DEFAULT_WORK_DIR

public static final java.lang.String DEFAULT_WORK_DIR
Constructor Detail

ContextManager

public ContextManager()
Construct a new ContextManager instance with default values.
Method Detail

setDefaults

public void setDefaults()
Set default settings ( interceptors, connectors, loader, manager ) It is called from init if no connector is set up - note that we try to avoid any "magic" - you either set up everything ( using server.xml or alternatives) or you don't set up and then defaults will be used. Set interceptors or call setDefaults before adding contexts.

getContextNames

public java.util.Enumeration getContextNames()
Get the names of all the contexts in this server.

init

public void init()
          throws TomcatException
Init() is called after the context manager is set up and configured.

initContext

public void initContext(Context ctx)
                 throws TomcatException
Initializes this context to take on requests. This action will cause the context to load it's configuration information from the webapp directory in the docbase.

This method may only be called once and must be called before any requests are handled by this context and after setContextManager() is called.


shutdownContext

public void shutdownContext(Context ctx)
                     throws TomcatException

start

public void start()
           throws java.lang.Exception
Will start the connectors and begin serving requests

stop

public void stop()
          throws java.lang.Exception

getContext

public Context getContext(java.lang.String name)
Gets a context by it's name, or null if there is no such context.
Parameters:
name - Name of the requested context

addContext

public void addContext(Context ctx)
                throws TomcatException
Adds a new Context to the set managed by this ContextManager.
Parameters:
ctx - context to be added.

removeContext

public void removeContext(java.lang.String name)
                   throws TomcatException
Shut down and removes a context from service.
Parameters:
name - Name of the Context to be removed

addContainer

public void addContainer(Container container)
                  throws TomcatException

removeContainer

public void removeContainer(Container container)
                     throws TomcatException

addServerConnector

public void addServerConnector(ServerConnector con)
Add the specified server connector to the those attached to this server.
Parameters:
con - The new server connector

getConnectors

public java.util.Enumeration getConnectors()

addRequestInterceptor

public void addRequestInterceptor(RequestInterceptor ri)

getRequestInterceptors

public RequestInterceptor[] getRequestInterceptors()
Return the context interceptors as an array. For performance reasons we use an array instead of returning the vector - the interceptors will not change at runtime and array access is faster and easier than vector access

addContextInterceptor

public void addContextInterceptor(ContextInterceptor ci)

getContextInterceptors

public ContextInterceptor[] getContextInterceptors()
Return the context interceptors as an array. For performance reasons we use an array instead of returning the vector - the interceptors will not change at runtime and array access is faster and easier than vector access

addLogger

public void addLogger(org.apache.tomcat.logging.Logger logger)

getHome

public java.lang.String getHome()
The root directory of tomcat

getTomcatHome

public java.lang.String getTomcatHome()
Tomcat installation directory, where libraries and default files are located

setTomcatHome

public void setTomcatHome(java.lang.String tH)

setHome

public void setHome(java.lang.String home)
Set installation directory. If path specified is relative, evaluate it relative to the current working directory. This is used for the home attribute and it's used to find webapps and conf. Note that libs are probably already configured, so it will not affect that.

setPort

public void setPort(int port)
Deprecated.  

Sets the port number on which this server listens.
Parameters:
port - The new port number

getPort

public int getPort()
Deprecated.  

Gets the port number on which this server listens.

setHostName

public void setHostName(java.lang.String host)
Deprecated.  

Sets the virtual host name of this server.
Parameters:
host - The new virtual host name

getHostName

public java.lang.String getHostName()
Deprecated.  

Gets the virtual host name of this server.

setWorkDir

public void setWorkDir(java.lang.String wd)
WorkDir property - where all temporary files will be created

getWorkDir

public java.lang.String getWorkDir()

service

public void service(Request rrequest,
                    Response rresponse)
Common for all connectors, needs to be shared in order to avoid code duplication

setDebug

public void setDebug(int level)

getDebug

public int getDebug()

log

public final void log(java.lang.String msg)

doLog

public final void doLog(java.lang.String msg)

doLog

public final void doLog(java.lang.String msg,
                        java.lang.Throwable t)


Copyright © 2000 Apache Software Foundation. All Rights Reserved.