ColdFusion Zeus POTW: Application Metadata

Time for another quick ColdFusion Zeus preview. This one will probably be of lesser value to some folks, but it addresses an issue I’ve been raising for years, and that is:

If ColdFusion knows something, I should know it.

Simple enough concept, right? However, it’s not been easy to discover simple, trivial things about your environment unless you were willing to hack around it. Here’s an incredibly trivial example: Session Management. How would you know if sessions were enabled for the current request? Currently you can’t unless you try to set or read a Session variable and wrap the call with a try and catch. I love ColdFusion, but I have no qualms about calling that stupid.

ColdFusion Zeus addresses this by exposing a new function, getApplicationMetaData, that returns settings about the current application. To be clear, it does not return application variables. Remember that the Application scope is a structure you can introspect easily enough. Instead, getApplicationMetaData will return current settings for the active application. Here's a quick example (and I snuck in a few things here too that are new):

component {"moo"; this.sessionManagement="true"; this.datasource="cfartgallery"; this.mappings = { "/foo":expandPath("./") }; this.customtagpaths=expandPath("./"); this.sessioncookies.httpOnly = true; this.invokeImplicitAccessor = true; this.inmemoryfilesystem.enabled = true; this.inmemoryfilesystem.size = 10; }

And then here is my test template:

<cfdump var="#getApplicationMetaData()#" label="get Application Metadata">

And the result:

So - how useful is this? Probably not very. Those of us working with open source libraries or those who ship packaged solutions though can really make good use of this. And darnit - ColdFusion knows this info, so should we!

p.s. If you look at the Application.cfc file above, you may notice a few new things. I'm not going to talk about all of them, but I will address one:

this.inmemoryfilesystem.enabled = true; this.inmemoryfilesystem.size = 10;

In ColdFusion Zeus, you can now use the VFS on a per Application basis. That means an Application can use a vfs folder like ram://info and not worry about another application using the same folder. Your virtual files and folders are 100% black boxes into your Application-memory space. You can also configure your own size too. Nice.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA