org.apache.jk.config
Class BaseJkConfig

java.lang.Object
  extended byorg.apache.jk.config.BaseJkConfig
All Implemented Interfaces:
LifecycleListener
Direct Known 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:

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

Version:
$Revision: 466585 $
Author:
Costin Manolache, Larry Isaacs, Bill Barker

Field Summary
protected  boolean append
           
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 legacy
           
protected  boolean noRoot
           
protected  boolean regenerate
           
protected  java.lang.String tomcatHome
           
protected  java.io.File workersConfig
           
 
Constructor Summary
BaseJkConfig()
           
 
Method Summary
protected  boolean addExtensionMapping(java.lang.String ctxPath, java.lang.String ext, java.io.PrintWriter pw)
          Add an extension mapping.
protected  boolean addMapping(java.lang.String fullPath, java.io.PrintWriter pw)
          Add a fulling specified mapping.
 void execute(LifecycleEvent evt)
          Generate configuration files.
 void executeContext(Context context, java.io.PrintWriter mod_jk)
          executes the ApacheConfig interceptor.
protected  void executeEngine(Engine egn, java.io.PrintWriter mod_jk)
          Generate configuration files.
protected  void executeHost(Host hst, java.io.PrintWriter mod_jk)
          Generate configuration files.
 void executeServer(Server svr, java.io.PrintWriter mod_jk)
          Generate configuration files.
protected  void generateContextMappings(Context context, java.io.PrintWriter mod_jk)
           
protected  boolean generateJkHead(java.io.PrintWriter mod_jk)
          Generate general options
protected  void generateJkTail(java.io.PrintWriter mod_jk)
          Generate general options
protected  void generateSSLConfig(java.io.PrintWriter mod_jk)
          Generate SSL options
protected  void generateStupidMappings(Context context, java.io.PrintWriter mod_jk)
           
protected  void generateVhostHead(Host host, java.io.PrintWriter mod_jk)
          Generate Virtual Host start
protected  void generateVhostTail(Host host, java.io.PrintWriter mod_jk)
          Generate Virtual Host end
protected  java.lang.String getAbsoluteDocBase(Context context)
           
static java.io.File getConfigFile(java.io.File base, java.io.File configDir, java.lang.String defaultF)
           
protected  Host getHost(Container child)
          Get the host associated with this Container (if any).
protected  java.io.PrintWriter getWriter()
          Get the output Writer.
protected  void initProperties()
          Initialize defaults for properties that are not set explicitely
static boolean isAbsolute(java.lang.String path)
           
 void lifecycleEvent(LifecycleEvent evt)
          Generate the configuration - only when the server is completely initialized ( before starting )
static java.lang.String patch(java.lang.String path)
           
 void setAppend(boolean apnd)
          Append to config file.
 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. ) If not set, no log is written.
 void setJkLog(java.lang.String path)
          set the path to the log file
 void setJkWorker(java.lang.String worker)
          Sets the JK worker.
 void setLegacy(boolean legacy)
           
 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 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

append

protected boolean append

legacy

protected boolean legacy
Constructor Detail

BaseJkConfig

public BaseJkConfig()
Method Detail

lifecycleEvent

public void lifecycleEvent(LifecycleEvent evt)
Generate the configuration - only when the server is completely initialized ( before starting )

Specified by:
lifecycleEvent in interface LifecycleListener
Parameters:
evt - LifecycleEvent that has occurred

execute

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


executeServer

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


generateSSLConfig

protected void generateSSLConfig(java.io.PrintWriter mod_jk)
Generate SSL options


generateJkHead

protected boolean generateJkHead(java.io.PrintWriter mod_jk)
Generate general options


generateJkTail

protected void generateJkTail(java.io.PrintWriter mod_jk)
Generate general options


generateVhostHead

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


generateVhostTail

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


executeEngine

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


executeHost

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


executeContext

public void executeContext(Context context,
                           java.io.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.

generateStupidMappings

protected void generateStupidMappings(Context context,
                                      java.io.PrintWriter mod_jk)

generateContextMappings

protected void generateContextMappings(Context context,
                                       java.io.PrintWriter mod_jk)

getWriter

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

Throws:
java.io.IOException

getHost

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


setAppend

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


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.

Parameters:
dir - - path to a directory

setWorkersConfig

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

Parameters:
path - String path to workers.properties file

setJkLog

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

Parameters:
path - String path to a 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)
Sets the JK worker.

Parameters:
worker - The worker

setLegacy

public void setLegacy(boolean legacy)

initProperties

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


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)

getConfigFile

public static java.io.File getConfigFile(java.io.File base,
                                         java.io.File configDir,
                                         java.lang.String defaultF)

patch

public static java.lang.String patch(java.lang.String path)

isAbsolute

public static boolean isAbsolute(java.lang.String path)


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