Search in sources :

Example 1 with PECoyoteConnector

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);
                }
            }
        }
    }
}
Also used : PECoyoteConnector(com.sun.enterprise.web.connector.coyote.PECoyoteConnector) Connector(org.apache.catalina.Connector) Mapper(org.glassfish.grizzly.http.server.util.Mapper) ContextMapper(org.glassfish.internal.grizzly.ContextMapper) ContainerMapper(com.sun.enterprise.v3.services.impl.ContainerMapper) LifecycleException(org.apache.catalina.LifecycleException) PECoyoteConnector(com.sun.enterprise.web.connector.coyote.PECoyoteConnector) LifecycleException(org.apache.catalina.LifecycleException) NamingException(javax.naming.NamingException) BindException(java.net.BindException) MalformedURLException(java.net.MalformedURLException)

Aggregations

ContainerMapper (com.sun.enterprise.v3.services.impl.ContainerMapper)1 PECoyoteConnector (com.sun.enterprise.web.connector.coyote.PECoyoteConnector)1 BindException (java.net.BindException)1 MalformedURLException (java.net.MalformedURLException)1 NamingException (javax.naming.NamingException)1 Connector (org.apache.catalina.Connector)1 LifecycleException (org.apache.catalina.LifecycleException)1 Mapper (org.glassfish.grizzly.http.server.util.Mapper)1 ContextMapper (org.glassfish.internal.grizzly.ContextMapper)1