Changeset 453
- Timestamp:
- 02/27/07 20:29:03 (6 years ago)
- Files:
-
- 1 modified
-
coldbox/trunk/src/system/controller.cfc (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
coldbox/trunk/src/system/controller.cfc
r433 r453 4 4 ------------------------------------------------------------------------- 5 5 Author : Luis Majano 6 Date : September 23, 2005 6 Date : September 23, 2005 7 7 Last Update : December 9, 2006 8 8 -----------------------------------------------------------------------> 9 9 <cfcomponent name="controller" hint="This is the ColdBox Front Controller." output="false"> 10 10 11 11 <!------------------------------------------- CONSTRUCTOR -------------------------------------------> 12 12 13 13 <cfscript> 14 14 variables.instance = structnew(); … … 19 19 //Services & Managers 20 20 variables.instance.ColdboxOCM = ""; 21 variables.instance.RequestService = ""; 21 variables.instance.RequestService = ""; 22 22 </cfscript> 23 23 24 24 <cffunction name="init" returntype="any" access="Public" hint="I am the constructor" output="false"> 25 25 <cfscript> … … 33 33 34 34 <!------------------------------------------- PUBLIC -------------------------------------------> 35 35 36 36 <!--- Getters / Setters Services & Managers ---> 37 37 <cffunction name="getRequestService" access="public" output="false" returntype="coldbox.system.util.requestService" hint="Get RequestService"> … … 41 41 <cfreturn instance.ColdboxOCM/> 42 42 </cffunction> 43 43 44 44 <!--- Accessor ColdBox Initiation Flag ---> 45 45 <cffunction name="getColdboxInitiated" access="public" output="false" returntype="boolean" hint="Get ColdboxInitiated"> … … 50 50 <cfargument name="AppStartHandlerFired" type="boolean" required="true"/> 51 51 <cfset instance.AppStartHandlerFired = arguments.AppStartHandlerFired/> 52 </cffunction> 52 </cffunction> 53 53 <cffunction name="getAppStartHandlerFired" access="public" output="false" returntype="boolean" hint="Get AppStartHandlerFired"> 54 54 <cfreturn instance.AppStartHandlerFired/> 55 55 </cffunction> 56 56 57 57 <!--- Debugging Accessor/Mutators ---> 58 58 <cffunction name="getDebugMode" access="public" hint="I Get the current user's debugmode" returntype="boolean" output="false"> … … 73 73 </cfif> 74 74 </cffunction> 75 75 76 76 <!--- Config Loader Method ---> 77 77 <cffunction name="configLoader" returntype="void" access="Public" hint="I Load the configurations and init the framework variables." output="false"> 78 78 <cfscript> 79 79 var XMLParser = getPlugin("XMLParser"); 80 //Load Coldbox Config Settings Structure 80 //Load Coldbox Config Settings Structure 81 81 instance.ColdboxSettings = XMLParser.loadFramework(); 82 82 //Load Application Config Settings … … 84 84 //Configure Caching Manager 85 85 instance.ColdboxOCM.configure(); 86 86 87 87 //IoC Plugin Manager 88 88 if ( getSetting("IOCFramework") neq "" ){ 89 getPlugin("ioc") .configure();89 getPlugin("ioc"); 90 90 } 91 91 //Load i18N if application is using it. 92 92 if ( getSetting("using_i18N") ) 93 93 getPlugin("i18n").init_i18N(getSetting("DefaultResourceBundle"),getSetting("DefaultLocale")); 94 94 95 95 //Initialize AOP Logging if requested. 96 96 if ( getSetting("EnableColdboxLogging") ) 97 97 getPlugin("logger").initLogLocation(); 98 98 99 99 //Set Debugging Mode according to configuration 100 100 setDebugMode(getSetting("DebugMode")); 101 101 102 102 // Flag the initiation, Framework is ready to serve requests. Praise be to GOD. 103 103 instance.ColdboxInitiated = true; … … 109 109 <cfset var Handlers = ArrayNew(1)> 110 110 <cfset var HandlerListing = ""> 111 111 112 112 <!--- Check for Handlers Directory Location ---> 113 113 <cfif not directoryExists(HandlersPath)> 114 114 <cfthrow type="Framework.plugins.settings.HandlersDirectoryNotFoundException" message="The handlers directory: #handlerspath# does not exist please check your application structure or your Application Mapping."> 115 115 </cfif> 116 116 117 117 <!--- Get Handlers to register ---> 118 118 <cfdirectory action="list" recurse="true" directory="#HandlersPath#" name="HandlerListing" filter="*.cfc"> 119 119 120 120 <!--- Verify handler's found, else, why continue ---> 121 121 <cfif not HandlerListing.recordcount> 122 122 <cfthrow type="Framework.plugins.settings.NoHandlersFoundException" message="No handlers were found in: #HandlerPath#. So I have no clue how you are going to run this application."> 123 123 </cfif> 124 124 125 125 <!--- Register Handlers ---> 126 126 <cfloop query="HandlerListing"> … … 133 133 <!--- Sort The Array ---> 134 134 <cfset ArraySort(Handlers,"text")> 135 135 136 136 <!--- Set registered Handlers ---> 137 137 <cfset setSetting("RegisteredHandlers",arrayToList(Handlers))> 138 138 </cffunction> 139 139 140 140 141 141 <!--- Config Structure Accessors/Mutators ---> 142 142 <cffunction name="getSettingStructure" hint="I get the entire setting structure. By default I retrieve the configStruct. You can change this by using the fwsetting flag." access="public" returntype="struct" output="false"> … … 172 172 throw("The setting #arguments.name# does not exist.","FWSetting flag is #arguments.FWSetting#","Framework.SettingNotFoundException"); 173 173 </cfscript> 174 </cffunction> 174 </cffunction> 175 175 <cffunction name="settingExists" returntype="boolean" access="Public" hint="I Check if a value exists in the configstruct or the fwsettingsStruct." output="false"> 176 176 <cfargument name="name" hint="Name of the setting to find." type="string"> … … 185 185 } 186 186 </cfscript> 187 </cffunction> 187 </cffunction> 188 188 <cffunction name="setSetting" access="Public" returntype="void" hint="I set a Global Coldbox setting variable in the configstruct, if it exists it will be overrided. This only sets in the ConfigStruct" output="false"> 189 189 <cfargument name="name" type="string" hint="The name of the setting" > … … 194 194 </cfscript> 195 195 </cffunction> 196 197 <!--- Plugin Factories ---> 196 197 <!--- Plugin Factories ---> 198 198 <cffunction name="getPlugin" access="Public" returntype="any" hint="I am the Plugin cfc object factory." output="false"> 199 199 <cfargument name="plugin" type="string" hint="The Plugin object's name to instantiate" > … … 205 205 <cfset var pluginKey = "plugin_" & arguments.plugin> 206 206 <cfset var pluginPath = "coldbox.system.plugins.#trim(arguments.plugin)#"> 207 207 208 208 <!--- Custom Plugin Test ---> 209 209 <cfif arguments.customPlugin> … … 211 211 <cfset pluginPath = "#getSetting("MyPluginsLocation")#.#trim(arguments.plugin)#"> 212 212 </cfif> 213 213 214 214 <!--- Lookup in Cache ---> 215 215 <cfif instance.ColdboxOCM.lookup(pluginKey)> … … 237 237 <cfreturn getPlugin(arguments.plugin, true)> 238 238 </cffunction> 239 239 240 240 <!--- Event Context Methods ---> 241 241 <cffunction name="setNextEvent" access="Public" returntype="void" hint="I Set the next event to run and relocate the browser to that event." output="false"> … … 247 247 <cflocation url="#cgi.SCRIPT_NAME#?event=#arguments.event#&#arguments.queryString#" addtoken="#arguments.addToken#"> 248 248 </cffunction> 249 249 250 250 <cffunction name="runEvent" returntype="void" access="Public" hint="I am an event handler runnable factory. If no event is passed in then it will run the default event from the config.xml."> 251 251 <cfargument name="event" hint="The event to run. If no current event is set, use the default event from the config.xml" type="string" required="no" default=""> … … 258 258 <cfset var ExecutingMethod = ""> 259 259 <cfset var RequestContext = instance.RequestService.getContext()> 260 260 261 261 <!--- Default Event Set ---> 262 262 <cfif arguments.event eq ""> 263 263 <cfset arguments.event = RequestContext.getValue("event")> 264 264 </cfif> 265 265 266 266 <!--- Start Timer ---> 267 267 <cfmodule template="includes/timer.cfm" timertag="invoking runEvent [#arguments.event#]"> … … 271 271 <cfset ExecutingHandler = oEventBean.getRunnable()> 272 272 <cfset ExecutingMethod = oEventBean.getMethod()> 273 273 274 274 <!--- Check if using handler caching ---> 275 275 <cfif getSetting("HandlerCaching")> 276 276 277 277 <!--- Lookup in Cache ---> 278 278 <cfif instance.ColdboxOCM.lookup("handler_" & ExecutingHandler)> … … 292 292 <!--- Set the Runnable Object ---> 293 293 <cfset instance.ColdboxOCM.set("handler_" & ExecutingHandler,oEventHandler,objTimeout)> 294 </cfif> 295 </cfif> 294 </cfif> 295 </cfif> 296 296 <cfelse> 297 297 <!--- Create Runnable Object ---> … … 310 310 </cfif> 311 311 </cfif> 312 312 313 313 <!--- Execute Method ---> 314 314 <cfinvoke component="#oEventHandler#" method="#ExecutingMethod#" RequestContext="#RequestContext#"> 315 315 316 316 </cfmodule> 317 317 </cffunction> 318 318 319 319 <cffunction name="ExceptionHandler" access="public" hint="I handle a framework/application exception. I return a framework exception bean" returntype="any" output="false"> 320 320 <!--- ************************************************************* ---> … … 330 330 if ( not reFindnocase("(application|framework)",arguments.errorType) ) 331 331 arguments.errorType = "application"; 332 332 333 333 if ( arguments.ErrorType eq "application" ){ 334 334 //Run custom Exception handler if Found, else run default … … 348 348 } 349 349 //return 350 return ExceptionBean; 350 return ExceptionBean; 351 351 </cfscript> 352 352 </cffunction> … … 362 362 <cfthrow type="#arguments.type#" message="#arguments.message#" detail="#arguments.detail#"> 363 363 </cffunction> 364 364 365 365 <cffunction name="getRegisteredHandler" access="private" hint="I get a registered handler and method according to passed event from the registeredHandlers setting." returntype="coldbox.system.beans.eventhandlerBean" output="false"> 366 366 <!--- ************************************************************* ---> … … 377 377 HandlerReceived = getPlugin("fileUtilities").ripExtension(arguments.event); 378 378 MethodReceived = listLast(arguments.event,"."); 379 379 380 380 //Check Registration 381 381 handlerIndex = listFindNoCase(handlersList, HandlerReceived); 382 382 383 383 //Check for registration results 384 384 if ( handlerIndex ){
