org.apache.tomcat.modules.config
Class BaseJkConfig

java.lang.Object
  extended byorg.apache.tomcat.core.BaseInterceptor
      extended byorg.apache.tomcat.modules.config.BaseJkConfig
Direct Known Subclasses:
ApacheConfig, IISConfig, NSConfig

public class BaseJkConfig
extends BaseInterceptor

Base class for automatic jk based configurations based on the Tomcat server.xml settings and the war contexts initialized during startup.

This config interceptor is enabled by inserting a Config element in the <ContextManager> tag body inside the server.xml file like so:

 < ContextManager ... >
   ...
   <???Config options />
   ...
 < /ContextManager >
    
where options can include any of the following attributes:

Version:
$Revision: 1.7 $
Author:
Costin Manolache, Larry Isaacs

Field Summary
protected  java.io.File configHome
           
protected  boolean forwardAll
           
protected  java.lang.String jkDebug
           
protected  java.io.File jkLog
           
protected  java.lang.String jkWorker
           
protected  boolean noRoot
           
protected  boolean regenerate
           
protected  java.lang.String tomcatHome
           
protected  java.io.File workersConfig
           
 
Fields inherited from class org.apache.tomcat.core.BaseInterceptor
cm, ct, ctx, debug, DECLINED, loghelper, OK
 
Constructor Summary
BaseJkConfig()
           
 
Method Summary
protected  boolean addExtensionMapping(java.lang.String ctxPath, java.lang.String ext, java.io.PrintWriter pw)
          Add an extension mapping.
 void addInterceptor(ContextManager cm, Context ctx, BaseInterceptor bi)
          Hook called when a new interceptor is added.
protected  boolean addMapping(Context ctx, Container ct, java.io.PrintWriter pw)
           
protected  boolean addMapping(java.lang.String fullPath, java.io.PrintWriter pw)
          Add a fulling specified mapping.
 void contextInit(Context ctx)
          Notify when a context is initialized.
 void engineState(ContextManager cm, int state)
          Generate the configuration - only when the server is completely initialized ( before starting )
 void execute(ContextManager cm)
          Generate configuration files.
protected  java.lang.String getAbsoluteDocBase(Context context)
           
protected  void initProperties(ContextManager cm)
          Initialize defaults for properties that are not set explicitely
