Changeset 1587

Show
Ignore:
Timestamp:
06/25/08 10:53:10 (2 months ago)
Author:
lmajano
Message:

Finalized interceptor stop chain by using a boolean return value. If true, then the chain breaks. Also, updated a future threadwrapper decorater class.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • coldbox/trunk/system/beans/interceptorState.cfc

    r1586 r1587  
    7777                <cfscript> 
    7878                var key = ""; 
     79                var stopChain = ""; 
    7980                 
    8081                /* Loop and execute each interceptor as registered in order */ 
    8182                for( key in getInterceptors()){ 
    8283                        /* Invoke the execution point */ 
    83                         invoker( getInterceptors().get(key), arguments.event, arguments.interceptData ); 
    84                         /* Check for _stopchain */ 
    85                         if( arguments.event.valueExists('_stopchain') ){ 
    86                                 break; 
    87                         } 
     84                        stopChain = invoker( getInterceptors().get(key), arguments.event, arguments.interceptData ); 
     85                        /* Check for results */ 
     86                        if( stopChain ){ break; } 
    8887                }                
    8988                </cfscript> 
     
    115114 
    116115        <!--- Interceptor Invoker ---> 
    117         <cffunction name="invoker" access="private" returntype="void" hint="Execute an interceptor execution point" output="false" > 
     116        <cffunction name="invoker" access="private" returntype="any" hint="Execute an interceptor execution point" output="false" > 
    118117                <!--- ************************************************************* ---> 
    119118                <cfargument name="interceptor"          required="true" type="any"              hint="The interceptor reference from cache"> 
     
    121120                <cfargument name="interceptData"        required="true" type="any"              hint="A metadata structure used to pass intercepted information."> 
    122121                <!--- ************************************************************* ---> 
    123                 <cfinvoke component="#arguments.interceptor#" method="#getstate()#"> 
     122                <cfset var results = false> 
     123                 
     124                <!--- Invoke the interceptor ---> 
     125                <cfinvoke component="#arguments.interceptor#" method="#getstate()#" returnvariable="results"> 
    124126                        <cfinvokeargument name="event"                  value="#arguments.event#"> 
    125127                        <cfinvokeargument name="interceptData"  value="#arguments.interceptData#"> 
    126                 </cfinvoke>              
     128                </cfinvoke> 
     129                 
     130                <!--- Check if we have results ---> 
     131                <cfif isDefined("results") and isBoolean(results)> 
     132                        <cfreturn results> 
     133                <cfelse> 
     134                        <cfreturn false> 
     135                </cfif>                  
    127136        </cffunction> 
    128137         
  • coldbox/trunk/system/interceptor.cfc

    r1549 r1587  
    8080 
    8181        <!--- After Configuration Load ---> 
    82         <cffunction name="afterConfigurationLoad" access="public" returntype="void" hint="Executes after the framework and application configuration loads, but before the aspects get configured. " output="false" > 
     82        <cffunction name="afterConfigurationLoad" access="public" returntype="boolean" hint="Executes after the framework and application configuration loads, but before the aspects get configured. " output="false" > 
    8383                <cfargument name="event"        required="true" type="any" hint="The event object : coldbox.system.beans.requestContext"> 
    8484                <cfargument name="interceptData" required="true" type="struct" hint="A structure containing intercepted information. NONE BY DEFAULT HERE"> 
     
    8787         
    8888        <!--- After Aspects Load ---> 
    89         <cffunction name="afterAspectsLoad" access="public" returntype="void" hint="Executes after the application aspects get configured." output="false" > 
     89        <cffunction name="afterAspectsLoad" access="public" returntype="boolean" hint="Executes after the application aspects get configured." output="false" > 
    9090                <cfargument name="event"        required="true" type="any" hint="The event object : coldbox.system.beans.requestContext"> 
    9191                <cfargument name="interceptData" required="true" type="struct" hint="A structure containing intercepted information. NONE BY DEFAULT HERE"> 
     
    9494         
    9595        <!--- After Handler Creation ---> 
    96         <cffunction name="afterHandlerCreation" access="public" returntype="void" output="false" hint="Executes after any handler gets created." > 
     96        <cffunction name="afterHandlerCreation" access="public" returntype="boolean" output="false" hint="Executes after any handler gets created." > 
    9797                <!--- ************************************************************* ---> 
    9898                <cfargument name="event"                 required="true" type="any" hint="The event object : coldbox.system.beans.requestContext"> 
     
    103103                 
    104104        <!--- After Plugin Creation ---> 
    105         <cffunction name="afterPluginCreation" access="public" returntype="void" output="false" hint="Executes after any plugin gets created." > 
     105        <cffunction name="afterPluginCreation" access="public" returntype="boolean" output="false" hint="Executes after any plugin gets created." > 
    106106                <!--- ************************************************************* ---> 
    107107                <cfargument name="event"                 required="true" type="any" hint="The event object : coldbox.system.beans.requestContext"> 
     
    112112         
    113113        <!--- Session Start ---> 
    114         <cffunction name="sessionStart" access="public" returntype="void" hint="Executes on Session start" output="false" > 
     114        <cffunction name="sessionStart" access="public" returntype="boolean" hint="Executes on Session start" output="false" > 
    115115                <cfargument name="event"        required="true" type="any" hint="The event object : coldbox.system.beans.requestContext"> 
    116116                <cfargument name="interceptData" required="true" type="struct" hint="A structure containing intercepted information. THE SESSION SCOPE"> 
     
    119119         
    120120        <!--- Session End ---> 
    121         <cffunction name="sessionEnd" access="public" returntype="void" hint="Executes on Session end." output="false" > 
     121        <cffunction name="sessionEnd" access="public" returntype="boolean" hint="Executes on Session end." output="false" > 
    122122                <cfargument name="event"        required="true" type="any" hint="The event object : coldbox.system.beans.requestContext"> 
    123123                <cfargument name="interceptData" required="true" type="struct" hint="A structure containing intercepted information. THE SESSION SCOPE"> 
     
    126126         
    127127        <!--- Pre execution process ---> 
    128         <cffunction name="preProcess" access="public" returntype="void" hint="Executes before any event execution occurs" output="false" > 
     128        <cffunction name="preProcess" access="public" returntype="boolean" hint="Executes before any event execution occurs" output="false" > 
    129129                <cfargument name="event"        required="true" type="any" hint="The event object : coldbox.system.beans.requestContext"> 
    130130                <cfargument name="interceptData" required="true" type="struct" hint="A structure containing intercepted information. NONE BY DEFAULT HERE"> 
     
    133133         
    134134        <!--- Pre Event execution ---> 
    135         <cffunction name="preEvent" access="public" returntype="void" hint="Executes right before any run event is executed." output="false" > 
     135        <cffunction name="preEvent" access="public" returntype="boolean" hint="Executes right before any run event is executed." output="false" > 
    136136                <cfargument name="event"                required="true" type="any" hint="The event object : coldbox.system.beans.requestContext"> 
    137137                <cfargument name="interceptData"        required="true" type="struct" hint="A structure containing intercepted information = [processedEvent]"> 
     
    140140         
    141141        <!--- Post Event Execution ---> 
    142         <cffunction name="postEvent" access="public" returntype="void" hint="Executes after a run event is executed" output="false" > 
     142        <cffunction name="postEvent" access="public" returntype="boolean" hint="Executes after a run event is executed" output="false" > 
    143143                <cfargument name="event"                required="true" type="any" hint="The event object : coldbox.system.beans.requestContext"> 
    144144                <cfargument name="interceptData"        required="true" type="struct" hint="A structure containing intercepted information = [processedEvent]"> 
     
    147147         
    148148        <!--- Pre Render Execution ---> 
    149         <cffunction name="preRender" access="public" returntype="void" hint="Executes before the framework starts the rendering cycle." output="false" > 
     149        <cffunction name="preRender" access="public" returntype="boolean" hint="Executes before the framework starts the rendering cycle." output="false" > 
    150150                <cfargument name="event" required="true" type="any" hint="The event object : coldbox.system.beans.requestContext"> 
    151151                <cfargument name="interceptData"        required="true" type="struct" hint="A structure containing intercepted information. NONE BY DEFAULT HERE"> 
     
    154154         
    155155        <!--- Post Rendering Cycle ---> 
    156         <cffunction name="postRender" access="public" returntype="void" hint="Executes after the rendering cycle." output="false" > 
     156        <cffunction name="postRender" access="public" returntype="boolean" hint="Executes after the rendering cycle." output="false" > 
    157157                <cfargument name="event"        required="true" type="any" hint="The event object : coldbox.system.beans.requestContext"> 
    158158                <cfargument name="interceptData" required="true" type="struct" hint="A structure containing intercepted information. NONE BY DEFAULT HERE"> 
     
    161161         
    162162        <!--- Post Process ---> 
    163         <cffunction name="postProcess" access="public" returntype="void" hint="Executes after executions and renderings." output="false" > 
     163        <cffunction name="postProcess" access="public" returntype="boolean" hint="Executes after executions and renderings." output="false" > 
    164164                <cfargument name="event"        required="true" type="any" hint="The event object : coldbox.system.beans.requestContext"> 
    165165                <cfargument name="interceptData" required="true" type="struct" hint="A structure containing intercepted information. NONE BY DEFAULT HERE"> 
     
    168168         
    169169        <!--- After an Elemente is inserted in the cache ---> 
    170         <cffunction name="afterCacheElementInsert" access="public" returntype="void" hint="Executes after an object is inserted into the cache." output="false" > 
     170        <cffunction name="afterCacheElementInsert" access="public" returntype="boolean" hint="Executes after an object is inserted into the cache." output="false" > 
    171171                <cfargument name="event"        required="true" type="any" hint="The event object : coldbox.system.beans.requestContext"> 
    172172                <cfargument name="interceptData" required="true" type="struct" hint="A structure containing intercepted information = [cacheObjectKey,cacheObjectTimeout]"> 
     
    175175         
    176176        <!--- After an Element is removed from the cache ---> 
    177         <cffunction name="afterCacheElementRemoved" access="public" returntype="void" hint="Executes after an object is removed from the cache." output="false" > 
     177        <cffunction name="afterCacheElementRemoved" access="public" returntype="boolean" hint="Executes after an object is removed from the cache." output="false" > 
    178178                <cfargument name="event"        required="true" type="any" hint="The event object : coldbox.system.beans.requestContext"> 
    179179                <cfargument name="interceptData" required="true" type="struct" hint="A structure containing intercepted information = [cacheObjectKey]"> 
  • coldbox/trunk/system/util/ThreadWrapper.cfc

    r1586 r1587  
    2525                        /* Save Wrapper */ 
    2626                        setTarget(arguments.target); 
    27                         //return instance. 
     27                        setThread(createObject("java", "java.lang.Thread")); 
     28                        /* return instance. */ 
    2829                        return this; 
    2930                </cfscript> 
     
    3637                <!--- ************************************************************* ---> 
    3738                <cfargument name="method"                type="string"  required="Yes" hint="Name of the method to invoke"> 
    38                 <cfargument name="argCollection" type="struct"  required="No"  hint="Called with an argument collection struct"> 
     39                <cfargument name="argCollection" type="struct"  required="No"  default="#structnew()#"  hint="Called with an argument collection struct"> 
    3940                <!--- ************************************************************* ---> 
    4041                <cfset var ThreadName = "coldbox.util.ThreadWrapper_#replace(createUUID(),"-","","all")#"> 
    4142                <cfset var ResponseToken = createUUID()> 
    4243                 
    43                 <!--- Thread it. ---> 
    44                 <cfthread name="#ThreadName#" attribs="#arguments.argCollection#"> 
     44                <!--- Validate if inside thread ---> 
     45                <cfif isInsideCFThread()> 
     46                         
     47                        <!--- Invoke the method sync ---> 
    4548                        <cfinvoke component="#getTarget()#" 
    4649                                          method="#attributes.method#" 
    47                                           argumentcollection="#attributes.attribs#" /> 
    48                 </cfthread> 
     50                                          argumentcollection="#attributes.args#" /> 
     51                                           
     52                <cfelse> 
     53                 
     54                        <!--- Thread it. ---> 
     55                        <cfthread name="#ThreadName#" args="#arguments.argCollection#"> 
     56                                 
     57                                <!--- Invoke the method async ---> 
     58                                <cfinvoke component="#getTarget()#" 
     59                                                  method="#attributes.method#" 
     60                                                  argumentcollection="#attributes.args#" /> 
     61                                                   
     62                        </cfthread> 
     63                 
     64                </cfif> 
    4965                 
    5066                <cfreturn ResponseToken> 
     
    5975                <cfset instance.target = arguments.target/> 
    6076        </cffunction> 
     77         
     78<!------------------------------------------- PRIVATE -------------------------------------------> 
     79         
     80        <!--- Check if inside cfthread ---> 
     81        <cffunction name="isInsideCFThread" access="private" returntype="boolean" hint="See if the running thread is inside a cfthread." output="false" > 
     82                <cfscript> 
     83                        try{ 
     84                                if ( findNoCase("cfthread", getThread().currentThread().getThreadGroup().getName() ) ){ 
     85                                        return true; 
     86                                } 
     87                                else{ 
     88                                        return false; 
     89                                } 
     90                        } 
     91                        catch(Any e){  
     92                                return true; 
     93                        } 
     94                </cfscript> 
     95        </cffunction>    
     96         
     97        <!--- Get/set thread object ---> 
     98        <cffunction name="getThread" access="private" returntype="any" output="false"> 
     99                <cfreturn instance.Thread /> 
     100        </cffunction>    
     101        <cffunction name="setThread" access="private" returntype="void" output="false"> 
     102                <cfargument name="Thread" type="any" required="true"> 
     103                <cfset instance.Thread = arguments.Thread /> 
     104        </cffunction> 
    61105 
    62106</cfcomponent> 

Copyright 2006 ColdBox Framework by Luis Majano