Creating Thread-Safe Components With OnMissingMethod()

<cfcomponent
	output="false"
	hint="Holds a queue of messages.">
 
	<!---
		Run pesudo code to set up default sturctures
		and data values.
	--->
	<cfset VARIABLES.Instance = {} />
	<cfset VARIABLES.Instance.Queue = [] />
 
 
	<cffunction
		name="Init"
		access="public"
		returntype="any"
		output="false"
		hint="Returns an intialized component.">
 
		<!--- Return This reference. --->
		<cfreturn THIS />
	</cffunction>
 
 
	<cffunction
		name="Add"
		access="public"
		returntype="any"
		output="false"
		hint="Adds a message to the internal queue and then returns This reference for method chaining.">
 
		<!--- Define arguments. --->
		<cfargument
			name="Message"
			type="string"
			required="true"
			hint="The queue to add to the message."
			/>
 
		<!--- Add the message to the queue. --->
		<cfset ArrayAppend(
			VARIABLES.Instance.Queue,
			ARGUMENTS.Message
			) />
 
		<!--- Return This reference. --->
		<cfreturn THIS />
	</cffunction>
 
 
	<cffunction
		name="GetMessages"
		access="public"
		returntype="array"
		output="false"
		hint="Returns a copy of the internal message queue.">
 
		<cfreturn VARIABLES.Instance.Queue />
	</cffunction>
 
 
	<cffunction
		name="Size"
		access="public"
		returntype="numeric"
		output="false"
		hint="Returns the size of the internal message queue.">
 
		<cfreturn ArrayLen( VARIABLES.Instance.Queue ) />
	</cffunction>
 
</cfcomponent>

For Cut-and-Paste