de.javakaffee.kryoserializers.cglib.CGLibProxySerializer Java Examples

The following examples show how to use de.javakaffee.kryoserializers.cglib.CGLibProxySerializer. 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 eagle with Apache License 2.0 6 votes vote down vote up
protected Kryo initialValue() {
    Kryo kryo = new Kryo();
    kryo.register(CGLibProxySerializer.CGLibProxyMarker.class, new CGLibProxySerializer());
    UnmodifiableCollectionsSerializer.registerSerializers(kryo);
    SynchronizedCollectionsSerializer.registerSerializers(kryo);
    kryo.register(Arrays.asList("").getClass(), new ArraysAsListSerializer());
    ImmutableListSerializer.registerSerializers(kryo);
    ImmutableSetSerializer.registerSerializers(kryo);
    ImmutableMapSerializer.registerSerializers(kryo);
    ImmutableMultimapSerializer.registerSerializers(kryo);
    ReverseListSerializer.registerSerializers(kryo);
    UnmodifiableNavigableSetSerializer.registerSerializers(kryo);
    ArrayListMultimapSerializer.registerSerializers(kryo);
    HashMultimapSerializer.registerSerializers(kryo);
    LinkedHashMultimapSerializer.registerSerializers(kryo);
    LinkedListMultimapSerializer.registerSerializers(kryo);
    TreeMultimapSerializer.registerSerializers(kryo);
    return kryo;
}
 
Example #2
Source File: JRedisSerializationUtils.java    From springJredisCache with Apache License 2.0 6 votes vote down vote up
KryoHolder(Kryo kryo) {
            this.kryo = kryo;
            this.kryo.register(Arrays.asList("").getClass(), new ArraysAsListSerializer());
            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());
            this.kryo.register(Collections.singletonList("").getClass(), new CollectionsSingletonListSerializer());
            this.kryo.register(Collections.singleton("").getClass(), new CollectionsSingletonSetSerializer());
            this.kryo.register(Collections.singletonMap("", "").getClass(), new CollectionsSingletonMapSerializer());
            this.kryo.register(GregorianCalendar.class, new GregorianCalendarSerializer());
            this.kryo.register(InvocationHandler.class, new JdkProxySerializer());
            // register CGLibProxySerializer, works in combination with the appropriate action in handleUnregisteredClass (see below)
            this.kryo.register(CGLibProxySerializer.CGLibProxyMarker.class, new CGLibProxySerializer());
            UnmodifiableCollectionsSerializer.registerSerializers(this.kryo);
            SynchronizedCollectionsSerializer.registerSerializers(this.kryo);


            //其他第三方
//        // joda datetime
//        kryo.register(DateTime.class, new JodaDateTimeSerializer());
//        // wicket
//        kryo.register(MiniMap.class, new MiniMapSerializer());
//        // guava ImmutableList
//        ImmutableListSerializer.registerSerializers(kryo);
        }
 
Example #3
Source File: KryoPoolSer.java    From springJredisCache with Apache License 2.0 6 votes vote down vote up
KryoHolder(Kryo kryo) {
            this.kryo = kryo;

            //   register
            this.kryo.register(Arrays.asList("").getClass(), new ArraysAsListSerializer());
            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());
            this.kryo.register(Collections.singletonList("").getClass(), new CollectionsSingletonListSerializer());
            this.kryo.register(Collections.singleton("").getClass(), new CollectionsSingletonSetSerializer());
            this.kryo.register(Collections.singletonMap("", "").getClass(), new CollectionsSingletonMapSerializer());
            this.kryo.register(GregorianCalendar.class, new GregorianCalendarSerializer());
            this.kryo.register(InvocationHandler.class, new JdkProxySerializer());
            // register CGLibProxySerializer, works in combination with the appropriate action in handleUnregisteredClass (see below)
            this.kryo.register(CGLibProxySerializer.CGLibProxyMarker.class, new CGLibProxySerializer());
            UnmodifiableCollectionsSerializer.registerSerializers(this.kryo);
            SynchronizedCollectionsSerializer.registerSerializers(this.kryo);

            //其他第三方
//        // joda datetime
//        kryo.register(DateTime.class, new JodaDateTimeSerializer());
//        // wicket
//        kryo.register(MiniMap.class, new MiniMapSerializer());
//        // guava ImmutableList
//        ImmutableListSerializer.registerSerializers(kryo);
        }
 
Example #4
Source File: KryoThreadLocalSer.java    From springJredisCache with Apache License 2.0 6 votes vote down vote up
KryoHolder(Kryo kryo) {
    this.kryo = kryo;
    this.kryo.setReferences(false);

    //   register
    this.kryo.register(Arrays.asList("").getClass(), new ArraysAsListSerializer());
    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());
    this.kryo.register(Collections.singletonList("").getClass(), new CollectionsSingletonListSerializer());
    this.kryo.register(Collections.singleton("").getClass(), new CollectionsSingletonSetSerializer());
    this.kryo.register(Collections.singletonMap("", "").getClass(), new CollectionsSingletonMapSerializer());
    this.kryo.register(GregorianCalendar.class, new GregorianCalendarSerializer());
    this.kryo.register(InvocationHandler.class, new JdkProxySerializer());
    // register CGLibProxySerializer, works in combination with the appropriate action in handleUnregisteredClass (see below)
    this.kryo.register(CGLibProxySerializer.CGLibProxyMarker.class, new CGLibProxySerializer());
    UnmodifiableCollectionsSerializer.registerSerializers(this.kryo);
    SynchronizedCollectionsSerializer.registerSerializers(this.kryo);

}
 
Example #5
Source File: SerDeUtils.java    From metron with Apache License 2.0 5 votes vote down vote up
@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 #6
Source File: SerDeUtils.java    From metron with Apache License 2.0 5 votes vote down vote up
@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 #7
Source File: KryoSerialization.java    From cuba with Apache License 2.0 4 votes vote down vote up
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;
}