Strategy interface used by
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 Map
> or a List>. These are simple
and require the user to manually configure a bean in each XD server and ensure that the configuration is always
consistent.*
The container looks in classpath*:META-INF/spring-xd/xd/bus/ext/*.xml for an instance of this type named
"kryoRegistrar". The KryoRegistrar provides the registration mapping and the strategy to apply the mapping to every
Kryo instance. Note that statically declared Java types must also be present in the XD class path (xd/lib) else the
container will fail to initialize. Only one instance may be registered and identically configured across all
containers.