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

x33g5p2x  于2022-01-29 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(120)

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

Registration.getSerializer介绍

暂无

代码示例

代码示例来源:origin: opentripplanner/OpenTripPlanner

public void summarize() {
  instanceCounts.forEachEntry((classe, count) -> {
    Registration registration = getRegistration(classe);
    String serializerName = registration.getSerializer().getClass().getSimpleName();
    System.out.println(count + " " + classe.getSimpleName() + " " + serializerName);
    return true;
  });
}

代码示例来源:origin: spring-projects/spring-integration

private void register(Kryo kryo, Registration registration) {
  int id = registration.getId();
  Registration existing = kryo.getRegistration(id);
  if (existing != null) {
    throw new IllegalStateException("registration already exists " + existing);
  }
  if (this.log.isInfoEnabled()) {
    this.log.info(String.format("registering %s with serializer %s", registration,
        registration.getSerializer().getClass().getName()));
  }
  kryo.register(registration);
}

代码示例来源:origin: spring-projects/spring-integration

private void validateRegistrations() {
  List<Integer> ids = new ArrayList<Integer>();
  List<Class<?>> types = new ArrayList<Class<?>>();
  for (Registration registration : getRegistrations()) {
    Assert.isTrue(registration.getId() >= MIN_REGISTRATION_VALUE,
        "registration ID must be >= " + MIN_REGISTRATION_VALUE);
    if (ids.contains(registration.getId())) {
      throw new RuntimeException(String.format("Duplicate registration ID found: %d",
          registration.getId()));
    }
    ids.add(registration.getId());
    if (types.contains(registration.getType())) {
      throw new RuntimeException(String.format("Duplicate registration found for type: %s",
          registration.getType()));
    }
    types.add(registration.getType());
    if (log.isInfoEnabled()) {
      log.info(String.format("configured Kryo registration %s with serializer %s", registration,
          registration.getSerializer().getClass().getName()));
    }
  }
}

代码示例来源:origin: com.esotericsoftware/kryo

/** Returns the serializer for the registration for the specified class.
 * @see #getRegistration(Class)
 * @see Registration#getSerializer() */
public Serializer getSerializer (Class type) {
  return getRegistration(type).getSerializer();
}

代码示例来源:origin: com.esotericsoftware.kryo/kryo

/** Returns the serializer for the registration for the specified class.
 * @see #getRegistration(Class)
 * @see Registration#getSerializer() */
public Serializer getSerializer (Class type) {
  return getRegistration(type).getSerializer();
}

代码示例来源:origin: com.esotericsoftware/kryo-shaded

/** Returns the serializer for the registration for the specified class.
 * @see #getRegistration(Class)
 * @see Registration#getSerializer() */
public Serializer getSerializer (Class type) {
  return getRegistration(type).getSerializer();
}

代码示例来源:origin: svn2github/kryo

/** Returns the serializer for the registration for the specified class.
 * @see #getRegistration(Class)
 * @see Registration#getSerializer() */
public Serializer getSerializer (Class type) {
  return getRegistration(type).getSerializer();
}

代码示例来源:origin: org.springframework.integration/spring-integration-core

private void register(Kryo kryo, Registration registration) {
  int id = registration.getId();
  Registration existing = kryo.getRegistration(id);
  if (existing != null) {
    throw new IllegalStateException("registration already exists " + existing);
  }
  if (this.log.isInfoEnabled()) {
    this.log.info(String.format("registering %s with serializer %s", registration,
        registration.getSerializer().getClass().getName()));
  }
  kryo.register(registration);
}

代码示例来源: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: org.springframework.xd/spring-xd-codec

protected void register(Kryo kryo, Registration registration) {
    int id = registration.getId();

    Registration existing = kryo.getRegistration(id);

    if (existing != null) {
      throw new SerializationException(String.format("registration already exists %s", existing));
    }

    log.info("registering {} with serializer {}", registration, registration.getSerializer().getClass()
          .getName());

    kryo.register(registration);
  }
}

