com.esotericsoftware.kryo.serializers.CollectionSerializer Java Examples

The following examples show how to use com.esotericsoftware.kryo.serializers.CollectionSerializer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KryoSerialization.java    From JPPF with Apache License 2.0 6 votes vote down vote up
/**
 * Create a Kryo instance, with its instantiator strategy and a set of
 * common serializers (from kryo-serializers project) initialized.
 * @return an instance of {@link Kryo}.
 */
private static Kryo createKryo() {
  final Kryo kryo = new Kryo(new CustomClassResolver(), new MapReferenceResolver());
  kryo.setAutoReset(true);
  kryo.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));

  kryo.register(ObjectName.class, new ObjectNameSerializer());
  kryo.register(OffloadableNotification.class, new GenericObjectSerializer());
  kryo.register(TaskExecutionNotification.class, new GenericObjectSerializer());
  kryo.register(TaskGraph.class, new JobTaskGraphSerializer());
  kryo.register(Collection.class, new CollectionSerializer());
  kryo.register(Arrays.asList( "" ).getClass(), new ArraysAsListSerializer() );
  kryo.register(Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer() );
  kryo.register(Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer() );
  kryo.register(Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer() );
  kryo.register(Collections.singletonList( "" ).getClass(), new CollectionsSingletonListSerializer() );
  kryo.register(Collections.singleton( "" ).getClass(), new CollectionsSingletonSetSerializer() );
  kryo.register(Collections.singletonMap( "", "" ).getClass(), new CollectionsSingletonMapSerializer() );
  kryo.register(GregorianCalendar.class, new GregorianCalendarSerializer());
  kryo.register(InvocationHandler.class, new JdkProxySerializer());
  UnmodifiableCollectionsSerializer.registerSerializers(kryo);
  SynchronizedCollectionsSerializer.registerSerializers(kryo);
  kryo.register(EnumMap.class, new EnumMapSerializer());
  kryo.register(EnumSet.class, new EnumSetSerializer());
  return kryo;
}
 
Example #2
Source File: DeflateTest.java    From kryonet with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
static public void register (Kryo kryo) {
	kryo.register(short[].class);
	kryo.register(SomeData.class, new DeflateSerializer(new FieldSerializer(kryo, SomeData.class)));
	kryo.register(ArrayList.class, new CollectionSerializer());
}