I thought I would follow-up on my last blog entry on XDoclet2. In the last week I have been going head-to-head with XDoclet2 in the hope it will save our team coding Java VOs and AS3 VOs. As the team started using more complex object types in Java it soon became apparent that the generated AS3 VOs weren’t going to work. This came as a bit of blow to us so we had to decide whether to drop XDoclet2 and hand-code both sets of VOs, fix XDoclet2 or look for a "home grown" alternative.
The problems we encountered were as follows:
- A number of the Java to AS3 types mappings were wrong, namely java.util.Collection mx.collection to ArrayCollection. It appears the AS3 codegen is still using the type mappings from Flex 1.5.
- The AS3 class contained Java import statements – so it wouldn’t compile.
- Java public static final constants were crashing XDoclet2.
We decided to push forward and see if we could fix XDoclet2. I have logged these bugs with XDoclet but you can also download my patched plugin JAR here. It should now implement all the Java to AS3 types mappings as defined in the Developing Flex Applications manual. The latest code in the XDoclet2 repository doesn’t appear to have the same issue with imports, although this version will filter out duplicates.
If you want to codegen the Java public static final constants you need to include the Java class files in your XDoclet2 classpath, which is part of the Ant build script, as it uses Java reflection to obtain the value of the constant.
We added our Ant build script as a builder on the project, by default this runs in the same Java VM as Eclipse but it caused memory issues (XDoclet2 appears to be memory intensive) that ultimately crash Eclipse. As a result we ended up configuring our builder to run in a separate JVM and setting the maximum heap size to 64MB.
My updated Ant build script is below, the location of our Java VO classes is now included in the <path> element:
Where does this leave us? I don’t like patching open-source libraries, but I saw little choice here. Given time I would like to create an AS3 plugin for XDoclet (v1.x), while XDoclet2 may be architecturally better it seems to lack the support given to XDoclet. XDoclet has better documentation and there are a number of books available. For me though the biggest benefit to XDoclet is the Eclipse tooling support.