Does exclusive cflockings of the application scope prevent to access the scope
from *everywhere*?
Sample code:
----------
Application.cfm:
<cfif not structKeyExists(application, "properties") or not
structKeyExists(application, "components")>
<cflock scope="application" timeout="20" type="exclusive">
<cfset application.properties = structNew() />
<cfset application.components = structNew() />
</cflock>
</cfif>
<cfif structKeyExists(url,"reload")>
<cflock scope="application" timeout="20" type="exclusive">
<cfset application.properties.dsn = "dsn" />
<cfset application.properties.attachmentsRoot = expandPath("../") />
<cfset application.properties.uploadRoot = expandPath("assets") />
<cfloop collection="application.components" item="comp">
<cfinvoke component="#application.components[comp]#"
method="setReloadFlag" value="true" />
</cfloop>
</cflock>
</cfif>
---------
---------
atemplate.cfm:
<cfif not structKeyExists(application.components, "productDAO") or
application.components.productDAO.getReloadFlag()>
<cflock scope="application" timeout="20" type="exclusive">
<cfset application.components.productDAO =
createObject("component","com.site.product.productdao").init(application.properties.dsn)
/>
</cflock>
</cfif>
<cfset abean = createObject("component","abean") />
<cfset application.components.productdao.read(abean, id) />
----------
-----------
anothertemplate.cfm:
<cfif not structKeyExists(application.components, "productGateway") or
application.components.productGateway.getReloadFlag()>
<cflock scope="application" timeout="20" type="exclusive">
<cfset application.components.productGateway =
createObject("component","com.site.product.productGateway").init(application.properties.dsn)
/>
</cflock>
</cfif>
<cfset aquery=application.components.productGateway.getAllProducts() />
<cfset aquery=application.components.productGateway.getProductsByName() />
------------
I'm not sure whether there are any problems or not under race conditions with
the sample code. Especially I wonder about the issues with two or more
exclusive cflocks for application scope. Those locks are treated as a
single-lock or not? Do you see any problem with the sample code?
Murat.
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at
[EMAIL PROTECTED]