Archive for October, 2008

BFusion + BFlex ’08

October 8, 2008

This September 6-7 a group of us attended the BFusion + BFlex ’08 conference in Bloomington, IN.  This was a free ColdFusion and Flex hands-on conference sponsored by Adobe, Indiana University, other business and local user groups.

Day One – BFusion

For BFusion, I participated in the Advanced ColdFusion track.  There were some great sessions, but for the purposes of this post, I’ll just recap on two.  Specifically those that were emceed by Elliott Sprehn and Mike Brunt.

Elliott’s presentation on “Frameworks for SOA Platforms” walked us through a custom implementation, his “Shared Services Architecture.” The platform technology stack includes ColdSpring, Model-Glue and Fusebox, and your ORM of choice. Model-Glue is a popular ColdFusion framework that uses a MVC design pattern. Elliot is running a customized version of Model-Glue and basically using the Controller as an ESB of sorts.  For ColdFusion shops who want to migrate to an SOA platform, check out Elliot’s presentation.

Mike Brunt’s session on “ColdFusion in the Enterprise Space – Tuning and Clustering” was perfect timing for us.  We’ve just purchased new web systems hardware and are in the throws of configuring it all and rolling it out.

Day Two – BFlex

This was my first foray into Flex development.  The first day really exceeded my expectations for a free conference and day two followed suit nicely.  The session on event bubbling was really sweet – Flex has done this very nicely.

The other presentation that interesting was “Extending Components.”  I wrote my first Flash app with Remoting and some of the earlier components back in 2002.  We all remember the Pet Store app that the Flash development team at Adobe (then Macromedia) put together.  It’s cool to see how far they’ve come with the entire inheritance structure and extendability in Flex.  Really slick.  Silverlight has it’s work cut out.

The Skinny

To sum it up, it was completely worth going to this conference.  Not every session was not groundbreaking or applicable to our situation, but the ones that were valuable give me the confidence to recommend next year’s event to others (assuming there is one).

Hats off to all of the speakers and volunteers WHO PAID THEIR OWN WAY to be there and put this on for us. It was amazing to know that they did that for those attending and really enjoyed being there.

At one point I was looking for a vending machine to buy bottled water, and couldn’t find one so one of the guys from IU went to his office to get a bottle for me.  Now that’s serving with excellence!

Thanks for sponsoring and hosting such a high-caliber event and making it FREE for those attending!

…oh and did I mention the LOADS of free books/products and free lunch?

ColdFusion Testing Woes With Java Objects

October 7, 2008

My team is currently working on a Flex-based mapping application. I’m working on the backend using ColdFusion to grab the data from our SQL server, package it in a Java based data transfer object (DTO), and send it to the requesting Flex app. My teammate wrote a great blog entry about the tech stack entitled “Flex, ColdFusion, Java, and BlazeDS: with JSON?“.

One minor glitch showed up while trying to test the ColdFusion method calls. I wrote a simple ColdFusion template to call the methods in the ColdFusion service component. All I wanted to do was simply check the methods were working before I tried calling them from the Flex application. I called the function and used the <cfdump> tag to see what was in the object:

...
<cfset obj = CreateObject("component",
      "components.lampo.mapping.service.MapToolWebServiceImpl") />
<cfset myobj = obj.getPostalCodePolygon(objUser, "37128") />
<cfdump var="#myobj#">
...

Sadly all the <cfdump> tag showed was the names of the methods and properties of the object. I.e. it did not show the property values!

I did a little bit of research and was unable to locate an elegant solution. One possibility would be to simply add a method to each DTO that dumps the current state of the object. But we have over a dozen DTOs and I didn’t really want to pollute them with a debugging method. So I wrote a simple function to display the property values of any object:

<cffunction name="dumpJObj" output="false" returntype="struct" access="public">
       <cfargument name="obj" type="any" required="yes" />
       <cfargument name="depth" type="numeric" required="no" default="1" />

       <cfset var stcRet = StructNew() />
       <cfset var ary = StructKeyArray(obj) />
       <cfloop index="i" from="1" to="#ArrayLen(ary)#">
              <cfif IsDefined("obj.#ary[i]#")>
                     <cfset value = Evaluate("obj.#ary[i]#") />
                     <cfif IsObject(value) AND depth GT 0>
                           <cfset stcRet[ary[i]] = dumpJObj(value, depth - 1) />
                     <cfelseif IsObject(value)>
                           <cfset stcRet[ary[i]] = "depth limit reached" />
                     <cfelse>
                           <cfset stcRet[ary[i]] = Evaluate("obj.#ary[i]#") />
                     </cfif>
              <cfelse>
                     <cfset stcRet[ary[i]] = "" />
             </cfif>
       </cfloop>
      <cfreturn stcRet />
</cffunction>

I wrote the function specifically for the Java based DTOs we are passing. My first thought was to write it using Java reflection but I was able to write it completely in ColdFusion. So I guess it should work for ColdFusion objects as well.

My first version did not handle nested objects so in the next version I added in some recursion. This opened the possibility of an infinite loop if the class has itself as a nested object. I simply added a depth count to prevent this from happening. The depth defaults to 1 so the function will display the values of the top level object and the values of the objects it contains.

To make the function available where I needed it, I made it a part of the service class.

...
<cfset obj = CreateObject("component",
      "components.lampo.mapping.service.MapToolWebServiceImpl") />
<cfset myobj = obj.getPostalCodePolygon(objUser, "37128") />
<cfdump var="#dumpJObj(myobj)#">
...