Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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:

- configHome - default parent directory for the following paths. If not set, this defaults to TOMCAT_HOME. Ignored whenever any of the following paths is absolute.
- jservConfig - path to use for writing Apache mod_jserv conf file. If not set, defaults to "conf/auto/tomcat-apache.conf".
- modJServ - path to Apache mod_jserv plugin file. If not set, defaults to "modules/ApacheModuleJserv.dll" on windows, and "libexec/mod_jserv.so" everywhere else.
- jservLog - path to log file to be used by mod_jserv.
- jservDebug - Jserv Loglevel setting. May be debug, info, notice, warn, error, crit, alert, or emerg. If not set, defaults to debug.
- forwardAll - If true, forward all requests to Tomcat. This helps insure that all the behavior configured in the web.xml file functions correctly. If false, let Apache serve static resources. The default is true. Warning: When false, some configuration in the web.xml may not be duplicated in Apache. Review the tomcat-apache conf file to see what configuration is actually being set in Apache.
- noRoot - If true, the root context is not mapped to Tomcat. If false and forwardAll is true, all requests to the root context are mapped to Tomcat. If false and forwardAll is false, only JSP and servlets requests to the root context are mapped to Tomcat. When false, to correctly serve Tomcat's root context you must also modify the DocumentRoot setting in Apache's httpd.conf file to point to Tomcat's root context directory. Otherwise some content, such as Apache's index.html, will be served by Apache before mod_jserv gets a chance to claim the request and pass it to Tomcat. The default is true.

Version:
  $Revision: 1.7 $ $Date: 2004/02/25 07:06:59 $
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, copyContext, engineInit, engineShutdown, engineStart, engineStop, findSession, getContext, getContextManager, getDebug, getInfo, getLog, getNote, getNote, handleError, log, log, log, log, postInitCheck, postReadRequest, postRequest, postService, postServletDestroy, postServletInit, preInitCheck, 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

  See Also:
    Constant Field Values

### JSERV_LOG_LOCATION

    public static final java.lang.String JSERV_LOG_LOCATION

  default mod_jserv log file location

  See Also:
    Constant Field Values

### 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

See Also:
  Constant Field Values

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`
  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`

### 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.

### 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

### setModJserv

    public void setModJserv(java.io.File path)

  set the path to the Jserv Apache Module

### setJservLog

    public void setJservLog(java.lang.String path)

  set the path to the mod_jserv log 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().

  Throws:
    `TomcatException`

### 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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001 Apache Software Foundation. All Rights Reserved.