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

The following examples show how to use org.apache.catalina.Host#getName() . 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: 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 3
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 4
Source File: MapperListener.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Unregister host.
 */
private void unregisterHost(Host host) {

    String hostname = host.getName();

    mapper.removeHost(hostname);

    if(log.isDebugEnabled()) {
        log.debug(sm.getString("mapperListener.unregisterHost", hostname,
                domain, service));
    }
}
 
Example 5
Source File: Tomcat.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
private String getLoggerName(Host host, String ctx) {
    String loggerName = "org.apache.catalina.core.ContainerBase.[default].[";
    if (host == null) {
        loggerName += getHost().getName();
    } else {
        loggerName += host.getName();
    }
    loggerName += "].[";
    loggerName += ctx;
    loggerName += "]";
    return loggerName;
}
 
Example 6
Source File: MapperListener.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Unregister host.
 */
private void unregisterHost(Host host) {

    String hostname = host.getName();

    mapper.removeHost(hostname);

    if(log.isDebugEnabled()) {
        log.debug(sm.getString("mapperListener.unregisterHost", hostname,
                domain, connector));
    }
}
 
Example 7
Source File: MapperListener.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Unregister host.
 */
private void unregisterHost(Host host) {

    String hostname = host.getName();

    mapper.removeHost(hostname);

    if(log.isDebugEnabled()) {
        log.debug(sm.getString("mapperListener.unregisterHost", hostname,
                domain, connector));
    }
}
 
Example 8
Source File: RegistryManager.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * @param host
 *            The virtual host to be stored in the registry
 * @param webApp
 *            The webapp to be deployed in the virtual host
 * @throws Exception
 */
public void updateHostToRegistry(Host host, String webApp) throws Exception {
	try {
		registryService.beginTransaction();
		Resource hostResource;
		String hostResourcePath = (UrlMapperConstants.HostProperties.HOSTINFO + host.getName());
		if (registryService.resourceExists(hostResourcePath)) {
			hostResource = registryService.get(hostResourcePath);
			hostResource.setProperty(UrlMapperConstants.HostProperties.HOST_NAME,
					host.getName());
			hostResource.setProperty(UrlMapperConstants.HostProperties.WEB_APP, webApp);
			registryService.put(UrlMapperConstants.HostProperties.HOSTINFO + host.getName(),
					hostResource);
		} else {
			hostResource = registryService.newResource();
			hostResource.addProperty(UrlMapperConstants.HostProperties.HOST_NAME,
					host.getName());
			hostResource.addProperty(UrlMapperConstants.HostProperties.WEB_APP, webApp);
			registryService.put(UrlMapperConstants.HostProperties.HOSTINFO + host.getName(),
					hostResource);
		}
		registryService.commitTransaction();

	} catch (Exception e) {
		registryService.rollbackTransaction();
		log.error("Unable to update the host", e);
		throw e;
	}
}
 
Example 9
Source File: FarmWarDeployer.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
@Override
public void start() throws Exception {
    if (started)
        return;
    Container hcontainer = getCluster().getContainer();
    if(!(hcontainer instanceof Host)) {
        log.error(sm.getString("farmWarDeployer.hostOnly"));
        return ;
    }
    host = (Host) hcontainer;

    // Check to correct engine and host setup
    Container econtainer = host.getParent();
    if(!(econtainer instanceof Engine)) {
        log.error(sm.getString("farmWarDeployer.hostParentEngine",
                host.getName()));
        return ;
    }
    Engine engine = (Engine) econtainer;
    String hostname = null;
    hostname = host.getName();
    try {
        oname = new ObjectName(engine.getName() + ":type=Deployer,host="
                + hostname);
    } catch (Exception e) {
        log.error(sm.getString("farmWarDeployer.mbeanNameFail",
                engine.getName(), hostname),e);
        return;
    }
    if (watchEnabled) {
        watcher = new WarWatcher(this, getWatchDirFile());
        if (log.isInfoEnabled()) {
            log.info(sm.getString(
                    "farmWarDeployer.watchDir", getWatchDir()));
        }
    }

    configBase = host.getConfigBaseFile();

    // Retrieve the MBean server
    mBeanServer = Registry.getRegistry(null, null).getMBeanServer();

    started = true;
    count = 0;

    getCluster().addClusterListener(this);

    if (log.isInfoEnabled())
        log.info(sm.getString("farmWarDeployer.started"));
}
 
