All Packages Class Hierarchy This Package Previous Next Index
Class org.apache.tomcat.core.ContextManager
java.lang.Object
|
+----org.apache.tomcat.core.ContextManager
- public class ContextManager
- extends 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
-
DEFAULT_HOSTNAME
-
-
DEFAULT_PORT
-
-
DEFAULT_WORK_DIR
-
-
ContextManager()
- Construct a new ContextManager instance with default values.
-
addContainer(Container)
-
-
addContext(Context)
- Adds a new Context to the set managed by this ContextManager.
-
addContextInterceptor(ContextInterceptor)
-
-
addLogger(Logger)
-
-
addRequestInterceptor(RequestInterceptor)
-
-
addServerConnector(ServerConnector)
- Add the specified server connector to the those attached to this server.
-
doLog(String)
-
-
doLog(String, Throwable)
-
-
getConnectors()
-
-
getContext(String)
- Gets a context by it's name, or
null
if there is
no such context.
-
getContextInterceptors()
- Return the context interceptors as an array.
-
getContextNames()
- Get the names of all the contexts in this server.
-
getDebug()
-
-
getHome()
- The root directory of tomcat
-
getHostName()
- Gets the virtual host name of this server.
Deprecated.
-
getPort()
- Gets the port number on which this server listens.
Deprecated.
-
getRequestInterceptors()
- Return the context interceptors as an array.
-
getTomcatHome()
- Tomcat installation directory, where libraries and default files are located
-
getWorkDir()
-
-
init()
- Init() is called after the context manager is set up
and configured.
-
initContext(Context)
- Initializes this context to take on requests.
-
log(String)
-
-
removeContainer(Container)
-
-
removeContext(String)
- Shut down and removes a context from service.
-
service(Request, Response)
- Common for all connectors, needs to be shared in order to avoid
code duplication
-
setDebug(int)
-
-
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.
-
setHome(String)
-
Set installation directory.
-
setHostName(String)
- Sets the virtual host name of this server.
Deprecated.
-
setPort(int)
- Sets the port number on which this server listens.
Deprecated.
-
setTomcatHome(String)
-
-
setWorkDir(String)
- WorkDir property - where all temporary files will be created
-
shutdownContext(Context)
-
-
start()
- Will start the connectors and begin serving requests
-
stop()
-
DEFAULT_HOSTNAME
public static final String DEFAULT_HOSTNAME
DEFAULT_PORT
public static final int DEFAULT_PORT
DEFAULT_WORK_DIR
public static final String DEFAULT_WORK_DIR
ContextManager
public ContextManager()
- Construct a new ContextManager instance with default values.
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 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 Exception
- Will start the connectors and begin serving requests
stop
public void stop() throws Exception
getContext
public Context getContext(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(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 synchronized void addServerConnector(ServerConnector con)
- Add the specified server connector to the those attached to this server.
- Parameters:
- con - The new server connector
getConnectors
public 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(Logger logger)
getHome
public String getHome()
- The root directory of tomcat
getTomcatHome
public String getTomcatHome()
- Tomcat installation directory, where libraries and default files are located
setTomcatHome
public void setTomcatHome(String tH)
setHome
public void setHome(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)
- Note: setPort() is deprecated.
- Sets the port number on which this server listens.
- Parameters:
- port - The new port number
getPort
public int getPort()
- Note: getPort() is deprecated.
- Gets the port number on which this server listens.
setHostName
public void setHostName(String host)
- Note: setHostName() is deprecated.
- Sets the virtual host name of this server.
- Parameters:
- host - The new virtual host name
getHostName
public String getHostName()
- Note: getHostName() is deprecated.
- Gets the virtual host name of this server.
setWorkDir
public void setWorkDir(String wd)
- WorkDir property - where all temporary files will be created
getWorkDir
public 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(String msg)
doLog
public final void doLog(String msg)
doLog
public final void doLog(String msg,
Throwable t)
All Packages Class Hierarchy This Package Previous Next Index