Author: jonesde
Date: Mon Oct 30 11:40:34 2006
New Revision: 469251

URL: http://svn.apache.org/viewvc?view=rev&rev=469251
Log:
The results of some playing to see what sort of thread info we can get from the 
JVM, and in Java5 it's pretty good; this contains conditional scripted elements 
that use Java5, but should work fine and just not run those on 1.4

Modified:
    
incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/threads.bsh
    incubator/ofbiz/trunk/framework/webtools/webapp/webtools/service/threads.ftl

Modified: 
incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/threads.bsh
URL: 
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/threads.bsh?view=diff&rev=469251&r1=469250&r2=469251
==============================================================================
--- 
incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/threads.bsh
 (original)
+++ 
incubator/ofbiz/trunk/framework/webtools/webapp/webtools/WEB-INF/actions/service/threads.bsh
 Mon Oct 30 11:40:34 2006
@@ -51,3 +51,17 @@
     }
 }
 context.put("threads", threads);
+
+// Some stuff for general threads on the server
+currentThread = Thread.currentThread();
+currentThreadGroup = currentThread.getThreadGroup();
+topThreadGroup = currentThreadGroup;
+while (topThreadGroup.getParent() != null) {
+    topThreadGroup = topThreadGroup.getParent();
+}
+
+Thread[] allThreadArray = new Thread[1000];
+topThreadGroup.enumerate(allThreadArray);
+allThreadList = Arrays.asList(allThreadArray);
+
+context.put("allThreadList", allThreadList);

Modified: 
incubator/ofbiz/trunk/framework/webtools/webapp/webtools/service/threads.ftl
URL: 
http://svn.apache.org/viewvc/incubator/ofbiz/trunk/framework/webtools/webapp/webtools/service/threads.ftl?view=diff&rev=469251&r1=469250&r2=469251
==============================================================================
--- 
incubator/ofbiz/trunk/framework/webtools/webapp/webtools/service/threads.ftl 
(original)
+++ 
incubator/ofbiz/trunk/framework/webtools/webapp/webtools/service/threads.ftl 
Mon Oct 30 11:40:34 2006
@@ -13,7 +13,11 @@
 License for the specific language governing permissions and limitations
 under the License.
 -->
+<#assign javaVer = Static["java.lang.System"].getProperty("java.vm.version")/>
+<#assign isJava5 = javaVer.startsWith("1.5")/>
+<#if parameters.maxElements?has_content><#assign maxElements = 
parameters.maxElements?number/><#else><#assign maxElements = 5/></#if>
 
+<div class="head3">Service Engine Threads</div>
 <table cellpadding="2" cellspacing="0" border="1" width="100%">
   <tr>
     <td><div class="tableheadtext">${uiLabelMap.WebtoolsThread}</div></td>
@@ -32,3 +36,39 @@
   </tr>
   </#list>
 </table>
+
+<hr/>
+<div class="head3">General Java Threads</div>
+<div class="tabletext">Note: certain things only work in Java 5. Java Version 
is ${javaVer}; is Java 5? ${isJava5?string}}</div>
+<table cellpadding="2" cellspacing="0" border="1" width="100%">
+  <tr>
+    <td><div class="tableheadtext">Group</div></td>
+    <td><div class="tableheadtext">ID</div></td>
+    <td><div class="tableheadtext">${uiLabelMap.WebtoolsThread}</div></td>
+    <td><div class="tableheadtext">${uiLabelMap.CommonStatus}</div></td>
+    <td><div class="tableheadtext">Priority</div></td>
+    <td><div class="tableheadtext">Daemon</div></td>
+  </tr>
+  <#list allThreadList as javaThread>
+    <#if javaThread?exists>
+      <#if isJava5><#assign stackTraceArray = 
javaThread.getStackTrace()/></#if>
+      <tr>
+        <td><div 
class="tabletext">${(javaThread.getThreadGroup().getName())?if_exists}&nbsp;</div></td>
+        <td><div class="tabletext"><#if 
isJava5>${javaThread.getId()?string}</#if>&nbsp;</div></td>
+        <td>
+          <div 
class="tableheadtext">${javaThread.getName()?if_exists}&nbsp;</div>
+          <#if isJava5>
+            <#list 1..maxElements as stackIdx>
+              <#assign stackElement = stackTraceArray[stackIdx]?if_exists/>
+              <#if (stackElement.toString())?has_content><div 
class="tabletext">${stackElement.toString()}&nbsp;</div></#if>
+            </#list>
+          </#if>
+        </td>
+        <td><div class="tabletext"><#if 
isJava5>${javaThread.getState().name()?if_exists}</#if>&nbsp;</div></td>
+        <td><div class="tabletext">${javaThread.getPriority()}</div></td>
+        <td><div class="tabletext">${javaThread.isDaemon()?string}<#-- 
/${javaThread.isAlive()?string}/${javaThread.isInterrupted()?string} 
--></div></td>
+      </tr>
+    </#if>
+  </#list>
+</table>
+


Reply via email to