Apache Tomcat 6.0.41

org.apache.catalina.startup
Class HostConfig

java.lang.Object
  extended by org.apache.catalina.startup.HostConfig
All Implemented Interfaces:
LifecycleListener

public class HostConfig
extends java.lang.Object
implements LifecycleListener

Startup event listener for a Host that configures the properties of that Host, and the associated defined contexts.

Author:
Craig R. McClanahan, Remy Maucherat

Nested Class Summary
protected  class HostConfig.DeployedApplication
          This class represents the state of a deployed application, as well as the monitored resources.
 
Field Summary
protected  java.io.File appBase
          App base.
protected  java.io.File configBase
          Config base.
protected  java.lang.String configClass
          The Java class name of the Context configuration class we should use.
protected  java.lang.String contextClass
          The Java class name of the Context implementation we should use.
protected  java.util.HashMap deployed
          Map of deployed applications.
protected  boolean deployXML
          Should we deploy XML Context config files?
protected static Digester digester
          The Digester instance used to parse context descriptors.
protected  Host host
          The Host we are associated with.
protected  java.util.Set<java.lang.String> invalidWars
          The list of Wars in the appBase to be ignored because they are invalid (e.g. contain /../ sequences).
protected static Log log
           
protected  javax.management.ObjectName oname
          The JMX ObjectName of this component.
protected  java.util.ArrayList serviced
          List of applications which are being serviced, and shouldn't be deployed/undeployed/redeployed at the moment.
protected static StringManager sm
          The string resources for this package.
protected  boolean unpackWARs
          Should we unpack WAR files when auto-deploying applications in the appBase directory?
protected  boolean xmlNamespaceAware
          Attribute value used to turn on/off XML namespace awarenes.
protected  boolean xmlValidation
          Attribute value used to turn on/off XML validation
 
Constructor Summary
HostConfig()
           
 
Method Summary
 void addServiced(java.lang.String name)
          Add a serviced application to the list.
protected  void addWatchedResources(HostConfig.DeployedApplication app, java.lang.String docBase, Context context)
          Add watched resources to the specified Context.
protected  java.io.File appBase()
          Return a File object representing the "application root" directory for our associated Host.
protected  void check()
          Check status of all webapps.
 void check(java.lang.String name)
          Check status of a specific webapp, for use with stuff like management webapps.
protected  void checkResources(HostConfig.DeployedApplication app)
          Check resources for redeployment and reloading.
protected  java.io.File configBase()
          Return a File object representing the "configuration root" directory for our associated Host.
protected static Digester createDigester()
          Create the digester which will be used to parse context config files.
protected  void deployApps()
          Deploy applications for any directories or WAR files that are found in our "application root" directory.
protected  void deployApps(java.lang.String name)
          Deploy applications for any directories or WAR files that are found in our "application root" directory.
protected  void deployDescriptor(java.lang.String contextPath, java.io.File contextXml, java.lang.String file)
           
protected  void deployDescriptors(java.io.File configBase, java.lang.String[] files)
          Deploy XML context descriptors.
protected  void deployDirectories(java.io.File appBase, java.lang.String[] files)
          Deploy directories.
protected  void deployDirectory(java.lang.String contextPath, java.io.File dir, java.lang.String file)
           
protected  boolean deploymentExists(java.lang.String contextPath)
          Check if a webapp is already deployed in this host.
protected  void deployWAR(java.lang.String contextPath, java.io.File war, java.lang.String file)
           
protected  void deployWARs(java.io.File appBase, java.lang.String[] files)
          Deploy WAR files.
protected  java.lang.String[] filterAppPaths(java.lang.String[] unfilteredAppPaths)
          Filter the list of application file paths to remove those that match the regular expression defined by Host.getDeployIgnore().
 java.lang.String getConfigBaseName()
          Get the name of the configBase.
 java.lang.String getConfigClass()
          Return the Context configuration class name.
protected  java.lang.String getConfigFile(java.lang.String path)
          Given a context path, get the config file name.
 java.lang.String getContextClass()
          Return the Context implementation class name.
 long getDeploymentTime(java.lang.String name)
          Get the instant where an application was deployed.
