A while back I had some fun playing with Flex, Spring, BlazeDS and Hibernate.
We recently won a contract to create quite a large on and offline application that we are implementing the GUI in Flex and the back-end in J2EE.
Given how much we like Spring and Hibernate, and how useful BlazeDS is, I have spent a bit of time again getting these all playing nicely together.
Firstly there is now a Spring and BlazeDS integration kit available which moves the configuration of BlazeDS completely to Spring. I really wanted this in our latest setup as it is far more elegant than the mish-mash of configuration files before.
Secondly there are now a couple of lazy loading frameworks for BlazeDS and Hibernate. We identified Gilead and dpHibernate as contenders. We really wanted decent automatic lazy loading for this particular project due to the size of the data model. Lazy loading is critical in any Flex-BlazeDS web app that is going to have a large and deep data model, otherwise the whole data model will have to go over the wire when only little bits of it are actually needed.
Getting this all working together nicely was not however straight forward!
Firstly I spent some time evaluating Gilead. At the time of writing, this simply doesn’t do what it says on the tin.
I was expecting automatic lazy loading but Gilead does not do this. Rather, it expects you to make the calls and what it does offer is the merging and cloning of objects. This solution is not a complete lazy loading solution and still would require quite a lot of code around it to achieve automatic lazy loading. So I moved onto dpHibernate…
And this gladly does do what one would expect! The source code is also very nicely written and well laid out, which made a thorough examination quite easy.
Next up was getting the Spring and Flex integration kit setup.
This went fine until trying to configure in dpHibernate, as the M2 release (which was current release at the time), didnt have support for wiring in and configuring a custom BlazeDS adapter, essential for any lazy loading solution.
Luckily, in the trunk was work by the very talented Jeremy Grelle which seemed to be the solution.
Getting it to actually work took a bit of debugging but I finally got there and documented the core stumbling block here.
So what we end up with is a Spring configured BlazeDS web app with a Hibernate persistence layer with lazy collection loading.
As I final point I want to highlight the issue of LiveCycle Data Services, which is Adobe’s commercial offering of BlazeDS, and does handle lazy loading out of the box.
My problem here was that after 6, yes SIX, attempts to get a cost from Adobe for LiveCycle DS, Adobe failed to ever respond (I tried all the contact options detailed on the product page).
Apart from lazy loading, the other reason we quite liked the idea of LiveCycle DS was the on/off-line data synchronization it has for AIR applications (as we will also be creating an AIR app for this particular project). Instead we will roll are own framework for this bit, and likely open-source it. So Adobe, if your listening, you lost a sale here by simply not responding. I wonder how many other potential sales have been missed?