org.apache.catalina.startup

Class HostConfig

public class HostConfig extends Object implements LifecycleListener

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

Version: $Revision: 892815 $ $Date: 2009-12-21 14:27:57 +0100 (Mon, 21 Dec 2009) $

Author: Craig R. McClanahan Remy Maucherat

Nested Class Summary
protected classHostConfig.DeployedApplication
This class represents the state of a deployed application, as well as the monitored resources.
Field Summary
protected FileappBase
App base.
protected FileconfigBase
Config base.
protected StringconfigClass
The Java class name of the Context configuration class we should use.
protected StringcontextClass
The Java class name of the Context implementation we should use.
protected HashMapdeployed
Map of deployed applications.
protected booleandeployXML
Should we deploy XML Context config files?
protected static Digesterdigester
The Digester instance used to parse context descriptors.
protected Hosthost
The Host we are associated with.
protected Set<String>invalidWars
The list of Wars in the appBase to be ignored because they are invalid (e.g. contain /../ sequences).
protected static Loglog
protected ObjectNameoname
The JMX ObjectName of this component.
protected ArrayListserviced
List of applications which are being serviced, and shouldn't be deployed/undeployed/redeployed at the moment.
protected static StringManagersm
The string resources for this package.
protected booleanunpackWARs
Should we unpack WAR files when auto-deploying applications in the appBase directory?
protected booleanxmlNamespaceAware
Attribute value used to turn on/off XML namespace awarenes.
protected booleanxmlValidation
Attribute value used to turn on/off XML validation
Method Summary
voidaddServiced(String name)
Add a serviced application to the list.
protected voidaddWatchedResources(HostConfig.DeployedApplication app, String docBase, Context context)
Add watched resources to the specified Context.
protected FileappBase()
Return a File object representing the "application root" directory for our associated Host.
protected voidcheck()
Check status of all webapps.
voidcheck(String name)
Check status of a specific webapp, for use with stuff like management webapps.
protected voidcheckResources(HostConfig.DeployedApplication app)
Check resources for redeployment and reloading.
protected FileconfigBase()
Return a File object representing the "configuration root" directory for our associated Host.
protected static DigestercreateDigester()
Create the digester which will be used to parse context config files.
protected voiddeployApps()
Deploy applications for any directories or WAR files that are found in our "application root" directory.
protected voiddeployApps(String name)
Deploy applications for any directories or WAR files that are found in our "application root" directory.
protected voiddeployDescriptor(String contextPath, File contextXml, String file)
protected voiddeployDescriptors(File configBase, String[] files)
Deploy XML context descriptors.
protected voiddeployDirectories(File appBase, String[] files)
Deploy directories.
protected voiddeployDirectory(String contextPath, File dir, String file)
protected booleandeploymentExists(String contextPath)
Check if a webapp is already deployed in this host.
protected voiddeployWAR(String contextPath, File war, String file)
protected voiddeployWARs(File appBase, String[] files)
Deploy WAR files.
StringgetConfigBaseName()
Get the name of the configBase.
StringgetConfigClass()
Return the Context configuration class name.
protected StringgetConfigFile(String path)
Given a context path, get the config file name.
StringgetContextClass()
Return the Context implementation class name.
longgetDeploymentTime(String name)
Get the instant where an application was deployed.
protected StringgetDocBase(String path)
Given a context path, get the docBase.
booleangetXmlNamespaceAware()
Get the server.xml <host> attribute's xmlNamespaceAware.
booleangetXmlValidation()
Get the server.xml <host> attribute's xmlValidation.
booleanisDeployed(String name)
Has the specified application been deployed?
booleanisDeployXML()
Return the deploy XML config file flag for this component.
booleanisServiced(String name)
Is application serviced ?
booleanisUnpackWARs()
Return the unpack WARs flag.
voidlifecycleEvent(LifecycleEvent event)
Process the START event for an associated Host.
voidmanageApp(Context context)
Add a new Context to be managed by us.
voidremoveServiced(String name)
Removed a serviced application from the list.
voidsetConfigClass(String configClass)
Set the Context configuration class name.
voidsetContextClass(String contextClass)
Set the Context implementation class name.
voidsetDeployXML(boolean deployXML)
Set the deploy XML config file flag for this component.
voidsetUnpackWARs(boolean unpackWARs)
Set the unpack WARs flag.
voidsetXmlNamespaceAware(boolean xmlNamespaceAware)
Set the namespace aware feature of the XML parser used when parsing xml instances.
voidsetXmlValidation(boolean xmlValidation)
Set the validation feature of the XML parser used when parsing xml instances.
voidstart()
Process a "start" event for this Host.
voidstop()
Process a "stop" event for this Host.
protected voidundeployApps()
Undeploy all deployed applications.
voidunmanageApp(String contextPath)
Remove a webapp from our control.

Field Detail

appBase

protected File appBase
App base.

configBase

protected File configBase
Config base.

configClass

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

contextClass

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

deployed

protected HashMap deployed
Map of deployed applications.

deployXML

protected boolean deployXML
Should we deploy XML Context config files?

digester

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

host

protected Host host
The Host we are associated with.

invalidWars

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

log

protected static Log log

oname

protected ObjectName oname
The JMX ObjectName of this component.

serviced

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

sm

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

unpackWARs

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

xmlNamespaceAware

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

xmlValidation

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

Method Detail

addServiced

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

addWatchedResources

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

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

appBase

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

check

protected void check()
Check status of all webapps.

check

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

checkResources

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

configBase

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

createDigester

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

deployApps

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

deployApps

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

deployDescriptor

protected void deployDescriptor(String contextPath, File contextXml, String file)

Parameters: contextPath contextXml file

deployDescriptors

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

deployDirectories

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

deployDirectory

protected void deployDirectory(String contextPath, File dir, String file)

Parameters: contextPath dir file

deploymentExists

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

Parameters: contextPath of the context which will be checked

deployWAR

protected void deployWAR(String contextPath, File war, String file)

Parameters: contextPath war file

deployWARs

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

getConfigBaseName

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

getConfigClass

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

getConfigFile

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

getContextClass

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

getDeploymentTime

public long getDeploymentTime(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

getDocBase

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

getXmlNamespaceAware

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

Returns: true if namespace awarenes is enabled.

getXmlValidation

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

Returns: true if validation is enabled.

isDeployed

public boolean isDeployed(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

isDeployXML

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

isServiced

public boolean isServiced(String name)
Is application serviced ?

Returns: state of the application

isUnpackWARs

public boolean isUnpackWARs()
Return the unpack WARs flag.

lifecycleEvent

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

Parameters: event The lifecycle event that has occurred

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.

removeServiced

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

setConfigClass

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

Parameters: configClass The new Context configuration class name.

setContextClass

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

Parameters: contextClass The new Context implementation class name.

setDeployXML

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

Parameters: deployXML The new deploy XML flag

setUnpackWARs

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

Parameters: unpackWARs The new unpack WARs flag

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

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

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.

unmanageApp

public void unmanageApp(String contextPath)
Remove a webapp from our control. Entry point for the admin webapp, and other JMX Context controlers.
Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.