Back in the day, (before CFMX) you had to lock all accesses to application scope or risk crashing the server. So to cut down on the number of locks you copied the stuff in application scope to request scope at the beginning of each request. The code you have is just someone bringing a familiar but no longer needed practice with them when they they moved to mx. As of MX7 you would instantiate utilities like this in the onApplication start method of Application.cfc and not need the locks or the isDefineds.


J MacKay wrote:

Hopefully someone can answer two newbie questions ..

I've read a few blog entries about storing general utility components in the application scope so they can accessed anywhere within the application.

<cfif NOT isDefined("application.Utilities")>
   <cflock scope="application" type="exclusive" timeout="10">
      <cfif NOT isDefined("application.Utilities")>
<cfset application.Utilities = createObject("component", "Utilities")>
      </cfif>
   </cflock>
</cfif>

<cflock ...>
   <cfset Request.Utilities = application.Utilities>
</cflock>

It makes sense to instantiate the component once and store it in the application scope, but 1) why copy it back into the Request scope ? So it will be available to custom tags? 2) Why is it necessary to use a lock when copying the component into the request scope?

------------------------------------------------------------------------
No need to miss a message. Get email on-the-go <http://us.rd.yahoo.com/evt=43910/*http://mobile.yahoo.com/mail> with Yahoo! Mail for Mobile. Get started. <http://us.rd.yahoo.com/evt=43910/*http://mobile.yahoo.com/mail> You are subscribed to cfcdev. To unsubscribe, please follow the instructions at http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

An archive of the CFCDev list is available at www.mail-archive.com/[email protected]



You are subscribed to cfcdev. To unsubscribe, please follow the instructions at 
http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

An archive of the CFCDev list is available at 
www.mail-archive.com/[email protected]

Reply via email to