You should be able to use java reflection to get you most of the way there.

Something like this:

***********************************************
<!--- Replace this with your own class name --->
<cfset someClass = "java.lang.String">
<cfset x = 0>
<cfset class = x.getClass().forName(someclass)>

<!--- Handle fields --->
<cfset Fields = class.getFields()>
<cfset stFields = structNew()>
<cfloop from="1" to="#arrayLen(fields)#" index="i">
   <cfset stFields[fields[i].getName()] = fields[i]>
    <!--- Do whatever you want for each field here --->
</cfloop>

<cfset aFieldNames = structKeyArray(stFields)>
<cfset arraySort(aFieldNames,'textnocase')>
<cfloop from="1" to="#arrayLen(aFieldNames)#" index="i">
   <cfset thisField = stFields[aFieldNames[i]]>
</cfloop>


<!--- Handle methods --->
<cfset Methods = class.getMethods()>

<cfset stMethods = structNew()>
<cfloop from="1" to="#arrayLen(methods)#" index="i">
        <cfset stMethods[methods[i].getName()] = methods[i]>
</cfloop>
<cfset aMethodNames = structKeyArray(stMethods)>
<cfset arraySort(aMethodNames,'textnocase')>
<cfloop from="1" to="#arrayLen(aMethodNames)#" index="i">
   <cfset thisMethod = stMethods[aMethodNames[i]]>
   <!--- Do whatever you want for each method here --->

   <cfset aParams = thisMethod.getParameterTypes()>
   <cfloop from="1" to="#arrayLen(aParams)#" index="j">
     <!--- Do whatever you want for each method parameter here --->
   </cfloop>

   <cfset aExceptions = thisMethod.getExceptionTypes()>
   <cfloop from="1" to="#arrayLen(aExceptions)#" index="j">
     <!--- Do whatever you want for each method exception here --->
   </cfloop>
</cfloop>

***************************************************

Spike

Edward Smith wrote:
> Has anybody written any code to autogenerate CFC wrappers for Java classes?
> 
> I have a bunch of Java classes that I want to use in CF, and I want to wrap
> them in CFCs for any Web/CF specific manipulation that might have to be
> done.
> 
> I'm looking for some code that might be able to examine the Java class and
> stub out the CFC for me automagically.
> 
> Has anybody heard of such a thing?  Any other suggestions on how I might
> accomplish it with as least effort as possible?
> 
> Thanks!
> 
> Edward Smith
> 
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:184196
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to