}
@Bean
- JsonSerializer<AbstractTo> chatMessageSerializer()
+ JsonSerializer<AbstractTo> chatMessageSerializer(String typeMappings)
{
JsonSerializer<AbstractTo> serializer = new JsonSerializer<>();
serializer.configure(
- Map.of(JsonSerializer.TYPE_MAPPINGS,
- "create:" + CreateChatRoomRequestTo.class.getCanonicalName() + "," +
- "message:" + ChatMessageTo.class.getCanonicalName()),
+ Map.of(
+ JsonSerializer.TYPE_MAPPINGS, typeMappings),
false);
return serializer;
}
}
@Bean
- JsonDeserializer<AbstractTo> chatMessageDeserializer()
+ JsonDeserializer<AbstractTo> chatMessageDeserializer(String typeMappings)
{
JsonDeserializer<AbstractTo> deserializer = new JsonDeserializer<>();
deserializer.configure(
- Map.of(JsonDeserializer.TRUSTED_PACKAGES, getClass().getPackageName()),
+ Map.of(
+ JsonDeserializer.TRUSTED_PACKAGES, getClass().getPackageName(),
+ JsonDeserializer.TYPE_MAPPINGS, typeMappings),
false );
return deserializer;
}
+ @Bean
+ String typeMappings ()
+ {
+ return
+ "create:" + CreateChatRoomRequestTo.class.getCanonicalName() + "," +
+ "message:" + ChatMessageTo.class.getCanonicalName();
+ }
+
@Bean
Properties defaultProducerProperties(ChatBackendProperties chatBackendProperties)
{