org.apache.jk.config

Class BaseJkConfig

public class BaseJkConfig extends 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:

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

Version: $Revision: 467222 $

Author: Costin Manolache Larry Isaacs Bill Barker

Field Summary
protected booleanappend
protected FileconfigHome
protected booleanforwardAll
protected StringjkDebug
protected FilejkLog
protected StringjkWorker
protected booleanlegacy
protected booleannoRoot
protected booleanregenerate
protected StringtomcatHome
protected FileworkersConfig
Method Summary
protected booleanaddExtensionMapping(String ctxPath, String ext, PrintWriter pw)
Add an extension mapping.
protected booleanaddMapping(String fullPath, PrintWriter pw)
Add a fulling specified mapping.
voidexecute(LifecycleEvent evt)
Generate configuration files.
voidexecuteContext(Context context, PrintWriter mod_jk)
executes the ApacheConfig interceptor.
protected voidexecuteEngine(Engine egn, PrintWriter mod_jk)
Generate configuration files.
protected voidexecuteHost(Host hst, PrintWriter mod_jk)
Generate configuration files.
voidexecuteServer(Server svr, PrintWriter mod_jk)
Generate configuration files.
protected voidgenerateContextMappings(Context context, PrintWriter mod_jk)
protected booleangenerateJkHead(PrintWriter mod_jk)
Generate general options
protected voidgenerateJkTail(PrintWriter mod_jk)
Generate general options
protected voidgenerateSSLConfig(PrintWriter mod_jk)
Generate SSL options
protected voidgenerateStupidMappings(Context context, PrintWriter mod_jk)
protected voidgenerateVhostHead(Host host, PrintWriter mod_jk)
Generate Virtual Host start
protected voidgenerateVhostTail(Host host, PrintWriter mod_jk)
Generate Virtual Host end
protected StringgetAbsoluteDocBase(Context context)
static FilegetConfigFile(File base, File configDir, String defaultF)
protected HostgetHost(Container child)
Get the host associated with this Container (if any).
protected PrintWritergetWriter()
Get the output Writer.
protected voidinitProperties()
Initialize defaults for properties that are not set explicitely
static booleanisAbsolute(String path)
voidlifecycleEvent(LifecycleEvent evt)
Generate the configuration - only when the server is completely initialized ( before starting )
static Stringpatch(String path)
voidsetAppend(boolean apnd)
Append to config file.
voidsetConfigHome(String dir)
set a path to the parent directory of the conf folder.
voidsetForwardAll(boolean b)
If false, we'll try to generate a config that will let apache serve static files.
voidsetJkDebug(String level)
Set the verbosity level ( use debug, error, etc.
voidsetJkLog(String path)
set the path to the log file
voidsetJkWorker(String worker)
Sets the JK worker.
voidsetLegacy(boolean legacy)
voidsetNoRoot(boolean b)
Special option - do not generate mappings for the ROOT context.
voidsetWorkersConfig(String path)
set a path to the workers.properties file.

Field Detail

append

protected boolean append

configHome

protected File configHome

forwardAll

protected boolean forwardAll

jkDebug

protected String jkDebug

jkLog

protected File jkLog

jkWorker

protected String jkWorker

legacy

protected boolean legacy

noRoot

protected boolean noRoot

regenerate

protected boolean regenerate

tomcatHome

protected String tomcatHome

workersConfig

protected File workersConfig

Method Detail

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: context a Context object. mod_jk Writer for output.

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()
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 )

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: dir - path to a directory

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: path String path to a file

setJkWorker

public void setJkWorker(String worker)
Sets the JK worker.

Parameters: worker The worker

setLegacy

public void setLegacy(boolean legacy)

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: path String path to workers.properties file

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.