Fields Summary |
---|
private static org.apache.juli.logging.Log | log |
private String[] | aliasesThe set of aliases for this Host. |
private String | appBaseThe application root for this Host. |
private boolean | autoDeployThe auto deploy flag for this Host. |
private String | configClassThe Java class name of the default context configuration class
for deployed web applications. |
private String | contextClassThe Java class name of the default Context implementation class for
deployed web applications. |
private boolean | deployOnStartupThe deploy on startup flag for this Host. |
private boolean | deployXMLdeploy Context XML config files property. |
private String | errorReportValveClassThe Java class name of the default error reporter implementation class
for deployed web applications. |
private ObjectName | errorReportValveObjectNameThe object name for the errorReportValve. |
private static final String | infoThe descriptive information string for this implementation. |
private boolean | liveDeployThe live deploy flag for this Host. |
private boolean | unpackWARsUnpack WARs property. |
private String | workDirWork Directory base for applications. |
private boolean | xmlValidationAttribute value used to turn on/off XML validation |
private boolean | xmlNamespaceAwareAttribute value used to turn on/off XML namespace awarenes. |
private boolean | initialized |
Methods Summary |
---|
public void | addAlias(java.lang.String alias)Add an alias name that should be mapped to this same Host.
alias = alias.toLowerCase();
// 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);
|
public void | addChild(org.apache.catalina.Container child)Add a child Container, only if the proposed child is an implementation
of Context.
if (!(child instanceof Context))
throw new IllegalArgumentException
(sm.getString("standardHost.notContext"));
super.addChild(child);
|
public javax.management.ObjectName | createObjectName(java.lang.String domain, javax.management.ObjectName parent)
if( log.isDebugEnabled())
log.debug("Create ObjectName " + domain + " " + parent );
return new ObjectName( domain + ":type=Host,host=" + getName());
|
public void | destroy()
// 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 java.lang.String[] | findAliases()Return the set of alias names for this Host. If none are defined,
a zero length array is returned.
return (this.aliases);
|
public java.lang.String[] | getAliases()
return aliases;
|
public java.lang.String | getAppBase()Return the application root for this Host. This can be an absolute
pathname, a relative pathname, or a URL.
// ------------------------------------------------------------- Properties
return (this.appBase);
|
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.
return (this.autoDeploy);
|
public java.lang.String | getConfigClass()Return the Java class name of the context configuration class
for new web applications.
return (this.configClass);
|
public java.lang.String | getContextClass()Return the Java class name of the Context implementation class
for new web applications.
return (this.contextClass);
|
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.
return (this.deployOnStartup);
|
public java.lang.String | getErrorReportValveClass()Return the Java class name of the error report valve class
for new web applications.
return (this.errorReportValveClass);
|
public java.lang.String | getInfo()Return descriptive information about this Container implementation and
the corresponding version number, in the format
<description>/<version> .
return (info);
|
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.
return (this.autoDeploy);
|
public java.lang.String | getName()Return the canonical, fully qualified, name of the virtual host
this Container represents.
return (name);
|
public java.lang.String[] | getValveNames()Return the MBean Names of the Valves assoicated with this Host
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;
|
public java.lang.String | getWorkDir()Host work directory base.
return (workDir);
|
public boolean | getXmlNamespaceAware()Get the server.xml attribute's xmlNamespaceAware.
return xmlNamespaceAware;
|
public boolean | getXmlValidation()Get the server.xml attribute's xmlValidation.
return 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()Deploy XML Context config files flag accessor.
return (deployXML);
|
public boolean | isUnpackWARs()Unpack WARs flag accessor.
return (unpackWARs);
|
public org.apache.catalina.Context | map(java.lang.String uri)Return the Context that would be used to process the specified
host-relative request URI, if any; otherwise return null .
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);
|
public javax.management.ObjectName | preRegister(javax.management.MBeanServer server, javax.management.ObjectName oname)
ObjectName res=super.preRegister(server, oname);
String name=oname.getKeyProperty("host");
if( name != null )
setName( name );
return res;
|
public void | removeAlias(java.lang.String alias)Remove the specified alias name from the aliases for this Host.
alias = alias.toLowerCase();
synchronized (aliases) {
// 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);
|
public void | setAppBase(java.lang.String appBase)Set the application root for this Host. This can be an absolute
pathname, a relative pathname, or a URL.
String oldAppBase = this.appBase;
this.appBase = appBase;
support.firePropertyChange("appBase", oldAppBase, this.appBase);
|
public void | setAutoDeploy(boolean autoDeploy)Set the auto deploy flag value for this host.
boolean oldAutoDeploy = this.autoDeploy;
this.autoDeploy = autoDeploy;
support.firePropertyChange("autoDeploy", oldAutoDeploy,
this.autoDeploy);
|
public void | setConfigClass(java.lang.String configClass)Set the Java class name of the context configuration class
for new web applications.
String oldConfigClass = this.configClass;
this.configClass = configClass;
support.firePropertyChange("configClass",
oldConfigClass, this.configClass);
|
public void | setContextClass(java.lang.String contextClass)Set the Java class name of the Context implementation class
for new web applications.
String oldContextClass = this.contextClass;
this.contextClass = contextClass;
support.firePropertyChange("contextClass",
oldContextClass, this.contextClass);
|
public void | setDeployOnStartup(boolean deployOnStartup)Set the deploy on startup flag value for this host.
boolean oldDeployOnStartup = this.deployOnStartup;
this.deployOnStartup = deployOnStartup;
support.firePropertyChange("deployOnStartup", oldDeployOnStartup,
this.deployOnStartup);
|
public void | setDeployXML(boolean deployXML)Deploy XML Context config files flag mutator.
this.deployXML = deployXML;
|
public void | setErrorReportValveClass(java.lang.String errorReportValveClass)Set the Java class name of the error report valve class
for new web applications.
String oldErrorReportValveClassClass = this.errorReportValveClass;
this.errorReportValveClass = errorReportValveClass;
support.firePropertyChange("errorReportValveClass",
oldErrorReportValveClassClass,
this.errorReportValveClass);
|
public void | setLiveDeploy(boolean liveDeploy)Set the live deploy flag value for this host.
setAutoDeploy(liveDeploy);
|
public void | setName(java.lang.String name)Set the canonical, fully qualified, name of the virtual host
this Container represents.
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);
|
public void | setUnpackWARs(boolean unpackWARs)Unpack WARs flag mutator.
this.unpackWARs = unpackWARs;
|
public void | setWorkDir(java.lang.String workDir)Host work directory base.
this.workDir = workDir;
|
public void | setXmlNamespaceAware(boolean xmlNamespaceAware)Set the namespace aware feature of the XML parser used when
parsing xml instances.
this.xmlNamespaceAware=xmlNamespaceAware;
|
public void | setXmlValidation(boolean xmlValidation)Set the validation feature of the XML parser used when
parsing xml instances.
this.xmlValidation = xmlValidation;
|
public synchronized void | start()Start this host.
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));
}
}
if(log.isDebugEnabled()) {
if (xmlValidation)
log.debug(sm.getString("standardHost.validationEnabled"));
else
log.debug(sm.getString("standardHost.validationDisabled"));
}
super.start();
|
public java.lang.String | toString()Return a String representation of this component.
StringBuffer sb = new StringBuffer();
if (getParent() != null) {
sb.append(getParent().toString());
sb.append(".");
}
sb.append("StandardHost[");
sb.append(getName());
sb.append("]");
return (sb.toString());
|