Java Code Examples for org.apache.catalina.util.ContextName#getDisplayName()

The following examples show how to use org.apache.catalina.util.ContextName#getDisplayName() . 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: ManagerServlet.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Start the web application at the specified context path.
 *
 * @param writer Writer to render to
 * @param cn Name of the application to be started
 * @param smClient i18n support for current client's locale
 */
protected void start(PrintWriter writer, ContextName cn,
        StringManager smClient) {

    if (debug >= 1)
        log("start: Starting web application '" + cn + "'");

    if (!validateContextName(cn, writer, smClient)) {
        return;
    }

    String displayPath = cn.getDisplayName();

    try {
        Context context = (Context) host.findChild(cn.getName());
        if (context == null) {
            writer.println(smClient.getString("managerServlet.noContext",
                    Escape.htmlElementContent(displayPath)));
            return;
        }
        context.start();
        if (context.getState().isAvailable())
            writer.println(smClient.getString("managerServlet.started",
                    displayPath));
        else
            writer.println(smClient.getString("managerServlet.startFailed",
                    displayPath));
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        getServletContext().log(sm.getString("managerServlet.startFailed",
                displayPath), t);
        writer.println(smClient.getString("managerServlet.startFailed",
                displayPath));
        writer.println(smClient.getString("managerServlet.exception",
                t.toString()));
    }

}
 
Example 2
Source File: ManagerServlet.java    From Tomcat8-Source-Read with MIT License 5 votes vote down vote up
/**
 * Stop the web application at the specified context path.
 *
 * @param writer Writer to render to
 * @param cn Name of the application to be stopped
 * @param smClient i18n support for current client's locale
 */
protected void stop(PrintWriter writer, ContextName cn,
        StringManager smClient) {

    if (debug >= 1)
        log("stop: Stopping web application '" + cn + "'");

    if (!validateContextName(cn, writer, smClient)) {
        return;
    }

    String displayPath = cn.getDisplayName();

    try {
        Context context = (Context) host.findChild(cn.getName());
        if (context == null) {
            writer.println(smClient.getString("managerServlet.noContext",
                    Escape.htmlElementContent(displayPath)));
            return;
        }
        // It isn't possible for the manager to stop itself
        if (context.getName().equals(this.context.getName())) {
            writer.println(smClient.getString("managerServlet.noSelf"));
            return;
        }
        context.stop();
        writer.println(smClient.getString(
                "managerServlet.stopped", displayPath));
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        log("ManagerServlet.stop[" + displayPath + "]", t);
        writer.println(smClient.getString("managerServlet.exception",
                t.toString()));
    }

}
 
Example 3
Source File: ManagerServlet.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Start the web application at the specified context path.
 *
 * @param writer Writer to render to
 * @param cn Name of the application to be started
 */
protected void start(PrintWriter writer, ContextName cn,
        StringManager smClient) {

    if (debug >= 1)
        log("start: Starting web application '" + cn + "'");

    if (!validateContextName(cn, writer, smClient)) {
        return;
    }

    String displayPath = cn.getDisplayName();

    try {
        Context context = (Context) host.findChild(cn.getName());
        if (context == null) {
            writer.println(smClient.getString("managerServlet.noContext", 
                    RequestUtil.filter(displayPath)));
            return;
        }
        context.start();
        if (context.getState().isAvailable())
            writer.println(smClient.getString("managerServlet.started",
                    displayPath));
        else
            writer.println(smClient.getString("managerServlet.startFailed",
                    displayPath));
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        getServletContext().log(sm.getString("managerServlet.startFailed",
                displayPath), t);
        writer.println(smClient.getString("managerServlet.startFailed",
                displayPath));
        writer.println(smClient.getString("managerServlet.exception",
                t.toString()));
    }

}
 
Example 4
Source File: ManagerServlet.java    From Tomcat7.0.67 with Apache License 2.0 5 votes vote down vote up
/**
 * Stop the web application at the specified context path.
 *
 * @param writer Writer to render to
 * @param cn Name of the application to be stopped
 */
