Last active
August 29, 2015 14:12
-
-
Save s7github/e9ecb8cbc2c9d82c40dd to your computer and use it in GitHub Desktop.
Get list of methods available in Coldfusion core class files (recursively)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="readCFCoreClass" output="false" hint="Get list of methods available in Coldfusion core class files (recursively)"> | |
<cfargument name="searchFolder" type="string" required="true" hint="Path of specific folder in which to be searched (with backslash at end)"> | |
<cfargument name="searchFile" type="string" required="true" hint="Path of specific class file to be searched (without .class extension)"> | |
<cfargument name="searchRecurse" type="boolean" required="false" default="false" hint="Search should be recursive or not?"> | |
<!--- Container for final results ---> | |
<cfset var searchResults = queryNew("Class,Method,Return_Type", "varchar,varchar,varchar")> | |
<!--- Path of folder into which jar file "<CF installation path>/WEB-INF/lib/cfusion.jar" is extracted ---> | |
<cfset var searchRootParentPath = ""> | |
<!--- Folder name where core CF classes exists ---> | |
<cfset var searchRootPath = "coldfusion\"> | |
<cfset var searchFullpath = searchRootParentPath & searchRootPath & searchPath> | |
<!--- Get list of class files available ---> | |
<cfdirectory name="fileList" action="list" directory="#searchFullPath#" filter="#searchFile#*.class" recurse="#searchRecurse#"> | |
<!--- Read each class file in loop ---> | |
<cfloop from="1" to="#fileList.recordCount#" index="idxFile"> | |
<cfset var fullPath = fileList.directory[idxFile] & "\" & fileList.name[idxFile]> | |
<cfset var relPath = replace(fullPath, ".class", "")> | |
<cfset relPath = replace(relPath, searchRootParentPath, "")> | |
<cfset relPath = replace(relPath, "\", ".", "all")> | |
<cfset var classObj = createObject("java", "#relPath#")> | |
<cfset var classMethods = classObj.getClass().getMethods()> | |
<cfif arrayLen(classMethods) gt 0> | |
<cfloop from="1" to="#arrayLen(classMethods)#" index="idxMethod"> | |
<cfset queryAddRow(searchResults)> | |
<cfset querySetCell(searchResults, "Class", relPath)> | |
<cfset querySetCell(searchResults, "Method", classMethods[idxMethod].getName()> | |
<cfset querySetCell(searchResults, "Return_Type", classMethods[idxMethod].getReturnType())> | |
</cfloop> | |
</cfif> | |
</cfloop> | |
<cfreturn searchResults> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment