Java Code Examples for org.apache.catalina.Context#getBaseName()

The following examples show how to use org.apache.catalina.Context#getBaseName() . 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: FarmWarDeployer.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Invoke the remove method on the deployer.
 * @param contextName The context to remove
 * @throws Exception If an error occurs removing the context
 */
protected void remove(String contextName) throws Exception {
    // TODO Handle remove also work dir content !
    // Stop the context first to be nicer
    Context context = (Context) host.findChild(contextName);
    if (context != null) {
        if(log.isDebugEnabled())
            log.debug(sm.getString("farmWarDeployer.undeployLocal",
                    contextName));
        context.stop();
        String baseName = context.getBaseName();
        File war = new File(host.getAppBaseFile(), baseName + ".war");
        File dir = new File(host.getAppBaseFile(), baseName);
        File xml = new File(configBase, baseName + ".xml");
        if (war.exists()) {
            if (!war.delete()) {
                log.error(sm.getString("farmWarDeployer.deleteFail", war));
            }
        } else if (dir.exists()) {
            undeployDir(dir);
        } else {
            if (!xml.delete()) {
                log.error(sm.getString("farmWarDeployer.deleteFail", xml));
            }
        }
        // Perform new deployment and remove internal HostConfig state
        check(contextName);
    }

}
 
Example 2
Source File: FarmWarDeployer.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Invoke the remove method on the deployer.
 */
protected void remove(String contextName) throws Exception {
    // TODO Handle remove also work dir content !
    // Stop the context first to be nicer
    Context context = (Context) host.findChild(contextName);
    if (context != null) {
        if(log.isDebugEnabled())
            log.debug(sm.getString("farmWarDeployer.undeployLocal",
                    contextName));
        context.stop();
        String baseName = context.getBaseName();
        File war = new File(getAppBase(), baseName + ".war");
        File dir = new File(getAppBase(), baseName);
        File xml = new File(configBase, baseName + ".xml");
        if (war.exists()) {
            if (!war.delete()) {
                log.error(sm.getString("farmWarDeployer.deleteFail", war));
            }
        } else if (dir.exists()) {
            undeployDir(dir);
        } else {
            if (!xml.delete()) {
                log.error(sm.getString("farmWarDeployer.deleteFail", xml));
            }
        }
        // Perform new deployment and remove internal HostConfig state
        check(contextName);
    }

}
 
Example 3
Source File: FarmWarDeployer.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Invoke the remove method on the deployer.
 */
protected void remove(String contextName) throws Exception {
    // TODO Handle remove also work dir content !
    // Stop the context first to be nicer
    Context context = (Context) host.findChild(contextName);
    if (context != null) {
        if(log.isDebugEnabled())
            log.debug(sm.getString("farmWarDeployer.undeployLocal",
                    contextName));
        context.stop();
        String baseName = context.getBaseName();
        File war = new File(getAppBase(), baseName + ".war");
        File dir = new File(getAppBase(), baseName);
        File xml = new File(configBase, baseName + ".xml");
        if (war.exists()) {
            if (!war.delete()) {
                log.error(sm.getString("farmWarDeployer.deleteFail", war));
            }
        } else if (dir.exists()) {
            undeployDir(dir);
        } else {
            if (!xml.delete()) {
                log.error(sm.getString("farmWarDeployer.deleteFail", xml));
            }
        }
        // Perform new deployment and remove internal HostConfig state
        check(contextName);
    }

}