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:
- 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.
- workersConfig - path to workers.properties file used by
jk connector. If not set, defaults to
"conf/jk/workers.properties".
- jkLog - path to log file to be used by jk connector.
- jkDebug - Loglevel setting. May be debug, info, error, or emerg.
If not set, defaults to emerg.
- jkWorker The desired worker. Must be set to one of the workers
defined in the workers.properties file. "ajp12", "ajp13"
or "inprocess" are the workers found in the default
workers.properties file. If not specified, defaults
to "ajp13" if an Ajp13Interceptor is in use, otherwise
it defaults to "ajp12".
- 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 mod_jk 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 may also
need to modify the web server to point it's home
directory to Tomcat's root context directory.
Otherwise some content, such as the root index.html,
may be served by the web server before the connector
gets a chance to claim the request and pass it to Tomcat.
The default is true.
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
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.
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)
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.
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
setJkWorker
public void setJkWorker(String worker)
set the Ajp protocal
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.