Martin Taal's Blog

About EMF, Teneo, CDO, Texo, Hibernate, Open-Source ERP and other topics

Archive for January 2012

Texo: Code Generation Patterns

leave a comment »

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.

In previous posts on Texo I talked about generating JPA annotated entities, Test-Data generation and generating a DAO layer.

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.

Hope you like it! If you have any questions or remarks please visit the EMFT newsgroup or forum.

gr. Martin

Written by martintaal

January 5, 2012 at 3:50 pm

Posted in Texo