use of de.javakaffee.kryoserializers.JdkProxySerializer 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;
}
use of de.javakaffee.kryoserializers.JdkProxySerializer in project quasar by puniverse.
the class KryoUtil method registerCommonClasses.
public static void registerCommonClasses(Kryo kryo) {
kryo.register(boolean[].class);
kryo.register(byte[].class);
kryo.register(short[].class);
kryo.register(char[].class);
kryo.register(int[].class);
kryo.register(float[].class);
kryo.register(long[].class);
kryo.register(double[].class);
kryo.register(String[].class);
kryo.register(int[][].class);
kryo.register(java.util.ArrayList.class);
kryo.register(java.util.LinkedList.class);
kryo.register(java.util.HashMap.class);
kryo.register(java.util.LinkedHashMap.class);
kryo.register(java.util.TreeMap.class);
kryo.register(java.util.EnumMap.class);
kryo.register(java.util.HashSet.class);
kryo.register(java.util.TreeSet.class);
kryo.register(java.util.EnumSet.class);
kryo.register(java.util.Arrays.asList("").getClass(), new ArraysAsListSerializer());
kryo.register(java.util.Collections.newSetFromMap(new java.util.HashMap()).getClass(), new CollectionsSetFromMapSerializer());
// kryo.register(java.util.Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer());
// kryo.register(java.util.Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer());
// kryo.register(java.util.Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer());
// kryo.register(java.util.Collections.singletonList("").getClass(), new CollectionsSingletonListSerializer());
// kryo.register(java.util.Collections.singleton("").getClass(), new CollectionsSingletonSetSerializer());
// kryo.register(java.util.Collections.singletonMap("", "").getClass(), new CollectionsSingletonMapSerializer());
kryo.register(java.util.GregorianCalendar.class, new GregorianCalendarSerializer());
kryo.register(java.lang.reflect.InvocationHandler.class, new JdkProxySerializer());
UnmodifiableCollectionsSerializer.registerSerializers(kryo);
SynchronizedCollectionsSerializer.registerSerializers(kryo);
kryo.addDefaultSerializer(Externalizable.class, new ExternalizableKryoSerializer());
kryo.addDefaultSerializer(java.lang.ref.Reference.class, new ReferenceSerializer());
}
Aggregations