ContextManager controls requests processing and server configuration. It maintains a list of Contexts ( web applications ) and a list of global modules that deal with server configuration and request processing, and global properties ( directories, general settings, etc ). The request processing is similar with Apache and other servers, with the addition of a "contextMap" chain that will select a tomcat-specific.
Configuration and startup
Starting tomcat involves a number of actions and states. In order to start tomcat:
- Create ContextManager. The server state is STATE_NEW
- Set properties for ContextManager ( home, debug, etc).
- Add the initial set of modules ( addInterceptor() ). ContextManager will call setContextManager() and then the addInterceptor() hook.
- Add the initial set of web applications ( Contexts ). Configuration modules can also add web applications - but no "addContext" hook will be called ( since the server is not initialized ).
- Call init().
- Init will notify all modules using the engineInit() hook. At this point the ContextManager will be in STATE_CONFIG.
- It'll then call addContext() hooks for each context that were added by config modules. Contexts will be in STATE_ADDED.
- It'll then call context.init() hooks for each context that were added by config modules. Contexts will be in STATE_READY.
- After all contexts are added and initialized, server will be in STATE_INIT.
XXX Do we need finer control ? ( like initModules(), initContexts() ? ) - At this point the server is fully configured, but not started. The user can add/remove modules and applications - the rules are defined in "run-time configuration".
- Call start(). The engineStart() hook will be called, the connector modules should accept and serve requests.
- Call stop() to stop the server ( engineStop() hook will be called, no requests more will be accepted )
- Call shutdown() to clean up all resources in use by web applications and modules. The server will revert to STATE_CONFIG.
- contextShutdown() will be called for each application. Modules must clean any resources allocated for that context.
- removeContext() will be called for each application.
- engineShutdown() will be called for each module
Runtime configuration
XXX The only "supported" feature is adding/removing web applications. Since each module can have a set of local modules, you can change the configuration or modules for each context. Changing "global" modules may work, but it's not finalized or tested. While tomcat is running, you can temporarily disable web applications, remove and add new applications.
@author James Duncan Davidson [duncan@eng.sun.com]
@author James Todd [gonzo@eng.sun.com]
@author Harish Prabandham
@author Costin Manolache
@author Hans Bergsten [hans@gefionsoftware.com]