protected  void initWorker(ContextManager cm)
           
 void setConfigHome(java.lang.String dir)
          set a path to the parent directory of the conf folder.
 void setForwardAll(boolean b)
          If false, we'll try to generate a config that will let apache serve static files.
 void setJkDebug(java.lang.String level)
          Set the verbosity level ( use debug, error, etc.
 void setJkLog(java.lang.String path)
          set the path to the log file
 void setJkWorker(java.lang.String worker)
          set the Ajp protocal
 void setNoRoot(boolean b)
          Special option - do not generate mappings for the ROOT context.
 void setWorkersConfig(java.lang.String path)
          set a path to the workers.properties file.
 
Methods inherited from class org.apache.tomcat.core.BaseInterceptor
addContainer, addContext, addHandler, addSecurityConstraint, afterBody, authenticate, authorize, beforeBody, beforeCommit, contextMap, contextShutdown, contextState, engineInit, engineShutdown, engineStart, engineStop, findSession, getContext, getContextManager, getDebug, getInfo, getLog, getNote, getNote, handleError, log, log, log, log, postReadRequest, postRequest, postService, postServletDestroy, postServletInit, preService, preServletDestroy, preServletInit, registerHooks, reload, removeContainer, removeContext, removeHandler, removeInterceptor, requestMap, sessionState, setContext, setContextManager, setDebug, setInfo, setNote, setNote
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configHome

protected java.io.File configHome

workersConfig

protected java.io.File workersConfig

jkLog

protected java.io.File jkLog

jkDebug

protected java.lang.String jkDebug

jkWorker

protected java.lang.String jkWorker

noRoot

protected boolean noRoot

forwardAll

protected boolean forwardAll

tomcatHome

protected java.lang.String tomcatHome

regenerate

protected boolean regenerate
Constructor Detail

BaseJkConfig

public BaseJkConfig()
Method Detail

addInterceptor

public void addInterceptor(ContextManager cm,
                           Context ctx,
                           BaseInterceptor bi)
                    throws TomcatException
Description copied from class: BaseInterceptor
Hook called when a new interceptor is added. All existing modules will be notified of the new added module. This hook will be called before the interceptor is initialized ( using engineInit hook ) An interceptor can add/remove other interceptors or applications, or alter the ordering of hooks, or change/set server properties.

Overrides:
addInterceptor in class BaseInterceptor
Parameters:
cm - the server
ctx - not null if this is a local interceptor
bi - the new added interceptor
Throws:
TomcatException - The module will not be added if any module throws an exception.

engineState

public void engineState(ContextManager cm,
                        int state)
                 throws TomcatException
Generate the configuration - only when the server is completely initialized ( before starting )

Overrides:
engineState in class BaseInterceptor
Throws:
TomcatException

contextInit

public void contextInit(Context ctx)
                 throws TomcatException
Description copied from class: BaseInterceptor
Notify when a context is initialized. The first interceptor in the chain for contextInit must read web.xml and set the context. When this method is called you can expect the context to be filled in with all the informations from web.xml.

Overrides:
contextInit in class BaseInterceptor
Throws:
TomcatException

execute

public void execute(ContextManager cm)
             throws TomcatException
Generate configuration files. Override with method to generate web server specific configuration.

Throws:
TomcatException

setForwardAll

public void setForwardAll(boolean b)
If false, we'll try to generate a config that will let apache serve static files. The default is true, forward all requests in a context to tomcat.


setNoRoot

public void setNoRoot(boolean b)
Special option - do not generate mappings for the ROOT context. The default is true, and will not generate the mappings, not redirecting all pages to tomcat (since /* matches everything). This means that the web server's root remains intact but isn't completely servlet/JSP enabled. If the ROOT webapp can be configured with the web server serving static files, there's no problem setting this option to false. If not, then setting it true means the web server will be out of picture for all requests.


setConfigHome

public void setConfigHome(java.lang.String dir)
set a path to the parent directory of the conf folder. That is, the parent directory within which path setters would be resolved against, if relative. For example if ConfigHome is set to "/home/tomcat" and regConfig is set to "conf/mod_jk.conf" then the resulting path used would be: "/home/tomcat/conf/mod_jk.conf".

However, if the path is set to an absolute path, this attribute is ignored.

If not set, execute() will set this to TOMCAT_HOME.


setWorkersConfig

public void setWorkersConfig(java.lang.String path)
set a path to the workers.properties file.


setJkLog

public void setJkLog(java.lang.String path)
set the path to the log file


setJkDebug

public void setJkDebug(java.lang.String level)
Set the verbosity level ( use debug, error, etc. ) If not set, no log is written.


setJkWorker

public void setJkWorker(java.lang.String worker)
set the Ajp protocal


initProperties

protected void initProperties(ContextManager cm)
Initialize defaults for properties that are not set explicitely


initWorker

protected void initWorker(ContextManager cm)

addMapping

protected boolean addMapping(Context ctx,
                             Container ct,
                             java.io.PrintWriter pw)

addExtensionMapping

protected boolean addExtensionMapping(java.lang.String ctxPath,
                                      java.lang.String ext,
                                      java.io.PrintWriter pw)
Add an extension mapping. Override with method to generate web server specific configuration


addMapping

protected boolean addMapping(java.lang.String fullPath,
                             java.io.PrintWriter pw)
Add a fulling specified mapping. Override with method to generate web server specific configuration


getAbsoluteDocBase

protected java.lang.String getAbsoluteDocBase(Context context)


Copyright © 2001 Apache Software Foundation. All Rights Reserved.