org.apache.tomcat.modules.config
Class JservConfig

java.lang.Object
  |
  +--org.apache.tomcat.core.BaseInterceptor
        |
        +--org.apache.tomcat.modules.config.JservConfig

public class JservConfig
extends BaseInterceptor

Generates automatic apache mod_jserv configurations based on the Tomcat server.xml settings and the war contexts initialized during startup.

This config interceptor is enabled by inserting a JservConfig element in the \ tag body inside the server.xml file like so:

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

Version:
$Revision: 1.5 $ $Date: 2001/12/17 05:24:09 $
Author:
Costin Manolache, Larry Isaacs, Mel Martinez

Field Summary
static java.lang.String AJPV12
           
static java.lang.String APACHE_CONFIG
          default path to JServ .conf location
static java.lang.String JSERV_LOG_LOCATION
          default mod_jserv log file location
static java.lang.String MOD_JSERV
          default location of mod_jserv Apache plug-in.
 
Fields inherited from class org.apache.tomcat.core.BaseInterceptor
cm, ct, ctx, debug, DECLINED, loghelper, OK
 
Constructor Summary
JservConfig()
           
 
Method Summary
protected  boolean addExtensionMapping(java.lang.String ctxPath, java.lang.String ext, java.io.PrintWriter pw)
          Add an Apache extension mapping.
protected  boolean addMapping(Context ctx, Container ct, java.io.PrintWriter pw)
           
protected  boolean addMapping(java.lang.String fullPath, java.lang.String app, java.io.PrintWriter pw)
          Add a fulling specified Appache mapping.
 void contextInit(Context ctx)
          Notify when a context is initialized.
 void engineState(ContextManager cm, int state)
          Generate the apache configuration - only when the server is completely initialized ( before starting )
 void execute(ContextManager cm)
          executes the JservConfig interceptor.
 java.io.File getConfigHome()
           
 void initProperties(ContextManager cm)
          Initialize defaults for properties that are not set explicitely
 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 setJservConfig(java.io.File path)
          sets a File object pointing to the output file in which to write the mod_jserv configuration.
 void setJservConfig(java.lang.String path)
          sets a path pointing to the output file in which to write the mod_jserv configuration.
 void setJservDebug(java.lang.String level)
          Set the verbosity level for mod_jserv.
 void setJservLog(java.lang.String path)
          set the path to the mod_jserv log file
 void setModJserv(java.io.File path)
          set the path to the Jserv Apache Module
 void setModJserv(java.lang.String path)
          set the path to the Jserv Apache Module
 void setNoRoot(boolean b)
          Special option - do not generate mappings for the ROOT context.
 
Methods inherited from class org.apache.tomcat.core.BaseInterceptor
addContainer, addContext, addHandler, addInterceptor, 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

APACHE_CONFIG

public static final java.lang.String APACHE_CONFIG
default path to JServ .conf location

JSERV_LOG_LOCATION

public static final java.lang.String JSERV_LOG_LOCATION
default mod_jserv log file location

MOD_JSERV

public static java.lang.String MOD_JSERV
default location of mod_jserv Apache plug-in.

AJPV12

public static final java.lang.String AJPV12
Constructor Detail

JservConfig

public JservConfig()
Method Detail

engineState

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

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
Following copied from class: org.apache.tomcat.core.BaseInterceptor
Throws:
If - the interceptor throws exception the context will not be initialized ( state==NEW or ADDED or DISABLED ).

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 Apache's root remains intact but isn't completely servlet/JSP enabled. If the ROOT webapp can be configured with apache serving static files, there's no problem setting this option to false. If not, then setting it true means Apache 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 setJkConfig() and other path setters would be resolved against if relative. For example if ConfigHome is set to "/home/tomcat" and JservConfig is set to "conf/tomcat-apache.conf" then the resulting path used would be: "/home/tomcat/conf/tomcat-apache.conf".

However, if JservConfig or other 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

getConfigHome

public java.io.File getConfigHome()
Returns:
the parent directory of the conf directory or null if not set.

setJservConfig

public void setJservConfig(java.lang.String path)
sets a path pointing to the output file in which to write the mod_jserv configuration.

setJservConfig

public void setJservConfig(java.io.File path)
sets a File object pointing to the output file in which to write the mod_jserv configuration.

setModJserv

public void setModJserv(java.lang.String path)
set the path to the Jserv Apache Module
Parameters:
path - String path to a file

setModJserv

public void setModJserv(java.io.File path)
set the path to the Jserv Apache Module
Parameters:
path - File object

setJservLog

public void setJservLog(java.lang.String path)
set the path to the mod_jserv log file
Parameters:
path - String path to a file

setJservDebug

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

initProperties

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

execute

public void execute(ContextManager cm)
             throws TomcatException
executes the JservConfig interceptor. This method generates apache configuration files for use with mod_jserv. If not already set, this method will setConfigHome() to the value returned from cm.getHome().

Parameters:
cm - a ContextManager object.

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 Apache extension mapping.

addMapping

protected boolean addMapping(java.lang.String fullPath,
                             java.lang.String app,
                             java.io.PrintWriter pw)
Add a fulling specified Appache mapping.


Copyright © 2001 Apache Software Foundation. All Rights Reserved.