org.apache.ajp.tomcat4.config

Class BaseJkConfig

Implemented Interfaces:
LifecycleListener
Known Direct Subclasses:
ApacheConfig, IISConfig, NSConfig

public class BaseJkConfig
extends java.lang.Object
implements LifecycleListener

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:

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

Version:
$Revision: 1.5 $

Authors:
Costin Manolache
Larry Isaacs
Bill Barker

Field Summary

protected boolean
append
protected File
configHome
protected int
debug
protected boolean
forwardAll
protected String
jkDebug
protected File
jkLog
protected String
jkWorker
protected boolean
noRoot
protected boolean
regenerate
protected String
tomcatHome
protected File
workersConfig

Method Summary

protected boolean
addExtensionMapping(String ctxPath, String ext, PrintWriter pw)
Add an extension mapping.
protected boolean
addMapping(String fullPath, PrintWriter pw)
Add a fulling specified mapping.
void
execute(LifecycleEvent evt)
Generate configuration files.
void
executeContext(Context context, PrintWriter mod_jk)
executes the ApacheConfig interceptor.
protected void
executeEngine(Engine egn, PrintWriter mod_jk)
Generate configuration files.
protected void
executeHost(Host hst, PrintWriter mod_jk)
Generate configuration files.
void
executeServer(Server svr, PrintWriter mod_jk)
Generate configuration files.
protected void
generateContextMappings(Context context, PrintWriter mod_jk)
protected boolean
generateJkHead(PrintWriter mod_jk)
Generate general options
protected void
generateJkTail(PrintWriter mod_jk)
Generate general options
protected void
generateSSLConfig(PrintWriter mod_jk)
Generate SSL options
protected void
generateStupidMappings(Context context, PrintWriter mod_jk)
protected void
generateVhostHead(Host host, PrintWriter mod_jk)
Generate Virtual Host start
protected void
generateVhostTail(Host host, PrintWriter mod_jk)
Generate Virtual Host end
protected String
getAbsoluteDocBase(Context context)
static File
getConfigFile(File base, File configDir, String defaultF)
protected Host
getHost(Container child)
Get the host associated with this Container (if any).
protected PrintWriter
getWriter()
Get the output Writer.
protected void
initProperties()
Initialize defaults for properties that are not set explicitely
static boolean
isAbsolute(String path)
void
lifecycleEvent(LifecycleEvent evt)
Generate the configuration - only when the server is completely initialized ( before starting )
protected void
log(String msg)
static String
patch(String path)
void
setAppend(boolean apnd)
Append to config file.
void
setConfigHome(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(String level)
Set the verbosity level ( use debug, error, etc.
void
setJkLog(String path)
set the path to the log file
void
setJkWorker(String worker)
set the Ajp protocal
void
setNoRoot(boolean b)
Special option - do not generate mappings for the ROOT context.
void
setWorkersConfig(String path)
set a path to the workers.properties file.

Field Details

append

protected boolean append


configHome

protected File configHome


debug

protected int debug


forwardAll

protected boolean forwardAll


jkDebug

protected String jkDebug


jkLog

protected File jkLog


jkWorker

protected String jkWorker


noRoot

protected boolean noRoot


regenerate

protected boolean regenerate


tomcatHome

protected String tomcatHome


workersConfig

protected File workersConfig

Method Details

addExtensionMapping

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


addMapping

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


execute

public void execute(LifecycleEvent evt)
Generate configuration files. Override with method to generate web server specific configuration.


executeContext

public void executeContext(Context context,
                           PrintWriter mod_jk)
executes the ApacheConfig interceptor. This method generates apache configuration files for use with mod_jk.

Parameters:


executeEngine

protected void executeEngine(Engine egn,
                             PrintWriter mod_jk)
Generate configuration files. Override with method to generate web server specific configuration.


executeHost

protected void executeHost(Host hst,
                           PrintWriter mod_jk)
Generate configuration files. Override with method to generate web server specific configuration.


executeServer

public void executeServer(Server svr,
                          PrintWriter mod_jk)
Generate configuration files. Override with method to generate web server specific configuration.


generateContextMappings

protected void generateContextMappings(Context context,
                                       PrintWriter mod_jk)


generateJkHead

protected boolean generateJkHead(PrintWriter mod_jk)
Generate general options


generateJkTail

protected void generateJkTail(PrintWriter mod_jk)
Generate general options


generateSSLConfig

protected void generateSSLConfig(PrintWriter mod_jk)
Generate SSL options


generateStupidMappings

protected void generateStupidMappings(Context context,
                                      PrintWriter mod_jk)


generateVhostHead

protected void generateVhostHead(Host host,
                                 PrintWriter mod_jk)
Generate Virtual Host start


generateVhostTail

protected void generateVhostTail(Host host,
                                 PrintWriter mod_jk)
Generate Virtual Host end


getAbsoluteDocBase

protected String getAbsoluteDocBase(Context context)


getConfigFile

public static File getConfigFile(File base,
                                 File configDir,
                                 String defaultF)


getHost

protected Host getHost(Container child)
Get the host associated with this Container (if any).


getWriter

protected PrintWriter getWriter()
            throws IOException
Get the output Writer. Override with method to generate web server specific configuration.


initProperties

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


isAbsolute

public static boolean isAbsolute(String path)


lifecycleEvent

public void lifecycleEvent(LifecycleEvent evt)
Generate the configuration - only when the server is completely initialized ( before starting )
Specified by:
lifecycleEvent in interface LifecycleListener


log

protected void log(String msg)


patch

public static String patch(String path)


setAppend

public void setAppend(boolean apnd)
Append to config file. Set to true if the config information should be appended.


setConfigHome

public void setConfigHome(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.

Parameters:


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.


setJkDebug

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


setJkLog

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

Parameters:


setJkWorker

public void setJkWorker(String worker)
set the Ajp protocal

Parameters:


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.


setWorkersConfig

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

Parameters:


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.