use of de.javakaffee.kryoserializers.CollectionsEmptySetSerializer 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);
}
use of de.javakaffee.kryoserializers.CollectionsEmptySetSerializer 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());
}
Aggregations