<cfcomponent output="true" hint="Handles application definition and application level events."> <!--- Run pseudo constructor. Set up the Application properties and session management. ---> <cfset THIS.ApplicationName = "KinkySolutions - My Shortie" /> <cfset THIS.ApplicationTimeOut = CreateTimeSpan( 2, <!--- Days. ---> 0, <!--- Hours. ---> 0, <!--- Minutes. ---> 0 <!--- Seconds. ---> ) /> <!--- Turn of session management. ---> <cfset THIS.SessionManagement = false /> <cfset THIS.SetClientCookies = false /> <!--- Set page request settings. ---> <cfsetting requesttimeout="20" showdebugoutput="false" /> <cffunction name="OnApplicationStart" access="public" returntype="boolean" output="false" hint="Runs when application starts or is manually reset."> <!--- Even though the OnApplicationStart() method is meant to be single threaded, since we might be calling it manually, we have to be sure to force the single thread - the act of calling this method alone will not accomplish that. ---> <cflock scope="APPLICATION" type="EXCLUSIVE" timeout="10"> <!--- Clear the application data. ---> <cfset StructClear( APPLICATION ) /> <!--- Create an instance of the user defined functions library, cached in the application. ---> <cfset APPLICATION.UDFLib = CreateObject( "component", "UDFLib" ).Init() /> <!--- Create a shortie and cache her in the APPLICATION scope. We only need one per application and we need her to persist across page requests. When creating the shortie, we need to initialize her with a brain that knows where to store its data (the data file path). ---> <cfset APPLICATION.Shortie = CreateObject( "component", "Shortie" ).Init( CreateObject( "component", "Brain" ).Init( ExpandPath( "./brain_data.xml" ) ) ) /> </cflock> <!--- Return out. ---> <cfreturn true /> </cffunction> <cffunction name="OnRequestStart" access="public" returntype="boolean" output="false" hint="Fires when prior to page processing."> <!--- Define arguments. ---> <cfargument name="TargetPage" type="string" required="true" /> <!--- Check to see if we have the manual appplication reset flag in the URL (we don't care about the actual value, just the key existance). ---> <cfif StructKeyExists( URL, "reset" )> <!--- Reset the application via the OnApplicationStart() event method. This method will take care of it own thread-safety concerns. ---> <cfset THIS.OnApplicationStart() /> </cfif> <!--- Return out. ---> <cfreturn true /> </cffunction> </cfcomponent>