本文整理了Java中com.esotericsoftware.kryo.Kryo.addDefaultSerializer()
方法的一些代码示例,展示了Kryo.addDefaultSerializer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Kryo.addDefaultSerializer()
方法的具体详情如下:
包路径:com.esotericsoftware.kryo.Kryo
类名称:Kryo
方法名:addDefaultSerializer
[英]Instances of the specified class will use the specified serializer.
[中]指定类的实例将使用指定的序列化程序。
代码示例来源:origin: apache/flink
private void checkKryoInitialized() {
if (this.kryo == null) {
this.kryo = getKryoInstance();
// Enable reference tracking.
kryo.setReferences(true);
// Throwable and all subclasses should be serialized via java serialization
// Note: the registered JavaSerializer is Flink's own implementation, and not Kryo's.
// This is due to a know issue with Kryo's JavaSerializer. See FLINK-6025 for details.
kryo.addDefaultSerializer(Throwable.class, new JavaSerializer());
// Add default serializers first, so that the type registrations without a serializer
// are registered with a default serializer
for (Map.Entry<Class<?>, ExecutionConfig.SerializableSerializer<?>> entry: defaultSerializers.entrySet()) {
kryo.addDefaultSerializer(entry.getKey(), entry.getValue().getSerializer());
}
for (Map.Entry<Class<?>, Class<? extends Serializer<?>>> entry: defaultSerializerClasses.entrySet()) {
kryo.addDefaultSerializer(entry.getKey(), entry.getValue());
}
KryoUtils.applyRegistrations(this.kryo, kryoRegistrations.values());
kryo.setRegistrationRequired(false);
kryo.setClassLoader(Thread.currentThread().getContextClassLoader());
}
}
代码示例来源:origin: fengjiachun/Jupiter
@Override
protected Kryo initialValue() throws Exception {
Kryo kryo = new Kryo();
for (Class<?> type : useJavaSerializerTypes) {
kryo.addDefaultSerializer(type, JavaSerializer.class);
}
kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
kryo.setRegistrationRequired(false);
kryo.setReferences(false);
return kryo;
}
};
代码示例来源:origin: fengjiachun/Jupiter
@Override
protected Kryo initialValue() throws Exception {
Kryo kryo = new Kryo();
for (Class<?> type : useJavaSerializerTypes) {
kryo.addDefaultSerializer(type, JavaSerializer.class);
}
kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
kryo.setRegistrationRequired(false);
kryo.setReferences(false);
return kryo;
}
};
代码示例来源:origin: atomix/atomix
r = kryo.register(type, id);
} else if (type.isInterface()) {
kryo.addDefaultSerializer(type, serializer);
} else {
r = kryo.register(type, serializer, id);
代码示例来源:origin: orbit/orbit
kryo.addDefaultSerializer(RemoteReference.class, new RemoteReferenceSerializer());
kryo.addDefaultSerializer(AbstractActor.class, new AbstractActorSerializer());
kryo.addDefaultSerializer(ActorObserver.class, new ActorObserverSerializer());
代码示例来源:origin: opentripplanner/OpenTripPlanner
kryo.addDefaultSerializer(TPrimitiveHash.class, ExternalizableSerializer.class);
kryo.register(TIntArrayList.class, new TIntArrayListSerializer());
kryo.register(TIntIntHashMap.class, new TIntIntHashMapSerializer());
kryo.addDefaultSerializer(unmodifiableCollection , UnmodifiableCollectionsSerializer.class);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
代码示例来源:origin: magro/memcached-session-manager
@Override
public void customize(Kryo kryo) {
kryo.addDefaultSerializer(Component.class, new com.esotericsoftware.kryo.factories.SerializerFactory() {
@Override
public Serializer makeSerializer(Kryo kryo, Class<?> type) {
final FieldSerializer result = new FieldSerializer<Component>(kryo, type);
result.setIgnoreSyntheticFields(false);
return result;
}
});
}
代码示例来源:origin: dremio/dremio-oss
public static void register(final Kryo kryo) {
final EnumSerializer enumSerializer = new EnumSerializer();
kryo.addDefaultSerializer(BindableConvention.class, enumSerializer);
kryo.addDefaultSerializer(EnumerableConvention.class, enumSerializer);
kryo.addDefaultSerializer(InterpretableConvention.class, enumSerializer);
kryo.addDefaultSerializer(Convention.Impl.class, ConventionSerializer.class);
kryo.addDefaultSerializer(RelDistributions.SINGLETON.getClass(), RelDistributionSerializer.class);
kryo.addDefaultSerializer(DistributionTrait.class, DistributionTraitSerializer.class);
kryo.addDefaultSerializer(RelCollation.class, RelCollationSerializer.class);
kryo.addDefaultSerializer(RelTraitSet.class, RelTraitSetSerializer.class);
}
代码示例来源:origin: magro/memcached-session-manager
SynchronizedCollectionsSerializer.registerSerializers(kryo);
kryo.addDefaultSerializer(EnumMap.class, EnumMapSerializer.class);
SubListSerializers.addDefaultSerializers(kryo);
代码示例来源:origin: org.ssf4j/ssf4j-kryo
/**
* Create a new {@link KryoSerialization} that uses a new default {@link Kryo} for
* each new serializer/deserializer
*/
public KryoSerialization() {
this(new Kryo());
kryo.addDefaultSerializer(Serialized.class, SerializedSerializer.class);
}
代码示例来源:origin: dremio/dremio-oss
public static void register(final Kryo kryo) {
kryo.addDefaultSerializer(RelCollationTraitDef.class, SingletonSerializer.of(Suppliers.ofInstance(RelCollationTraitDef.INSTANCE)));
kryo.addDefaultSerializer(DistributionTraitDef.class, SingletonSerializer.of(Suppliers.ofInstance(DistributionTraitDef.INSTANCE)));
kryo.addDefaultSerializer(RelDistributionTraitDef.class, SingletonSerializer.of(Suppliers.ofInstance(RelDistributionTraitDef.INSTANCE)));
kryo.addDefaultSerializer(ConventionTraitDef.class, SingletonSerializer.of(Suppliers.ofInstance(ConventionTraitDef.INSTANCE)));
}
代码示例来源:origin: org.springframework.statemachine/spring-statemachine-kryo
@Override
protected void configureKryoInstance(Kryo kryo) {
kryo.addDefaultSerializer(StateMachineContext.class, new StateMachineContextSerializer<S, E>());
kryo.addDefaultSerializer(MessageHeaders.class, new MessageHeadersSerializer());
kryo.addDefaultSerializer(UUID.class, new UUIDSerializer());
}
}
代码示例来源:origin: com.guestful.module/guestful.module.jsr310-extensions
public static void addJsr310Serializers(Kryo kryo) {
kryo.addDefaultSerializer(ZonedInterval.class, new ZonedIntervalSerializer());
kryo.addDefaultSerializer(LocalDate.class, new LocalDateSerializer());
kryo.addDefaultSerializer(ZonedDateTime.class, new ZonedDateTimeSerializer());
kryo.addDefaultSerializer(Duration.class, new DurationSerializer());
kryo.addDefaultSerializer(LocalTime.class, new LocalTimeSerializer());
kryo.addDefaultSerializer(Period.class, new PeriodSerializer());
}
}
代码示例来源:origin: magro/kryo-serializers
public static Kryo addDefaultSerializer(Kryo kryo) {
if(SUBLIST_CLASS != null) kryo.addDefaultSerializer(SUBLIST_CLASS, new AbstractListSubListSerializer());
return kryo;
}
代码示例来源:origin: dremio/dremio-oss
public static void register(final Kryo kryo) {
// register list
ImmutableListSerializer.register(kryo);
// register set
ImmutableSetSerializer.register(kryo);
// register set
ImmutableMapSerializer.register(kryo);
// others
kryo.addDefaultSerializer(FlatLists.AbstractFlatList.class, FieldSerializer.class);
kryo.addDefaultSerializer(ImmutableNullableList.class, ImmutableNullableListSerializer.class);
}
代码示例来源:origin: com.esotericsoftware/kryo
public static void addDefaultSerializers (Kryo kryo) {
if (isClassAvailable("java.util.Optional")) kryo.addDefaultSerializer(Optional.class, new OptionalSerializer());
if (isClassAvailable("java.util.OptionalInt")) kryo.addDefaultSerializer(OptionalInt.class, new OptionalIntSerializer());
if (isClassAvailable("java.util.OptionalLong")) kryo.addDefaultSerializer(OptionalLong.class, new OptionalLongSerializer());
if (isClassAvailable("java.util.OptionalDouble"))
kryo.addDefaultSerializer(OptionalDouble.class, new OptionalDoubleSerializer());
}
代码示例来源:origin: com.esotericsoftware/kryo-shaded
public static void addDefaultSerializers (Kryo kryo) {
if (isClassAvailable("java.util.Optional")) kryo.addDefaultSerializer(Optional.class, new OptionalSerializer());
if (isClassAvailable("java.util.OptionalInt")) kryo.addDefaultSerializer(OptionalInt.class, new OptionalIntSerializer());
if (isClassAvailable("java.util.OptionalLong")) kryo.addDefaultSerializer(OptionalLong.class, new OptionalLongSerializer());
if (isClassAvailable("java.util.OptionalDouble"))
kryo.addDefaultSerializer(OptionalDouble.class, new OptionalDoubleSerializer());
}
代码示例来源:origin: seznam/euphoria
private Kryo initKryo() {
if (this.kryo == null) {
this.kryo = new Kryo();
((Kryo.DefaultInstantiatorStrategy) kryo.getInstantiatorStrategy())
.setFallbackInstantiatorStrategy(new StdInstantiatorStrategy());
serializers.forEach((k, v) -> kryo.addDefaultSerializer(k, v.getSerializer()));
registeredClasses.forEach(kryo::register);
}
return this.kryo;
}
代码示例来源:origin: org.jupiter-rpc/jupiter-all
@Override
protected Kryo initialValue() throws Exception {
Kryo kryo = new Kryo();
for (Class<?> type : useJavaSerializerTypes) {
kryo.addDefaultSerializer(type, JavaSerializer.class);
}
kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
kryo.setRegistrationRequired(false);
kryo.setReferences(false);
return kryo;
}
};
代码示例来源:origin: org.jupiter-rpc/jupiter-serialization-kryo
@Override
protected Kryo initialValue() throws Exception {
Kryo kryo = new Kryo();
for (Class<?> type : useJavaSerializerTypes) {
kryo.addDefaultSerializer(type, JavaSerializer.class);
}
kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
kryo.setRegistrationRequired(false);
kryo.setReferences(false);
return kryo;
}
};
内容来源于网络,如有侵权,请联系作者删除!