Skip to content

Commit 236c7e2

Browse files
AxonSerializers - add KDoc
1 parent 6e47726 commit 236c7e2

File tree

1 file changed

+64
-15
lines changed
  • kotlin/src/main/kotlin/org/axonframework/extensions/kotlin/serialization

1 file changed

+64
-15
lines changed

kotlin/src/main/kotlin/org/axonframework/extensions/kotlin/serialization/AxonSerializers.kt

Lines changed: 64 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,32 @@ import org.axonframework.messaging.responsetypes.ResponseType
5050
import kotlin.reflect.KClass
5151

5252
/**
53-
* TODO - documentation
53+
* Serializer for Axon's [TrackingToken] class.
54+
* Provides serialization and deserialization support for nullable instances of TrackingToken.
55+
* This serializer uses [replyTokenContextSerializer] to serialize the context field and now only [String] type or null value is supported!
56+
*
57+
* @see TrackingToken
5458
*/
5559
val trackingTokenSerializer = PolymorphicSerializer(TrackingToken::class).nullable
60+
61+
/**
62+
* Serializer for the [ReplayToken.context], represented as a nullable String.
63+
* This context is typically used to provide additional information during token replay operations.
64+
*
65+
* This serializer is used by [trackingTokenSerializer] to serialize the context field and now only [String] type or null value is supported!
66+
* Sadly enough, there's no straightforward solution to support [Any]; not without adjusting the context field of the ReplayToken in Axon Framework itself.
67+
* That is, however, a breaking change, and as such, cannot be done till version 5.0.0 of the Axon Framework.
68+
* This also allow more complex objects as the context, although it requires the user to do the de-/serialization to/from String, instead of the Axon Framework itself.
69+
* Look at AxonSerializersTest, case `replay token with complex object as String context` for an example how to handle that using Kotlin Serialization.
70+
*
71+
* @see ReplayToken.context
72+
*/
5673
val replyTokenContextSerializer = String.serializer().nullable
5774

