Texo: Code Generation Patterns
Texo provides code/JPA entity generation from ecore/xsd models specific for web server/service environments. A main characteristic of Texo is that it separates the Texo/EMF specific generated code from the core entities. This means that generated code can be used directly in other frameworks like ORM’s and GWT without additional runtime layers.
It is very easy to generate JPA annotated entities from an ecore/xsd model using Texo. After installing Texo, right-click any ecore/model and in the Texo submenu choose one of the generate code options.
A next question is how to extend/customize the code generation to fit to specific requirements. In this post I will talk about specific code generation patterns supported by Texo. In a subsequent post I will discuss adding/overriding Texo with your own code generation templates.
Texo supports several different code generation patterns:
- optional safe bi-directional collection access: resulting in a more extensive (safer) api, but also a bit more complex to understand for many developers
- list/set: use List or Set for collection instances
- mix generated and non-generated classes: non-generated classes can be used for eclasses in the model
- model/framework classes can be generated into a separate package: for runtime model support Texo can generate model-classes, these classes can be generated in separate classes.
All these options are described in more detail on this wiki page.
In addition to the code generation Texo provides a separate runtime layer for XML/XMI serialization, REST webservices etc.