Example 10
Source File: FarmWarDeployer.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public void start() throws Exception {
    if (started)
        return;
    Container hcontainer = getCluster().getContainer();
    if(!(hcontainer instanceof Host)) {
        log.error(sm.getString("farmWarDeployer.hostOnly"));
        return ;
    }
    host = (Host) hcontainer;

    // Check to correct engine and host setup
    Container econtainer = host.getParent();
    if(!(econtainer instanceof Engine)) {
        log.error(sm.getString("farmWarDeployer.hostParentEngine",
                host.getName())); 
        return ;
    }
    Engine engine = (Engine) econtainer;
    String hostname = null;
    hostname = host.getName();
    try {
        oname = new ObjectName(engine.getName() + ":type=Deployer,host="
                + hostname);
    } catch (Exception e) {
        log.error(sm.getString("farmWarDeployer.mbeanNameFail",
                engine.getName(), hostname),e);
        return;
    }
    if (watchEnabled) {
        watcher = new WarWatcher(this, getWatchDirFile());
        if (log.isInfoEnabled()) {
            log.info(sm.getString(
                    "farmWarDeployer.watchDir", getWatchDir()));
        }
    }

    if (host.getXmlBase()!=null) {
        configBase = getAbsolutePath(host.getXmlBase());
    } else {
        StringBuilder xmlDir = new StringBuilder("conf");
        xmlDir.append('/');
        xmlDir.append(engine.getName());
        xmlDir.append('/');
        xmlDir.append(host.getName());
        configBase = getAbsolutePath(xmlDir.toString());
    }

    // Retrieve the MBean server
    mBeanServer = Registry.getRegistry(null, null).getMBeanServer();

    started = true;
    count = 0;

    getCluster().addClusterListener(this);

    if (log.isInfoEnabled())
        log.info(sm.getString("farmWarDeployer.started"));
}
 
Example 11
Source File: FarmWarDeployer.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public void start() throws Exception {
    if (started)
        return;
    Container hcontainer = getCluster().getContainer();
    if(!(hcontainer instanceof Host)) {
        log.error(sm.getString("farmWarDeployer.hostOnly"));
        return ;
    }
    host = (Host) hcontainer;

    // Check to correct engine and host setup
    Container econtainer = host.getParent();
    if(!(econtainer instanceof Engine)) {
        log.error(sm.getString("farmWarDeployer.hostParentEngine",
                host.getName())); 
        return ;
    }
    Engine engine = (Engine) econtainer;
    String hostname = null;
    hostname = host.getName();
    try {
        oname = new ObjectName(engine.getName() + ":type=Deployer,host="
                + hostname);
    } catch (Exception e) {
        log.error(sm.getString("farmWarDeployer.mbeanNameFail",
                engine.getName(), hostname),e);
        return;
    }
    if (watchEnabled) {
        watcher = new WarWatcher(this, getWatchDirFile());
        if (log.isInfoEnabled()) {
            log.info(sm.getString(
                    "farmWarDeployer.watchDir", getWatchDir()));
        }
    }

    if (host.getXmlBase()!=null) {
        configBase = getAbsolutePath(host.getXmlBase());
    } else {
        StringBuilder xmlDir = new StringBuilder("conf");
        xmlDir.append('/');
        xmlDir.append(engine.getName());
        xmlDir.append('/');
        xmlDir.append(host.getName());
        configBase = getAbsolutePath(xmlDir.toString());
    }

    // Retrieve the MBean server
    mBeanServer = Registry.getRegistry(null, null).getMBeanServer();

    started = true;
    count = 0;

    getCluster().addClusterListener(this);

    if (log.isInfoEnabled())
        log.info(sm.getString("farmWarDeployer.started"));
}