protected void stop(PrintWriter writer, ContextName cn,
        StringManager smClient) {

    if (debug >= 1)
        log("stop: Stopping web application '" + cn + "'");

    if (!validateContextName(cn, writer, smClient)) {
        return;
    }

    String displayPath = cn.getDisplayName();

    try {
        Context context = (Context) host.findChild(cn.getName());
        if (context == null) {
            writer.println(smClient.getString("managerServlet.noContext",
                    RequestUtil.filter(displayPath)));
            return;
        }
        // It isn't possible for the manager to stop itself
        if (context.getName().equals(this.context.getName())) {
            writer.println(smClient.getString("managerServlet.noSelf"));
            return;
        }
        context.stop();
        writer.println(smClient.getString(
                "managerServlet.stopped", displayPath));
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        log("ManagerServlet.stop[" + displayPath + "]", t);
        writer.println(smClient.getString("managerServlet.exception",
                t.toString()));
    }

}
 
Example 5
Source File: ManagerServlet.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Start the web application at the specified context path.
 *
 * @param writer Writer to render to
 * @param cn Name of the application to be started
 */
protected void start(PrintWriter writer, ContextName cn,
        StringManager smClient) {

    if (debug >= 1)
        log("start: Starting web application '" + cn + "'");

    if (!validateContextName(cn, writer, smClient)) {
        return;
    }

    String displayPath = cn.getDisplayName();

    try {
        Context context = (Context) host.findChild(cn.getName());
        if (context == null) {
            writer.println(smClient.getString("managerServlet.noContext", 
                    RequestUtil.filter(displayPath)));
            return;
        }
        context.start();
        if (context.getState().isAvailable())
            writer.println(smClient.getString("managerServlet.started",
                    displayPath));
        else
            writer.println(smClient.getString("managerServlet.startFailed",
                    displayPath));
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        getServletContext().log(sm.getString("managerServlet.startFailed",
                displayPath), t);
        writer.println(smClient.getString("managerServlet.startFailed",
                displayPath));
        writer.println(smClient.getString("managerServlet.exception",
                t.toString()));
    }

}
 
Example 6
Source File: ManagerServlet.java    From tomcatsrc with Apache License 2.0 5 votes vote down vote up
/**
 * Stop the web application at the specified context path.
 *
 * @param writer Writer to render to
 * @param cn Name of the application to be stopped
 */
protected void stop(PrintWriter writer, ContextName cn,
        StringManager smClient) {

    if (debug >= 1)
        log("stop: Stopping web application '" + cn + "'");

    if (!validateContextName(cn, writer, smClient)) {
        return;
    }

    String displayPath = cn.getDisplayName();

    try {
        Context context = (Context) host.findChild(cn.getName());
        if (context == null) {
            writer.println(smClient.getString("managerServlet.noContext",
                    RequestUtil.filter(displayPath)));
            return;
        }
        // It isn't possible for the manager to stop itself
        if (context.getName().equals(this.context.getName())) {
            writer.println(smClient.getString("managerServlet.noSelf"));
            return;
        }
        context.stop();
        writer.println(smClient.getString(
                "managerServlet.stopped", displayPath));
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        log("ManagerServlet.stop[" + displayPath + "]", t);
        writer.println(smClient.getString("managerServlet.exception",
                t.toString()));
    }

}
 
Example 7
Source File: ManagerServlet.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
/**
 * Install an application for the specified path from the specified
 * web application archive.
 *
 * @param writer    Writer to render results to
 * @param tag       Revision tag to deploy from
 * @param cn        Name of the application to be installed
 * @param smClient  i18n messages using the locale of the client
 */
