use of com.sun.enterprise.web.connector.coyote.PECoyoteConnector in project Payara by payara.
the class WebContainer method updateDefaultWebModule.
/*
* Updates the given virtual server with the given default path.
*
* The given default path corresponds to the context path of one of the
* web contexts deployed on the virtual server that has been designated
* as the virtual server's new default-web-module.
*
* @param virtualServer The virtual server to update
* @param ports The port numbers of the HTTP listeners with which the
* given virtual server is associated
* @param defaultContextPath The context path of the web module that has
* been designated as the virtual server's new default web module, or null
* if the virtual server no longer has any default-web-module
*/
protected void updateDefaultWebModule(VirtualServer virtualServer, String[] listenerNames, WebModuleConfig wmInfo) throws LifecycleException {
String defaultContextPath = null;
if (wmInfo != null) {
defaultContextPath = wmInfo.getContextPath();
}
if (defaultContextPath != null && !defaultContextPath.startsWith("/")) {
defaultContextPath = "/" + defaultContextPath;
wmInfo.getDescriptor().setContextRoot(defaultContextPath);
}
Connector[] connectors = _embedded.findConnectors();
for (Connector connector : connectors) {
PECoyoteConnector conn = (PECoyoteConnector) connector;
String name = conn.getName();
for (String listenerName : listenerNames) {
if (name.equals(listenerName)) {
Mapper mapper = conn.getMapper();
try {
mapper.setDefaultContextPath(virtualServer.getName(), defaultContextPath);
for (String alias : virtualServer.findAliases()) {
mapper.setDefaultContextPath(alias, defaultContextPath);
}
virtualServer.setDefaultContextPath(defaultContextPath);
} catch (Exception e) {
throw new LifecycleException(e);
}
}
}
}
}
Aggregations