Java Code Examples for org.apache.catalina.Host#findAliases()

The following examples show how to use org.apache.catalina.Host#findAliases() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HostManagerServlet.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Render a list of the currently active Contexts in our virtual host.
 *
 * @param writer Writer to render to
 * @param smClient StringManager for the client's locale
 */
protected void list(PrintWriter writer, StringManager smClient) {

    if (debug >= 1) {
        log(sm.getString("hostManagerServlet.list", engine.getName()));
    }

    writer.println(smClient.getString("hostManagerServlet.listed",
            engine.getName()));
    Container[] hosts = engine.findChildren();
    for (int i = 0; i < hosts.length; i++) {
        Host host = (Host) hosts[i];
        String name = host.getName();
        String[] aliases = host.findAliases();
        writer.println(smClient.getString("hostManagerServlet.listitem",
                name, StringUtils.join(aliases)));
    }
}
 
Example 2
Source File: MapperListener.java    From Tomcat8-Source-Read with MIT License 6 votes vote down vote up
/**
 * Register host.
 */
private void registerHost(Host host) {

    String[] aliases = host.findAliases();
    mapper.addHost(host.getName(), aliases, host);

    for (Container container : host.findChildren()) {
        if (container.getState().isAvailable()) {
            registerContext((Context) container);
        }
    }
    if(log.isDebugEnabled()) {
        log.debug(sm.getString("mapperListener.registerHost",
                host.getName(), domain, service));
    }
}
 
Example 3
Source File: HostManagerServlet.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Render a list of the currently active Contexts in our virtual host.
 *
 * @param writer Writer to render to
 */
protected void list(PrintWriter writer, StringManager smClient) {

    if (debug >= 1) {
        log(sm.getString("hostManagerServlet.list", engine.getName()));
    }

    writer.println(smClient.getString("hostManagerServlet.listed",
            engine.getName()));
    Container[] hosts = engine.findChildren();
    for (int i = 0; i < hosts.length; i++) {
        Host host = (Host) hosts[i];
        String name = host.getName();
        String[] aliases = host.findAliases();
        StringBuilder buf = new StringBuilder();
        if (aliases.length > 0) {
            buf.append(aliases[0]);
            for (int j = 1; j < aliases.length; j++) {
                buf.append(',').append(aliases[j]);
            }
        }
        writer.println(smClient.getString("hostManagerServlet.listitem",
                                    name, buf.toString()));
    }
}
 
Example 4
Source File: MapperListener.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
/**
 * Register host.
 */
private void registerHost(Host host) {

    String[] aliases = host.findAliases();
    mapper.addHost(host.getName(), aliases, host);

    for (Container container : host.findChildren()) {
        if (container.getState().isAvailable()) {
            registerContext((Context) container);
        }
    }
    if(log.isDebugEnabled()) {
        log.debug(sm.getString("mapperListener.registerHost",
                host.getName(), domain, connector));
    }
}
 
Example 5
Source File: HostManagerServlet.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Render a list of the currently active Contexts in our virtual host.
 *
 * @param writer Writer to render to
 */
protected void list(PrintWriter writer, StringManager smClient) {

    if (debug >= 1) {
        log(sm.getString("hostManagerServlet.list", engine.getName()));
    }

    writer.println(smClient.getString("hostManagerServlet.listed",
            engine.getName()));
    Container[] hosts = engine.findChildren();
    for (int i = 0; i < hosts.length; i++) {
        Host host = (Host) hosts[i];
        String name = host.getName();
        String[] aliases = host.findAliases();
        StringBuilder buf = new StringBuilder();
        if (aliases.length > 0) {
            buf.append(aliases[0]);
            for (int j = 1; j < aliases.length; j++) {
                buf.append(',').append(aliases[j]);
            }
        }
        writer.println(smClient.getString("hostManagerServlet.listitem",
                                    name, buf.toString()));
    }
}
 
Example 6
Source File: MapperListener.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
/**
 * Register host.
 */
private void registerHost(Host host) {

    String[] aliases = host.findAliases();
    mapper.addHost(host.getName(), aliases, host);

    for (Container container : host.findChildren()) {
        if (container.getState().isAvailable()) {
            registerContext((Context) container);
        }
    }
    if(log.isDebugEnabled()) {
        log.debug(sm.getString("mapperListener.registerHost",
                host.getName(), domain, connector));
    }
}
 
Example 7
Source File: MapperListener.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
private void findDefaultHost() {

        Engine engine = service.getContainer();
        String defaultHost = engine.getDefaultHost();

        boolean found = false;

        if (defaultHost != null && defaultHost.length() >0) {
            Container[] containers = engine.findChildren();

            for (Container container : containers) {
                Host host = (Host) container;
                if (defaultHost.equalsIgnoreCase(host.getName())) {
                    found = true;
                    break;
                }

                String[] aliases = host.findAliases();
                for (String alias : aliases) {
                    if (defaultHost.equalsIgnoreCase(alias)) {
                        found = true;
                        break;
                    }
                }
            }
        }

        if(found) {
            mapper.setDefaultHostName(defaultHost);
        } else {
            log.warn(sm.getString("mapperListener.unknownDefaultHost",
                    defaultHost, service));
        }
    }
 
Example 8
Source File: MapperListener.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
private void findDefaultHost() {

        Engine engine = (Engine) connector.getService().getContainer();
        String defaultHost = engine.getDefaultHost();

        boolean found = false;

        if (defaultHost != null && defaultHost.length() >0) {
            Container[] containers = engine.findChildren();

            for (Container container : containers) {
                Host host = (Host) container;
                if (defaultHost.equalsIgnoreCase(host.getName())) {
                    found = true;
                    break;
                }

                String[] aliases = host.findAliases();
                for (String alias : aliases) {
                    if (defaultHost.equalsIgnoreCase(alias)) {
                        found = true;
                        break;
                    }
                }
            }
        }

        if(found) {
            mapper.setDefaultHostName(defaultHost);
        } else {
            log.warn(sm.getString("mapperListener.unknownDefaultHost",
                    defaultHost, connector));
        }
    }
 
Example 9
Source File: MapperListener.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
private void findDefaultHost() {

        Engine engine = (Engine) connector.getService().getContainer();
        String defaultHost = engine.getDefaultHost();

        boolean found = false;

        if (defaultHost != null && defaultHost.length() >0) {
            Container[] containers = engine.findChildren();

            for (Container container : containers) {
                Host host = (Host) container;
                if (defaultHost.equalsIgnoreCase(host.getName())) {
                    found = true;
                    break;
                }

                String[] aliases = host.findAliases();
                for (String alias : aliases) {
                    if (defaultHost.equalsIgnoreCase(alias)) {
                        found = true;
                        break;
                    }
                }
            }
        }

        if(found) {
            mapper.setDefaultHostName(defaultHost);
        } else {
            log.warn(sm.getString("mapperListener.unknownDefaultHost",
                    defaultHost, connector));
        }
    }