Copy link to clipboard
Copied
I just wanted to know when I need use CFLOCK.
For example, do I need to CFLOCK when I assign my data source database in my Application.cfc.
If I use CFLOCK then web server will lock the database for timeout seconds to connect the database server?
Your information and help is great appreciated,
Regards,
Iccsi,
You need to lock when there will be a race condition, that's about it. http://en.wikipedia.org/wiki/Race_condition#Example
onApplicationStart() is single threaded when it's called as part of the application lifecycle (http://adamcameroncoldfusion.blogspot.co.nz/2012/07/onapplicationstart-is-not-intrinsically.html), so there's no need to worry about locking application-scoped stuff in there.
--
Adam
Copy link to clipboard
Copied
You need to lock when there will be a race condition, that's about it. http://en.wikipedia.org/wiki/Race_condition#Example
onApplicationStart() is single threaded when it's called as part of the application lifecycle (http://adamcameroncoldfusion.blogspot.co.nz/2012/07/onapplicationstart-is-not-intrinsically.html), so there's no need to worry about locking application-scoped stuff in there.
--
Adam
Copy link to clipboard
Copied
Thanks a million for the information and help.
I see onApplicationStart even in the file.
Must I put this event within cfcomponent?
Should this event only can have once and in Application.cfc, since it trigger on application start.
Thanks again for a million for helping and information,
Regards,
Iccsi,
Copy link to clipboard
Copied
onApplicationStart() must be in a CFC, yes - specifically Application.cfc as you say. One can only have one method of a given name in a CFC, and Application.cfc is no different in this regard, so only one onApplicationStart() method, yes. I think that's what you're asking.
However one can use inheritance with Application.cfcs just like with any other CFC, so one can have this:
/mainapp/Application.cfc
/mainapp/subsection/Application.cfc - extends /mainapp/Application.cfc.
This means one can implement your general-case event handlers in /mainapp/Application.cfc, and if the subsection requires different behaviour, then the Application.cfc there can override the event handlers as required. Plus they can call the extended Application.cfc's event handlers too, via - for example - super.onApplicationStart().
It's all well documented:
Application.cfc reference:
http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-74fa.html
Defining the application and its event handlers in Application.cfc
And also google for "application.cfc". Plenty of people have blogged about it.
HTH.
--
Adam
Copy link to clipboard
Copied
Thanks a million for helping and information,
Regards,
Iccsi,