Apache Tomcat 7.0.28

org.apache.catalina.startup
Class HostConfig

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

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:
$Id: HostConfig.java 1343337 2012-05-28 17:50:14Z kkolinko $
Author:
Craig R. McClanahan, Remy Maucherat

Nested Class Summary
protected static class HostConfig.DeployedApplication
          This class represents the state of a deployed application, as well as the monitored resources.
 
Field Summary
protected  File appBase
          App base.
protected  File configBase
          Config base.
protected  String configClass
          The Java class name of the Context configuration class we should use.
protected  String contextClass
          The Java class name of the Context implementation we should use.
protected  boolean copyXML
          Should XML files be copied to $CATALINA_BASE/conf/<engine>/<host> by default when a web application is deployed?
protected  Map<String,HostConfig.DeployedApplication> deployed
          Map of deployed applications.
protected  boolean deployXML
          Should we deploy XML Context config files packaged with WAR files and directories?
protected static Digester digester
          The Digester instance used to parse context descriptors.
protected  Host host
          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  ObjectName oname
          The JMX ObjectName of this component.
protected  ArrayList<String> 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?
 
Constructor Summary
HostConfig()
           
 
Method Summary
protected  void addGlobalRedeployResources(HostConfig.DeployedApplication app)
           
 void addServiced(String name)
          Add a serviced application to the list.
protected  void addWatchedResources(HostConfig.DeployedApplication app, String docBase, Context context)
          Add watched resources to the specified Context.
protected  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(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  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(String name)
          Deploy applications for any directories or WAR files that are found in our "application root" directory.
protected  void deployDescriptor(ContextName cn, File contextXml)
           
protected  void deployDescriptors(File configBase, String[] files)
          Deploy XML context descriptors.
protected  void deployDirectories(File appBase, String[] files)
          Deploy directories.
protected  void deployDirectory(ContextName cn, File dir)
           
protected  boolean deploymentExists(String contextName)
          Check if a webapp is already deployed in this host.
protected  void deployWAR(ContextName cn, File war)
           
protected  void deployWARs(File appBase, String[] files)
          Deploy WAR files.
protected  String[] filterAppPaths(String[] unfilteredAppPaths)
          Filter the list of application file paths to remove those that match the regular expression defined by Host.getDeployIgnore().
 String getConfigBaseName()
          Get the name of the configBase.
 String getConfigClass()
          Return the Context configuration class name.
 String getContextClass()
          Return the Context implementation class name.
 long getDeploymentTime(String name)
          Get the instant where an application was deployed.
 boolean isCopyXML()
          Return the copy XML config file flag for this component.
 boolean isDeployed(String name)
          Has the specified application been deployed?
 boolean isDeployXML()
          Return the deploy XML config file flag for this component.
 boolean isServiced(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(String name)
          Removed a serviced application from the list.
protected  File returnCanonicalPath(String path)
           
 void setConfigClass(String configClass)
          Set the Context configuration class name.
 void setContextClass(String contextClass)
          Set the Context implementation class name.
 void setCopyXML(boolean copyXML)
          Set the copy XML config file flag for this component.
 void setDeployXML(boolean deployXML)
          Set the deploy XML config file flag for this component.
 void setUnpackWARs(boolean unpackWARs)
          Set the unpack WARs flag.
 void start()
          Process a "start" event for this Host.
 void stop()
          Process a "stop" event for this Host.
 void unmanageApp(String contextName)
          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

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.


host

protected Host host
The Host we are associated with.


oname

protected 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 packaged with WAR files and directories?


copyXML

protected boolean copyXML
Should XML files be copied to $CATALINA_BASE/conf/<engine>/<host> by default when a web application is deployed?


unpackWARs

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


deployed

protected Map<String,HostConfig.DeployedApplication> deployed
Map of deployed applications.


serviced

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


digester

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


invalidWars

protected Set<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 String getConfigClass()
Return the Context configuration class name.


setConfigClass

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

Parameters:
configClass - The new Context configuration class name.

getContextClass

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


setContextClass

public void setContextClass(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

isCopyXML

public boolean isCopyXML()
Return the copy XML config file flag for this component.


setCopyXML

public void setCopyXML(boolean copyXML)
Set the copy XML config file flag for this component.

Parameters:
copyXML - The new copy 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

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(String name)
Add a serviced application to the list.


isServiced

public boolean isServiced(String name)
Is application serviced ?

Returns:
state of the application

removeServiced

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


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

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


returnCanonicalPath

protected File returnCanonicalPath(String path)

appBase

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


configBase

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


getConfigBaseName

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


deployApps

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


filterAppPaths

protected String[] filterAppPaths(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(String name)
Deploy applications for any directories or WAR files that are found in our "application root" directory.


deployDescriptors

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


deployDescriptor

protected void deployDescriptor(ContextName cn,
                                File contextXml)
Parameters:
cn -
contextXml -

deployWARs

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


deployWAR

protected void deployWAR(ContextName cn,
                         File war)
Parameters:
cn -
war -

deployDirectories

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


deployDirectory

protected void deployDirectory(ContextName cn,
                               File dir)
Parameters:
cn -
dir -

deploymentExists

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

Parameters:
contextName - of the context which will be checked

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

addGlobalRedeployResources

protected void addGlobalRedeployResources(HostConfig.DeployedApplication app)

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.


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.


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


unmanageApp

public void unmanageApp(String contextName)
Remove a webapp from our control. Entry point for the admin webapp, and other JMX Context controllers.


Apache Tomcat 7.0.28

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