org.apache.catalina.core

Class StandardHost

Implemented Interfaces:
Container, Deployer, Host, Lifecycle, MBeanRegistration, Pipeline, Serializable

public class StandardHost
extends ContainerBase
implements Deployer, Host

Standard implementation of the Host interface. Each child container must be a Context implementation to process the requests directed to a particular web application.

Version:
$Revision: 1.31 $ $Date: 2004/05/26 15:41:07 $

Authors:
Craig R. McClanahan
Remy Maucherat

Nested Class Summary

Nested classes/interfaces inherited from class org.apache.catalina.core.ContainerBase

ContainerBase.ContainerBackgroundProcessor, ContainerBase.PrivilegedAddChild

Field Summary

Fields inherited from class org.apache.catalina.core.ContainerBase

backgroundProcessorDelay, children, cluster, controller, debug, domain, initialized, lifecycle, listeners, loader, logger, manager, mserver, name, oname, parent, parentClassLoader, pipeline, realm, resources, sm, started, suffix, support, type

Fields inherited from interface org.apache.catalina.Container

ADD_CHILD_EVENT, ADD_MAPPER_EVENT, ADD_VALVE_EVENT, REMOVE_CHILD_EVENT, REMOVE_MAPPER_EVENT, REMOVE_VALVE_EVENT

Fields inherited from interface org.apache.catalina.Deployer

INSTALL_EVENT, PRE_INSTALL_EVENT, REMOVE_EVENT

Fields inherited from interface org.apache.catalina.Host

ADD_ALIAS_EVENT, REMOVE_ALIAS_EVENT

Fields inherited from interface org.apache.catalina.Lifecycle

AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, START_EVENT, STOP_EVENT

Constructor Summary

StandardHost()
Create a new StandardHost component with the default basic Valve.

Method Summary

void
addAlias(String alias)
Add an alias name that should be mapped to this same Host.
void
addChild(Container child)
Add a child Container, only if the proposed child is an implementation of Context.
void
addDefaultContext(DefaultContext defaultContext)
Set the DefaultContext for new web applications.
void
backgroundProcess()
Execute a periodic task, such as reloading, etc.
ObjectName
createObjectName(String domain, ObjectName parent)
String[]
findAliases()
Return the set of alias names for this Host.
Context
findDeployedApp(String contextPath)
Return the Context for the deployed application that is associated with the specified context path (if any); otherwise return null.
String[]
findDeployedApps()
Return the context paths of all deployed web applications in this Container.
String[]
getAliases()
String
getAppBase()
Return the application root for this Host.
boolean
getAutoDeploy()
Return the value of the auto deploy flag.
String
getConfigClass()
Return the Java class name of the context configuration class for new web applications.
String
getContextClass()
Return the Java class name of the Context implementation class for new web applications.
DefaultContext
getDefaultContext()
Retrieve the DefaultContext for new web applications.
boolean
getDeployOnStartup()
Return the value of the deploy on startup flag.
Deployer
getDeployer()
String
getErrorReportValveClass()
Return the Java class name of the error report valve class for new web applications.
String
getInfo()
Return descriptive information about this Container implementation and the corresponding version number, in the format <description>/<version>.
boolean
getLiveDeploy()
Return the value of the live deploy flag.
String
getName()
Return the canonical, fully qualified, name of the virtual host this Container represents.
String[]
getValveNames()
Return the MBean Names of the Valves assoicated with this Host
String
getWorkDir()
Host work directory base.
boolean
getXmlNamespaceAware()
Get the server.xml attribute's xmlNamespaceAware.
boolean
getXmlValidation()
Get the server.xml attribute's xmlValidation.
void
importDefaultContext(Context context)
Import the DefaultContext config into a web application context.
void
init()
void
install(String contextPath, URL war)
Install a new web application, whose web application archive is at the specified URL, into this container with the specified context path.
void
install(URL war)
Installs a new web application from the web application archive at the specified URL, which must contain a META-INF/context.xml context configuration file (consisting of a <Context> element).
void
install(URL config, URL war)
Install a new web application, whose context configuration file (consisting of a <Context> element) and web application archive are at the specified URLs.
void
installDefaultContext(Context context)
Install the StandardContext portion of the DefaultContext configuration into current Context.
boolean
isDeployXML()
Deploy XML Context config files flag accessor.
boolean
isUnpackWARs()
Unpack WARs flag accessor.
Context
map(String uri)
Return the Context that would be used to process the specified host-relative request URI, if any; otherwise return null.
ObjectName
preRegister(MBeanServer server, ObjectName oname)
void
remove(String contextPath)
Remove an existing web application, attached to the specified context path.
void
remove(String contextPath, boolean undeploy)
Remove an existing web application, attached to the specified context path.
void
removeAlias(String alias)
Remove the specified alias name from the aliases for this Host.
void
setAppBase(String appBase)
Set the application root for this Host.
void
setAutoDeploy(boolean autoDeploy)
Set the auto deploy flag value for this host.
void
setConfigClass(String configClass)
Set the Java class name of the context configuration class for new web applications.
void
setContextClass(String contextClass)
Set the Java class name of the Context implementation class for new web applications.
void
setDeployOnStartup(boolean deployOnStartup)
Set the deploy on startup flag value for this host.
void
setDeployXML(boolean deployXML)
Deploy XML Context config files flag mutator.
void
setDeployer(Deployer d)
void
setErrorReportValveClass(String errorReportValveClass)
Set the Java class name of the error report valve class for new web applications.
void
setLiveDeploy(boolean liveDeploy)
Set the live deploy flag value for this host.
void
setName(String name)
Set the canonical, fully qualified, name of the virtual host this Container represents.
void
setUnpackWARs(boolean unpackWARs)
Unpack WARs flag mutator.
void
setWorkDir(String workDir)
Host work directory base.
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()
Start this host.
void
start(String contextPath)
Start an existing web application, attached to the specified context path.
void
stop(String contextPath)
Stop an existing web application, attached to the specified context path.
String
toString()
Return a String representation of this component.

