本文整理汇总了Java中de.javakaffee.kryoserializers.SynchronizedCollectionsSerializer类的典型用法代码示例。如果您正苦于以下问题:Java SynchronizedCollectionsSerializer类的具体用法?Java SynchronizedCollectionsSerializer怎么用?Java SynchronizedCollectionsSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SynchronizedCollectionsSerializer类属于de.javakaffee.kryoserializers包,在下文中一共展示了SynchronizedCollectionsSerializer类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createKryoInstance
import de.javakaffee.kryoserializers.SynchronizedCollectionsSerializer; //导入依赖的package包/类
private Kryo createKryoInstance() {
Kryo kryo = new Kryo();
kryo.register(RakTable.class);
kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
kryo.setReferences(false);
kryo.register(Collections.singletonList("").getClass(), new ArraysAsListSerializer());
UnmodifiableCollectionsSerializer.registerSerializers(kryo);
SynchronizedCollectionsSerializer.registerSerializers(kryo);
kryo.addDefaultSerializer(new ArrayList<>().subList(0, 0).getClass(), new CollectionSerializer());
kryo.addDefaultSerializer(new LinkedList<>().subList(0, 0).getClass(), new CollectionSerializer());
kryo.register(UUID.class, new UUIDSerializer());
for (Class<?> clazz : mCustomSerializers.keySet()) {
kryo.register(clazz, mCustomSerializers.get(clazz));
}
kryo.setInstantiatorStrategy(
new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
return kryo;
}
示例2: createKryoInstance
import de.javakaffee.kryoserializers.SynchronizedCollectionsSerializer; //导入依赖的package包/类
public static Kryo createKryoInstance() {
Kryo kryo = new Kryo();
// add custom serialisers to work with joda time (the kryo version that we get when including spark as a dependency cannot handle joda time by default)
// see https://github.com/magro/kryo-serializers
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( GregorianCalendar.class, new GregorianCalendarSerializer() );
kryo.register( InvocationHandler.class, new JdkProxySerializer() );
UnmodifiableCollectionsSerializer.registerSerializers( kryo );
SynchronizedCollectionsSerializer.registerSerializers( kryo );
// custom serializers for non-jdk libs
return kryo;
}
示例3: createKryoInstance
import de.javakaffee.kryoserializers.SynchronizedCollectionsSerializer; //导入依赖的package包/类
private Kryo createKryoInstance(boolean compatibilityMode) {
Kryo kryo = new Kryo();
if (compatibilityMode) {
kryo.getFieldSerializerConfig().setOptimizedGenerics(true);
}
kryo.register(PaperTable.class);
kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
kryo.setReferences(false);
// Serialize Arrays$ArrayList
//noinspection ArraysAsListWithZeroOrOneArgument
kryo.register(Arrays.asList("").getClass(), new ArraysAsListSerializer());
UnmodifiableCollectionsSerializer.registerSerializers(kryo);
SynchronizedCollectionsSerializer.registerSerializers(kryo);
// Serialize inner AbstractList$SubAbstractListRandomAccess
kryo.addDefaultSerializer(new ArrayList<>().subList(0, 0).getClass(),
new NoArgCollectionSerializer());
// Serialize AbstractList$SubAbstractList
kryo.addDefaultSerializer(new LinkedList<>().subList(0, 0).getClass(),
new NoArgCollectionSerializer());
// To keep backward compatibility don't change the order of serializers above
// UUID support
kryo.register(UUID.class, new UUIDSerializer());
for (Class<?> clazz : mCustomSerializers.keySet())
kryo.register(clazz, mCustomSerializers.get(clazz));
kryo.setInstantiatorStrategy(
new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
return kryo;
}
示例4: tryRegister
import de.javakaffee.kryoserializers.SynchronizedCollectionsSerializer; //导入依赖的package包/类
public static void tryRegister(Kryo kryo) {
kryo.register(ARRAYS_AS_LIST_CLASS, new ArraysAsListSerializer());
kryo.register(GregorianCalendar.class, new GregorianCalendarSerializer());
kryo.register(InvocationHandler.class, new JdkProxySerializer());
kryo.register(GregorianCalendar.class, new GregorianCalendarSerializer());
kryo.register(InvocationHandler.class, new JdkProxySerializer());
UnmodifiableCollectionsSerializer.registerSerializers(kryo);
SynchronizedCollectionsSerializer.registerSerializers(kryo);
}
示例5: createKryo
import de.javakaffee.kryoserializers.SynchronizedCollectionsSerializer; //导入依赖的package包/类
/**
* Creates a new instance of Kryo serializer, for use with the given object type.
* <p/>
* Note: this method is public to allow end-users to validate compatibility of their POJOs,
* with the Kryo serializer as used by CQEngine.
*
* @param objectType The type of object which the instance of Kryo will serialize
* @return a new instance of Kryo serializer
*/
@SuppressWarnings({"ArraysAsListWithZeroOrOneArgument", "WeakerAccess"})
protected Kryo createKryo(Class<?> objectType) {
Kryo kryo = new Kryo();
// Instantiate serialized objects via a no-arg constructor when possible, falling back to Objenesis...
kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
// Register the object which this index will persist...
kryo.register(objectType);
// Register additional serializers which are not built-in to Kryo 3.0...
kryo.register(Arrays.asList().getClass(), new ArraysAsListSerializer());
UnmodifiableCollectionsSerializer.registerSerializers(kryo);
SynchronizedCollectionsSerializer.registerSerializers(kryo);
return kryo;
}
示例6: initialValue
import de.javakaffee.kryoserializers.SynchronizedCollectionsSerializer; //导入依赖的package包/类
@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;
}
示例7: registerClasses
import de.javakaffee.kryoserializers.SynchronizedCollectionsSerializer; //导入依赖的package包/类
@Override
public void registerClasses(Kryo kryo) {
kryo.register(Nd4j.getBackend().getNDArrayClass(), new Nd4jSerializer());
kryo.register(Nd4j.getBackend().getComplexNDArrayClass(), new Nd4jSerializer());
kryo.register(AtomicDouble.class, new AtomicDoubleSerializer());
//Also register Java types (synchronized/unmodifiable collections), which will fail by default
UnmodifiableCollectionsSerializer.registerSerializers(kryo);
SynchronizedCollectionsSerializer.registerSerializers(kryo);
}
示例8: initialValue
import de.javakaffee.kryoserializers.SynchronizedCollectionsSerializer; //导入依赖的package包/类
protected Kryo initialValue() {
Kryo _kryo = new KryoReflectionFactorySupport() {
@Override
@SuppressWarnings( { "rawtypes", "unchecked" } )
public Serializer<?> getDefaultSerializer( final Class type ) {
if ( EnumSet.class.isAssignableFrom( type ) ) {
return new EnumSetSerializer();
}
if ( EnumMap.class.isAssignableFrom( type ) ) {
return new EnumMapSerializer();
}
if ( Collection.class.isAssignableFrom( type ) ) {
return new CopyForIterateCollectionSerializer();
}
if ( Map.class.isAssignableFrom( type ) ) {
return new CopyForIterateMapSerializer();
}
if ( Date.class.isAssignableFrom( type ) ) {
return new DateSerializer( type );
}
return super.getDefaultSerializer( type );
}
};
_kryo.setRegistrationRequired(false);
_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( BigDecimal.class, new BigDecimalSerializer() );
_kryo.register( BigInteger.class, new 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() );
_kryo.register( GregorianCalendar.class, new GregorianCalendarSerializer() );
_kryo.register( InvocationHandler.class, new JdkProxySerializer() );
UnmodifiableCollectionsSerializer.registerSerializers( _kryo );
SynchronizedCollectionsSerializer.registerSerializers( _kryo );
// DeflateSerializer d;
// _kryo..setDefaultSerializer(CompatibleFieldSerializer.class);
return _kryo;
}