[jboss-cvs] JBossAS SVN: r64272 - in trunk: varia and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jul 25 09:43:50 EDT 2007
Author: dimitris at jboss.org
Date: 2007-07-25 09:43:49 -0400 (Wed, 25 Jul 2007)
New Revision: 64272
Added:
trunk/varia/src/main/org/jboss/varia/threaddump/
trunk/varia/src/main/org/jboss/varia/threaddump/ThreadDumpBean.java
trunk/varia/src/resources/varia/
trunk/varia/src/resources/varia/threaddump/
trunk/varia/src/resources/varia/threaddump/index.jsp
trunk/varia/src/resources/varia/threaddump/web.xml
Modified:
trunk/build/build-distr.xml
trunk/varia/build.xml
Log:
Simple jsp facility for sorted theaddumps
Modified: trunk/build/build-distr.xml
===================================================================
--- trunk/build/build-distr.xml 2007-07-25 13:33:28 UTC (rev 64271)
+++ trunk/build/build-distr.xml 2007-07-25 13:43:49 UTC (rev 64272)
@@ -1001,6 +1001,7 @@
</fileset>
<fileset dir="${_module.output}/lib">
<include name="derby-plugin.jar"/>
+ <include name="threaddump.war"/>
</fileset>
</copy>
Modified: trunk/varia/build.xml
===================================================================
--- trunk/varia/build.xml 2007-07-25 13:33:28 UTC (rev 64271)
+++ trunk/varia/build.xml 2007-07-25 13:43:49 UTC (rev 64272)
@@ -616,6 +616,14 @@
</fileset>
</jar>
+ <!-- Build threaddump.war -->
+ <war warfile="${build.lib}/threaddump.war" webxml="${build.resources}/varia/threaddump/web.xml">
+ <fileset dir="${build.resources}/varia/threaddump" excludes="web.xml"/>
+ <classes dir="${build.classes}">
+ <include name="org/jboss/varia/threaddump/**"/>
+ </classes>
+ </war>
+
<!-- Update the build marker to allow bypassing -->
<touch file="${build-bypass.marker}"/>
Added: trunk/varia/src/main/org/jboss/varia/threaddump/ThreadDumpBean.java
===================================================================
--- trunk/varia/src/main/org/jboss/varia/threaddump/ThreadDumpBean.java (rev 0)
+++ trunk/varia/src/main/org/jboss/varia/threaddump/ThreadDumpBean.java 2007-07-25 13:43:49 UTC (rev 64272)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.varia.threaddump;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * Threaddump code adapted from:
+ * http://www.javaspecialists.eu/archive/Issue132.html
+ */
+public class ThreadDumpBean
+ implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+
+ private final Map<Thread, StackTraceElement[]> stackTraces;
+
+ /**
+ * Compare threads by name and id.
+ */
+ private static final Comparator<Thread> THREAD_COMPARATOR =
+ new Comparator<Thread>()
+ {
+ public int compare(Thread t1, Thread t2)
+ {
+ int result = t1.getName().compareTo(t2.getName());
+ if (result == 0)
+ {
+ Long tid1 = t1.getId();
+ Long tid2 = t2.getId();
+ result = tid1.compareTo(tid2);
+ }
+ return result;
+ }
+ };
+
+ public final static void main(String[] args)
+ {
+ ThreadDumpBean dump = new ThreadDumpBean();
+
+ System.out.println(dump.getStackTraces());
+ }
+
+ public ThreadDumpBean()
+ {
+ stackTraces = new TreeMap<Thread, StackTraceElement[]>(THREAD_COMPARATOR);
+ stackTraces.putAll(Thread.getAllStackTraces());
+ }
+
+ public Collection<Thread> getThreads()
+ {
+ return stackTraces.keySet();
+ }
+
+ public Map<Thread, StackTraceElement[]> getStackTraces()
+ {
+ return stackTraces;
+ }
+}
+
Added: trunk/varia/src/resources/varia/threaddump/index.jsp
===================================================================
--- trunk/varia/src/resources/varia/threaddump/index.jsp (rev 0)
+++ trunk/varia/src/resources/varia/threaddump/index.jsp 2007-07-25 13:43:49 UTC (rev 64272)
@@ -0,0 +1,37 @@
+<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
+
+<jsp:useBean id="threadDump"
+ class="org.jboss.varia.threaddump.ThreadDumpBean"
+ scope="request"/>
+
+<html>
+<body>
+<h2>Thread Summary</h2>
+<table cellpadding="5" cellspacing="5">
+ <tr>
+ <th>Thread</th>
+ <th>State</th>
+ <th>Priority</th>
+ <th>Daemon</th>
+ </tr>
+ <c:forEach items="${threadDump.threads}" var="thr">
+ <tr>
+ <td><c:out value='<a href="#${thr.id}">${thr.name}</a>' escapeXml="false"/></td>
+ <td><c:out value="${thr.state}"/></td>
+ <td><c:out value="${thr.priority}"/></td>
+ <td><c:out value="${thr.daemon}"/></td>
+ </tr>
+ </c:forEach>
+</table>
+
+<h2>Thread Stack Traces</h2>
+<c:forEach items="${threadDump.stackTraces}" var="trace">
+ <h4><c:out value='<a name="${trace.key.id}">${trace.key}</a>' escapeXml="false"/></h4>
+ <pre>
+ <c:forEach items="${trace.value}" var="traceline">
+ at <c:out value="${traceline}"/></c:forEach>
+ </pre>
+</c:forEach>
+
+</body>
+</html>
Added: trunk/varia/src/resources/varia/threaddump/web.xml
===================================================================
--- trunk/varia/src/resources/varia/threaddump/web.xml (rev 0)
+++ trunk/varia/src/resources/varia/threaddump/web.xml 2007-07-25 13:43:49 UTC (rev 64272)
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+
+<web-app>
+</web-app>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list