protected  java.lang.String getDocBase(java.lang.String path)
          Given a context path, get the docBase.
 boolean getXmlNamespaceAware()
          Get the server.xml <host> attribute's xmlNamespaceAware.
 boolean getXmlValidation()
          Get the server.xml <host> attribute's xmlValidation.
 boolean isDeployed(java.lang.String name)
          Has the specified application been deployed?
 boolean isDeployXML()
          Return the deploy XML config file flag for this component.
 boolean isServiced(java.lang.String name)
          Is application serviced ?
 boolean isUnpackWARs()
          Return the unpack WARs flag.
 void lifecycleEvent(LifecycleEvent event)
          Process the START event for an associated Host.
 void manageApp(Context context)
          Add a new Context to be managed by us.
 void removeServiced(java.lang.String name)
          Removed a serviced application from the list.
 void setConfigClass(java.lang.String configClass)
          Set the Context configuration class name.
 void setContextClass(java.lang.String contextClass)
          Set the Context implementation class name.
 void setDeployXML(boolean deployXML)
          Set the deploy XML config file flag for this component.
 void setUnpackWARs(boolean unpackWARs)
          Set the unpack WARs flag.
 void setXmlNamespaceAware(boolean xmlNamespaceAware)
          Set the namespace aware feature of the XML parser used when parsing xml instances.
 void setXmlValidation(boolean xmlValidation)
          Set the validation feature of the XML parser used when parsing xml instances.
 void start()
          Process a "start" event for this Host.
 void stop()
          Process a "stop" event for this Host.
protected  void undeployApps()
          Undeploy all deployed applications.
 void unmanageApp(java.lang.String contextPath)
          Remove a webapp from our control.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static Log log

appBase

protected java.io.File appBase
App base.


configBase

protected java.io.File configBase
Config base.


configClass

protected java.lang.String configClass
The Java class name of the Context configuration class we should use.


contextClass

protected java.lang.String contextClass
The Java class name of the Context implementation we should use.


host

protected Host host
The Host we are associated with.


oname

protected javax.management.ObjectName oname
The JMX ObjectName of this component.


sm

protected static final StringManager sm
The string resources for this package.


deployXML

protected boolean deployXML
Should we deploy XML Context config files?


unpackWARs

protected boolean unpackWARs
Should we unpack WAR files when auto-deploying applications in the appBase directory?


deployed

protected java.util.HashMap deployed
Map of deployed applications.


serviced

protected java.util.ArrayList serviced
List of applications which are being serviced, and shouldn't be deployed/undeployed/redeployed at the moment.


xmlValidation

protected boolean xmlValidation
Attribute value used to turn on/off XML validation


xmlNamespaceAware

protected boolean xmlNamespaceAware
Attribute value used to turn on/off XML namespace awarenes.


digester

protected static Digester digester
The Digester instance used to parse context descriptors.


invalidWars

protected java.util.Set<java.lang.String> invalidWars
The list of Wars in the appBase to be ignored because they are invalid (e.g. contain /../ sequences).

Constructor Detail

HostConfig

public HostConfig()
Method Detail

getConfigClass

public java.lang.String getConfigClass()
Return the Context configuration class name.


setConfigClass

public void setConfigClass(java.lang.String configClass)
Set the Context configuration class name.

Parameters:
configClass - The new Context configuration class name.

getContextClass

public java.lang.String getContextClass()
Return the Context implementation class name.


setContextClass

public void setContextClass(java.lang.String contextClass)
Set the Context implementation class name.

Parameters:
contextClass - The new Context implementation class name.

isDeployXML

public boolean isDeployXML()
Return the deploy XML config file flag for this component.


setDeployXML

public void setDeployXML(boolean deployXML)
Set the deploy XML config file flag for this component.

Parameters:
deployXML - The new deploy XML flag

isUnpackWARs

public boolean isUnpackWARs()
Return the unpack WARs flag.


setUnpackWARs

public void setUnpackWARs(boolean unpackWARs)
Set the unpack WARs flag.

Parameters:
unpackWARs - The new unpack WARs flag

setXmlValidation

public void setXmlValidation(boolean xmlValidation)
Set the validation feature of the XML parser used when parsing xml instances.

Parameters:
xmlValidation - true to enable xml instance validation

getXmlValidation

public boolean getXmlValidation()
Get the server.xml <host> attribute's xmlValidation.

Returns:
true if validation is enabled.

getXmlNamespaceAware

public boolean getXmlNamespaceAware()
Get the server.xml <host> attribute's xmlNamespaceAware.

Returns:
true if namespace awarenes is enabled.

setXmlNamespaceAware

