Pratical use #1:

Being able to write custom error messages which says what method threw
the error!

Adam Wayne Lehman
Web Systems Developer
Johns Hopkins Bloomberg School of Public Health
Distance Education Division


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Matt Liotta
Sent: Wednesday, September 17, 2003 3:38 PM
To: [EMAIL PROTECTED]
Subject: Re: [CFCDev] Programmatically determining a method call

BTW, someone posted to my blog asking what practical use the code had. 
Possibly you would like to share your application as an example.

-Matt

On Wednesday, September 17, 2003, at 03:09 PM, Justin Balog wrote:

> That was me who was asking, I will give this a run, thanks Matt!
>
> -----Original Message-----
> From: Matt Liotta [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, September 17, 2003 12:53 PM
> To: [EMAIL PROTECTED]
> Subject: [CFCDev] Programmatically determining a method call
>
>
> A while back I seem to remember someone asking how to programmatically
> determine what method of a CFC was called and by whom. At the time it
> didn't seem like there was a way to do it, but I have come up with a
> way through a new feature found in JDK 1.4. Below is an example CFC
> that has a single method, which determines who called it and what
> method it is.
>
> <cfcomponent>
>       <cffunction name="getCaller" returntype="struct"
access="public">
>               <cfscript>
>                       e = CreateObject("java", "java.lang.Exception");
>                       sts = e.getStackTrace();
>                       foundme = false;
>                       theCaller = StructNew();
>                       for(itr = 1; itr lte ArrayLen(sts); itr = itr +
1) {
>                               className = sts[itr].getClassName();
>                               if(foundme and className contains
"2ecf") {
>                                       index = Find("2ecf", className);
>                                       theCaller.from = Mid(className,
3,
> index - 3);
>                                       break;
>                               }
>                               if(not foundme and className contains
> "2ecfc") {
>                                       foundme = true;
>                                       methodName =
> sts[itr].getClassName();
>                                       index = Find("$func",
methodName);
>                                       theCaller.toMethod =
Mid(methodName,
> index + 5, Len(methodName));
>                               }
>                       }
>               </cfscript>
>               <cfreturn theCaller>
>       </cffunction>
> </cfcomponent>
>
> Again, the above only works in JDK 1.4. There is a way to make it work
> with earlier JDKs, but that would be more time consuming both from a
> development point of view and a performance one.
>
> I also blogged this at http://devilm.com/archives/000044.html.
>
> Matt Liotta
> President & CEO
> Montara Software, Inc.
> http://www.MontaraSoftware.com
> (888) 408-0900 x901
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at
> www.mail-archive.com/[EMAIL PROTECTED]
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at 
> www.mail-archive.com/[EMAIL PROTECTED]
>
>
Matt Liotta
President & CEO
Montara Software, Inc.
http://www.MontaraSoftware.com
(888) 408-0900 x901


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at
www.mail-archive.com/[EMAIL PROTECTED]

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to