Methods inherited from class org.apache.catalina.core.ContainerBase

addChild, addContainerListener, addLifecycleListener, addPropertyChangeListener, addValve, backgroundProcess, createObjectName, destroy, findChild, findChildren, findContainerListeners, findLifecycleListeners, fireContainerEvent, getBackgroundProcessorDelay, getBasic, getChildren, getCluster, getContainerSuffix, getDebug, getDomain, getInfo, getJSR77Suffix, getJmxName, getLoader, getLogger, getManager, getMappingObject, getName, getObjectName, getParent, getParentClassLoader, getParentName, getPipeline, getRealm, getResources, getType, getValveObjectNames, getValves, init, invoke, log, log, logName, postDeregister, postRegister, preDeregister, preRegister, removeChild, removeContainerListener, removeLifecycleListener, removePropertyChangeListener, removeValve, setBackgroundProcessorDelay, setBasic, setCluster, setDebug, setDomain, setLoader, setLogger, setManager, setName, setParent, setParentClassLoader, setRealm, setResources, start, stop, threadStart, threadStop

Constructor Details

StandardHost

public StandardHost()
Create a new StandardHost component with the default basic Valve.

Method Details

addAlias

public void addAlias(String alias)
Add an alias name that should be mapped to this same Host.
Specified by:
addAlias in interface Host

Parameters:
alias - The alias to be added


addChild

public void addChild(Container child)
Add a child Container, only if the proposed child is an implementation of Context.
Specified by:
addChild in interface Container
Overrides:
addChild in interface ContainerBase

Parameters:
child - Child container to be added


addDefaultContext

public void addDefaultContext(DefaultContext defaultContext)
Set the DefaultContext for new web applications.
Specified by:
addDefaultContext in interface Host

Parameters:
defaultContext - The new DefaultContext


backgroundProcess

public void backgroundProcess()
Execute a periodic task, such as reloading, etc. This method will be invoked inside the classloading context of this container. Unexpected throwables will be caught and logged.
Specified by:
backgroundProcess in interface Container
Overrides:
backgroundProcess in interface ContainerBase


createObjectName

public ObjectName createObjectName(String domain,
                                   ObjectName parent)
            throws Exception
Overrides:
createObjectName in interface ContainerBase


findAliases

public String[] findAliases()
Return the set of alias names for this Host. If none are defined, a zero length array is returned.
Specified by:
findAliases in interface Host


findDeployedApp

public Context findDeployedApp(String contextPath)
Return the Context for the deployed application that is associated with the specified context path (if any); otherwise return null.
Specified by:
findDeployedApp in interface Deployer

Parameters:
contextPath - The context path of the requested web application


findDeployedApps

public String[] findDeployedApps()
Return the context paths of all deployed web applications in this Container. If there are no deployed applications, a zero-length array is returned.
Specified by:
findDeployedApps in interface Deployer


getAliases

public String[] getAliases()


getAppBase

