Force POJO2 to implement Externalizable
Externalizable. Using a Mixin The next example forces POJO2 to implement Externalizable. Now, for this to work, POJO2 must implement the readExternal and writeExternal methods required by the Externalizable interface. These methods are provided by the POJO2ExternalizableMixin class. Take a look at the XML binding for this: java.io.Externalizable POJO2ExternalizableMixin new POJO2ExternalizableMixin(this) Most of this makes sense, but what is the element? Whenever a Mixin is introduced to a class, the AOP framework creates a field within that class that holds the instance of the Mixin. The tag allows you to initialize this instance. You can specify any Java code within the tag. It must be a one liner and you have to provide the fully qualified name of any class you use. So, the above tag allocates a POJO2ExternalizableMixin and passes in a this pointer. The this pointer is actually the instance of the class that the Mixin is being applied to. This allows the Mixin class to handle externalization.