Java源码示例:com.esotericsoftware.kryo.factories.ReflectionSerializerFactory
示例1
public Serializer<?> getSerializer(Kryo kryo) {
switch (serializerDefinitionType) {
case UNSPECIFIED:
return null;
case CLASS:
return ReflectionSerializerFactory.makeSerializer(kryo, serializerClass, registeredClass);
case INSTANCE:
return serializableSerializerInstance.getSerializer();
default:
// this should not happen; adding as a guard for the future
throw new IllegalStateException(
"Unrecognized Kryo registration serializer definition type: " + serializerDefinitionType);
}
}
示例2
public Serializer<?> getSerializer(Kryo kryo) {
switch (serializerDefinitionType) {
case UNSPECIFIED:
return null;
case CLASS:
return ReflectionSerializerFactory.makeSerializer(kryo, serializerClass, registeredClass);
case INSTANCE:
return serializableSerializerInstance.getSerializer();
default:
// this should not happen; adding as a guard for the future
throw new IllegalStateException(
"Unrecognized Kryo registration serializer definition type: " + serializerDefinitionType);
}
}
示例3
private void registerDefaultSerializer(Kryo kryo) {
if (defaultSerializerClass != null || !serializerConfigurers.isEmpty()) {
Class<? extends Serializer> serializerClass = defaultSerializerClass == null
? FieldSerializer.class
: defaultSerializerClass;
SerializerFactory serializerFactory = new ReflectionSerializerFactory(serializerClass);
if (!serializerConfigurers.isEmpty()) {
SerializerConfigurer configurer = serializerConfigurers.get(0);
serializerFactory = new PostProcessingSerializerFactory(serializerFactory, configurer);
}
kryo.setDefaultSerializer(serializerFactory);
}
}
示例4
public Serializer<?> getSerializer(Kryo kryo) {
switch (serializerDefinitionType) {
case UNSPECIFIED:
return null;
case CLASS:
return ReflectionSerializerFactory.makeSerializer(kryo, serializerClass, registeredClass);
case INSTANCE:
return serializableSerializerInstance.getSerializer();
default:
// this should not happen; adding as a guard for the future
throw new IllegalStateException(
"Unrecognized Kryo registration serializer definition type: " + serializerDefinitionType);
}
}