Raymond Camden

Where Does The Mysterious Method Added To Your CFCs Come From?

By: Raymond Camden

August 10th, 2007 · No Comments

If you’ve been working with CFCs in ColdFusion 8, you may come across a mysterious method. Consider this screen shot from a CFC descriptor:

Notice the method, _cffunccfthread_cftest2ecfc6414264711. What the heck is that? As may be able to guess, it has something to do with threading. Check out the source for my CFC:

<cfcomponent output="false">

<cffunction name=”sayHi” access=”public” returnType=”string” output=”false”>

   <cfargument name=”name” type=”string” required=”false” default=”Nameless”>

   <cfthread name=”t”>

   <cfparam name=”request.x” default=”1″>

   <cfset request.x++>

   </cfthread>

   <cfreturn arguments.name>

</cffunction>

</cfcomponent>

See the cfthread call? Whenever threading is used inside a CFC method, a new method is added to the CFC metadata. You will also see this function if you call getComponentMetaData on the CFC. You can even call this method:

<cfset goo = createObject("component", "test")>

<cfset goo._cffunccfthread_cftest2ecfc6414264711()>

When run, the code inside your cfthread tags are executed. Now I would not recommend actually doing that. As a related note - if you put a cfthread inside a normal CFM file and dump the variables scope, you will see a UDF with a similar name.

As a side note - I’ve always meant to play with the code that generates documentation for CFCs. In case you didn’t know, this is open source. It isn’t encrypted like the rest of the CFM files Adobe ships. It would be rather trivial to hide this from the documentation. I’d also like to add ways to execute methods by clicking on the event name or create a PDF version of the doc.

Tags: Uncategorized

About The Author

Raymond Camden, ray@camdenfamily.com http://ray.camdenfamily.com Raymond Camden is Vice President of Technology for roundpeg, Inc. A long time ColdFusion user, Raymond has worked on numerous ColdFusion books and is the creator of many of the most popular ColdFusion community web sites. He is an Adobe Community Expert, user group manager, and the proud father of three little bundles of joy.

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment