Changeset 453

Show
Ignore:
Timestamp:
02/27/07 20:29:03 (6 years ago)
Author:
lmajano
Message:

Fixes for ioc Configuration

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • coldbox/trunk/src/system/controller.cfc

    r433 r453  
    44------------------------------------------------------------------------- 
    55Author                  : Luis Majano 
    6 Date                    : September 23, 2005  
     6Date                    : September 23, 2005 
    77Last Update     : December 9, 2006 
    88-----------------------------------------------------------------------> 
    99<cfcomponent name="controller" hint="This is the ColdBox Front Controller." output="false"> 
    10          
     10 
    1111<!------------------------------------------- CONSTRUCTOR -------------------------------------------> 
    12          
     12 
    1313        <cfscript> 
    1414                variables.instance = structnew(); 
     
    1919                //Services & Managers 
    2020                variables.instance.ColdboxOCM = ""; 
    21                 variables.instance.RequestService = "";          
     21                variables.instance.RequestService = ""; 
    2222        </cfscript> 
    23          
     23 
    2424        <cffunction name="init" returntype="any" access="Public" hint="I am the constructor" output="false"> 
    2525                <cfscript> 
     
    3333 
    3434<!------------------------------------------- PUBLIC -------------------------------------------> 
    35          
     35 
    3636        <!--- Getters / Setters Services & Managers ---> 
    3737        <cffunction name="getRequestService" access="public" output="false" returntype="coldbox.system.util.requestService" hint="Get RequestService"> 
     
    4141                <cfreturn instance.ColdboxOCM/> 
    4242        </cffunction> 
    43          
     43 
    4444        <!--- Accessor ColdBox Initiation Flag ---> 
    4545        <cffunction name="getColdboxInitiated" access="public" output="false" returntype="boolean" hint="Get ColdboxInitiated"> 
     
    5050                <cfargument name="AppStartHandlerFired" type="boolean" required="true"/> 
    5151                <cfset instance.AppStartHandlerFired = arguments.AppStartHandlerFired/> 
    52         </cffunction>    
     52        </cffunction> 
    5353        <cffunction name="getAppStartHandlerFired" access="public" output="false" returntype="boolean" hint="Get AppStartHandlerFired"> 
    5454                <cfreturn instance.AppStartHandlerFired/> 
    5555        </cffunction> 
    56          
     56 
    5757        <!--- Debugging Accessor/Mutators ---> 
    5858        <cffunction name="getDebugMode" access="public" hint="I Get the current user's debugmode" returntype="boolean"  output="false"> 
     
    7373                </cfif> 
    7474        </cffunction> 
    75                  
     75 
    7676        <!--- Config Loader Method ---> 
    7777        <cffunction name="configLoader" returntype="void" access="Public" hint="I Load the configurations and init the framework variables." output="false"> 
    7878                <cfscript> 
    7979                var XMLParser = getPlugin("XMLParser"); 
    80                 //Load Coldbox Config Settings Structure  
     80                //Load Coldbox Config Settings Structure 
    8181                instance.ColdboxSettings = XMLParser.loadFramework(); 
    8282                //Load Application Config Settings 
     
    8484                //Configure Caching Manager 
    8585                instance.ColdboxOCM.configure(); 
    86                  
     86 
    8787                //IoC Plugin Manager 
    8888                if ( getSetting("IOCFramework") neq "" ){ 
    89                         getPlugin("ioc").configure(); 
     89                        getPlugin("ioc"); 
    9090                } 
    9191                //Load i18N if application is using it. 
    9292                if ( getSetting("using_i18N") ) 
    9393                        getPlugin("i18n").init_i18N(getSetting("DefaultResourceBundle"),getSetting("DefaultLocale")); 
    94                  
     94 
    9595                //Initialize AOP Logging if requested. 
    9696                if ( getSetting("EnableColdboxLogging") ) 
    9797                        getPlugin("logger").initLogLocation(); 
    98                          
     98 
    9999                //Set Debugging Mode according to configuration 
    100100                setDebugMode(getSetting("DebugMode")); 
    101                  
     101 
    102102                // Flag the initiation, Framework is ready to serve requests. Praise be to GOD. 
    103103                instance.ColdboxInitiated = true; 
     
    109109                <cfset var Handlers = ArrayNew(1)> 
    110110                <cfset var HandlerListing = ""> 
    111                  
     111 
    112112                <!--- Check for Handlers Directory Location ---> 
    113113                <cfif not directoryExists(HandlersPath)> 
    114114                        <cfthrow type="Framework.plugins.settings.HandlersDirectoryNotFoundException" message="The handlers directory: #handlerspath# does not exist please check your application structure or your Application Mapping."> 
    115115                </cfif> 
    116                  
     116 
    117117                <!--- Get Handlers to register ---> 
    118118                <cfdirectory action="list" recurse="true" directory="#HandlersPath#" name="HandlerListing" filter="*.cfc"> 
    119                  
     119 
    120120                <!--- Verify handler's found, else, why continue ---> 
    121121                <cfif not HandlerListing.recordcount> 
    122122                        <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."> 
    123123                </cfif> 
    124                  
     124 
    125125                <!--- Register Handlers ---> 
    126126                <cfloop query="HandlerListing"> 
     
    133133                <!--- Sort The Array ---> 
    134134                <cfset ArraySort(Handlers,"text")> 
    135                  
     135 
    136136                <!--- Set registered Handlers ---> 
    137137                <cfset setSetting("RegisteredHandlers",arrayToList(Handlers))> 
    138138        </cffunction> 
    139139 
    140          
     140 
    141141        <!--- Config Structure Accessors/Mutators ---> 
    142142        <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"> 
     
    172172                        throw("The setting #arguments.name# does not exist.","FWSetting flag is #arguments.FWSetting#","Framework.SettingNotFoundException"); 
    173173                </cfscript> 
    174         </cffunction>    
     174        </cffunction> 
    175175        <cffunction name="settingExists" returntype="boolean" access="Public"   hint="I Check if a value exists in the configstruct or the fwsettingsStruct." output="false"> 
    176176                <cfargument name="name" hint="Name of the setting to find." type="string"> 
     
    185185                } 
    186186                </cfscript> 
    187         </cffunction>            
     187        </cffunction> 
    188188        <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"> 
    189189                <cfargument name="name"  type="string"   hint="The name of the setting" > 
     
    194194                </cfscript> 
    195195        </cffunction> 
    196          
    197         <!--- Plugin Factories --->      
     196 
     197        <!--- Plugin Factories ---> 
    198198        <cffunction name="getPlugin" access="Public" returntype="any" hint="I am the Plugin cfc object factory." output="false"> 
    199199                <cfargument name="plugin"               type="string" hint="The Plugin object's name to instantiate" > 
     
    205205                <cfset var pluginKey = "plugin_" & arguments.plugin> 
    206206                <cfset var pluginPath = "coldbox.system.plugins.#trim(arguments.plugin)#"> 
    207                  
     207 
    208208                <!--- Custom Plugin Test ---> 
    209209                <cfif arguments.customPlugin> 
     
    211211                        <cfset pluginPath = "#getSetting("MyPluginsLocation")#.#trim(arguments.plugin)#"> 
    212212                </cfif> 
    213                  
     213 
    214214                <!--- Lookup in Cache ---> 
    215215                <cfif instance.ColdboxOCM.lookup(pluginKey)> 
     
    237237                <cfreturn getPlugin(arguments.plugin, true)> 
    238238        </cffunction> 
    239          
     239 
    240240        <!--- Event Context Methods ---> 
    241241        <cffunction name="setNextEvent" access="Public" returntype="void" hint="I Set the next event to run and relocate the browser to that event."  output="false"> 
     
    247247                        <cflocation url="#cgi.SCRIPT_NAME#?event=#arguments.event#&#arguments.queryString#" addtoken="#arguments.addToken#"> 
    248248        </cffunction> 
    249          
     249 
    250250        <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."> 
    251251                <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=""> 
     
    258258                <cfset var ExecutingMethod = ""> 
    259259                <cfset var RequestContext = instance.RequestService.getContext()> 
    260                  
     260 
    261261                <!--- Default Event Set ---> 
    262262                <cfif arguments.event eq ""> 
    263263                        <cfset arguments.event = RequestContext.getValue("event")> 
    264264                </cfif> 
    265                  
     265 
    266266                <!--- Start Timer ---> 
    267267                <cfmodule template="includes/timer.cfm" timertag="invoking runEvent [#arguments.event#]"> 
     
    271271                        <cfset ExecutingHandler = oEventBean.getRunnable()> 
    272272                        <cfset ExecutingMethod = oEventBean.getMethod()> 
    273                          
     273 
    274274                        <!--- Check if using handler caching ---> 
    275275                        <cfif getSetting("HandlerCaching")> 
    276                          
     276 
    277277                                <!--- Lookup in Cache ---> 
    278278                                <cfif instance.ColdboxOCM.lookup("handler_" & ExecutingHandler)> 
     
    292292                                                <!--- Set the Runnable Object ---> 
    293293                                                <cfset instance.ColdboxOCM.set("handler_" & ExecutingHandler,oEventHandler,objTimeout)> 
    294                                         </cfif>                          
    295                                 </cfif>                  
     294                                        </cfif> 
     295                                </cfif> 
    296296                        <cfelse> 
    297297                                <!--- Create Runnable Object ---> 
     
    310310                                </cfif> 
    311311                        </cfif> 
    312                          
     312 
    313313                        <!--- Execute Method ---> 
    314314                        <cfinvoke component="#oEventHandler#" method="#ExecutingMethod#" RequestContext="#RequestContext#"> 
    315                                  
     315 
    316316                </cfmodule> 
    317317        </cffunction> 
    318          
     318 
    319319        <cffunction name="ExceptionHandler" access="public" hint="I handle a framework/application exception. I return a framework exception bean" returntype="any" output="false"> 
    320320                <!--- ************************************************************* ---> 
     
    330330                if ( not reFindnocase("(application|framework)",arguments.errorType) ) 
    331331                        arguments.errorType = "application"; 
    332                          
     332 
    333333                if ( arguments.ErrorType eq "application" ){ 
    334334                        //Run custom Exception handler if Found, else run default 
     
    348348                } 
    349349                //return 
    350                 return ExceptionBean;    
     350                return ExceptionBean; 
    351351                </cfscript> 
    352352        </cffunction> 
     
    362362                <cfthrow type="#arguments.type#" message="#arguments.message#"  detail="#arguments.detail#"> 
    363363        </cffunction> 
    364          
     364 
    365365        <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"> 
    366366                <!--- ************************************************************* ---> 
     
    377377                HandlerReceived = getPlugin("fileUtilities").ripExtension(arguments.event); 
    378378                MethodReceived = listLast(arguments.event,"."); 
    379                  
     379 
    380380                //Check Registration 
    381381                handlerIndex = listFindNoCase(handlersList, HandlerReceived); 
    382                  
     382 
    383383                //Check for registration results 
    384384                if ( handlerIndex ){