]
Donald Naro commented on ISPN-12626:
------------------------------------
[~ryanemerson] This is for 12 only, right? No backport to 11.0.x?
Document @ProtoAdaptor for marshalling of external classes
----------------------------------------------------------
Key: ISPN-12626
URL:
https://issues.redhat.com/browse/ISPN-12626
Project: Infinispan
Issue Type: Task
Components: Documentation
Affects Versions: 12.0.0.CR1
Reporter: Ryan Emerson
Assignee: Donald Naro
Priority: Major
Fix For: 12.0.0.Final
Protostream 4.4.0.Alpha4 added support for automatically generating marshallers for
external classes via the {{@ProtoAdaptor}} field. This greatly simplifies how a user can
marshall third party classes, as it's no longer necessary to implement the
{{MessageMarshaller}} interface and explicitly create a
{{SerializationContextInitializer}} implementation.
Process for using {{@ProtoAdaptor}}
1. Create an adaptor class and add the {{@ProtoAdaptor}} annotation
{code:java}
@ProtoAdapter(UUID.class)
public class UUIDAdapter {
@ProtoFactory
UUID create(Long mostSigBitsFixed, Long leastSigBitsFixed) {
return new UUID(mostSigBitsFixed, leastSigBitsFixed);
}
@ProtoField(number = 1, type = Type.FIXED64, defaultValue = "0")
Long getMostSigBitsFixed(UUID uuid) {
return uuid.getMostSignificantBits();
}
@ProtoField(number = 2, type = Type.FIXED64, defaultValue = "0")
Long getLeastSigBitsFixed(UUID uuid) {
return uuid.getLeastSignificantBits();
}
}
{code}
2. Register {{UUIDAdapter}} with your {{SerialiazationContextInitializer}} interface
(LibraryInitializer in the docs examples).