Title: Message
Hi Jim,
 
Many thanks - great resource! I went through cacheDPMetaData() and the called setDPMetaData() and also had a look at the rest of the methods (including dump() and dumpThis() - simple but useful!). I found how it provided the name, path, display name and properties. I wasn't immediately able to see any reference to getting the methods of a given method. I went through the component source code, but couldn't find anything there. Anything I'm missing?
 
Best Wishes,
Peter
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jim Davis
Sent: Sunday, March 05, 2006 8:37 PM
To: CFCDev@cfczone.org
Subject: RE: [CFCDev] Using Introspection of methods on Init?

This is one of the features my libraries:

 

http://www.depressedpress.com/Content/Development/ColdFusion/DPLibraries/Index.cfm

 

If you extend the root component you’ll get metadata caching which (at least so far) has scaled pretty well.  The root component documentation is here:

 

http://www.depressedpress.com/Content/Development/ColdFusion/DPLibraries/Documentation/DocViewer.cfm?Component=cfc_DepressedPress.DP_Component

 

The method cacheDPMetaData() caches method and property information along with ancestry and other information – it stores the information in the application (if available) or server scope for later reference.

 

The documentation I referenced has all the code used – feel free to either use it or take from it (it’s all under the BSD license).

 

Jim Davis

 

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter Bell
Sent: Sunday, March 05, 2006 7:14 PM
To: CFCDev@cfczone.org
Subject: [CFCDev] Using Introspection of methods on Init?

 

I thought it might be nice to have a list of valid method names when initiating an object so I'd be able to make sure I didn't try to run a method (perhaps based on user input) that was inappropriate. Of course, I could use try/catch but that wouldn't distinguish between calling invalid methods and errors within the method.

 

Anyhow, getMetaData() works fine, but I ran into problems getting a clean method list:

  <cfset Local.TempMetaData = getMetaData(THIS)>
  <cfset Local.FunctionList = Local.TempMetaData.Functions>
  <cfset THIS.MethodList = Local.FunctionList[1].Name>

Successfully returns the name of the first method of the object.

 

Trying to loop through them as below gives "Invalid collection "[Ljava.lang.Object;@1f4c4a3" - must be a valid struct or COM object. "

  <cfloop collection="#Local.FunctionList#" item="Count">
   <cfset ThisVal = Local.FunctionList[#Count#].Name>
   <cfset THIS.MethodList = ListAppend(THIS.MethodList,ThisVal)>
  </cfloop>

I have a feeling this is a simple syntax problem but am not sure . . . Anyone have simple code for returning a list of methods?

 

FYI, I know Sean suggested some time back that run time introspection doesn't scale, but by only running this routine on a small number of objects that I persist throughout an application and by only calling it once on object creation I'm betting the performance overhead will be minimal.

 

Best Wishes,
Peter

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to cfcdev@cfczone.org with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

An archive of the CFCDev list is available at www.mail-archive.com/cfcdev@cfczone.org ----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to cfcdev@cfczone.org with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

An archive of the CFCDev list is available at www.mail-archive.com/cfcdev@cfczone.org
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to cfcdev@cfczone.org with the words 'unsubscribe cfcdev' as the subject of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com).

An archive of the CFCDev list is available at www.mail-archive.com/cfcdev@cfczone.org

Reply via email to