1 5 package org.exoplatform.portlets.monitor.portlet.renderer.html; 6 7 import java.util.* ; 8 import javax.faces.component.UIComponent; 9 import javax.faces.context.FacesContext; 10 import javax.faces.context.ResponseWriter ; 11 import org.exoplatform.faces.core.renderer.html.HtmlBasicRenderer; 12 import org.exoplatform.portlets.monitor.portlet.component.UIPortletMonitor; 13 import org.exoplatform.services.portletcontainer.monitor.PortletRequestMonitorData; 14 import org.exoplatform.services.portletcontainer.monitor.PortletRuntimeData; 15 import java.io.IOException ; 16 17 28 public class PortletMonitorRenderer extends HtmlBasicRenderer { 29 30 public void encodeChildren( FacesContext context, UIComponent component ) throws IOException { 31 UIPortletMonitor uiMonitor = (UIPortletMonitor) component ; 32 ResourceBundle res = getApplicationResourceBundle(context.getExternalContext()) ; 33 ResponseWriter w = context.getResponseWriter() ; 34 w.write("<table class='UIPortletMonitor'>") ; 35 w. write("<tr>") ; 36 w. write("<th rowspan='2'>") ; w.write(res.getString("UIPortletMonitor.header.time-range")) ; w.write("</th>") ; 37 w. write("<th colspan='4'>") ; w.write(res.getString("UIPortletMonitor.header.process-action-method")) ; w.write("</th>") ; 38 w. write("<th colspan='5'>") ; w.write(res.getString("UIPortletMonitor.header.render-method")) ; w.write("</th>") ; 39 w. write("</tr>") ; 40 w. write("<tr>") ; 41 w. write("<th>") ; w.write(res.getString("UIPortletMonitor.header.counter")) ; w.write("</th>") ; 42 w. write("<th>") ; w.write(res.getString("UIPortletMonitor.header.min")) ; w.write("</th>") ; 43 w. write("<th>") ; w.write(res.getString("UIPortletMonitor.header.max")) ; w.write("</th>") ; 44 w. write("<th>") ; w.write(res.getString("UIPortletMonitor.header.avg")) ; w.write("</th>") ; 45 w. write("<th>") ; w.write(res.getString("UIPortletMonitor.header.counter")) ; w.write("</th>") ; 46 w. write("<th>") ; w.write(res.getString("UIPortletMonitor.header.cache-hit")) ; w.write("</th>") ; 47 w. write("<th>") ; w.write(res.getString("UIPortletMonitor.header.min")) ; w.write("</th>") ; 48 w. write("<th>") ; w.write(res.getString("UIPortletMonitor.header.max")) ; w.write("</th>") ; 49 w. write("<th>") ; w.write(res.getString("UIPortletMonitor.header.avg")) ; w.write("</th>") ; 50 w. write("</tr>") ; 51 PortletRuntimeData rtdata = uiMonitor.getPortletRuntimeData() ; 52 PortletRequestMonitorData[] datas = rtdata.getPortletRequestMonitorData(); 53 for(int i = 0 ; i < datas.length; i++) { 54 String clazz = "odd"; 55 if (i % 2 == 0) 56 clazz = "even"; 57 w.write("<tr class='" + clazz + "'>") ; 58 w. write("<td>") ; 59 w. write(Long.toString(datas[i].minRange())) ; 60 w. write(" - ") ; 61 w. write(Long.toString(datas[i].maxRange())) ; 62 w. write("</td>") ; 63 w. write("<td>") ; w.write(Integer.toString(datas[i].getActionRequestCounter())) ; w.write("</td>") ; 64 w. write("<td>") ; w.write(Long.toString(datas[i].getMinActionExecutionTime())) ; w.write("</td>") ; 65 w. write("<td>") ; w.write(Long.toString(datas[i].getMaxActionExecutionTime())) ; w.write("</td>") ; 66 w. write("<td>") ; w.write(Long.toString(datas[i].getAvgActionExecutionTime())) ; w.write("</td>") ; 67 w. write("<td>") ; w.write(Integer.toString(datas[i].getRenderRequestCounter())) ; w.write("</td>") ; 68 w. write("<td>") ; w.write(Integer.toString(datas[i].getCacheHitCounter())) ; w.write("</td>") ; 69 w. write("<td>") ; w.write(Long.toString(datas[i].getMinRenderExecutionTime())) ; w.write("</td>") ; 70 w. write("<td>") ; w.write(Long.toString(datas[i].getMaxRenderExecutionTime())) ; w.write("</td>") ; 71 w. write("<td>") ; w.write(Long.toString(datas[i].getAvgRenderExecutionTime())) ; w.write("</td>") ; 72 w.write("</tr>") ; 73 } 74 w.write("</table>") ; 75 } 76 } | Popular Tags |