com.esotericsoftware.kryo.Kryo.getClassResolver()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中com.esotericsoftware.kryo.Kryo.getClassResolver()方法的一些代码示例,展示了Kryo.getClassResolver()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Kryo.getClassResolver()方法的具体详情如下:
包路径:com.esotericsoftware.kryo.Kryo
类名称:Kryo
方法名:getClassResolver

Kryo.getClassResolver介绍

暂无

代码示例

代码示例来源:origin: co.paralleluniverse/quasar-core

private static boolean canSerialize(Kryo kryo, ThreadLocal<?> tl, Object val) {
    if (val == null)
      return true;
    if (val instanceof Serializable || kryo.getClassResolver().getRegistration(val.getClass()) != null)
      return true;
    if (val instanceof co.paralleluniverse.io.serialization.Serialization)
      return false;
    if (!kryo.getDefaultSerializer(val.getClass()).getClass().isAssignableFrom(FieldSerializer.class))
      return true;

    // If we can't serialize the ThreadLocal then we just deserialise it as null. In practice, TLS slots are
    // almost always filled out on demand with some sort of cached object, so this is often OK.
    if (PRINT_WARNINGS_ON_UNSERIALIZABLE_THREAD_LOCAL)
      System.err.println("WARNING: Cannot serialize ThreadLocal (" + tl + " = " + val + "), it will be restored as null.");

    return false;
  }
}

代码示例来源:origin: de.javakaffee/kryo-serializers

private static Serializer<?> getSerializer(Kryo kryo, Class<?> type) {
  Registration registration = kryo.getClassResolver().getRegistration(type);
  return registration != null ? registration.getSerializer() : null;
}

代码示例来源:origin: magro/kryo-serializers

private static Serializer<?> getSerializer(Kryo kryo, Class<?> type) {
  Registration registration = kryo.getClassResolver().getRegistration(type);
  return registration != null ? registration.getSerializer() : null;
}

代码示例来源:origin: de.javakaffee/kryo-serializers

private static Serializer<?> getSerializer(Kryo kryo, Class<?> type) {
  Registration registration = kryo.getClassResolver().getRegistration(type);
  return registration != null ? registration.getSerializer() : null;
}

代码示例来源:origin: magro/kryo-serializers

private static Serializer<?> getSerializer(Kryo kryo, Class<?> type) {
  Registration registration = kryo.getClassResolver().getRegistration(type);
  return registration != null ? registration.getSerializer() : null;
}

代码示例来源:origin: hank-whu/turbo-rpc

/**
 * 快速写入
 * 
 * @param kryo
 * @param output
 * @param defaultRegistration
 * @param value
 */
public static void fastWrite(Kryo kryo, Output output, Registration defaultRegistration, Object value) {
  if (value == null) {
    kryo.writeClass(output, null);
    return;
  }
  Class<?> type = value.getClass();
  if (defaultRegistration.getType().equals(type)) {
    if (defaultRegistration.getId() == FastClassResolver.NAME) {
      ((FastClassResolver) kryo.getClassResolver()).writeName(output, type, defaultRegistration);
    } else {
      output.writeVarInt(defaultRegistration.getId() + 2, true);
    }
    kryo.writeObject(output, value, defaultRegistration.getSerializer());
  } else {
    Registration registration = kryo.writeClass(output, value.getClass());
    Serializer<?> serializer = registration.getSerializer();
    kryo.writeObject(output, value, serializer);
  }
}

相关文章