Package org.apache.catalina.startup
Class HostConfig
- java.lang.Object
- 
- 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 SummaryNested Classes Modifier and Type Class Description protected static classHostConfig.DeployedApplicationThis class represents the state of a deployed application, as well as the monitored resources.
 - 
Field SummaryFields Modifier and Type Field Description protected java.lang.StringcontextClassThe Java class name of the Context implementation we should use.protected booleancopyXMLShould XML files be copied to $CATALINA_BASE/conf/<engine>/<host> by default when a web application is deployed?protected java.util.Map<java.lang.String,HostConfig.DeployedApplication>deployedMap of deployed applications.protected booleandeployXMLShould we deploy XML Context config files packaged with WAR files and directories?protected DigesterdigesterTheDigesterinstance used to parse context descriptors.protected static longFILE_MODIFICATION_RESOLUTION_MSThe resolution, in milliseconds, of file modification times.protected HosthostThe Host we are associated with.protected java.util.Set<java.lang.String>invalidWarsThe list of Wars in the appBase to be ignored because they are invalid (e.g. contain /../ sequences).protected javax.management.ObjectNameonameThe JMX ObjectName of this component.protected java.util.ArrayList<java.lang.String>servicedDeprecated.Unused.protected static StringManagersmThe string resources for this package.protected booleanunpackWARsShould we unpack WAR files when auto-deploying applications in theappBasedirectory?
 - 
Constructor SummaryConstructors Constructor Description HostConfig()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidaddGlobalRedeployResources(HostConfig.DeployedApplication app)voidaddServiced(java.lang.String name)Deprecated.Unused.protected voidaddWatchedResources(HostConfig.DeployedApplication app, java.lang.String docBase, Context context)Add watched resources to the specified Context.voidbeforeStart()protected voidcheck()Check status of all webapps.voidcheck(java.lang.String name)Check status of a specific web application and reload, redeploy or deploy it as necessary.protected voidcheckResources(HostConfig.DeployedApplication app, boolean skipFileModificationResolutionCheck)Check resources for redeployment and reloading.voidcheckUndeploy()Check for old versions of applications using parallel deployment that are now unused (have no active sessions) and undeploy any that are found.protected static DigestercreateDigester(java.lang.String contextClassName)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(java.lang.String name)Deploy applications for any directories or WAR files that are found in our "application root" directory.protected voiddeployDescriptor(ContextName cn, java.io.File contextXml)Deploy specified context descriptor.protected voiddeployDescriptors(java.io.File configBase, java.lang.String[] files)Deploy XML context descriptors.protected voiddeployDirectories(java.io.File appBase, java.lang.String[] files)Deploy exploded webapps.protected voiddeployDirectory(ContextName cn, java.io.File dir)Deploy exploded webapp.protected booleandeploymentExists(java.lang.String contextName)Check if a webapp is already deployed in this host.protected voiddeployWAR(ContextName cn, java.io.File war)Deploy packed WAR.protected voiddeployWARs(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 byHost.getDeployIgnore().java.lang.StringgetConfigBaseName()Get the name of the configBase.java.lang.StringgetContextClass()longgetDeploymentTime(java.lang.String name)Get the instant where an application was deployed.booleanisCopyXML()booleanisDeployed(java.lang.String name)Has the specified application been deployed?booleanisDeployXML()booleanisServiced(java.lang.String name)Deprecated.Unused.booleanisUnpackWARs()voidlifecycleEvent(LifecycleEvent event)Process the START event for an associated Host.voidmanageApp(Context context)Add a new Context to be managed by us.voidremoveServiced(java.lang.String name)Removed a serviced application from the list.protected java.io.FilereturnCanonicalPath(java.lang.String path)voidsetContextClass(java.lang.String contextClass)Set the Context implementation class name.voidsetCopyXML(boolean copyXML)Set the copy XML config file flag for this component.voidsetDeployXML(boolean deployXML)Set the deploy XML config file flag for this component.voidsetUnpackWARs(boolean unpackWARs)Set the unpack WARs flag.voidstart()Process a "start" event for this Host.voidstop()Process a "stop" event for this Host.booleantryAddServiced(java.lang.String name)Add a serviced application to the list and indicates if the application was already present in the list.voidunmanageApp(java.lang.String contextName)Remove a webapp from our control.
 
- 
- 
- 
Field Detail- 
smprotected static final StringManager sm The string resources for this package.
 - 
FILE_MODIFICATION_RESOLUTION_MSprotected static final long FILE_MODIFICATION_RESOLUTION_MS The resolution, in milliseconds, of file modification times.- See Also:
- Constant Field Values
 
 - 
contextClassprotected java.lang.String contextClass The Java class name of the Context implementation we should use.
 - 
hostprotected Host host The Host we are associated with.
 - 
onameprotected javax.management.ObjectName oname The JMX ObjectName of this component.
 - 
deployXMLprotected boolean deployXML Should we deploy XML Context config files packaged with WAR files and directories?
 - 
copyXMLprotected boolean copyXML Should XML files be copied to $CATALINA_BASE/conf/<engine>/<host> by default when a web application is deployed?
 - 
unpackWARsprotected boolean unpackWARs Should we unpack WAR files when auto-deploying applications in theappBasedirectory?
 - 
deployedprotected final java.util.Map<java.lang.String,HostConfig.DeployedApplication> deployed Map of deployed applications.
 - 
serviced@Deprecated protected final java.util.ArrayList<java.lang.String> serviced Deprecated.Unused. Will be removed in Tomcat 10.1.x onwards. Replaced by the privateservicedSetfield.List of applications which are being serviced, and shouldn't be deployed/undeployed/redeployed at the moment.
 - 
digesterprotected Digester digester TheDigesterinstance used to parse context descriptors.
 - 
invalidWarsprotected final 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).
 
