SerializationContextInitializer
and utilise ProtoStream annotations on Java objects instead, or
specify a custom Marshaller
implementation via the SerializationConfiguration.@Deprecated public interface Externalizer<T> extends Serializable
Externalizer
implementation for the type that they want
to marshall/unmarshall, and then annotate the marshalled type class with
SerializeWith
indicating 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 SerializeWith
but 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 SerializeWith
). AdvancedExternalizer
instances 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, Externalizer
implements Serializable
but
this requirement is only needed for those user friendly externalizers.
There's a chance that in future major releases Externalizer
won't
extend Serializable
any more, hence we strongly recommend that any
user-friendly externalizer users mark their externalizer implementations as
either Serializable
or Externalizable
.Modifier and Type | Method and Description |
---|---|
T |
readObject(ObjectInput input)
Deprecated.
Read an instance from the stream.
|
void |
writeObject(ObjectOutput output,
T object)
Deprecated.
Write the object reference to the stream.
|
void writeObject(ObjectOutput output, T object) throws IOException
output
- the object output to write toobject
- the object reference to writeIOException
- if an I/O error occursT 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.input
- the object input to read fromIOException
- if an I/O error occursClassNotFoundException
- if a class could not be foundCopyright © 2021 JBoss by Red Hat. All rights reserved.