public interface Externalizer<T> extends Serializable
Externalizerimplementation for the type that they want to marshall/unmarshall, and then annotate the marshalled type class with
SerializeWithindicating the externalizer class to use and that's all about it. At runtime JBoss Marshaller will inspect the object and discover that's marshallable thanks to the annotation and so marshall it using the externalizer class passed. It's common practice to include externalizer implementations within the classes that they marshall/unmarshall as
public static classes. To make externalizer implementations easier to code and more typesafe, make sure you define type
SerializeWithbut a user might need to provide an Externalizer for a class for which source code is not available, or for any other constraints, it cannot be modified.
AdvancedExternalizer. More details can be found in this interface's javadoc. Please note that even though Externalizer is marked as
Serializable, the need to marshall the externalizer is only really needed when developing user friendly externalizers (using
AdvancedExternalizerinstances do not require the externalizer to be serializable since the externalizer itself is not marshalled. Even though it's not strictly necessary, to avoid breaking compatibility with old clients,
Serializablebut this requirement is only needed for those user friendly externalizers. There's a chance that in future major releases
Serializableany more, hence we strongly recommend that any user-friendly externalizer users mark their externalizer implementations as either
void writeObject(ObjectOutput output, T object) throws IOException
output- the object output to write to
object- the object reference to write
IOException- if an I/O error occurs
T readObject(ObjectInput input) throws IOException, ClassNotFoundException
writeObject(ObjectOutput, Object)method. Implementations are free to create instances of the object read from the stream in any way that they feel like. This could be via constructor, factory or reflection.
Copyright © 2017 JBoss, a division of Red Hat. All Rights Reserved.