public interface KryoRegistrar
PojoCodec
to register
classes consistently across Kryo
instances. An XD user may register an instance of this type in the Spring XD
Application Context to enable kryo class registration which results in efficiency gains if you know the types your
application needs in advance. Note that Kryo serialization only applies to types used as message payloads in XD
streams.
By default, user defined types are not registered to Kryo. Registration allows a unique ID (small positive integer is
ideal) to represent the type in the byte stream. In a distributed environment, all Kryo instances must maintain the
same registration state in order to properly take advantage of this feature.
This is can result in better performance in demanding situations, but requires some care to maintain. Only use this
if you really need it. Otherwise, it is a great example of premature optimization.
This interface applies a strategy to register a statically configured, one-to-one mapping of a Java type to an
integer. Basic implementations are provided backed by a MapModifier and Type | Method and Description |
---|---|
void |
registerTypes(com.esotericsoftware.kryo.Kryo kryo)
This method is invoked by the
PojoCodec and
applied to the Kryo instance whenever one is provided. |
void registerTypes(com.esotericsoftware.kryo.Kryo kryo)
PojoCodec
and
applied to the Kryo
instance whenever one is provided. This is currently done using an object pool so it
is inevitable that this method will be invoked repeatedly on the same instance. Kryo registration is idempotent,
but this could become inefficient if registering a large amount of types.kryo
- the provided instance