My previous post about a ColdFusion Server scope enhancer provided a chunk of code that you could include somewhere in your application to provide much more detailed information about the state and properties of your Java application server.
In an effort to clean up that code and make it perform slightly faster, I created a Java library that you can now include in your ColdFusion web application’s WEB-INF\lib directory.

This makes the code much more simple to read and maintain. Here’s an example call to enhance your Server scope.
<cfscript>
runtime = createobject("java", "java.lang.Runtime");
enhancer = createobject("java", "orbwave.ScopeEnhancer");
mgmtFactory = createobject("java", "java.lang.management.ManagementFactory");
sys = createobject("java", "java.lang.System");
memoryPoolBean = mgmtFactory.MemoryPoolMXBeans;
server.jvm = StructNew();
server.jvm.memory = StructNew();
server.jvm.memory.pools = enhancer.memoryPools();
server.jvm.memory.free = runtime.getRuntime().freeMemory();
server.jvm.memory.max = runtime.getRuntime().maxMemory();
server.jvm.arguments = mgmtFactory.RuntimeMXBean.getInputArguments();
server.jvm.threads = enhancer.serverThreads();
server.jvm.properties = enhancer.systemProperties();
server.os.environmentVariables = enhancer.environmentVariables();
</cfscript>
There is one major difference between using the ColdFusion code version and the new Java library, and that is that the jvm.memory.pools and jvm.threads keys were queries in the CF version but are now structures in the Java version.
One addition was made in the new library and that is the os.environmentVariables key that holds all of the environment variables of your operating system.

Now all of the information is available for your use. Once again, you’ll need to be running at least the 1.5 JDK for this to work.
3 Responses for "Enhanced ColdFusion Server Scope"
Bad news 0
ERR s
thanks for all the info… if i can get this working it will save my bacon!
but, seems that our cf server hasn’t got the java.lang.management package on it… where can i get hold of it?
Leave a reply