Search in sources :

Example 1 with RegexSerializer

use of de.javakaffee.kryoserializers.RegexSerializer 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 RegexSerializer

use of de.javakaffee.kryoserializers.RegexSerializer in project dubbo by alibaba.

the class AbstractKryoFactory method create.

public Kryo create() {
    if (!kryoCreated) {
        kryoCreated = true;
    }
    Kryo kryo = new CompatibleKryo();
    // TODO
    // kryo.setReferences(false);
    kryo.setRegistrationRequired(registrationRequired);
    kryo.register(Arrays.asList("").getClass(), new ArraysAsListSerializer());
    kryo.register(GregorianCalendar.class, new GregorianCalendarSerializer());
    kryo.register(InvocationHandler.class, new JdkProxySerializer());
    kryo.register(BigDecimal.class, new DefaultSerializers.BigDecimalSerializer());
    kryo.register(BigInteger.class, new DefaultSerializers.BigIntegerSerializer());
    kryo.register(Pattern.class, new RegexSerializer());
    kryo.register(BitSet.class, new BitSetSerializer());
    kryo.register(URI.class, new URISerializer());
    kryo.register(UUID.class, new UUIDSerializer());
    UnmodifiableCollectionsSerializer.registerSerializers(kryo);
    SynchronizedCollectionsSerializer.registerSerializers(kryo);
    // now just added some very common classes
    // TODO optimization
    kryo.register(HashMap.class);
    kryo.register(ArrayList.class);
    kryo.register(LinkedList.class);
    kryo.register(HashSet.class);
    kryo.register(TreeSet.class);
    kryo.register(Hashtable.class);
    kryo.register(Date.class);
    kryo.register(Calendar.class);
    kryo.register(ConcurrentHashMap.class);
    kryo.register(SimpleDateFormat.class);
    kryo.register(GregorianCalendar.class);
    kryo.register(Vector.class);
    kryo.register(BitSet.class);
    kryo.register(StringBuffer.class);
    kryo.register(StringBuilder.class);
    kryo.register(Object.class);
    kryo.register(Object[].class);
    kryo.register(String[].class);
    kryo.register(byte[].class);
    kryo.register(char[].class);
    kryo.register(int[].class);
    kryo.register(float[].class);
    kryo.register(double[].class);
    for (Class clazz : registrations) {
        kryo.register(clazz);
    }
    for (Class clazz : SerializableClassRegistry.getRegisteredClasses()) {
        kryo.register(clazz);
    }
    return kryo;
}
Also used : JdkProxySerializer(de.javakaffee.kryoserializers.JdkProxySerializer) DefaultSerializers(com.esotericsoftware.kryo.serializers.DefaultSerializers) GregorianCalendarSerializer(de.javakaffee.kryoserializers.GregorianCalendarSerializer) CompatibleKryo(com.alibaba.dubbo.common.serialize.kryo.CompatibleKryo) RegexSerializer(de.javakaffee.kryoserializers.RegexSerializer) URISerializer(de.javakaffee.kryoserializers.URISerializer) UUIDSerializer(de.javakaffee.kryoserializers.UUIDSerializer) ArraysAsListSerializer(de.javakaffee.kryoserializers.ArraysAsListSerializer) Kryo(com.esotericsoftware.kryo.Kryo) CompatibleKryo(com.alibaba.dubbo.common.serialize.kryo.CompatibleKryo) BitSetSerializer(de.javakaffee.kryoserializers.BitSetSerializer)

Example 3 with RegexSerializer

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

the class CloseableKryoFactory method registerNativeJdkComponentsWithKryo.

private void registerNativeJdkComponentsWithKryo(final Kryo kryo) {
    kryo.register(Class.class, new DefaultSerializers.ClassSerializer());
    kryo.register(ZonedDateTime.class, new ZonedDateTimeSerializer());
    kryo.register(ArrayList.class);
    kryo.register(HashMap.class);
    kryo.register(LinkedHashMap.class);
    kryo.register(byte[].class);
    kryo.register(LinkedHashSet.class);
    kryo.register(ByteBuffer.class);
    kryo.register(HashSet.class);
    kryo.register(URL.class, new URLSerializer());
    kryo.register(URI.class, new URISerializer());
    kryo.register(Pattern.class, new RegexSerializer());
    kryo.register(UUID.class, new UUIDSerializer());
    kryo.register(EnumMap.class, new EnumMapSerializer());
    kryo.register(EnumSet.class, new EnumSetSerializer());
}
Also used : URISerializer(de.javakaffee.kryoserializers.URISerializer) DefaultSerializers(com.esotericsoftware.kryo.serializers.DefaultSerializers) ZonedDateTimeSerializer(org.apereo.cas.memcached.kryo.serial.ZonedDateTimeSerializer) UUIDSerializer(de.javakaffee.kryoserializers.UUIDSerializer) URLSerializer(org.apereo.cas.memcached.kryo.serial.URLSerializer) EnumMapSerializer(de.javakaffee.kryoserializers.EnumMapSerializer) RegexSerializer(de.javakaffee.kryoserializers.RegexSerializer) EnumSetSerializer(de.javakaffee.kryoserializers.EnumSetSerializer)

Aggregations

DefaultSerializers (com.esotericsoftware.kryo.serializers.DefaultSerializers)3 RegexSerializer (de.javakaffee.kryoserializers.RegexSerializer)3 URISerializer (de.javakaffee.kryoserializers.URISerializer)3 UUIDSerializer (de.javakaffee.kryoserializers.UUIDSerializer)3 EnumMapSerializer (de.javakaffee.kryoserializers.EnumMapSerializer)2 EnumSetSerializer (de.javakaffee.kryoserializers.EnumSetSerializer)2 CompatibleKryo (com.alibaba.dubbo.common.serialize.kryo.CompatibleKryo)1 Kryo (com.esotericsoftware.kryo.Kryo)1 ArraysAsListSerializer (de.javakaffee.kryoserializers.ArraysAsListSerializer)1 BitSetSerializer (de.javakaffee.kryoserializers.BitSetSerializer)1 CollectionsEmptyListSerializer (de.javakaffee.kryoserializers.CollectionsEmptyListSerializer)1 CollectionsEmptyMapSerializer (de.javakaffee.kryoserializers.CollectionsEmptyMapSerializer)1 CollectionsEmptySetSerializer (de.javakaffee.kryoserializers.CollectionsEmptySetSerializer)1 GregorianCalendarSerializer (de.javakaffee.kryoserializers.GregorianCalendarSerializer)1 JdkProxySerializer (de.javakaffee.kryoserializers.JdkProxySerializer)1 PostConstruct (javax.annotation.PostConstruct)1 URLSerializer (org.apereo.cas.memcached.kryo.serial.URLSerializer)1 ZonedDateTimeSerializer (org.apereo.cas.memcached.kryo.serial.ZonedDateTimeSerializer)1 RegisteredServiceSerializer (org.apereo.cas.ticket.registry.support.kryo.serial.RegisteredServiceSerializer)1 SimpleWebApplicationServiceSerializer (org.apereo.cas.ticket.registry.support.kryo.serial.SimpleWebApplicationServiceSerializer)1