@@ -137,7 +137,6 @@ component extends="coldbox.system.web.services.BaseService" accessors="true" {
137137 */
138138 function getHandler ( required ehBean , required requestContext ){
139139 var oRequestContext = arguments .requestContext ;
140- var oEventURLFacade = variables .templateCache .getEventURLFacade ();
141140
142141 // Create Runnable Object via WireBox
143142 var oEventHandler = newHandler ( arguments .ehBean );
@@ -197,7 +196,7 @@ component extends="coldbox.system.web.services.BaseService" accessors="true" {
197196 structAppend ( eventCachingData , eventDictionaryEntry , true );
198197
199198 // Create the Cache Key to save
200- eventCachingData .cacheKey = oEventURLFacade .buildEventKey (
199+ eventCachingData .cacheKey = variables . templateCache . getEventURLFacade () .buildEventKey (
201200 targetEvent = arguments .ehBean .getFullEvent (),
202201 targetContext = oRequestContext ,
203202 eventDictionary = eventDictionaryEntry
@@ -342,30 +341,27 @@ component extends="coldbox.system.web.services.BaseService" accessors="true" {
342341
343342 // Module Check?
344343 if ( find ( " :" , currentEvent ) ) {
345- var module = listFirst ( currentEvent , " :" );
344+ var separatorIndex = find ( " :" , currentEvent );
345+ var module = left ( currentEvent , separatorIndex - 1 );
346346 if ( structKeyExists ( modulesConfig , module ) ) {
347347 // Get module's handler struct for O(1) lookup
348348 var moduleHandlers = modulesConfig [ module ].registeredHandlers ?: {};
349- var handlerKey = reReplaceNoCase ( currentEvent , " ^([^:.]*): " , " " );
349+ var handlerKey = mid ( currentEvent , separatorIndex + 1 , len ( currentEvent ) );
350350 if ( structKeyExists ( moduleHandlers , handlerKey ) ) {
351- // Append the default event action
352- currentEvent = currentEvent & " ." & variables .eventAction ;
353351 // Save it as the current Event
354- event .setValue ( variables .eventName , currentEvent );
352+ event .setValue ( variables .eventName , moduleHandlers [ handlerKey ]. defaultEvent );
355353 }
356354 }
357355 return this ;
358356 }
359357
360358 // O(1) struct lookup for default action test
361- if (
362- structKeyExists ( variables .registeredHandlers , currentEvent ) OR
363- structKeyExists ( variables .registeredExternalHandlers , currentEvent )
364- ) {
365- // Append the default event action
366- currentEvent = currentEvent & " ." & variables .eventAction ;
359+ if ( structKeyExists ( variables .registeredHandlers , currentEvent ) ) {
367360 // Save it as the current Event now with the default action
368- event .setValue ( variables .eventName , currentEvent );
361+ event .setValue ( variables .eventName , variables .registeredHandlers [ currentEvent ].defaultEvent );
362+ } else if ( structKeyExists ( variables .registeredExternalHandlers , currentEvent ) ) {
363+ // Save it as the current Event now with the default action
364+ event .setValue ( variables .eventName , variables .registeredExternalHandlers [ currentEvent ].defaultEvent );
369365 }
370366
371367 return this ;
@@ -592,16 +588,18 @@ component extends="coldbox.system.web.services.BaseService" accessors="true" {
592588 // Convert windows \ to java /
593589 arguments .directory = replace ( arguments .directory , " \" , " /" , " all" )
594590
595- var util = variables .controller .getUtil ()
596-
597- return directoryList (
591+ var util = variables .controller .getUtil ()
592+ var handlerList = {}
593+ var files = directoryList (
598594 arguments .directory ,
599595 true ,
600596 " array" ,
601597 " *.cfc|*.bx"
602- ).reduce ( ( accumulator , item ) = > {
603- var this AbsolutePath = replace ( arguments .item , " \" , " /" , " all" )
604- var cleanHandler = replaceNoCase ( this AbsolutePath , directory , " " , " all" )
598+ )
599+
600+ for ( var item in files ) {
601+ var this AbsolutePath = replace ( item , " \" , " /" , " all" )
602+ var cleanHandler = replaceNoCase ( this AbsolutePath , arguments .directory , " " , " all" )
605603 // Clean OS separators to dot notation.
606604 cleanHandler = removeChars (
607605 replaceNoCase ( cleanHandler , " /" , " ." , " all" ),
@@ -614,18 +612,21 @@ component extends="coldbox.system.web.services.BaseService" accessors="true" {
614612 var extension = listLast ( cleanHandler , " ." )
615613 // Build runnable path if invocationPath provided
616614 var runnable = len ( invocationPath ) ? invocationPath & " ." & handlerName : " "
615+ var defaultEvent = len ( moduleName ) ? moduleName & " :" & handlerName & " ." & variables .eventAction : handlerName & " ." & variables .eventAction
617616 // Store in struct with metadata
618- arguments . accumulator [ handlerName ] = {
617+ handlerList [ handlerName ] = {
619618 handler : handlerName ,
620619 path : this AbsolutePath ,
621620 extension : extension ,
622621 invocationPath : invocationPath ,
623622 runnable : runnable ,
623+ defaultEvent : defaultEvent ,
624624 source : source ,
625625 moduleName : moduleName
626626 }
627- return arguments .accumulator
628- }, {} )
627+ }
628+
629+ return handlerList
629630 }
630631
631632 /* *********************************** PRIVATE ************************************/
0 commit comments