public String getAppBase()
Return the application root for this Host. This can be an absolute pathname, a relative pathname, or a URL.
Specified by:
getAppBase in interface Host


getAutoDeploy

public boolean getAutoDeploy()
Return the value of the auto deploy flag. If true, it indicates that this host's child webapps will be dynamically deployed.
Specified by:
getAutoDeploy in interface Host


getConfigClass

public String getConfigClass()
Return the Java class name of the context configuration class for new web applications.


getContextClass

public String getContextClass()
Return the Java class name of the Context implementation class for new web applications.


getDefaultContext

public DefaultContext getDefaultContext()
Retrieve the DefaultContext for new web applications.
Specified by:
getDefaultContext in interface Host


getDeployOnStartup

public boolean getDeployOnStartup()
Return the value of the deploy on startup flag. If true, it indicates that this host's child webapps should be discovred and automatically deployed at startup time.
Specified by:
getDeployOnStartup in interface Host


getDeployer

public Deployer getDeployer()


getErrorReportValveClass

public String getErrorReportValveClass()
Return the Java class name of the error report valve class for new web applications.


getInfo

public String getInfo()
Return descriptive information about this Container implementation and the corresponding version number, in the format <description>/<version>.
Specified by:
getInfo in interface Container
Overrides:
getInfo in interface ContainerBase


getLiveDeploy

public boolean getLiveDeploy()
Return the value of the live deploy flag. If true, it indicates that a background thread should be started that looks for web application context files, WAR files, or unpacked directories being dropped in to the appBase directory, and deploys new ones as they are encountered.


getName

public String getName()
Return the canonical, fully qualified, name of the virtual host this Container represents.
Specified by:
getName in interface Deployer
getName in interface Host
getName in interface Container
Overrides:
getName in interface ContainerBase


getValveNames

public String[] getValveNames()
            throws Exception
Return the MBean Names of the Valves assoicated with this Host


getWorkDir

public String getWorkDir()
Host work directory base.


getXmlNamespaceAware

public boolean getXmlNamespaceAware()
Get the server.xml attribute's xmlNamespaceAware.
Specified by:
getXmlNamespaceAware in interface Host

Returns:
true if namespace awarenes is enabled.


getXmlValidation

public boolean getXmlValidation()
Get the server.xml attribute's xmlValidation.
Specified by:
getXmlValidation in interface Host

Returns:
true if validation is enabled.


importDefaultContext

public void importDefaultContext(Context context)
Import the DefaultContext config into a web application context.
Specified by:
importDefaultContext in interface Host

Parameters:
context - web application context to import default context


init

public void init()
Overrides:
init in interface ContainerBase


install

public void install(String contextPath,
                    URL war)
            throws IOException
Install a new web application, whose web application archive is at the specified URL, into this container with the specified context path. A context path of "" (the empty string) should be used for the root application for this container. Otherwise, the context path must start with a slash.

If this application is successfully installed, a ContainerEvent of type INSTALL_EVENT will be sent to all registered listeners, with the newly created Context as an argument.

Specified by:
install in interface Deployer

Parameters:
contextPath - The context path to which this application should be installed (must be unique)
war - A URL of type "jar:" that points to a WAR file, or type "file:" that points to an unpacked directory structure containing the web application to be installed


install

public void install(URL war)
            throws IOException
Installs a new web application from the web application archive at the specified URL, which must contain a META-INF/context.xml context configuration file (consisting of a <Context> element).

The web application is installed at the path specified inside the embedded META-INF/context.xml. The docBase (if any) specified inside the embedded META-INF/context.xml is overridden with the web application's location.

If the installation succeeds, a ContainerEvent of type INSTALL_EVENT is sent to all registered listeners, with the newly created Context as its argument.

Specified by:
install in interface Deployer

Parameters:
war - URL pointing to web application location (WAR-packaged or unpacked directory)


install

public void install(URL config,
                    URL war)
            throws IOException
Install a new web application, whose context configuration file (consisting of a <Context> element) and web application archive are at the specified URLs.

If this application is successfully installed, a ContainerEvent of type INSTALL_EVENT will be sent to all registered listeners, with the newly created Context as an argument.

Specified by:
install in interface Deployer

Parameters:
config - A URL that points to the context configuration file to be used for configuring the new Context
war - A URL of type "jar:" that points to a WAR file, or type "file:" that points to an unpacked directory structure containing the web application to be installed


installDefaultContext

public void installDefaultContext(Context context)
Install the StandardContext portion of the DefaultContext configuration into current Context.

Parameters:
context - current web application context


isDeployXML