代码示例来源:origin: com.esotericsoftware.kryo/kryo

public EnumSet read (Kryo kryo, Input input, Class<EnumSet> type) {
  Registration registration = kryo.readClass(input);
  EnumSet object = EnumSet.noneOf(registration.getType());
  Serializer serializer = registration.getSerializer();
  int length = input.readInt(true);
  for (int i = 0; i < length; i++)
    object.add(serializer.read(kryo, input, null));
  return object;
}

代码示例来源:origin: com.esotericsoftware/kryo-shaded

public EnumSet read (Kryo kryo, Input input, Class<EnumSet> type) {
  Registration registration = kryo.readClass(input);
  EnumSet object = EnumSet.noneOf(registration.getType());
  Serializer serializer = registration.getSerializer();
  int length = input.readInt(true);
  for (int i = 0; i < length; i++)
    object.add(serializer.read(kryo, input, null));
  return object;
}

代码示例来源:origin: com.esotericsoftware/kryo

public EnumSet read (Kryo kryo, Input input, Class<EnumSet> type) {
  Registration registration = kryo.readClass(input);
  EnumSet object = EnumSet.noneOf(registration.getType());
  Serializer serializer = registration.getSerializer();
  int length = input.readInt(true);
  for (int i = 0; i < length; i++)
    object.add(serializer.read(kryo, input, null));
  return object;
}

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

@Override
  public void writeObject(Output output, Object object, Serializer serializer) {
    Method m = getMethods(object.getClass()).writeReplace;
    if (m != null) {
      object = getReplacement(m, object);
      Registration reg = super.writeClass(output, object.getClass());
      serializer = reg.getSerializer();
    }
    super.writeObject(output, object, serializer);
//        System.out.println("wrote2 an object "+object+" id "+getRegistration(object.getClass()).getId());

  }

代码示例来源:origin: svn2github/kryo

public EnumSet read (Kryo kryo, Input input, Class<EnumSet> type) {
  Registration registration = kryo.readClass(input);
  EnumSet object = EnumSet.noneOf(registration.getType());
  Serializer serializer = registration.getSerializer();
  int length = input.readInt(true);
  for (int i = 0; i < length; i++)
    object.add(serializer.read(kryo, input, null));
  return object;
}

代码示例来源:origin: co.paralleluniverse/galaxy

@Override
  public void writeObject(Output output, Object object, Serializer serializer) {
    Method m = getMethods(object.getClass()).writeReplace;
    if (m != null) {
      object = getReplacement(m, object);
      Registration reg = super.writeClass(output, object.getClass());
      serializer = reg.getSerializer();
    }
    super.writeObject(output, object, serializer);
//        System.out.println("wrote2 an object "+object+" id "+getRegistration(object.getClass()).getId());

  }

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

@SuppressWarnings("unchecked")
public static Object slowRead(Kryo kryo, Input input) {
  Registration registration = kryo.readClass(input);
  if (registration == null) {
    return null;
  } else {
    Serializer<?> serializer = registration.getSerializer();
    return kryo.readObject(input, registration.getType(), serializer);
  }
}

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

private void register(Registration r) {
  if (r.getId() < 0 && r.getSerializer() == NULL_SERIALIZER)
    kryo.register(r.getType());
  else if (r.getId() < 0)
    kryo.register(r.getType(), r.getSerializer());
  else if (r.getSerializer() == NULL_SERIALIZER)
    kryo.register(r.getType(), r.getId());
  else
    kryo.register(r.getType(), r.getSerializer(), r.getId());
}

代码示例来源:origin: co.paralleluniverse/galaxy

private void register(Registration r) {
  if (r.getId() < 0 && r.getSerializer() == NULL_SERIALIZER)
    kryo.register(r.getType());
  else if (r.getId() < 0)
    kryo.register(r.getType(), r.getSerializer());
  else if (r.getSerializer() == NULL_SERIALIZER)
    kryo.register(r.getType(), r.getId());
  else
    kryo.register(r.getType(), r.getSerializer(), r.getId());
}

相关文章