我正在尝试调整 PSI Probe 中使用的代码(或者更一般地说,PSI Probe 的想法)将在我公司的 Web 应用程序内部使用。我可以获得我想要做的大部分内容,但我已经陷入了一小部分代码 - “状态”选项卡。一列数据是线程的处理时间,我真的很想拥有这些数据,但我不知道它来自哪里。这是相关片段:
<c:forEach items="${pools}" var="pool" varStatus="poolStatus">
<div class="poolInfo">
<h3>${pool.name}</h3>
<div class="processorInfo">
<span class="name">
<spring:message code="probe.jsp.status.processor.maxTime"/>
</span>
${pool.maxTime}
我不知道pools
对象来自哪里!有人有此类事情的经验吗?谢谢!
最佳答案
查看源代码(这是 Google 代码,Google 搜索速度非常快)
池正在填充 ListThreadPoolsController
List pools = containerListenerBean.getThreadPools();
return new ModelAndView(getViewName())
.addObject("pools", pools);
显示 status.jsp
中列出的属性
<span class="name"><spring:message code="probe.jsp.status.currentThreadCount"/></span> ${pool.currentThreadCount}
<span class="name"><spring:message code="probe.jsp.status.currentThreadsBusy"/></span> ${pool.currentThreadsBusy}
<span class="name"><spring:message code="probe.jsp.status.maxThreads"/></span> ${pool.maxThreads}
<span class="name"><spring:message code="probe.jsp.status.maxSpareThreads"/></span> ${pool.maxSpareThreads}
<span class="name"><spring:message code="probe.jsp.status.minSpareThreads"/></span> ${pool.minSpareThreads}
正在 getThreadPools()
方法中填充
ThreadPool threadPool = new ThreadPool();
threadPool.setName(executorName.getKeyProperty("name"));
threadPool.setMaxThreads(JmxTools.getIntAttr(server, executorName, "maxThreads"));
threadPool.setMaxSpareThreads(JmxTools.getIntAttr(server, executorName, "largestPoolSize"));
threadPool.setMinSpareThreads(JmxTools.getIntAttr(server, executorName, "minSpareThreads"));
threadPool.setCurrentThreadsBusy(JmxTools.getIntAttr(server, executorName, "activeCount"));
threadPool.setCurrentThreadCount(JmxTools.getIntAttr(server, executorName, "poolSize"));
关于Java EL对象 `${pools}`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7639249/