Return Types in Application.cfc

Peter sent in an interesting question this morning, especially as it relates to my last presentation:

Just wanted to quickly check something about your App.cfc reference:

The onApplicationStart and onRequestStart functions have a returntype of Boolean, whilst the rest are all Void.

Is there a reason for these two being different than the others, particularly the onSessionStart function?

The fact that you can return true or false in onApplicationStart and onRequestStart simply are ways to let you abort the application start up, or request, based on some condition. The example I believe I gave in my presentation was doing a quick database check. If the check fails, then send some kind of message to the admin and prevent the application from starting up. You could do the same in onRequestStart, although it is probably overkill to check every request. What you could do instead is log the last time you checked (in the application scope for example), and check only if sixty minutes have passed.

Anyone out there using something like this in their Application.cfc files?

Archived Comments

Comment 1 by Phillip Senn posted on 9/5/2006 at 7:28 PM

You also alluded to creating a shorter variable name that shared the same memory location as the Application scope, so that you could refer to
app.ObjectName.Method
as opposed to
Application.ObjectName.Method.

Comment 2 by Peter Boughton posted on 9/5/2006 at 9:17 PM

Thanks.

Didn't see your entry about the presentation; the rss syndicate e-mail hasn't been working for the last few days.

Not using it at the moment (obviously), but that database check does sound a sensible thing to do, so I probably will implement that. :)

Comment 3 by Raymond Camden posted on 9/5/2006 at 9:33 PM

Peter - what RSS isn't working for you? The email subscription? The Feedburner URL?

Comment 4 by Peter Boughton posted on 9/5/2006 at 9:48 PM

Oh sorry, that's just a local thing - we have a daily e-mail that sends a CF feed (feed-squirrel I think) to all the developers in the company.
Haven't received one since Friday morning, but I keep forgetting to mention it to my manager.

Comment 5 by Raymond Camden posted on 9/5/2006 at 9:52 PM

You can always use RSSWatcher.com. It lets you monitor rss feeds and send emails.

Comment 6 by Peter Boughton posted on 9/5/2006 at 10:08 PM

Just signed up. :)

I may be missing something but the search profile page says "To view all the matches for a search profile, simply click on the name of the profile." - except I don't see a profile name to click on?

Comment 7 by Raymond Camden posted on 9/5/2006 at 10:13 PM

Sorry, you click on View in the Matches column on your Search Profiles page.

Comment 8 by Peter Boughton posted on 9/5/2006 at 10:15 PM

Ah, currently 0 matches - I'm guessing that's just because there's no new entries since I created the profile?

Comment 9 by Raymond Camden posted on 9/5/2006 at 10:18 PM

Exactly. It searches once an hour.