Author: alessio.soldano(a)jboss.com
Date: 2008-01-10 09:43:53 -0500 (Thu, 10 Jan 2008)
New Revision: 5457
Modified:
framework/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java
framework/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorderMBean.java
Log:
[JBWS-1950] Adding methods to the MemoryBufferRecorder to output html code
Modified:
framework/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java
===================================================================
---
framework/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java 2008-01-10
14:16:57 UTC (rev 5456)
+++
framework/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java 2008-01-10
14:43:53 UTC (rev 5457)
@@ -140,6 +140,11 @@
filters[0] = new HostFilter(clientHost, true);
return this.getMatchingRecords(filters);
}
+
+ public String getRecordsByClientHostAsHTMLTable(boolean groupRecords, boolean
showDetails, String clientHost)
+ {
+ return toHtml(groupRecords, showDetails, this.getRecordsByClientHost(clientHost));
+ }
public Map<String, List<Record>> getRecordsByOperation(String namespace,
String localPart)
{
@@ -147,6 +152,11 @@
filters[0] = new OperationFilter(new QName(namespace, localPart));
return this.getMatchingRecords(filters);
}
+
+ public String getRecordsByOperationAsHTMLTable(boolean groupRecords, boolean
showDetails, String namespace, String localPart)
+ {
+ return toHtml(groupRecords, showDetails, this.getRecordsByOperation(namespace,
localPart));
+ }
public int getMaxSize()
{
@@ -170,4 +180,84 @@
return size;
}
+ public String getRecordsAsHTMLTable(boolean groupRecords, boolean showDetails)
+ {
+ Map<String,List<Record>> records = this.getRecentRecords();
+ return toHtml(groupRecords, showDetails, records);
+ }
+
+ private String toHtml(boolean groupRecords, boolean showDetails, Map<String,
List<Record>> records)
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("</pre></span>");
+ if (!groupRecords)
+ openTable(sb, showDetails);
+ for (String key : records.keySet())
+ {
+ if (groupRecords)
+ openTable(sb, showDetails);
+ for (Record record : records.get(key))
+ {
+ appendRecordRow(sb, record, showDetails);
+ }
+ if (groupRecords)
+ closeTable(sb);
+ }
+ if (!groupRecords)
+ closeTable(sb);
+ sb.append("<pre><span class='OpResult'>");
+ return sb.toString();
+ }
+
+ private void openTable(StringBuffer sb, boolean showDetails)
+ {
+ sb.append("<table border='1'><tr
class='AttributesHeader'><th>Type</th><th>Date</th><th>From</th><th>To</th><th>Operation</th>");
+ if (showDetails)
+
sb.append("<th>Headers</th><th>Envelope</th>");
+ sb.append("</tr><tr>");
+ }
+
+ private void closeTable(StringBuffer sb)
+ {
+ sb.append("</tr></table><br />");
+ }
+
+ private void appendRecordRow(StringBuffer sb, Record record, boolean showDetails) {
+ sb.append("<tr><td><pre>");
+ sb.append(record.getMessageType() != null ? record.getMessageType() : "[Not
available]");
+ sb.append("</pre></td>");
+ sb.append("<td><pre>");
+ sb.append(record.getDate() != null ? record.getDate() : "[Not
available]");
+ sb.append("</pre></td>");
+ sb.append("<td><pre>");
+ sb.append(record.getSourceHost() != null ? record.getSourceHost() : "[Not
available]");
+ sb.append("</pre></td>");
+ sb.append("<td><pre>");
+ sb.append(record.getDestinationHost() != null ? record.getDestinationHost() :
"[Not available]");
+ sb.append("</pre></td>");
+ sb.append("<td><pre>");
+ sb.append(record.getOperation() != null ? record.getOperation() : "[Not
available]");
+ sb.append("</pre></td>");
+ if (showDetails)
+ {
+ sb.append("<td><pre>");
+ if (record.getHeaders() != null)
+ {
+ for (String headerName : record.getHeaders().keySet())
+ {
+ sb.append(headerName);
+ sb.append(": ");
+ sb.append(record.getHeaders().get(headerName));
+ sb.append("<br />");
+ }
+ }
+ else
+ sb.append("[Not available]");
+ sb.append("</pre></td>");
+ sb.append("<td><pre>");
+ sb.append(record.getEnvelope() != null ?
record.getEnvelope().replaceAll("<",
"<").replaceAll(">", ">") : "[Not
available]");
+ sb.append("</pre></td>");
+ }
+ sb.append("</tr>");
+ }
}
Modified:
framework/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorderMBean.java
===================================================================
---
framework/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorderMBean.java 2008-01-10
14:16:57 UTC (rev 5456)
+++
framework/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorderMBean.java 2008-01-10
14:43:53 UTC (rev 5457)
@@ -87,4 +87,34 @@
* @return
*/
public int getSize();
+
+ /**
+ * Shows all the records as a HTML table
+ *
+ * @param groupRecords whether the records should be grouped using the record ID
+ * @param showDetails whether to show headers and envelopes
+ * @return
+ */
+ public String getRecordsAsHTMLTable(boolean groupRecords, boolean showDetails);
+
+ /**
+ * Shows the records with the given client host as a HTML table.
+ *
+ * @param groupRecords
+ * @param showDetails
+ * @param clientHost
+ * @return
+ */
+ public String getRecordsByClientHostAsHTMLTable(boolean groupRecords, boolean
showDetails, String clientHost);
+
+ /**
+ * Shows the records with the given operation as a HTML table.
+ *
+ * @param groupRecords
+ * @param showDetails
+ * @param namespace
+ * @param localPart
+ * @return
+ */
+ public String getRecordsByOperationAsHTMLTable(boolean groupRecords, boolean
showDetails, String namespace, String localPart);
}