public void setXmlNamespaceAware(boolean xmlNamespaceAware)
Set the namespace aware feature of the XML parser used when parsing xml instances.

Parameters:
xmlNamespaceAware - true to enable namespace awareness

lifecycleEvent

public void lifecycleEvent(LifecycleEvent event)
Process the START event for an associated Host.

Specified by:
lifecycleEvent in interface LifecycleListener
Parameters:
event - The lifecycle event that has occurred

addServiced

public void addServiced(java.lang.String name)
Add a serviced application to the list.


isServiced

public boolean isServiced(java.lang.String name)
Is application serviced ?

Returns:
state of the application

removeServiced

public void removeServiced(java.lang.String name)
Removed a serviced application from the list.


getDeploymentTime

public long getDeploymentTime(java.lang.String name)
Get the instant where an application was deployed.

Returns:
0L if no application with that name is deployed, or the instant on which the application was deployed

isDeployed

public boolean isDeployed(java.lang.String name)
Has the specified application been deployed? Note applications defined in server.xml will not have been deployed.

Returns:
true if the application has been deployed and false if the applciation has not been deployed or does not exist

createDigester

protected static Digester createDigester()
Create the digester which will be used to parse context config files.


appBase

protected java.io.File appBase()
Return a File object representing the "application root" directory for our associated Host.


configBase

protected java.io.File configBase()
Return a File object representing the "configuration root" directory for our associated Host.


getConfigBaseName

public java.lang.String getConfigBaseName()
Get the name of the configBase. For use with JMX management.


getConfigFile

protected java.lang.String getConfigFile(java.lang.String path)
Given a context path, get the config file name.


getDocBase

protected java.lang.String getDocBase(java.lang.String path)
Given a context path, get the docBase.


deployApps

protected void deployApps()
Deploy applications for any directories or WAR files that are found in our "application root" directory.


filterAppPaths

protected java.lang.String[] filterAppPaths(java.lang.String[] unfilteredAppPaths)
Filter the list of application file paths to remove those that match the regular expression defined by Host.getDeployIgnore().

Parameters:
unfilteredAppPaths - The list of application paths to filtert
Returns:
The filtered list of application paths

deployApps

protected void deployApps(java.lang.String name)
Deploy applications for any directories or WAR files that are found in our "application root" directory.


deployDescriptors

protected void deployDescriptors(java.io.File configBase,
                                 java.lang.String[] files)
Deploy XML context descriptors.


deployDescriptor

protected void deployDescriptor(java.lang.String contextPath,
                                java.io.File contextXml,
                                java.lang.String file)
Parameters:
contextPath -
contextXml -
file -

deployWARs

protected void deployWARs(java.io.File appBase,
                          java.lang.String[] files)
Deploy WAR files.


deployWAR

protected void deployWAR(java.lang.String contextPath,
                         java.io.File war,
                         java.lang.String file)
Parameters:
contextPath -
war -
file -

deployDirectories

protected void deployDirectories(java.io.File appBase,
                                 java.lang.String[] files)
Deploy directories.


deployDirectory

protected void deployDirectory(java.lang.String contextPath,
                               java.io.File dir,
                               java.lang.String file)
Parameters:
contextPath -
dir -
file -

deploymentExists

protected boolean deploymentExists(java.lang.String contextPath)
Check if a webapp is already deployed in this host.

Parameters:
contextPath - of the context which will be checked

addWatchedResources

protected void addWatchedResources(HostConfig.DeployedApplication app,
                                   java.lang.String docBase,
                                   Context context)
Add watched resources to the specified Context.

Parameters:
app - HostConfig deployed app
docBase - web app docBase
context - web application context

checkResources

protected void checkResources(HostConfig.DeployedApplication app)
Check resources for redeployment and reloading.


start

public void start()
Process a "start" event for this Host.


stop

public void stop()
Process a "stop" event for this Host.


undeployApps

protected void undeployApps()
Undeploy all deployed applications.


check

protected void check()
Check status of all webapps.


check

public void check(java.lang.String name)
Check status of a specific webapp, for use with stuff like management webapps.


manageApp

public void manageApp(Context context)
Add a new Context to be managed by us. Entry point for the admin webapp, and other JMX Context controlers.


unmanageApp

public void unmanageApp(java.lang.String contextPath)
Remove a webapp from our control. Entry point for the admin webapp, and other JMX Context controlers.


Apache Tomcat 6.0.41

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