Hi Matt, I have tested your script and I don't get what you mention... the
only thing I'm getting when I'm doing... <cfoutput>Caller Method:
#theCaller.toMethod# #methodname#</cfoutput>... I'm getting the same method
name that execute your script!...
When I put your peace of code in the cfscript into my VerifyOnlineStatus
method that it's being called by GetEmail method... it's telling me when I'm
doing the cfoutput above... "Caller Method: VERIFYONLINESTATUS"... it does
not tell me this... "Caller Method: GetEmail".... may be I'm missing
something here!!
Your method does not any arguments!... and how can I verify what the version
of JDK that I'm running... JDK does not mean anything for me!...
Stephane
----- Original Message -----
From: "Matt Liotta" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 17, 2003 2:52 PM
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]