Tuesday, August 10, 2004

ColdFusion/Java Hybrid Application - Proof of Concept

I completed a very simple real estate listing application that I think serves as a decent proof of concept for combining ColdFusion and Java within the Mach-II framework. If you're interested you can download the zip file here.


 


Overall this was a really interesting exercise, and I sent the link out to the Mach-II list on Topica, so I'll be curious to see what others think. The Java code is far from stellar since my Java's pretty rusty at this point, and I only spent about a day on the whole thing, so while it's not spectacular, it works and was fun to put together. Quite honestly I ran into fewer issues than I thought I would.


The natural break point in my mind between Java and CF in a Mach-II application is that the Listeners need to stay as CFCs. Once you start monkeying with those you're looking at modifying the Mach-II framework code, which I wanted to avoid. The bean objects and the DAOs and Gateways all seem to work fairly well in Java. Not being able to throw the Mach-II Event object into a Java object was a minor annoyance, but no real concern.


I'd say the biggest issue in my mind is running a database query in Java and getting those results back to CF. Because you can't just toss CF a Java ResultSet, there are of course several options. In the case of a bean, no worries at all because you run the query and populate the bean all within Java, and the bean itself is a Java object that CF can use. For a "list"-type query it's a bit more of an issue. I thought about using a Java Vector since that can be thrown back to CF and will become an Array, but I decided instead just to build an XML string from my Java query results and pass that back to CF. Works well and also keeps the data pretty usable by anything that can consume XML.


I'm sure I'll come up with more ideas as I go further down this path, and I'll post any feedback I get from the Mach-II list folks here. I'm pretty excited about the potential this offers!

No comments: