use of org.apache.felix.webconsole.DefaultVariableResolver in project felix by apache.
the class MemoryUsagePanel method renderContent.
@SuppressWarnings("unchecked")
@Override
protected void renderContent(HttpServletRequest req, HttpServletResponse res) throws IOException {
final PrintWriter pw = res.getWriter();
final StringBuilder statusBuf = new StringBuilder(1024);
statusBuf.append('{');
final StringBuilder filesBuf = new StringBuilder(1024);
filesBuf.append('[');
final File[] files = support.getDumpFiles();
if (files != null) {
long totalSize = 0;
for (File file : files) {
filesBuf.append('{');
filesBuf.append("'name':'").append(file.getName());
filesBuf.append("',").append("'date':").append(file.lastModified());
support.formatNumber(filesBuf, "size", file.length());
filesBuf.append("},");
totalSize += file.length();
}
statusBuf.append("'files':").append(files.length);
support.formatNumber(statusBuf, "total", totalSize);
} else {
statusBuf.append("'files':0,'total':0");
}
filesBuf.append(']');
statusBuf.append('}');
JsonPrintHelper jph = new JsonPrintHelper();
support.printOverallMemory(jph);
DefaultVariableResolver resolver = (DefaultVariableResolver) WebConsoleUtil.getVariableResolver(req);
resolver.put("__files__", filesBuf.toString());
resolver.put("__status__", statusBuf.toString());
resolver.put("__threshold__", String.valueOf(support.getThreshold()));
resolver.put("__interval__", String.valueOf(support.getInterval()));
resolver.put("__overall__", jph.getString());
resolver.put("__pools__", support.getMemoryPoolsJson());
String template = readTemplateFile("/templates/memoryusage.html");
pw.println(template);
}
use of org.apache.felix.webconsole.DefaultVariableResolver in project felix by apache.
the class WebConsolePlugin method renderContent.
/**
* @see org.apache.felix.webconsole.AbstractWebConsolePlugin#renderContent(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
protected void renderContent(HttpServletRequest request, HttpServletResponse response) throws IOException {
// prepare variables
DefaultVariableResolver vars = ((DefaultVariableResolver) WebConsoleUtil.getVariableResolver(request));
// $NON-NLS-1$
vars.put("__data__", getData(request));
response.getWriter().print(TEMPLATE);
}
use of org.apache.felix.webconsole.DefaultVariableResolver in project felix by apache.
the class ScriptConsolePlugin method renderContent.
@SuppressWarnings("unchecked")
@Override
protected void renderContent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
final PrintWriter pw = response.getWriter();
DefaultVariableResolver varResolver = (DefaultVariableResolver) WebConsoleUtil.getVariableResolver(request);
varResolver.put("__scriptConfig__", getScriptConfig());
pw.println(TEMPLATE);
}
use of org.apache.felix.webconsole.DefaultVariableResolver in project felix by apache.
the class IPOJOPlugin method renderContent.
/**
* This methods is called by the web console when the plugin is required.
* This methods writes the corresponding page (loads template and set variables).
* @param request the request
* @param response the response
* @throws ServletException something bad happened
* @throws IOException something bad happened
* @see org.apache.felix.webconsole.AbstractWebConsolePlugin#renderContent(
* javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
protected void renderContent(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// get request info from request attribute
final RequestInfo reqInfo = new RequestInfo(request);
// prepare variables
DefaultVariableResolver vars = ((DefaultVariableResolver) WebConsoleUtil.getVariableResolver(request));
if (reqInfo.instances) {
// Instance
if (reqInfo.name == null) {
// All
response.getWriter().print(INSTANCES);
} else {
// Specific
// Inject the name variable.
vars.put("name", reqInfo.name);
response.getWriter().print(INSTANCE_DETAILS);
}
} else if (reqInfo.factories) {
// Factory
if (reqInfo.name == null) {
// All
response.getWriter().print(FACTORIES);
} else {
// Specific
// Inject the name variable.
vars.put("name", reqInfo.name);
response.getWriter().print(FACTORY_DETAILS);
}
} else if (reqInfo.handlers) {
// Handlers
response.getWriter().print(HANDLERS);
// No detailed view for handlers.
} else {
// Default
response.getWriter().print(INSTANCES);
}
}
Aggregations