204
dynamic value for the NAME attribute to allow protection of a file with any given
name.
<CFLOCK NAME=#FileName# TIMEOUT=60 TYPE="Exclusive">
<CFFILE ACTION="Append"
</CFLOCK>
Example of protecting ColdFusion Extensions
This example illustrates how a custom tag wrapper can be built around CFXs that are
not thread-safe. The wrapper simply forwards attributes to the non thread-safe CFX
that is used inside a CFLOCK tag. An anonymous lock is used here because this is the
only place from which the CFX will be invoked.
<CFPARAM NAME="Attributes.AttributeOne" Default="">
<CFPARAM NAME="Attributes.AttributeTwo" Default="">
<CFPARAM NAME="Attributes.AttributeThree" Default="">
<CFLOCK TIMEOUT=10 TYPE="Exclusive">
<CFX_NOT_THREAD_SAFE AttributeOne=#Attributes.AttributeOne#
</CFLOCK>
Note
For more information
See the CFML Language Reference for more information on using CFLOCK.
FILE=#FileName#
OUTPUT=#TextToAppend#>
AttributeTwo=#Attributes.AttributeTwo#
AttributeThree=#Attributes.AttributeThree#>
This example assumes that this is the only instance this CFX is used in the
application. To lock a non-thread safe CFX that used multiple times in an
application, used named locking rather than anonymous locking,
specifying the same name for each lock.
Developing Web Applications with ColdFusion
Need help?
Do you have a question about the COLDFUSION 4.5-DEVELOPING WEB and is the answer not in the manual?