- 
 - 
Method Detail- 
getContextClasspublic java.lang.String getContextClass() - Returns:
- the Context implementation class name.
 
 - 
setContextClasspublic void setContextClass(java.lang.String contextClass) Set the Context implementation class name.- Parameters:
- contextClass- The new Context implementation class name.
 
 - 
isDeployXMLpublic boolean isDeployXML() - Returns:
- the deploy XML config file flag for this component.
 
 - 
setDeployXMLpublic void setDeployXML(boolean deployXML) Set the deploy XML config file flag for this component.- Parameters:
- deployXML- The new deploy XML flag
 
 - 
isCopyXMLpublic boolean isCopyXML() - Returns:
- the copy XML config file flag for this component.
 
 - 
setCopyXMLpublic void setCopyXML(boolean copyXML) Set the copy XML config file flag for this component.- Parameters:
- copyXML- The new copy XML flag
 
 - 
isUnpackWARspublic boolean isUnpackWARs() - Returns:
- the unpack WARs flag.
 
 - 
setUnpackWARspublic void setUnpackWARs(boolean unpackWARs) Set the unpack WARs flag.- Parameters:
- unpackWARs- The new unpack WARs flag
 
 - 
lifecycleEventpublic void lifecycleEvent(LifecycleEvent event) Process the START event for an associated Host.- Specified by:
- lifecycleEventin interface- LifecycleListener
- Parameters:
- event- The lifecycle event that has occurred
 
 - 
tryAddServicedpublic boolean tryAddServiced(java.lang.String name) Add a serviced application to the list and indicates if the application was already present in the list.- Parameters:
- name- the context name
- Returns:
- trueif the application was not already in the list
 
 - 
addServiced@Deprecated public void addServiced(java.lang.String name) Deprecated.Unused. This method will be removed in Tomcat 10.1.x onwards. UsetryAddServiced(java.lang.String)instead.Add a serviced application to the list if it is not already present. If the application is already in the list of serviced applications this method is a NO-OP.- Parameters:
- name- the context name
 
 - 
isServiced@Deprecated public boolean isServiced(java.lang.String name) Deprecated.Unused. This method will be removed in Tomcat 10.1.x onwards. UsetryAddServiced(java.lang.String)instead.Is application serviced ?- Parameters:
- name- the context name
- Returns:
- state of the application
 
 - 
removeServicedpublic void removeServiced(java.lang.String name) Removed a serviced application from the list.- Parameters:
- name- the context name
 
 - 
getDeploymentTimepublic long getDeploymentTime(java.lang.String name) Get the instant where an application was deployed.- Parameters:
- name- the context name
- Returns:
- 0L if no application with that name is deployed, or the instant on which the application was deployed
 
 - 
isDeployedpublic boolean isDeployed(java.lang.String name) Has the specified application been deployed? Note applications defined in server.xml will not have been deployed.- Parameters:
- name- the context name
- Returns:
- trueif the application has been deployed and- falseif the application has not been deployed or does not exist
 
 - 
createDigesterprotected static Digester createDigester(java.lang.String contextClassName) Create the digester which will be used to parse context config files.- Parameters:
- contextClassName- The class which will be used to create the context instance
- Returns:
- the digester
 
 - 
