Solved

Is there a way to find out who invoked a CFC?

Posted on 2006-07-13
7
346 Views
Last Modified: 2013-12-24
Is there a way to find out who invoked a CFC? I would like to check and log who the calling .CFM or .CFC file is from within the CFC being invoked. Sort of like back in the Custom Tag days, I need to know which templated called me. I am looking at the GetMetaData() and GetPageContext() functions but nothing stands out yet as how to do what I need to do.

This is a pretty tough one, and I wish I could diagram it to help explain.

cfc1
cfc2
...
...
cfc55

In any of these CFC's, we have code wraped in try/catch statements. When an exception is thrown, the catch statements kick in. in the catch blocks, I invoke a cfc called myErrorCFC.cfc..

err = createObject("component", "myError");

From there inside of the catch block I am invoking a method (see below) which performs legancy handling/logging.

err.parseException(cfcatch.Message);

What I now need to do is extend that method to log who thrown the exception. Yes the simple way is to pass the name of the cfc or cfm page as an argument, but changing the code which invokes the err cfc is out of my control. So I am left with trying to solve this the hard way.

So far this is where I am at (in my "myErrorCFC.cfc", invoked from within the catch blocks) which is not currently working:

tmp = getPageContext().getException();

This does not work but it may clearify the approach I am taking. Does anyone have any good ideas on how to return the error object from the JRun/jsp/java side of things. "getPageContext()" returns a "coldfusion.runtime.NeoPageContext" object. The end result I am trying to achieve is simply (ha ha) to find out which cfc or cfm page that the exception was thrown and having access to any additional info would be benificial as well.

Any help will be appriciated greatly.

Thank you,
Erik
0
Comment
Question by:SealWeb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
7 Comments
 
LVL 18

Accepted Solution

by:
Plucka earned 250 total points
ID: 17105119
SealWeb,

Try

GetCurrentTemplatePath()

This should work for the page, not sure what will happen when another component has called it.

Regards
Plucka
0
 
LVL 9

Assisted Solution

by:73Spyder
73Spyder earned 250 total points
ID: 17107966
It may be more work, but you could pass an extra argument with the page name to the cfc.  This way you would have the information right there.

You would have to modify all the invokes to include this though.
0
 
LVL 1

Expert Comment

by:micahp
ID: 17110206
this is just a shot in the dark and i certainly havent tried it but you may try diggin into the coldfusion debug variables accessible via:

coldfusion.server.ServiceFactory.getDebuggingService().getDebugger().getData();

or something close to that... (note: this is a java object so be sure to specify java in your createobject call)

you may be able to futz around with the stack trace or template trace and get what u are looking for...

gosh, this would be highly invasive tho it seems... the whole templatepath thing would probably be less so
0
 
LVL 1

Expert Comment

by:micahp
ID: 17112683
er... coldfusion.server.ServiceFactory.getDebuggingService() is what you want to be looking at...

coldfusion.server.ServiceFactory.getDebuggingService().getDebugger().getData() will return a query with all the queries that were run for the request...

sorry =P
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question