Search in sources :

Example 1 with CollectionsEmptyMapSerializer

use of de.javakaffee.kryoserializers.CollectionsEmptyMapSerializer in project cas by apereo.

the class KryoTranscoder method initialize.

/**
     * Initialize and register classes with kryo.
     */
@PostConstruct
public void initialize() {
    // Register types we know about and do not require external configuration
    this.kryo.register(EncodedTicket.class);
    this.kryo.register(ArrayList.class);
    this.kryo.register(BasicCredentialMetaData.class);
    this.kryo.register(Class.class, new DefaultSerializers.ClassSerializer());
    this.kryo.register(ZonedDateTime.class, new ZonedDateTimeTranscoder());
    this.kryo.register(HardTimeoutExpirationPolicy.class);
    this.kryo.register(HashMap.class);
    this.kryo.register(LinkedHashMap.class);
    this.kryo.register(HashSet.class);
    this.kryo.register(DefaultHandlerResult.class);
    this.kryo.register(DefaultAuthentication.class);
    this.kryo.register(MultiTimeUseOrTimeoutExpirationPolicy.class);
    this.kryo.register(NeverExpiresExpirationPolicy.class);
    this.kryo.register(RememberMeDelegatingExpirationPolicy.class);
    this.kryo.register(ServiceTicketImpl.class);
    this.kryo.register(SimpleWebApplicationServiceImpl.class, new SimpleWebApplicationServiceSerializer());
    this.kryo.register(ThrottledUseAndTimeoutExpirationPolicy.class);
    this.kryo.register(TicketGrantingTicketExpirationPolicy.class);
    this.kryo.register(TicketGrantingTicketImpl.class);
    this.kryo.register(TimeoutExpirationPolicy.class);
    this.kryo.register(UsernamePasswordCredential.class);
    this.kryo.register(SimplePrincipal.class);
    this.kryo.register(URL.class, new URLSerializer());
    this.kryo.register(URI.class, new URISerializer());
    this.kryo.register(Pattern.class, new RegexSerializer());
    this.kryo.register(UUID.class, new UUIDSerializer());
    this.kryo.register(EnumMap.class, new EnumMapSerializer());
    this.kryo.register(EnumSet.class, new EnumSetSerializer());
    // we add these ones for tests only
    this.kryo.register(RegexRegisteredService.class, new RegisteredServiceSerializer());
    // from the kryo-serializers library (https://github.com/magro/kryo-serializers)
    UnmodifiableCollectionsSerializer.registerSerializers(this.kryo);
    ImmutableListSerializer.registerSerializers(this.kryo);
    ImmutableSetSerializer.registerSerializers(this.kryo);
    ImmutableMapSerializer.registerSerializers(this.kryo);
    ImmutableMultimapSerializer.registerSerializers(this.kryo);
    this.kryo.register(Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer());
    this.kryo.register(Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer());
    this.kryo.register(Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer());
    // Register other types
    if (this.serializerMap != null) {
        this.serializerMap.forEach(this.kryo::register);
    }
    // don't reinit the registered classes after every write or read
    this.kryo.setAutoReset(false);
    // don't replace objects by references
    this.kryo.setReferences(false);
    // Catchall for any classes not explicitly registered
    this.kryo.setRegistrationRequired(false);
}
Also used : DefaultSerializers(com.esotericsoftware.kryo.serializers.DefaultSerializers) RegisteredServiceSerializer(org.apereo.cas.ticket.registry.support.kryo.serial.RegisteredServiceSerializer) CollectionsEmptyMapSerializer(de.javakaffee.kryoserializers.CollectionsEmptyMapSerializer) EnumMapSerializer(de.javakaffee.kryoserializers.EnumMapSerializer) RegexSerializer(de.javakaffee.kryoserializers.RegexSerializer) SimpleWebApplicationServiceSerializer(org.apereo.cas.ticket.registry.support.kryo.serial.SimpleWebApplicationServiceSerializer) URISerializer(de.javakaffee.kryoserializers.URISerializer) UUIDSerializer(de.javakaffee.kryoserializers.UUIDSerializer) CollectionsEmptyListSerializer(de.javakaffee.kryoserializers.CollectionsEmptyListSerializer) CollectionsEmptySetSerializer(de.javakaffee.kryoserializers.CollectionsEmptySetSerializer) ZonedDateTimeTranscoder(org.apereo.cas.ticket.registry.support.kryo.serial.ZonedDateTimeTranscoder) URLSerializer(org.apereo.cas.ticket.registry.support.kryo.serial.URLSerializer) EnumSetSerializer(de.javakaffee.kryoserializers.EnumSetSerializer) PostConstruct(javax.annotation.PostConstruct)

Example 2 with CollectionsEmptyMapSerializer

use of de.javakaffee.kryoserializers.CollectionsEmptyMapSerializer in project cas by apereo.

the class CloseableKryoFactory method registerImmutableOrEmptyCollectionsWithKryo.

private void registerImmutableOrEmptyCollectionsWithKryo(final Kryo kryo) {
    LOGGER.debug("Registering immutable/empty collections with Kryo");
    UnmodifiableCollectionsSerializer.registerSerializers(kryo);
    ImmutableListSerializer.registerSerializers(kryo);
    ImmutableSetSerializer.registerSerializers(kryo);
    ImmutableMapSerializer.registerSerializers(kryo);
    ImmutableMultimapSerializer.registerSerializers(kryo);
    kryo.register(Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer());
    kryo.register(Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer());
    kryo.register(Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer());
    // Can't directly access Collections classes (private class), so instantiate one and do a getClass().
    final Set singletonSet = Collections.singleton("key");
    kryo.register(singletonSet.getClass());
    final Map singletonMap = Collections.singletonMap("key", "value");
    kryo.register(singletonMap.getClass());
    final List list = Arrays.asList("key");
    kryo.register(list.getClass(), new ArraysAsListSerializer());
}
Also used : EnumSet(java.util.EnumSet) Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) CollectionsEmptyListSerializer(de.javakaffee.kryoserializers.CollectionsEmptyListSerializer) CollectionsEmptySetSerializer(de.javakaffee.kryoserializers.CollectionsEmptySetSerializer) List(java.util.List) ArrayList(java.util.ArrayList) CollectionsEmptyMapSerializer(de.javakaffee.kryoserializers.CollectionsEmptyMapSerializer) ArraysAsListSerializer(de.javakaffee.kryoserializers.ArraysAsListSerializer) Map(java.util.Map) EnumMap(java.util.EnumMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

CollectionsEmptyListSerializer (de.javakaffee.kryoserializers.CollectionsEmptyListSerializer)2 CollectionsEmptyMapSerializer (de.javakaffee.kryoserializers.CollectionsEmptyMapSerializer)2 CollectionsEmptySetSerializer (de.javakaffee.kryoserializers.CollectionsEmptySetSerializer)2 DefaultSerializers (com.esotericsoftware.kryo.serializers.DefaultSerializers)1 ArraysAsListSerializer (de.javakaffee.kryoserializers.ArraysAsListSerializer)1 EnumMapSerializer (de.javakaffee.kryoserializers.EnumMapSerializer)1 EnumSetSerializer (de.javakaffee.kryoserializers.EnumSetSerializer)1 RegexSerializer (de.javakaffee.kryoserializers.RegexSerializer)1 URISerializer (de.javakaffee.kryoserializers.URISerializer)1 UUIDSerializer (de.javakaffee.kryoserializers.UUIDSerializer)1 ArrayList (java.util.ArrayList)1 EnumMap (java.util.EnumMap)1 EnumSet (java.util.EnumSet)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1