Class HttpdTomcatSiteManager<T extends TomcatCommon>
java.lang.Object
com.aoindustries.aoserv.daemon.httpd.HttpdSiteManager
com.aoindustries.aoserv.daemon.httpd.tomcat.HttpdTomcatSiteManager<T>
- All Implemented Interfaces:
StopStartable
- Direct Known Subclasses:
HttpdJBossSiteManager
public abstract class HttpdTomcatSiteManager<T extends TomcatCommon>
extends HttpdSiteManager
implements StopStartable
Manages Site configurations.
- Author:
- AO Industries, Inc.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.aoindustries.aoserv.daemon.httpd.HttpdSiteManager
HttpdSiteManager.JkSetting, HttpdSiteManager.Location, HttpdSiteManager.PermanentRewriteRule, HttpdSiteManager.WebAppSettings
-
Field Summary
FieldsFields inherited from class com.aoindustries.aoserv.daemon.httpd.HttpdSiteManager
httpdSite
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
buildSiteDirectory
(PosixFile siteDirectory, String optSlash, Set<Site> sitesNeedingRestarted, Set<SharedTomcat> sharedTomcatsNeedingRestarted, Set<PosixFile> restorecon) Every Tomcat site is built through the same overall set of steps.protected abstract void
buildSiteDirectoryContents
(String optSlash, PosixFile siteDirectory, boolean isUpgrade) Builds the complete directory tree for a new site.protected abstract void
enableDisable
(PosixFile siteDirectory) Enables/disables the site by adding/removing symlinks, if appropriate for the type of site.protected abstract void
flagNeedsRestart
(Set<Site> sitesNeedingRestarted, Set<SharedTomcat> sharedTomcatsNeedingRestarted) Flags that the site needs restarted.protected abstract byte[]
generateReadmeTxt
(String optSlash, String apacheTomcatDir, PosixFile installDir) Generates the README.txt that is used to detect major version changes to rebuild the Tomcat installation.protected abstract Worker
Gets the Jk worker for the site.static HttpdTomcatSiteManager<? extends TomcatCommon>
getInstance
(Site tomcatSite) Gets the specific manager for one type of web site.Gets the JkMount and JkUnmounts for this site.abstract PosixFile
Gets the PID file for the wrapper script.In addition to the standard values, also protects the /WEB-INF/ and /META-INF/ directories of all contexts.protected Set<PackageManager.PackageName>
Gets any packages that must be installed for this site.abstract PosixPath
Gets the path to the start/stop script.abstract User.Name
Gets the username to run the start/stop script as.abstract File
Gets the working directory to run the start/stop script in.abstract T
Gets all the webapps for this site.protected abstract boolean
rebuildConfigFiles
(PosixFile siteDirectory, Set<PosixFile> restorecon) Rebuilds any config files that need updated.start()
Starts all processes for this website if it is not running.stop()
Stops all processes for this website if it is running.protected abstract boolean
upgradeSiteDirectoryContents
(String optSlash, PosixFile siteDirectory) Upgrades the site directory contents for an auto-upgrade.Methods inherited from class com.aoindustries.aoserv.daemon.httpd.HttpdSiteManager
blockAllTraceAndTrackRequests, configureFtpDirectory, createCgiPhpScript, createTestIndex, enableAnonymousFtp, enableCgi, enablePhp, getApacheUid, getAutoWarningXml, getAutoWarningXmlOld, getInstance, getPermanentRewriteRules, startHttpdSite, stopAndDisableDaemons, stopHttpdSite
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.aoindustries.aoserv.daemon.httpd.StopStartable
isStartable
-
Field Details
-
tomcatSite
-
-
Constructor Details
-
HttpdTomcatSiteManager
- Throws:
IOException
SQLException
-
-
Method Details
-
getInstance
public static HttpdTomcatSiteManager<? extends TomcatCommon> getInstance(Site tomcatSite) throws IOException, SQLException Gets the specific manager for one type of web site.- Throws:
IOException
SQLException
-
getTomcatCommon
-
getRejectedLocations
public Map<String,List<HttpdSiteManager.Location>> getRejectedLocations() throws IOException, SQLExceptionIn addition to the standard values, also protects the /WEB-INF/ and /META-INF/ directories of all contexts. This is only done when the "use_apache" flag is on. Otherwise, Tomcat should protect the necessary paths.- Overrides:
getRejectedLocations
in classHttpdSiteManager
- Throws:
IOException
SQLException
-
getHttpdWorker
Gets the Jk worker for the site.- Throws:
IOException
SQLException
-
stop
Description copied from interface:StopStartable
Stops all processes for this website if it is running.- Specified by:
stop
in interfaceStopStartable
- Returns:
true
if actually stopped orfalse
if was already stopped ornull
when unknown- Throws:
IOException
SQLException
-
start
Description copied from interface:StopStartable
Starts all processes for this website if it is not running.- Specified by:
start
in interfaceStopStartable
- Returns:
true
if actually started orfalse
if was already started ornull
when unknown- Throws:
IOException
SQLException
-
getJkSettings
Description copied from class:HttpdSiteManager
Gets the JkMount and JkUnmounts for this site.This default implementation returns an empty set.
- Overrides:
getJkSettings
in classHttpdSiteManager
- Returns:
- An empty set if no Jk enabled.
- Throws:
IOException
SQLException
-
getWebapps
public SortedMap<String,HttpdSiteManager.WebAppSettings> getWebapps() throws IOException, SQLExceptionDescription copied from class:HttpdSiteManager
Gets all the webapps for this site. The key is the webapp path and the value is the settings for that path. If any webapp enables CGI, then this site overall must allow CGI.- Specified by:
getWebapps
in classHttpdSiteManager
- Throws:
IOException
SQLException
-
getPidFile
Gets the PID file for the wrapper script. When this file exists the script is assumed to be running. This PID file may be shared between multiple sites in the case of a shared Tomcat. Also, it is possible that the JVM may be disabled while the site overall is not.- Returns:
- the .pid file or
null
if should not be running - Throws:
IOException
SQLException
-
getStartStopScriptPath
Gets the path to the start/stop script.- Throws:
IOException
SQLException
-
getStartStopScriptUsername
Gets the username to run the start/stop script as.- Throws:
IOException
SQLException
-
getStartStopScriptWorkingDirectory
Gets the working directory to run the start/stop script in.- Throws:
IOException
SQLException
-
getRequiredPackages
Description copied from class:HttpdSiteManager
Gets any packages that must be installed for this site.By default, no specific packages are required.
- Overrides:
getRequiredPackages
in classHttpdSiteManager
- Throws:
IOException
SQLException
-
buildSiteDirectory
protected final void buildSiteDirectory(PosixFile siteDirectory, String optSlash, Set<Site> sitesNeedingRestarted, Set<SharedTomcat> sharedTomcatsNeedingRestarted, Set<PosixFile> restorecon) throws IOException, SQLException Every Tomcat site is built through the same overall set of steps.- Specified by:
buildSiteDirectory
in classHttpdSiteManager
- Throws:
IOException
SQLException
-
buildSiteDirectoryContents
protected abstract void buildSiteDirectoryContents(String optSlash, PosixFile siteDirectory, boolean isUpgrade) throws IOException, SQLException Builds the complete directory tree for a new site. This should not include the siteDirectory itself, which has already been created. This should also not include any files that enable/disable the site.This doesn't need to create the cgi-bin, cgi-bin/test, or index.html
- Parameters:
optSlash
- Relative path from the CATALINA_HOME to /opt/, including trailing slash, such as../../opt/
.- Throws:
IOException
SQLException
-
upgradeSiteDirectoryContents
protected abstract boolean upgradeSiteDirectoryContents(String optSlash, PosixFile siteDirectory) throws IOException, SQLException Upgrades the site directory contents for an auto-upgrade.- Parameters:
optSlash
- Relative path from the CATALINA_HOME to /opt/, including trailing slash, such as../../opt/
.- Returns:
true
if the site needs to be restarted.- Throws:
IOException
SQLException
-
rebuildConfigFiles
protected abstract boolean rebuildConfigFiles(PosixFile siteDirectory, Set<PosixFile> restorecon) throws IOException, SQLException Rebuilds any config files that need updated. This should not include any files/symlinks that enable/disable this site.- Returns:
true
if the site needs to be restarted.- Throws:
IOException
SQLException
-
enableDisable
Enables/disables the site by adding/removing symlinks, if appropriate for the type of site.- Throws:
IOException
SQLException
-
flagNeedsRestart
protected abstract void flagNeedsRestart(Set<Site> sitesNeedingRestarted, Set<SharedTomcat> sharedTomcatsNeedingRestarted) throws SQLException, IOException Flags that the site needs restarted.- Throws:
SQLException
IOException
-
generateReadmeTxt
protected abstract byte[] generateReadmeTxt(String optSlash, String apacheTomcatDir, PosixFile installDir) throws IOException, SQLException Generates the README.txt that is used to detect major version changes to rebuild the Tomcat installation.TODO: Generate and use these readme.txt files to detect when version changed
- Returns:
- The README.txt file contents or
null
if no README.txt used for change detection - Throws:
IOException
SQLException
- See Also:
-