Search in sources :

Example 91 with Container

use of org.apache.catalina.Container in project tomcat by apache.

the class StandardContext method getErrorCount.

/**
     * Gets the cumulative error count of all servlets in this
     * StandardContext.
     *
     * @return Cumulative error count of all servlets in this
     * StandardContext
     */
public int getErrorCount() {
    int result = 0;
    Container[] children = findChildren();
    if (children != null) {
        for (int i = 0; i < children.length; i++) {
            result += ((StandardWrapper) children[i]).getErrorCount();
        }
    }
    return result;
}
Also used : Container(org.apache.catalina.Container) SecurityConstraint(org.apache.tomcat.util.descriptor.web.SecurityConstraint)

Example 92 with Container

use of org.apache.catalina.Container in project tomcat by apache.

the class StandardContext method postWorkDirectory.

/**
     * Set the appropriate context attribute for our work directory.
     */
private void postWorkDirectory() {
    // Acquire (or calculate) the work directory path
    String workDir = getWorkDir();
    if (workDir == null || workDir.length() == 0) {
        // Retrieve our parent (normally a host) name
        String hostName = null;
        String engineName = null;
        String hostWorkDir = null;
        Container parentHost = getParent();
        if (parentHost != null) {
            hostName = parentHost.getName();
            if (parentHost instanceof StandardHost) {
                hostWorkDir = ((StandardHost) parentHost).getWorkDir();
            }
            Container parentEngine = parentHost.getParent();
            if (parentEngine != null) {
                engineName = parentEngine.getName();
            }
        }
        if ((hostName == null) || (hostName.length() < 1))
            hostName = "_";
        if ((engineName == null) || (engineName.length() < 1))
            engineName = "_";
        String temp = getBaseName();
        if (temp.startsWith("/"))
            temp = temp.substring(1);
        temp = temp.replace('/', '_');
        temp = temp.replace('\\', '_');
        if (temp.length() < 1)
            temp = ContextName.ROOT_NAME;
        if (hostWorkDir != null) {
            workDir = hostWorkDir + File.separator + temp;
        } else {
            workDir = "work" + File.separator + engineName + File.separator + hostName + File.separator + temp;
        }
        setWorkDir(workDir);
    }
    // Create this directory if necessary
    File dir = new File(workDir);
    if (!dir.isAbsolute()) {
        String catalinaHomePath = null;
        try {
            catalinaHomePath = getCatalinaBase().getCanonicalPath();
            dir = new File(catalinaHomePath, workDir);
        } catch (IOException e) {
            log.warn(sm.getString("standardContext.workCreateException", workDir, catalinaHomePath, getName()), e);
        }
    }
    if (!dir.mkdirs() && !dir.isDirectory()) {
        log.warn(sm.getString("standardContext.workCreateFail", dir, getName()));
    }
    // Set the appropriate servlet context attribute
    if (context == null) {
        getServletContext();
    }
    context.setAttribute(ServletContext.TEMPDIR, dir);
    context.setAttributeReadOnly(ServletContext.TEMPDIR);
}
Also used : Container(org.apache.catalina.Container) IOException(java.io.IOException) File(java.io.File)

Example 93 with Container

use of org.apache.catalina.Container in project tomcat by apache.

the class StandardContext method getNamingContextName.

/**
     * Get naming context full name.
     *
     * @return the context name
     */
private String getNamingContextName() {
    if (namingContextName == null) {
        Container parent = getParent();
        if (parent == null) {
            namingContextName = getName();
        } else {
            Stack<String> stk = new Stack<>();
            StringBuilder buff = new StringBuilder();
            while (parent != null) {
                stk.push(parent.getName());
                parent = parent.getParent();
            }
            while (!stk.empty()) {
                buff.append("/" + stk.pop());
            }
            buff.append(getName());
            namingContextName = buff.toString();
        }
    }
    return namingContextName;
}
Also used : Container(org.apache.catalina.Container) Stack(java.util.Stack)

Example 94 with Container

use of org.apache.catalina.Container in project tomcat by apache.

the class StandardContext method getProcessingTime.

/**
     * Gets the cumulative processing times of all servlets in this
     * StandardContext.
     *
     * @return Cumulative processing times of all servlets in this
     * StandardContext
     */
public long getProcessingTime() {
    long result = 0;
    Container[] children = findChildren();
    if (children != null) {
        for (int i = 0; i < children.length; i++) {
            result += ((StandardWrapper) children[i]).getProcessingTime();
        }
    }
    return result;
}
Also used : Container(org.apache.catalina.Container) SecurityConstraint(org.apache.tomcat.util.descriptor.web.SecurityConstraint)

Example 95 with Container

use of org.apache.catalina.Container in project tomcat by apache.

the class StandardContext method getMinTime.

/**
     * Gets the minimum processing time of all servlets in this
     * StandardContext.
     *
     * @return Minimum processing time of all servlets in this
     * StandardContext
     */
public long getMinTime() {
    long result = -1;
    long time;
    Container[] children = findChildren();
    if (children != null) {
        for (int i = 0; i < children.length; i++) {
            time = ((StandardWrapper) children[i]).getMinTime();
            if (result < 0 || time < result)
                result = time;
        }
    }
    return result;
}
Also used : Container(org.apache.catalina.Container) SecurityConstraint(org.apache.tomcat.util.descriptor.web.SecurityConstraint)

Aggregations

Container (org.apache.catalina.Container)163 Context (org.apache.catalina.Context)28 IOException (java.io.IOException)24 Host (org.apache.catalina.Host)22 StandardContext (org.apache.catalina.core.StandardContext)21 Engine (org.apache.catalina.Engine)18 LifecycleException (org.apache.catalina.LifecycleException)17 File (java.io.File)15 ObjectName (javax.management.ObjectName)15 Wrapper (org.apache.catalina.Wrapper)13 StandardHost (org.apache.catalina.core.StandardHost)13 ArrayList (java.util.ArrayList)12 ServletException (javax.servlet.ServletException)11 MalformedURLException (java.net.MalformedURLException)10 Valve (org.apache.catalina.Valve)10 StandardWrapper (org.apache.catalina.core.StandardWrapper)10 SecurityConstraint (org.apache.tomcat.util.descriptor.web.SecurityConstraint)10 NamingException (javax.naming.NamingException)9 Lifecycle (org.apache.catalina.Lifecycle)9 Realm (org.apache.catalina.Realm)9