Class KryoStateMachineSerialisationService<S,E>
java.lang.Object
org.springframework.statemachine.kryo.AbstractKryoStateMachineSerialisationService<S,E>
org.springframework.statemachine.kryo.KryoStateMachineSerialisationService<S,E>
- Type Parameters:
S- the type of stateE- the type of event
- All Implemented Interfaces:
StateMachineSerialisationService<S,E>
public class KryoStateMachineSerialisationService<S,E>
extends AbstractKryoStateMachineSerialisationService<S,E>
Implementation for
StateMachineSerialisationService using kryo.-
Field Summary
Fields inherited from class org.springframework.statemachine.kryo.AbstractKryoStateMachineSerialisationService
pool -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates a new kryo state machine serialisation service with no extra class registrations beyond the framework defaults.KryoStateMachineSerialisationService(Consumer<com.esotericsoftware.kryo.Kryo> kryoCustomizer) Instantiates a new kryo state machine serialisation service with an application-supplied Kryo customizer. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidconfigureKryoInstance(com.esotericsoftware.kryo.Kryo kryo) Applies the optionalkryoCustomizersupplied at construction time.protected <T> TdoDecode(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input, Class<T> type) Subclasses implement this method to decode with Kryo.protected voiddoEncode(com.esotericsoftware.kryo.Kryo kryo, Object object, com.esotericsoftware.kryo.io.Output output) Subclasses implement this method to encode with Kryo.Methods inherited from class org.springframework.statemachine.kryo.AbstractKryoStateMachineSerialisationService
deserialiseStateMachineContext, serialiseStateMachineContext
-
Constructor Details
-
KryoStateMachineSerialisationService
public KryoStateMachineSerialisationService()Instantiates a new kryo state machine serialisation service with no extra class registrations beyond the framework defaults. -
KryoStateMachineSerialisationService
public KryoStateMachineSerialisationService(Consumer<com.esotericsoftware.kryo.Kryo> kryoCustomizer) Instantiates a new kryo state machine serialisation service with an application-supplied Kryo customizer.The customizer is invoked once per Kryo instance after the framework's safe-by-default registrations have been applied (via
KryoStateMachineSerialisationDefaults.registerDefaults(Kryo)). Use it to register application-specific types — typically theSandEenums used by the state machine — so they are accepted by the registration-required allowlist:new KryoStateMachineSerialisationService<>(kryo -> { kryo.register(MyStates.class); kryo.register(MyEvents.class); })- Parameters:
kryoCustomizer- callback applied to each new Kryo instance; may benull- Since:
- 4.0.2
-
-
Method Details
-
doEncode
protected void doEncode(com.esotericsoftware.kryo.Kryo kryo, Object object, com.esotericsoftware.kryo.io.Output output) Description copied from class:AbstractKryoStateMachineSerialisationServiceSubclasses implement this method to encode with Kryo.- Specified by:
doEncodein classAbstractKryoStateMachineSerialisationService<S,E> - Parameters:
kryo- the Kryo instanceobject- the object to encodeoutput- the Kryo Output instance
-
doDecode
protected <T> T doDecode(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input, Class<T> type) Description copied from class:AbstractKryoStateMachineSerialisationServiceSubclasses implement this method to decode with Kryo.- Specified by:
doDecodein classAbstractKryoStateMachineSerialisationService<S,E> - Type Parameters:
T- the type for decoded object- Parameters:
kryo- the Kryo instanceinput- the Kryo Input instancetype- the class of the decoded object- Returns:
- the decoded object
-
configureKryoInstance
protected void configureKryoInstance(com.esotericsoftware.kryo.Kryo kryo) Applies the optionalkryoCustomizersupplied at construction time. Subclasses may override this to register additional types on top of the framework defaults and the customizer.- Specified by:
configureKryoInstancein classAbstractKryoStateMachineSerialisationService<S,E> - Parameters:
kryo- the kryo instance
-