Changeset 1753

Show
Ignore:
Timestamp:
09/01/08 13:09:14 (4 months ago)
Author:
lmajano
Message:

Ticket #525
fixes for proxy exception handler
fixes on MT logger.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • coldbox/trunk/system/extras/ColdboxProxy.cfc

    r1663 r1753  
    3636                                /* Test Event Name */ 
    3737                                if( not structKeyExists(arguments, "#event.getEventName()#") ){ 
    38                                         throwit("Event not detected","The #event.geteventName()# variable does not exist in the arguments."); 
     38                                        getUtil().throwit("Event not detected","The #event.geteventName()# variable does not exist in the arguments."); 
    3939                                } 
    4040                                 
     
    6868                                //Execute the post process interceptor 
    6969                                cbController.getInterceptorService().processState("postProcess"); 
     70                                 
     71                                /* Request Profilers */ 
     72                                pushTimers(); 
    7073                        } 
    7174                        catch(Any e){ 
    7275                                /* Log Exception */ 
    73                                 cbController.getExceptionService().ExceptionHandler(e,"coldboxproxy","Process Exception"); 
    74                                  
    75                                 /* Verify stacktrace */ 
    76                                 if( not structKeyExists(e,"stacktrace") ){ 
    77                                         e.stacktrace = ""; 
    78                                 } 
    79                                  
    80                                 /* Request Profilers */ 
    81                                 pushTimers(); 
    82                                 /* Custom throw. */ 
    83                                 throwit(e.message.toString(),e.detail.toString() & e.stacktrace.toString()); 
    84                         } 
    85                          
    86                         /* Request Profilers */ 
    87                         pushTimers(); 
     76                                handleException(e); 
     77                                /* Rethrow it */ 
     78                                getUtil().rethrowit(e); 
     79                        } 
    8880                                 
    8981                        /* Determine what to return via the setting */ 
     
    136128                        } 
    137129                        catch(Any e){ 
    138                                 /* Intercept Exception */ 
    139                                 interceptData = structnew(); 
    140                                 interceptData.exception = e; 
    141                                 cbController.getInterceptorService().processState("onException",interceptData); 
    142                                  
    143                                 /* Log Exception */ 
    144                                 cbController.getExceptionService().ExceptionHandler(e,"coldboxproxy","Interception Exception"); 
    145                                  
    146                                 /* Request Profilers */ 
    147                                 pushTimers(); 
    148                                  
    149                                 /* Return */ 
    150                                 return false; 
     130                                /* Handle Exception */ 
     131                                handleException(e);                              
     132                                /* Rethrow it */ 
     133                                getUtil().rethrowit(e); 
    151134                        } 
    152135                         
     
    158141                </cfscript> 
    159142        </cffunction> 
    160          
     143                
    161144<!------------------------------------------- PRIVATE ------------------------------------------->       
     145         
     146        <!--- handleException ---> 
     147        <cffunction name="handleException" output="false" access="private" returntype="void" hint="Handle a ColdBox request Exception"> 
     148                <cfargument name="exceptionObject" type="any" required="true" hint="The exception object"/> 
     149                <cfscript> 
     150                        var cbController = ""; 
     151                        var interceptData = structnew(); 
     152                         
     153                        /* Get ColdBox Controller */ 
     154                        cbController = getController(); 
     155                         
     156                        /* Intercept Exception */ 
     157                        interceptData = structnew(); 
     158                        interceptData.exception = arguments.exceptionObject; 
     159                        cbController.getInterceptorService().processState("onException",interceptData); 
     160                         
     161                        /* Log Exception */ 
     162                        cbController.getExceptionService().ExceptionHandler(arguments.exceptionObject,"coldboxproxy","ColdBox Proxy Exception"); 
     163                         
     164                        /* Request Profilers */ 
     165                        pushTimers(); 
     166                </cfscript> 
     167        </cffunction> 
    162168         
    163169        <!--- Trace messages to the tracer panel ---> 
     
    196202        <cffunction name="verifyColdBox" output="false" access="private" returntype="boolean" hint="Verify the coldbox app"> 
    197203                <cfscript> 
    198                 //Verify the coldbox app is ok, else throw 
    199                 if ( not structKeyExists(application,"cbController") ){ 
    200                         throwit("ColdBox Controller Not Found", "The coldbox main controller has not been initialized"); 
    201                 } 
    202                 else 
    203                         return true; 
     204                        //Verify the coldbox app is ok, else throw 
     205                        if ( not structKeyExists(application,"cbController") ){ 
     206                                getUtil().throwit("ColdBox Controller Not Found", "The coldbox main controller has not been initialized"); 
     207                        } 
     208                        else{ 
     209                                return true; 
     210                        } 
    204211                </cfscript> 
    205212        </cffunction> 
     
    284291                </cfif> 
    285292        </cffunction> 
    286  
    287         <!--- Throw Facade ---> 
    288         <cffunction name="throwit" access="private" hint="Facade for cfthrow" output="false"> 
    289                 <!--- ************************************************************* ---> 
    290                 <cfargument name="message"      type="any"      required="yes"> 
    291                 <cfargument name="detail"       type="any"      required="no" default=""> 
    292                 <!--- ************************************************************* ---> 
    293                 <cfthrow type="coldboxproxyException" message="#arguments.message#"  detail="#arguments.detail#"> 
    294         </cffunction>    
    295         <!--- Dump it Facade ---> 
    296         <cffunction name="dumpit" access="private" hint="Facade for cfmx dump" returntype="void"> 
    297                 <cfargument name="var" required="yes" type="any"> 
    298                 <cfdump var="#var#"> 
    299         </cffunction>    
    300         <!--- Abort it facade ---> 
    301         <cffunction name="abortit" access="private" hint="Facade for cfabort" returntype="void" output="false"> 
    302                 <cfabort> 
     293         
     294        <cffunction name="getUtil" access="private" output="false" returntype="coldbox.system.util.util" hint="Create and return a util object"> 
     295                <cfreturn CreateObject("component","coldbox.system.util.util")/> 
    303296        </cffunction> 
    304297         
  • coldbox/trunk/system/plugins/MTlogger.cfc

    r1624 r1753  
    3535                <cfscript> 
    3636                        super.Init(arguments.controller); 
    37                         setThread(createObject("java", "java.lang.Thread")); 
     37                         
     38                        instance.thread = createObject("java", "java.lang.Thread"); 
     39                         
    3840                        return this; 
    3941                </cfscript> 
     
    6264                                  ExtraInfo="#arguments.ExtraInfo#">  
    6365                                <cfscript>   
    64                                         super.logEntry(Attributes.Severity,Attributes.Message,Attributes.ExtraInfo);  
     66                                        super.logEntry(Severity=Attributes.Severity,Message=Attributes.Message,ExtraInfo=Attributes.ExtraInfo);  
    6567                                </cfscript> 
    6668                        </cfthread> 
     
    9597                <cfscript> 
    9698                        try{ 
    97                                 if ( findNoCase("cfthread", getThread().currentThread().getThreadGroup().getName() ) ){ 
     99                                if ( findNoCase("cfthread", instance.thread.currentThread().getThreadGroup().getName() ) ){ 
    98100                                        return true; 
    99101                                } 
     
    107109                </cfscript> 
    108110        </cffunction>    
    109  
    110         <!--- Get/set thread object ---> 
    111         <cffunction name="getThread" access="private" returntype="any" output="false"> 
    112                 <cfreturn instance.Thread /> 
    113         </cffunction>    
    114         <cffunction name="setThread" access="private" returntype="void" output="false"> 
    115                 <cfargument name="Thread" type="any" required="true"> 
    116                 <cfset instance.Thread = arguments.Thread /> 
    117         </cffunction> 
    118111                 
    119112</cfcomponent> 
  • coldbox/trunk/system/plugins/logger.cfc

    r1736 r1753  
    3232        <cffunction name="init" access="public" returntype="logger" hint="Constructor" output="false"> 
    3333                <cfargument name="controller" type="any" required="true"> 
    34                 <cfset super.Init(arguments.controller) /> 
    35                  
    36                 <!--- Setup Plugin Properties ---> 
    37                 <cfset setpluginName("Logger")> 
    38                 <cfset setpluginVersion("1.1")> 
    39                 <cfset setpluginDescription("This plugin is used for logging methods and facilities.")> 
    40                  
    41                 <!--- log name without extension ---> 
    42                 <cfset setLogFileName( URLEncodedFormat(replace(replace(getSetting("AppName")," ","","all"),".","_","all")) )> 
    43                  
    44                 <!--- The full absolute path of the log file ---> 
    45                 <cfif settingExists("ColdboxLogsLocation")> 
    46                         <cfset setlogFullPath( getSetting("ColdboxLogsLocation") )> 
    47                 <cfelse> 
    48                         <cfset setlogFullPath('')> 
    49                 </cfif> 
    50                  
    51                 <!--- Available valid severities ---> 
    52                 <cfset instance.validSeverities = "information|fatal|warning|error|debug"> 
    53                 <!--- Lock Name ---> 
    54                 <cfset instance.lockName = getController().getAppHash() & "_LOGGER_OPERATION"> 
    55                  
    56                 <!--- Return ---> 
    57                 <cfreturn this> 
     34                <cfscript> 
     35                        //super init it. 
     36                        super.Init(arguments.controller); 
     37                        /* setup properties */ 
     38                        setpluginName("Logger"); 
     39                        setpluginVersion("1.1"); 
     40                        setpluginDescription("This plugin is used for logging methods and facilities."); 
     41                         
     42                        /* log name without extension */ 
     43                        setLogFileName( URLEncodedFormat(replace(replace(getSetting("AppName")," ","","all"),".","_","all")) ); 
     44                         
     45                        /* The full absolute path of the log file */ 
     46                        if ( settingExists("ColdboxLogsLocation") ){ 
     47                                setlogFullPath( getSetting("ColdboxLogsLocation") ); 
     48                        } 
     49                        else{ 
     50                                setlogFullPath(''); 
     51                        } 
     52                         
     53                        /* Available valid severities */ 
     54                        instance.validSeverities = "information|fatal|warning|error|debug"; 
     55                        /* Lock Name */ 
     56                        instance.lockName = getController().getAppHash() & "_LOGGER_OPERATION"; 
     57                        instance.lockTimeout = 15; 
     58                                 
     59                        return this; 
     60                </cfscript> 
    5861        </cffunction> 
    5962 
     
    187190                         
    188191                        <!--- Append Message ---> 
    189                         <cflock type="exclusive" name="#getLockName()#" timeout="120"> 
    190                                 <cftry> 
    191                                         <cffile action="append"  
    192                                                         addnewline="true"  
    193                                                         file="#getlogFullPath()#"  
    194                                                         output="#formatLogEntry(arguments.severity,arguments.message,arguments.extraInfo)#" 
    195                                                         charset="#getSetting("LogFileEncoding",1)#"> 
    196                                         <cfcatch type="any"> 
    197                                                 <cfthrow type="ColdBox.plugins.logger.WritingEntryException" message="An error occurred writing an entry to the log file." detail="#cfcatch.Detail#<br>#cfcatch.message#"> 
    198                                         </cfcatch> 
    199                                 </cftry> 
     192                        <cflock type="exclusive" name="#instance.lockName#" timeout="#instance.lockTimeout#" throwontimeout="true"> 
     193                                <cffile action="append"  
     194                                                addnewline="true"  
     195                                                file="#getlogFullPath()#"  
     196                                                output="#formatLogEntry(arguments.severity,arguments.message,arguments.extraInfo)#" 
     197                                                charset="#getSetting("LogFileEncoding",1)#"> 
    200198                        </cflock> 
    201199                </cfif> 
     
    211209                <cfset var oFileUtilities = ""> 
    212210 
    213                 <cflock name="#getlockName()#" type="exclusive" timeout="120"> 
     211                <cflock name="#instance.lockName#" type="exclusive" timeout="#instance.lockTimeout#" throwontimeout="true"> 
    214212                        <!--- Determine First Run ---> 
    215213                        <cfif arguments.firstRunFlag> 
     
    259257                <cfargument name="reinitializeFlag" required="false" default="true" type="boolean" hint="Flag to reinitialize the log location or not." > 
    260258                <!--- ************************************************************* ---> 
    261                 <cflock name="#getLockName()#" type="exclusive" timeout="120"> 
     259                <cflock name="#instance.lockName#" type="exclusive" timeout="#instance.lockTimeout#" throwontimeout="true"> 
    262260                        <cffile action="delete" file="#getLogFullPath()#"> 
    263261                </cflock> 
     
    295293        <cffunction name="getvalidSeverities" access="public" hint="Get the validSeverities" output="false" returntype="string"> 
    296294                <cfreturn instance.validSeverities > 
    297         </cffunction> 
    298  
    299         <!--- Get Lock Name ---> 
    300         <cffunction name="getlockName" access="public" output="false" returntype="string" hint="Get lockName"> 
    301                 <cfreturn instance.lockName/> 
    302         </cffunction> 
    303                  
     295        </cffunction>    
    304296         
    305297<!------------------------------------------- PRIVATE -------------------------------------------> 
     
    392384                                 
    393385                                <!--- Zip Log File ---> 
    394                                 <cflock name="#getlockName()#" type="exclusive" timeout="120"> 
     386                                <cflock name="#instance.lockName#" type="exclusive" timeout="#instance.lockTimeout#" throwontimeout="true"> 
    395387                                        <!--- Should I remove log Files ---> 
    396388                                        <cfif qArchivedLogs.recordcount gte getSetting("LogFileMaxArchives",1)> 
  • coldbox/trunk/system/util/util.cfc

    r1631 r1753  
    2626        </cffunction> 
    2727         
    28         <cffunction name="rethrowit" access="public" returntype="void" hint="" output="false" > 
    29                 <cfargument name="throwObject" required="true" type="any" hint=""> 
     28        <cffunction name="rethrowit" access="public" returntype="void" hint="Rethrow an exception" output="false" > 
     29                <cfargument name="throwObject" required="true" type="any" hint="The exception object"> 
    3030                <cfthrow object="#arguments.throwObject#"> 
    3131        </cffunction> 

Copyright 2006 ColdBox Framework by Luis Majano