First of all I would like to say that I really like the new approach with generating descriptors straight from XSDs. It saves us from quite tedious work and we can focus on important things. While working on SHRINKDESC-86 I looked at tests ported from POC and I would like to share my findings.
1. API differences
I've noticed that with the new, generated descriptors (which pretty cool idea by the way) we sacrificed some convenient behaviour from the previous version, such as:
- Mutually exclusive properties are not taken into consideration - for instance jta/non-jta datasource. If we will stick with XSD-based generation I think we should consider extending metadata to cover such cases. If you think it's reasonable to have it supported I can create JIRA issue. Currently failing tests from POC are annotated with
@Ignore("Missing in the new API")
- There is no easy way to replace property with the given name (or remove it by name) as it was with the previous version by simply chaining
create().property(name, name2).property(name, name)methods we now use following construct:
Descriptors.create(PersistenceDescriptor.class) .getOrCreatePersistenceUnit().name(name) .getOrCreateProperties() .createProperty().name(name).value(name2).up() .createProperty().name(name).value(name).up().up().up().exportAsString();
In general I find it a little bit cumbersome sometimes.
- We lost vendor-specific descriptors such as Hibernate or Eclipse Link. However I don't know how important it is.
- Some things which were enums before (like SharedCacheMode) now are simply strings.
- Dealing with descriptors might sometimes look quite awkward for newcomers, for instance:
List<Property<Properties<PersistenceUnit<PersistenceDescriptor>>>> properties = def.getOrCreateProperties().getAllProperty();
I know that it models type-safe tree traversal but maybe we could think about less verbose way to achieve the same thing? Also from type semantic perspective I'm not convinced if it's the way to go.
2. Other small things
- All generated enums are underscored, for instance
- Formatting of generated classes is not always compliant with JBoss Formatter
- I also found some copied javadoc comments which were not relevant to the code actually. Maybe it's worth to review XSLT transformations?