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

The following examples show how to use org.apache.catalina.Host#getParent() . 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: TestHostConfigAutomaticDeployment.java    From Tomcat7.0.67 with Apache License 2.0 6 votes vote down vote up
private static File getConfigBaseFile(Host host) {
    String path = null;
    if (host.getXmlBase() != null) {
        path = host.getXmlBase();
    } else {
        StringBuilder xmlDir = new StringBuilder("conf");
        Container parent = host.getParent();
        if (parent instanceof Engine) {
            xmlDir.append('/');
            xmlDir.append(parent.getName());
        }
        xmlDir.append('/');
        xmlDir.append(host.getName());
        path = xmlDir.toString();
    }
    
    return getCanonicalPath(path);
}
 
Example 2
Source File: TestHostConfigAutomaticDeployment.java    From tomcatsrc with Apache License 2.0 6 votes vote down vote up
private static File getConfigBaseFile(Host host) {
    String path = null;
    if (host.getXmlBase() != null) {
        path = host.getXmlBase();
    } else {
        StringBuilder xmlDir = new StringBuilder("conf");
        Container parent = host.getParent();
        if (parent instanceof Engine) {
            xmlDir.append('/');
            xmlDir.append(parent.getName());
        }
        xmlDir.append('/');
        xmlDir.append(host.getName());
        path = xmlDir.toString();
    }
    
    return getCanonicalPath(path);
}
 
Example 3
Source File: WebappLoaderStartInterceptor.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
private String extractContextKey(WebappLoader webappLoader) {
    final String defaultContextName = "";
    try {
        Container container = extractContext(webappLoader);
        // WebappLoader's associated Container should be a Context.
        if (container instanceof Context) {
            Context context = (Context)container;
            String contextName = context.getName();
            Host host = (Host)container.getParent();
            Engine engine = (Engine)host.getParent();
            StringBuilder sb = new StringBuilder();
            sb.append(engine.getName()).append("/").append(host.getName());
            if (!contextName.startsWith("/")) {
                sb.append('/');
            }
            sb.append(contextName);
            return sb.toString();
        }
    } catch (Exception e) {
        // Same action for any and all exceptions.
        logger.warn("Error extracting context name.", e);
    }
    return defaultContextName;
}
 
Example 4
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 5
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 6
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"));
}
 
Example 7
Source File: TomcatWebAppBuilder.java    From tomee with Apache License 2.0 4 votes vote down vote up
private void addTomEERealm(final Host host) {
    final Realm realm = host.getRealm();
    if (realm != null && !(realm instanceof TomEERealm) && (host.getParent() == null || (!realm.equals(host.getParent().getRealm())))) {
        host.setRealm(tomeeRealm(realm));
    }
}