and*_*xon 2 coldfusion coldfusion-9
有谁知道 Adobe ColdFusion 9 标准版中是否有办法获取正在运行的请求列表?也许通过从 CF Java 对象之一调用方法,例如 Coldfusion.server.ServiceFactory???
我知道在企业中您可以使用服务器监视器来实现此目的,但由于我们使用的是标准版,因此我们没有可用的服务器监视器。
谢谢。
感谢 @barnyr 的指导,我已经设法获得一些代码,这些代码将输出当前正在运行的脚本名称的列表,这正是我所需要的。这里适合任何有兴趣的人。
<!--- Create the thread object --->
<cfobject type="JAVA" action="Create" name="thread" class="java.lang.Thread">
<!--- Get all stack traces from the thread object --->
<cfset stackTrace = thread.getAllStackTraces()>
<!--- Convert the entrySet into an array --->
<cfset stackArray = stackTrace.entrySet().toArray()>
<cfoutput>
<!--- Loop over the entrySet array --->
<cfloop from="1" to="#ArrayLen(stackArray)#" index="sIndex">
<!--- Get the current thread values --->
<cfset thisThread = stackArray[sIndex].getValue()>
<!--- Loop over current thread values --->
<cfloop from="1" to="#ArrayLen(thisThread)#" index="tIndex">
<!--- Get the filename for this thread --->
<cfset thisThreadFile = thisThread[tIndex].getFileName()>
<!--- If the file name contains .cfm output it --->
<cfif isDefined("thisThreadFile") AND thisThreadFile CONTAINS ".cfm">
#thisThreadFile#<br>
</cfif>
</cfloop>
</cfloop>
</cfoutput>
Run Code Online (Sandbox Code Playgroud)