interface. Each
child container must be a Context implementation to process the
requests directed to a particular web application.
| Method from org.apache.catalina.core.StandardHost Detail: |
public void addAlias(String alias) {
alias = alias.toLowerCase();
synchronized (aliasesLock) {
// Skip duplicate aliases
for (int i = 0; i < aliases.length; i++) {
if (aliases[i].equals(alias))
return;
}
// Add this alias to the list
String newAliases[] = new String[aliases.length + 1];
for (int i = 0; i < aliases.length; i++)
newAliases[i] = aliases[i];
newAliases[aliases.length] = alias;
aliases = newAliases;
}
// Inform interested listeners
fireContainerEvent(ADD_ALIAS_EVENT, alias);
}
Add an alias name that should be mapped to this same Host. |
public void addChild(Container child) {
if (child instanceof Lifecycle) {
((Lifecycle) child).addLifecycleListener(
new MemoryLeakTrackingListener());
}
if (!(child instanceof Context))
throw new IllegalArgumentException
(sm.getString("standardHost.notContext"));
super.addChild(child);
}
Add a child Container, only if the proposed child is an implementation
of Context. |
public ObjectName createObjectName(String domain,
ObjectName parent) throws Exception {
if( log.isDebugEnabled())
log.debug("Create ObjectName " + domain + " " + parent );
return new ObjectName( domain + ":type=Host,host=" + getName());
}
|
public void destroy() throws Exception {
// destroy our child containers, if any
Container children[] = findChildren();
super.destroy();
for (int i = 0; i < children.length; i++) {
if(children[i] instanceof StandardContext)
((StandardContext)children[i]).destroy();
}
}
|
public String[] findAliases() {
synchronized (aliasesLock) {
return (this.aliases);
}
}
Return the set of alias names for this Host. If none are defined,
a zero length array is returned. |
public String[] findReloadedContextMemoryLeaks() {
System.gc();
List< String > result = new ArrayList< String >();
for (Map.Entry< ClassLoader, String > entry :
childClassLoaders.entrySet()) {
ClassLoader cl = entry.getKey();
if (cl instanceof WebappClassLoader) {
if (!((WebappClassLoader) cl).isStarted()) {
result.add(entry.getValue());
}
}
}
return result.toArray(new String[result.size()]);
}
Attempt to identify the contexts that have a class loader memory leak.
This is usually triggered on context reload. Note: This method attempts
to force a full garbage collection. This should be used with extreme
caution on a production system. |
public String[] getAliases() {
synchronized (aliasesLock) {
return aliases;
}
}
|
public String getAppBase() {
return (this.appBase);
}
Return the application root for this Host. This can be an absolute
pathname, a relative pathname, or a URL. |
public boolean getAutoDeploy() {
return (this.autoDeploy);
}
Return the value of the auto deploy flag. If true, it indicates that
this host's child webapps will be dynamically deployed. |
public String getConfigClass() {
return (this.configClass);
}
Return the Java class name of the context configuration class
for new web applications. |
public String getContextClass() {
return (this.contextClass);
}
Return the Java class name of the Context implementation class
for new web applications. |
public boolean getDeployOnStartup() {
return (this.deployOnStartup);
}
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. |
public String getErrorReportValveClass() {
return (this.errorReportValveClass);
}
Return the Java class name of the error report valve class
for new web applications. |
public String getInfo() {
return (info);
}
Return descriptive information about this Container implementation and
the corresponding version number, in the format
<description>/<version>. |
public boolean getLiveDeploy() {
return (this.autoDeploy);
}
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. |
public String getName() {
return (name);
}
Return the canonical, fully qualified, name of the virtual host
this Container represents. |
public String[] getValveNames() throws Exception {
Valve [] valves = this.getValves();
String [] mbeanNames = new String[valves.length];
for (int i = 0; i < valves.length; i++) {
if( valves[i] == null ) continue;
if( ((ValveBase)valves[i]).getObjectName() == null ) continue;
mbeanNames[i] = ((ValveBase)valves[i]).getObjectName().toString();
}
return mbeanNames;
}
Return the MBean Names of the Valves assoicated with this Host |
public String getWorkDir() {
return (workDir);
}
Host work directory base. |
public boolean getXmlNamespaceAware() {
return xmlNamespaceAware;
}
Get the server.xml <host> attribute's xmlNamespaceAware. |
public boolean getXmlValidation() {
return xmlValidation;
}
Get the server.xml <host> attribute's xmlValidation. |
public void init() {
if( initialized ) return;
initialized=true;
// already registered.
if( getParent() == null ) {
try {
// Register with the Engine
ObjectName serviceName=new ObjectName(domain +
":type=Engine");
HostConfig deployer = new HostConfig();
addLifecycleListener(deployer);
if( mserver.isRegistered( serviceName )) {
if(log.isDebugEnabled())
log.debug("Registering "+ serviceName +" with the Engine");
mserver.invoke( serviceName, "addChild",
new Object[] { this },
new String[] { "org.apache.catalina.Container" } );
}
} catch( Exception ex ) {
log.error("Host registering failed!",ex);
}
}
if( oname==null ) {
// not registered in JMX yet - standalone mode
try {
StandardEngine engine=(StandardEngine)parent;
domain=engine.getName();
if(log.isDebugEnabled())
log.debug( "Register host " + getName() + " with domain "+ domain );
oname=new ObjectName(domain + ":type=Host,host=" +
this.getName());
controller = oname;
Registry.getRegistry(null, null)
.registerComponent(this, oname, null);
} catch( Throwable t ) {
log.error("Host registering failed!", t );
}
}
}
|
public boolean isDeployXML() {
return (deployXML);
}
Deploy XML Context config files flag accessor. |
public boolean isUnpackWARs() {
return (unpackWARs);
}
Unpack WARs flag accessor. |
public Context map(String uri) {
if (log.isDebugEnabled())
log.debug("Mapping request URI '" + uri + "'");
if (uri == null)
return (null);
// Match on the longest possible context path prefix
if (log.isTraceEnabled())
log.trace(" Trying the longest context path prefix");
Context context = null;
String mapuri = uri;
while (true) {
context = (Context) findChild(mapuri);
if (context != null)
break;
int slash = mapuri.lastIndexOf('/');
if (slash < 0)
break;
mapuri = mapuri.substring(0, slash);
}
// If no Context matches, select the default Context
if (context == null) {
if (log.isTraceEnabled())
log.trace(" Trying the default context");
context = (Context) findChild("");
}
// Complain if no Context has been selected
if (context == null) {
log.error(sm.getString("standardHost.mappingError", uri));
return (null);
}
// Return the mapped Context (if any)
if (log.isDebugEnabled())
log.debug(" Mapped to context '" + context.getPath() + "'");
return (context);
}
Return the Context that would be used to process the specified
host-relative request URI, if any; otherwise return null. |
public ObjectName preRegister(MBeanServer server,
ObjectName oname) throws Exception {
ObjectName res=super.preRegister(server, oname);
String name=oname.getKeyProperty("host");
if( name != null )
setName( name );
return res;
}
|
public void removeAlias(String alias) {
alias = alias.toLowerCase();
synchronized (aliasesLock) {
// Make sure this alias is currently present
int n = -1;
for (int i = 0; i < aliases.length; i++) {
if (aliases[i].equals(alias)) {
n = i;
break;
}
}
if (n < 0)
return;
// Remove the specified alias
int j = 0;
String results[] = new String[aliases.length - 1];
for (int i = 0; i < aliases.length; i++) {
if (i != n)
results[j++] = aliases[i];
}
aliases = results;
}
// Inform interested listeners
fireContainerEvent(REMOVE_ALIAS_EVENT, alias);
}
Remove the specified alias name from the aliases for this Host. |
public void setAppBase(String appBase) {
String oldAppBase = this.appBase;
this.appBase = appBase;
support.firePropertyChange("appBase", oldAppBase, this.appBase);
}
Set the application root for this Host. This can be an absolute
pathname, a relative pathname, or a URL. |
public void setAutoDeploy(boolean autoDeploy) {
boolean oldAutoDeploy = this.autoDeploy;
this.autoDeploy = autoDeploy;
support.firePropertyChange("autoDeploy", oldAutoDeploy,
this.autoDeploy);
}
Set the auto deploy flag value for this host. |
public void setConfigClass(String configClass) {
String oldConfigClass = this.configClass;
this.configClass = configClass;
support.firePropertyChange("configClass",
oldConfigClass, this.configClass);
}
Set the Java class name of the context configuration class
for new web applications. |
public void setContextClass(String contextClass) {
String oldContextClass = this.contextClass;
this.contextClass = contextClass;
support.firePropertyChange("contextClass",
oldContextClass, this.contextClass);
}
Set the Java class name of the Context implementation class
for new web applications. |
public void setDeployOnStartup(boolean deployOnStartup) {
boolean oldDeployOnStartup = this.deployOnStartup;
this.deployOnStartup = deployOnStartup;
support.firePropertyChange("deployOnStartup", oldDeployOnStartup,
this.deployOnStartup);
}
Set the deploy on startup flag value for this host. |
public void setDeployXML(boolean deployXML) {
this.deployXML = deployXML;
}
Deploy XML Context config files flag mutator. |
public void setErrorReportValveClass(String errorReportValveClass) {
String oldErrorReportValveClassClass = this.errorReportValveClass;
this.errorReportValveClass = errorReportValveClass;
support.firePropertyChange("errorReportValveClass",
oldErrorReportValveClassClass,
this.errorReportValveClass);
}
Set the Java class name of the error report valve class
for new web applications. |
public void setLiveDeploy(boolean liveDeploy) {
setAutoDeploy(liveDeploy);
}
Set the live deploy flag value for this host. |
public void setName(String name) {
if (name == null)
throw new IllegalArgumentException
(sm.getString("standardHost.nullName"));
name = name.toLowerCase(); // Internally all names are lower case
String oldName = this.name;
this.name = name;
support.firePropertyChange("name", oldName, this.name);
}
Set the canonical, fully qualified, name of the virtual host
this Container represents. |
public void setUnpackWARs(boolean unpackWARs) {
this.unpackWARs = unpackWARs;
}
Unpack WARs flag mutator. |
public void setWorkDir(String workDir) {
this.workDir = workDir;
}
Host work directory base. |
public void setXmlNamespaceAware(boolean xmlNamespaceAware) {
this.xmlNamespaceAware=xmlNamespaceAware;
}
Set the namespace aware feature of the XML parser used when
parsing xml instances. |
public void setXmlValidation(boolean xmlValidation) {
this.xmlValidation = xmlValidation;
}
Set the validation feature of the XML parser used when
parsing xml instances. |
public synchronized void start() throws LifecycleException {
if( started ) {
return;
}
if( ! initialized )
init();
// Look for a realm - that may have been configured earlier.
// If the realm is added after context - it'll set itself.
if( realm == null ) {
ObjectName realmName=null;
try {
realmName=new ObjectName( domain + ":type=Realm,host=" + getName());
if( mserver.isRegistered(realmName ) ) {
mserver.invoke(realmName, "init",
new Object[] {},
new String[] {}
);
}
} catch( Throwable t ) {
log.debug("No realm for this host " + realmName);
}
}
// Set error report valve
if ((errorReportValveClass != null)
&& (!errorReportValveClass.equals(""))) {
try {
boolean found = false;
if(errorReportValveObjectName != null) {
ObjectName[] names =
((StandardPipeline)pipeline).getValveObjectNames();
for (int i=0; !found && i< names.length; i++)
if(errorReportValveObjectName.equals(names[i]))
found = true ;
}
if(!found) {
Valve valve = (Valve) Class.forName(errorReportValveClass)
.newInstance();
addValve(valve);
errorReportValveObjectName = ((ValveBase)valve).getObjectName() ;
}
} catch (Throwable t) {
log.error(sm.getString
("standardHost.invalidErrorReportValveClass",
errorReportValveClass), t);
}
}
if(log.isDebugEnabled()) {
if (xmlValidation)
log.debug(sm.getString("standardHost.validationEnabled"));
else
log.debug(sm.getString("standardHost.validationDisabled"));
}
super.start();
}
|
public String toString() {
StringBuffer sb = new StringBuffer();
if (getParent() != null) {
sb.append(getParent().toString());
sb.append(".");
}
sb.append("StandardHost[");
sb.append(getName());
sb.append("]");
return (sb.toString());
}
Return a String representation of this component. |