public boolean isDeployXML()
Deploy XML Context config files flag accessor.
Specified by:
isDeployXML in interface Deployer


isUnpackWARs

public boolean isUnpackWARs()
Unpack WARs flag accessor.


map

public Context map(String uri)
Return the Context that would be used to process the specified host-relative request URI, if any; otherwise return null.
Specified by:
map in interface Host

Parameters:
uri - Request URI to be mapped


preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName oname)
            throws Exception
Overrides:
preRegister in interface ContainerBase


remove

public void remove(String contextPath)
            throws IOException
Remove an existing web application, attached to the specified context path. If this application is successfully removed, a ContainerEvent of type REMOVE_EVENT will be sent to all registered listeners, with the removed Context as an argument.
Specified by:
remove in interface Deployer

Parameters:
contextPath - The context path of the application to be removed


remove

public void remove(String contextPath,
                   boolean undeploy)
            throws IOException
Remove an existing web application, attached to the specified context path. If this application is successfully removed, a ContainerEvent of type REMOVE_EVENT will be sent to all registered listeners, with the removed Context as an argument. Deletes the web application war file and/or directory if they exist in the Host's appBase.
Specified by:
remove in interface Deployer

Parameters:
contextPath - The context path of the application to be removed
undeploy - boolean flag to remove web application from server


removeAlias

public void removeAlias(String alias)
Remove the specified alias name from the aliases for this Host.
Specified by:
removeAlias in interface Host

Parameters:
alias - Alias name to be removed


setAppBase

public void setAppBase(String appBase)
Set the application root for this Host. This can be an absolute pathname, a relative pathname, or a URL.
Specified by:
setAppBase in interface Host

Parameters:
appBase - The new application root


setAutoDeploy

public void setAutoDeploy(boolean autoDeploy)
Set the auto deploy flag value for this host.
Specified by:
setAutoDeploy in interface Host

Parameters:
autoDeploy - The new auto deploy flag


setConfigClass

public void setConfigClass(String configClass)
Set the Java class name of the context configuration class for new web applications.

Parameters:
configClass - The new context configuration class


setContextClass

public void setContextClass(String contextClass)
Set the Java class name of the Context implementation class for new web applications.

Parameters:
contextClass - The new context implementation class


setDeployOnStartup

public void setDeployOnStartup(boolean deployOnStartup)
Set the deploy on startup flag value for this host.
Specified by:
setDeployOnStartup in interface Host

Parameters:
deployOnStartup - The new deploy on startup flag


setDeployXML

public void setDeployXML(boolean deployXML)
Deploy XML Context config files flag mutator.


setDeployer

public void setDeployer(Deployer d)


setErrorReportValveClass

public void setErrorReportValveClass(String errorReportValveClass)
Set the Java class name of the error report valve class for new web applications.

Parameters:
errorReportValveClass - The new error report valve class


setLiveDeploy

public void setLiveDeploy(boolean liveDeploy)
Set the live deploy flag value for this host.

Parameters:
liveDeploy - The new live deploy flag


setName

public void setName(String name)
Set the canonical, fully qualified, name of the virtual host this Container represents.
Specified by:
setName in interface Host
setName in interface Container
Overrides:
setName in interface ContainerBase

Parameters:
name - Virtual host name


setUnpackWARs

public void setUnpackWARs(boolean unpackWARs)
Unpack WARs flag mutator.


setWorkDir

public void setWorkDir(String workDir)
Host work directory base.


setXmlNamespaceAware

public void setXmlNamespaceAware(boolean xmlNamespaceAware)
Set the namespace aware feature of the XML parser used when parsing xml instances.
Specified by:
setXmlNamespaceAware in interface Host

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.
Specified by:
setXmlValidation in interface Host

Parameters:
xmlValidation - true to enable xml instance validation


start

public void start()
            throws LifecycleException
Start this host.
Specified by:
start in interface Lifecycle
Overrides:
start in interface ContainerBase

Throws:
LifecycleException - if this component detects a fatal error that prevents it from being started


start

public void start(String contextPath)
            throws IOException
Start an existing web application, attached to the specified context path. Only starts a web application if it is not running.
Specified by:
start in interface Deployer

Parameters:
contextPath - The context path of the application to be started


stop

public void stop(String contextPath)
            throws IOException
Stop an existing web application, attached to the specified context path. Only stops a web application if it is running.
Specified by:
stop in interface Deployer

Parameters:
contextPath - The context path of the application to be stopped


toString

public String toString()
Return a String representation of this component.


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.