de.javakaffee.kryoserializers.guava.ImmutableMultimapSerializer Java Examples
The following examples show how to use
de.javakaffee.kryoserializers.guava.ImmutableMultimapSerializer.
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: SerDeUtils.java From metron with Apache License 2.0 | 5 votes |
@Override protected Kryo initialValue() { Kryo ret = new Kryo(); ret.setReferences(true); ret.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); ret.register(Arrays.asList("").getClass(), new ArraysAsListSerializer()); ret.register(Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer()); ret.register(Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer()); ret.register(Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer()); ret.register(Collections.singletonList("").getClass(), new CollectionsSingletonListSerializer()); ret.register(Collections.singleton("").getClass(), new CollectionsSingletonSetSerializer()); ret.register(Collections.singletonMap("", "").getClass(), new CollectionsSingletonMapSerializer()); ret.register(GregorianCalendar.class, new GregorianCalendarSerializer()); ret.register(InvocationHandler.class, new JdkProxySerializer()); UnmodifiableCollectionsSerializer.registerSerializers(ret); SynchronizedCollectionsSerializer.registerSerializers(ret); // custom serializers for non-jdk libs // register CGLibProxySerializer, works in combination with the appropriate action in handleUnregisteredClass (see below) ret.register(CGLibProxySerializer.CGLibProxyMarker.class, new CGLibProxySerializer()); // joda DateTime, LocalDate and LocalDateTime ret.register(LocalDate.class, new JodaLocalDateSerializer()); ret.register(LocalDateTime.class, new JodaLocalDateTimeSerializer()); // guava ImmutableList, ImmutableSet, ImmutableMap, ImmutableMultimap, UnmodifiableNavigableSet ImmutableListSerializer.registerSerializers(ret); ImmutableSetSerializer.registerSerializers(ret); ImmutableMapSerializer.registerSerializers(ret); ImmutableMultimapSerializer.registerSerializers(ret); return ret; }
Example #2
Source File: SerDeUtils.java From metron with Apache License 2.0 | 5 votes |
@Override protected Kryo initialValue() { Kryo ret = new Kryo(); ret.setReferences(true); ret.setInstantiatorStrategy(new DefaultInstantiatorStrategy(new StdInstantiatorStrategy())); ret.register(Arrays.asList("").getClass(), new ArraysAsListSerializer()); ret.register(Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer()); ret.register(Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer()); ret.register(Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer()); ret.register(Collections.singletonList("").getClass(), new CollectionsSingletonListSerializer()); ret.register(Collections.singleton("").getClass(), new CollectionsSingletonSetSerializer()); ret.register(Collections.singletonMap("", "").getClass(), new CollectionsSingletonMapSerializer()); ret.register(GregorianCalendar.class, new GregorianCalendarSerializer()); ret.register(InvocationHandler.class, new JdkProxySerializer()); UnmodifiableCollectionsSerializer.registerSerializers(ret); SynchronizedCollectionsSerializer.registerSerializers(ret); // custom serializers for non-jdk libs // register CGLibProxySerializer, works in combination with the appropriate action in handleUnregisteredClass (see below) ret.register(CGLibProxySerializer.CGLibProxyMarker.class, new CGLibProxySerializer()); // joda DateTime, LocalDate and LocalDateTime ret.register(LocalDate.class, new JodaLocalDateSerializer()); ret.register(LocalDateTime.class, new JodaLocalDateTimeSerializer()); // guava ImmutableList, ImmutableSet, ImmutableMap, ImmutableMultimap, UnmodifiableNavigableSet ImmutableListSerializer.registerSerializers(ret); ImmutableSetSerializer.registerSerializers(ret); ImmutableMapSerializer.registerSerializers(ret); ImmutableMultimapSerializer.registerSerializers(ret); return ret; }
Example #3
Source File: ValkyrienSkiesMod.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
/** * Create our new instance of {@link Kryo}. This is done asynchronously with CompletableFuture * so as not to slow down initialization. We save a lot of time this way! */ private void serializationInitAsync() { kryoInstance = CompletableFuture.supplyAsync(() -> { long start = System.currentTimeMillis(); Kryo kryo = new Kryo(); // region More serializers //noinspection ArraysAsListWithZeroOrOneArgument UnmodifiableCollectionsSerializer.registerSerializers(kryo); SynchronizedCollectionsSerializer.registerSerializers(kryo); ImmutableListSerializer.registerSerializers(kryo); ImmutableSetSerializer.registerSerializers(kryo); ImmutableMapSerializer.registerSerializers(kryo); ImmutableMultimapSerializer.registerSerializers(kryo); ImmutableTableSerializer.registerSerializers(kryo); ReverseListSerializer.registerSerializers(kryo); UnmodifiableNavigableSetSerializer.registerSerializers(kryo); ArrayListMultimapSerializer.registerSerializers(kryo); HashMultimapSerializer.registerSerializers(kryo); LinkedHashMultimapSerializer.registerSerializers(kryo); LinkedListMultimapSerializer.registerSerializers(kryo); TreeMultimapSerializer.registerSerializers(kryo); ArrayTableSerializer.registerSerializers(kryo); HashBasedTableSerializer.registerSerializers(kryo); TreeBasedTableSerializer.registerSerializers(kryo); // endregion kryo.register(ConcurrentIndexedCollection.class); kryo.register(ShipData.class); kryo.register(ShipPositionData.class); kryo.register(VSChunkClaim.class); kryo.register(HashSet.class); kryo.register(UUID.class, new UUIDSerializer()); // This should be changed to true but only once we're stable kryo.setRegistrationRequired(false); log.debug("Kryo initialization: " + (System.currentTimeMillis() - start) + "ms"); return kryo; }); }
Example #4
Source File: KryoSerialization.java From cuba with Apache License 2.0 | 4 votes |
protected Kryo newKryoInstance() { Kryo kryo = new Kryo(new DefaultClassResolver(), new CubaMapReferenceResolver()); kryo.setInstantiatorStrategy(new CubaInstantiatorStrategy()); if (onlySerializable) { kryo.setDefaultSerializer(CubaFieldSerializer.class); } //To work properly must itself be loaded by the application classloader (i.e. by classloader capable of loading //all the other application classes). For web application it means placing this class inside webapp folder. kryo.setClassLoader(KryoSerialization.class.getClassLoader()); //noinspection ArraysAsListWithZeroOrOneArgument 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(BitSet.class, new BitSetSerializer()); kryo.register(GregorianCalendar.class, new GregorianCalendarSerializer()); kryo.register(InvocationHandler.class, new JdkProxySerializer()); kryo.register(EnumSet.class, new EnumSetSerializer()); kryo.register(TreeSet.class, new DefaultSerializers.TreeSetSerializer()); UnmodifiableCollectionsSerializer.registerSerializers(kryo); SynchronizedCollectionsSerializer.registerSerializers(kryo); kryo.register(Pattern.class, new RegexSerializer()); kryo.register(CGLibProxySerializer.CGLibProxyMarker.class, new CGLibProxySerializer()); ImmutableListSerializer.registerSerializers(kryo); ImmutableSetSerializer.registerSerializers(kryo); ImmutableMapSerializer.registerSerializers(kryo); ImmutableMultimapSerializer.registerSerializers(kryo); kryo.register(IndirectList.class, new IndirectContainerSerializer()); kryo.register(IndirectMap.class, new IndirectContainerSerializer()); kryo.register(IndirectSet.class, new IndirectContainerSerializer()); kryo.register(org.eclipse.persistence.indirection.IndirectList.class, new IndirectContainerSerializer()); kryo.register(org.eclipse.persistence.indirection.IndirectMap.class, new IndirectContainerSerializer()); kryo.register(org.eclipse.persistence.indirection.IndirectSet.class, new IndirectContainerSerializer()); //classes with custom serialization methods kryo.register(HashMultimap.class, new CubaJavaSerializer()); kryo.register(ArrayListMultimap.class, new CubaJavaSerializer()); kryo.register(MetaClassImpl.class, new CubaJavaSerializer()); kryo.register(MetaPropertyImpl.class, new CubaJavaSerializer()); kryo.register(UnitOfWorkQueryValueHolder.class, new UnitOfWorkQueryValueHolderSerializer(kryo)); kryo.addDefaultSerializer(Collection.class, new CubaCollectionSerializer()); registerEntitySerializer(kryo); return kryo; }