-
Task
-
Resolution: Done
-
Major
-
12.0.0.Final
-
None
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
@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(); } }
2. Register UUIDAdapter with your SerialiazationContextInitializer interface (LibraryInitializer in the docs examples).
- is cloned by
-
ISPN-12637 Remove superfluous config example from eviction content
- Closed
- relates to
-
ISPN-12463 Upgrade to protostream 4.4.0.Alpha4
- Closed