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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations