A first take on Spicefactory projects Pimento and Parsley

I’ve been meaning to take a look at the projects from the Spicefactory guys for quite a while after hearing Borre Wessel give a talk at Skills Matter a year or so ago about the Matrix project he’d worked on.

I’d been putting this off for couple of reasons really:

  1. I’d got to grips with the likes of Cairngorm/PureMVC by reading Chris Giametta’s APress Pro Flex on Spring book. But it didn’t quite give me a good enough understanding how some of the XML configuration would work for a basic Java project using BlazeDS – which I finally mastered this past week or so after reading Filippo di Pisa’s APress Beginning Java and Flex book. I figured it would be prudent to have a good understanding of the basics before moving on to Spicefactory’s wares.
    See my Amazon reviews here: 

  2. The fact you can’t print the documentation off, and you have to sift through a tons of it whilst glued to the web browser which took me the best part of a couple of days solid reading.
    I much prefer to print stuff off and pencil notes against a hard copy…

In summary Spicefactory has four projects:

Spicelib

This is a foundational project for Parsley that provides:

  • enhanced Flex reflection capabilities
  • a bi-directional XML to AS3 object class mapper.(I wasn’t sure if there was a pluggable implementation here and how scalable it was. I.e. a event driven streaming affair a la SAX or a load the whole thing into memory).
    It didn’t grab me as having the same elegance you find with Groovy XML builders. (XMLParser/XMLSlurper). (Scott Davis’s Groovy Recipes book rocks on this subject).
  • An expressions parser a la JSP EL/Velocity/Freemarker/Groovy GStrings etc. (which seemed to have a missing swc in download)
  • Logging capabilities (a la Commons logging for AS3)
  • A task framework. I really though this was a great idea, enabling you to abstract away fine grained events into a a higher level unit of work.

Parsley

A Flex DI framework. It sounds similar to RobotLegs, but my take it’s a bit more extensible and consequently a bit more of a learning curve. (Think Spring/Google Guice for the Flex world). The framework makes extensive use of metatags that works in either a Flash or Flex world. (Things like [Inject]) – similar to annotations in the Java world.
There’s a few strokes of genius in that the project, although I was a bit surprised none of the examples made use of the newer Vector class and still used Arrays:

  • It uses a DSL builder, somewhat reminiscent of jQuery, so that configuration/wiring of components can be done with XML, AS3 or MXML that builds upon the DSL under the covers.
  • The messaging infrastructure does away with the nasty constants and lots if type casting you see in the likes of Cairngorm and instead uses metatags for the publication/subscription process for events which is very clean. You can also scope the level at which you listen for events which is useful when dealing with nested visual components (Think filtered bubbling).

If you want to see a sample project, Christophe Coenraet has a handy blog post here.
Unfortunately, he didn’t go the extra mile and demonstrate integration with Pimento too.
Watch this space. I’m going to have a crack at modifying the project to do just that.

Cinammon Remoting

Jens Halm points out that the regular RemoteObject MXML tag is not type safe and you normally have to write a business delegate wrapper. Consequently in essence, this is the nut this project cracks.

Pimento

There’s some definite pluses to this project, but it has some peculiarities to it as well.
In essence it provides JPA/Hibernate/Flex/Spring integration and solves a lot of the complex issues with like lazy loading. It does this by embellishing the Java domain classes with annotations and effectively provides client-side caching. You can tweak the properties that get sent across the wire via AMF too, by doing things like making things read-only on the AS3 side, or using a @Hidden annotation.
It did seem awkward however to use interceptors to provide constrain functionality (See section 2.6 of documentation). I’d much prefer to have seen something along the lines of utilising annotations (as you see in the JSR303 Bean Validation framework/Hibernate Validator) (see Willie Wheeler’s blog post for an example). Or even better from my perspective integration with GORM.
It would be good if the project could create the appropriate MXML components for things like emails, dates etc too from annotations/data types/constraints etc.
If I can get my head around elegantly creating an example that uses Pimento and Parsley, I’ll have a crack at creating some Grails plug-ins.

Integration testing makes use of DBUnit server-side and Fluint client-side (which facilitates asynchronous operations).
I think there are some better options that have surfaced server-side than DBUnit, that I’ve seen in the Grails community. (but I’m wracking my memory to remember them as I write this… Will post back later).

The project bears a slight bit resemblance to Struts 2 in a couple of ways, in that it uses interceptors and Freemarker templates to convert Java domain classes into ActionScript. These get invoked by running Ant tasks. Felippo’s book also mentioned you can achieve similar results via UML tooling too with the likes of Visual Paradigm. (UML to Java and ActionScript 3).

You can also do things like have a named query in your Hibernate class and call into it from the Actionscript side. (Although I’m not sure if this is a potential security hole. Can you obfuscate your SWCs to avoid this?)


About this entry