returnCanonicalPathprotected java.io.File returnCanonicalPath(java.lang.String path) 
 - 
getConfigBaseNamepublic java.lang.String getConfigBaseName() Get the name of the configBase. For use with JMX management.- Returns:
- the config base
 
 - 
deployAppsprotected void deployApps() Deploy applications for any directories or WAR files that are found in our "application root" directory.
 - 
filterAppPathsprotected java.lang.String[] filterAppPaths(java.lang.String[] unfilteredAppPaths) Filter the list of application file paths to remove those that match the regular expression defined byHost.getDeployIgnore().- Parameters:
- unfilteredAppPaths- The list of application paths to filter
- Returns:
- The filtered list of application paths
 
 - 
deployAppsprotected void deployApps(java.lang.String name) Deploy applications for any directories or WAR files that are found in our "application root" directory.Note: It is expected that the caller has successfully added the app to servicedSet before calling this method. - Parameters:
- name- The context name which should be deployed
 
 - 
deployDescriptorsprotected void deployDescriptors(java.io.File configBase, java.lang.String[] files)Deploy XML context descriptors.- Parameters:
- configBase- The config base
- files- The XML descriptors which should be deployed
 
 - 
deployDescriptorprotected void deployDescriptor(ContextName cn, java.io.File contextXml) Deploy specified context descriptor.Note: It is expected that the caller has successfully added the app to servicedSet before calling this method. - Parameters:
- cn- The context name
- contextXml- The descriptor
 
 - 
deployWARsprotected void deployWARs(java.io.File appBase, java.lang.String[] files)Deploy WAR files.- Parameters:
- appBase- The base path for applications
- files- The WARs to deploy
 
 - 
deployWARprotected void deployWAR(ContextName cn, java.io.File war) Deploy packed WAR.Note: It is expected that the caller has successfully added the app to servicedSet before calling this method. - Parameters:
- cn- The context name
- war- The WAR file
 
 - 
deployDirectoriesprotected void deployDirectories(java.io.File appBase, java.lang.String[] files)Deploy exploded webapps.- Parameters:
- appBase- The base path for applications
- files- The exploded webapps that should be deployed
 
 - 
deployDirectoryprotected void deployDirectory(ContextName cn, java.io.File dir) Deploy exploded webapp.Note: It is expected that the caller has successfully added the app to servicedSet before calling this method. - Parameters:
- cn- The context name
- dir- The path to the root folder of the webapp
 
 - 
deploymentExistsprotected boolean deploymentExists(java.lang.String contextName) Check if a webapp is already deployed in this host.- Parameters:
- contextName- of the context which will be checked
- Returns:
- trueif the specified deployment exists
 
 - 
addWatchedResourcesprotected 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
 
 - 
addGlobalRedeployResourcesprotected void addGlobalRedeployResources(HostConfig.DeployedApplication app) 
 - 
checkResourcesprotected void checkResources(HostConfig.DeployedApplication app, boolean skipFileModificationResolutionCheck) Check resources for redeployment and reloading.- Parameters:
- app- The web application to check
- skipFileModificationResolutionCheck- When checking files for modification should the check that requires that any file modification must have occurred at least as long ago as the resolution of the file time stamp be skipped
 
 - 
beforeStartpublic void beforeStart() 
 - 
startpublic void start() Process a "start" event for this Host.
 - 
stoppublic void stop() Process a "stop" event for this Host.
 - 
checkprotected void check() Check status of all webapps.
 - 
checkpublic void check(java.lang.String name) Check status of a specific web application and reload, redeploy or deploy it as necessary. This method is for use with functionality such as management web applications that upload new/updated web applications and need to trigger the appropriate action to deploy them. This method assumes that any uploading/updating has been completed before this method is called. Any action taken as a result of the checks will complete before this method returns.- Parameters:
- name- The name of the web application to check
 
 - 
checkUndeploypublic void checkUndeploy() Check for old versions of applications using parallel deployment that are now unused (have no active sessions) and undeploy any that are found.
 - 
manageApppublic void manageApp(Context context) Add a new Context to be managed by us. Entry point for the admin webapp, and other JMX Context controllers.- Parameters:
- context- The context instance
 
 - 
unmanageApppublic void unmanageApp(java.lang.String contextName) Remove a webapp from our control. Entry point for the admin webapp, and other JMX Context controllers.Note: It is expected that the caller has successfully added the app to servicedSet before calling this method. - Parameters:
- contextName- The context name
 
 
- 
 
-