5875
/**
59-
* TODO - documentation
76+
* Module defining serializers for Axon Framework's core event handling and messaging components.
77+
* This module includes serializers for TrackingTokens, ScheduleTokens, and ResponseTypes, enabling
78+
* seamless integration with Axon-based applications.
6079
*/
6180
val AxonSerializersModule = SerializersModule {
6281
contextual(ConfigToken::class) { ConfigTokenSerializer }
@@ -94,7 +113,9 @@ val AxonSerializersModule = SerializersModule {
94113
}
95114

96115
/**
97-
* TODO - documentation
116+
* Serializer for [ConfigToken].
117+
*
118+
* @see ConfigToken
98119
*/
99120
object ConfigTokenSerializer : KSerializer<ConfigToken> {
100121

@@ -123,7 +144,11 @@ object ConfigTokenSerializer : KSerializer<ConfigToken> {
123144
}
124145

125146
/**
126-
* TODO - documentation
147+
* Serializer for [GapAwareTrackingToken], which represents tracking tokens with an index and associated gap set.
148+
*
149+
* This implementation supports the serialization and deserialization of tokens that manage tracking gaps.
150+
*
151+
* @see GapAwareTrackingToken
127152
*/
128153
object GapAwareTrackingTokenSerializer : KSerializer<GapAwareTrackingToken> {
129154

@@ -157,7 +182,12 @@ object GapAwareTrackingTokenSerializer : KSerializer<GapAwareTrackingToken> {
157182
}
158183

159184
/**
160-
* TODO - documentation
185+
* Serializer for [MultiSourceTrackingToken], which maps source identifiers to corresponding TrackingTokens.
186+
*
187+
* This allows for managing tracking tokens in multi-source scenarios, enabling serialization and deserialization
188+
* of complex token mappings.
189+
*
190+
* @see MultiSourceTrackingToken
161191
*/
162192
object MultiSourceTrackingTokenSerializer : KSerializer<MultiSourceTrackingToken> {
163193

@@ -186,7 +216,9 @@ object MultiSourceTrackingTokenSerializer : KSerializer<MultiSourceTrackingToken
186216
}
187217

188218
/**
189-
* TODO - documentation
219+
* Serializer for [MergedTrackingToken], which combines two [TrackingToken] (lower segment and upper segment) into a single token.
220+
*
221+
* @see MergedTrackingToken
190222
*/
191223
object MergedTrackingTokenSerializer : KSerializer<MergedTrackingToken> {
192224

@@ -219,14 +251,17 @@ object MergedTrackingTokenSerializer : KSerializer<MergedTrackingToken> {
219251
}
220252

221253
/**
222-
* TODO - documentation
254+
* Serializer for [ReplayToken].
255+
* The [ReplayToken.context] value can be only a String or null. See [replyTokenContextSerializer] for more information how to handle the context field.
256+
*
257+
* @see ReplayToken
223258
*/
224259
object ReplayTokenSerializer : KSerializer<ReplayToken> {
225260

226261
override val descriptor = buildClassSerialDescriptor(ReplayToken::class.java.name) {
227262
element<TrackingToken>("tokenAtReset")
228263
element<TrackingToken>("currentToken")
229-
element<TrackingToken>("context")
264+
element<String>("context")
230265
}
231266

232267
override fun deserialize(decoder: Decoder) = decoder.decodeStructure(descriptor) {
@@ -265,7 +300,9 @@ object ReplayTokenSerializer : KSerializer<ReplayToken> {
265300
}
266301

267302
/**
268-
* TODO - documentation
303+
* Serializer for [GlobalSequenceTrackingToken], which includes a global index.
304+
*
305+
* @see GlobalSequenceTrackingToken
269306
*/
270307
object GlobalSequenceTrackingTokenSerializer : KSerializer<GlobalSequenceTrackingToken> {
271308

@@ -293,7 +330,9 @@ object GlobalSequenceTrackingTokenSerializer : KSerializer<GlobalSequenceTrackin
293330
}
294331

295332
/**
296-
* TODO - documentation
333+
* Serializer for [SimpleScheduleToken].
334+
*
335+
* @see SimpleScheduleToken
297336
*/
298337
object SimpleScheduleTokenSerializer : KSerializer<SimpleScheduleToken> {
299338

@@ -321,7 +360,9 @@ object SimpleScheduleTokenSerializer : KSerializer<SimpleScheduleToken> {
321360
}
322361

323362
/**
324-
* TODO - documentation
363+
* Serializer for [QuartzScheduleToken].
364+
*
365+
* @see QuartzScheduleToken
325366
*/
326367
object QuartzScheduleTokenSerializer : KSerializer<QuartzScheduleToken> {
327368

@@ -379,25 +420,33 @@ abstract class ResponseTypeSerializer<R : ResponseType<*>>(kClass: KClass<R>, pr
379420
}
380421

381422
/**
382-
* TODO - documentation
423+
* Serializer for [InstanceResponseType].
424+
*
425+
* @see InstanceResponseType
383426
*/
384427
object InstanceResponseTypeSerializer : KSerializer<InstanceResponseType<*>>,
385428
ResponseTypeSerializer<InstanceResponseType<*>>(InstanceResponseType::class, { InstanceResponseType(it) })
386429

387430
/**
388-
* TODO - documentation
431+
* Serializer for [OptionalResponseType].
432+
*
433+
* @see OptionalResponseType
389434
*/
390435
object OptionalResponseTypeSerializer : KSerializer<OptionalResponseType<*>>,
391436
ResponseTypeSerializer<OptionalResponseType<*>>(OptionalResponseType::class, { OptionalResponseType(it) })
392437

393438
/**
394-
* TODO - documentation
439+
* Serializer for [MultipleInstancesResponseType].
440+
*
441+
* @see MultipleInstancesResponseType
395442
*/
396443
object MultipleInstancesResponseTypeSerializer : KSerializer<MultipleInstancesResponseType<*>>,
397444
ResponseTypeSerializer<MultipleInstancesResponseType<*>>(MultipleInstancesResponseType::class, { MultipleInstancesResponseType(it) })
398445

399446
/**
400-
* TODO - documentation
447+
* Serializer for [ArrayResponseType].
448+
*
449+
* @see ArrayResponseType
401450
*/
402451
object ArrayResponseTypeSerializer : KSerializer<ArrayResponseType<*>>,
403452
ResponseTypeSerializer<ArrayResponseType<*>>(ArrayResponseType::class, { ArrayResponseType(it) })

0 commit comments

Comments
 (0)