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.
Archived Comments
For those who haven't seen it, Jared has a cfcToPrinter UDF on cflib that can create a PDF/Flashpaper version of the docs.
http://www.cflib.org/udf.cf...
Ray,
What's the scope on the generated method?
Thanks,
Ron
Scope? All functions in a CFC are... well, not scoped - just part of the methods. Are you asking about the access attribute? If so - it isn't set, so it should be public.
@Ron,
If it can be printed / dumped, it must be the THIS scope. Not even ColdFusion can introspect the VARIABLES scope in a CFC.
Well wait a minute Ben. While getComponentMetaData can't, you _can_ introspect Variables from inside a CFC. It's one more scope. You could build a method that would cfreturn variables and then call it from outside.
@Ray, yes, true. From within a CFC, you can do all of that. I was just thinking about passing the CFC to another method that would need to "scan" the CFC for documentation.
Access is what I meant. Sorry for the confusion.
I was curious because the screenshot shows "* - private method" but neither of the methods have an asterisk next to them.
Thanks for the clarification.
Ron
@Ron - That's just the standard header. It doesn't mean you _have_ private methods.
@Ben - gotcha.