protected void deploy(PrintWriter writer, ContextName cn, String tag,
        StringManager smClient) {

    // NOTE: It is assumed that update is always true in this method.

    // Validate the requested context path
    if (!validateContextName(cn, writer, smClient)) {
        return;
    }

    String baseName = cn.getBaseName();
    String name = cn.getName();
    String displayPath = cn.getDisplayName();

    // Find the local WAR file
    File localWar = new File(new File(versioned, tag), baseName + ".war");

    File deployedWar = new File(host.getAppBaseFile(), baseName + ".war");

    // Copy WAR to appBase
    try {
        if (isServiced(name)) {
            writer.println(smClient.getString("managerServlet.inService", displayPath));
        } else {
            addServiced(name);
            try {
                if (!deployedWar.delete()) {
                    writer.println(smClient.getString("managerServlet.deleteFail",
                            deployedWar));
                    return;
                }
                copy(localWar, deployedWar);
                // Perform new deployment
                check(name);
            } finally {
                removeServiced(name);
            }
        }
    } catch (Exception e) {
        log("managerServlet.check[" + displayPath + "]", e);
        writer.println(smClient.getString("managerServlet.exception",
                e.toString()));
        return;
    }

    writeDeployResult(writer, smClient, name, displayPath);
}
 
Example 8
Source File: ManagerServlet.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
/**
 * Install an application for the specified path from the specified
 * web application archive.
 *
 * @param writer    Writer to render results to
 * @param tag       Revision tag to deploy from
 * @param cn        Name of the application to be installed
 * @param smClient  i18n messages using the locale of the client
 */
protected void deploy(PrintWriter writer, ContextName cn, String tag,
        StringManager smClient) {

    // NOTE: It is assumed that update is always true in this method.

    // Validate the requested context path
    if (!validateContextName(cn, writer, smClient)) {
        return;
    }

    String baseName = cn.getBaseName();
    String name = cn.getName();
    String displayPath = cn.getDisplayName();
    
    // Find the local WAR file
    File localWar = new File(new File(versioned, tag), baseName + ".war");

    File deployedWar = new File(deployed, baseName + ".war");

    // Copy WAR to appBase
    try {
        if (isServiced(name)) {
            writer.println(smClient.getString("managerServlet.inService", displayPath));
        } else {
            addServiced(name);
            try {
                if (!deployedWar.delete()) {
                    writer.println(smClient.getString("managerServlet.deleteFail",
                            deployedWar));
                    return;
                }
                copy(localWar, deployedWar);
                // Perform new deployment
                check(name);
            } finally {
                removeServiced(name);
            }
        }
    } catch (Exception e) {
        log("managerServlet.check[" + displayPath + "]", e);
        writer.println(smClient.getString("managerServlet.exception",
                e.toString()));
        return;
    }
    
    writeDeployResult(writer, smClient, name, displayPath);
}
 
Example 9
Source File: ManagerServlet.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
/**
 * Install an application for the specified path from the specified
 * web application archive.
 *
 * @param writer    Writer to render results to
 * @param tag       Revision tag to deploy from
 * @param cn        Name of the application to be installed
 * @param smClient  i18n messages using the locale of the client
 */
protected void deploy(PrintWriter writer, ContextName cn, String tag,
        StringManager smClient) {

    // NOTE: It is assumed that update is always true in this method.

    // Validate the requested context path
    if (!validateContextName(cn, writer, smClient)) {
        return;
    }

    String baseName = cn.getBaseName();
    String name = cn.getName();
    String displayPath = cn.getDisplayName();
    
    // Find the local WAR file
    File localWar = new File(new File(versioned, tag), baseName + ".war");

    File deployedWar = new File(deployed, baseName + ".war");

    // Copy WAR to appBase
    try {
        if (isServiced(name)) {
            writer.println(smClient.getString("managerServlet.inService", displayPath));
        } else {
            addServiced(name);
            try {
                if (!deployedWar.delete()) {
                    writer.println(smClient.getString("managerServlet.deleteFail",
                            deployedWar));
                    return;
                }
                copy(localWar, deployedWar);
                // Perform new deployment
                check(name);
            } finally {
                removeServiced(name);
            }
        }
    } catch (Exception e) {
        log("managerServlet.check[" + displayPath + "]", e);
        writer.println(smClient.getString("managerServlet.exception",
                e.toString()));
        return;
    }
    
    writeDeployResult(writer, smClient, name, displayPath);
}