O'Reilly logo

Play Framework Cookbook by Alexander Reelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding annotations via bytecode enhancement

If you remember the JSON and XML plugin written in Chapter 5, which was called API plugin, there was a possible improvement at the end of the recipe: adding the XML annotations is cumbersome and a lot of work, so why not add them automatically, so every entity defined in your application does not need the usually required annotations for XML processing with JAXB.

The source code of the example is available at examples/chapter6/bytecode-enhancement-xml.

Getting ready

As usual, write a test first, which actually ensures that the annotations are really added to the model. In this case they should not have been added manually to the entity, but with the help of bytecode enhancement:

public class XmlEnhancerTest ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required