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
.
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 extends UnitTest { @Test public void testThingEntity() { XmlRootElement xmlRootElem = Thing.class.getAnnotation(XmlRootElement.class); assertNotNull(xmlRootElem); assertEquals("thing", xmlRootElem.name()); ...