Creating Thread-Safe Components With OnMissingMethod()

<cfcomponent
	output="false"
	extends="MessageQueue"
	hint="Holds a thread safe queue of messages.">
 
	<!---
		Run pesudo code to set up default sturctures
		and data values.
	--->
	<cfset VARIABLES.Instance.LockID = CreateUUID() />
 
 
	<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."
			/>
 
		<!--- Lock method call. --->
		<cflock
			name="#VARIABLES.Instance.LockID#-Message"
			type="exclusive"
			timeout="5">
 
			<cfreturn SUPER.Add(
				Message = ARGUMENTS.Message
				) />
 
		</cflock>
	</cffunction>
 
 
	<cffunction
		name="GetMessages"
		access="public"
		returntype="array"
		output="false"
		hint="Returns a copy of the internal message queue.">
 
		<!--- Lock method call. --->
		<cflock
			name="#VARIABLES.Instance.LockID#-GetMessages"
			type="exclusive"
			timeout="5">
 
			<cfreturn SUPER.GetMessages() />
 
		</cflock>
	</cffunction>
 
 
	<cffunction
		name="Size"
		access="public"
		returntype="numeric"
		output="false"
		hint="Returns the size of the internal message queue.">
 
		<!--- Lock method call. --->
		<cflock
			name="#VARIABLES.Instance.LockID#-Size"
			type="exclusive"
			timeout="5">
 
			<cfreturn SUPER.Size() />
 
		</cflock>
	</cffunction>
 
</cfcomponent>

For Cut-and-Paste