• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CompatibleFieldSerializer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer的典型用法代码示例。如果您正苦于以下问题:Java CompatibleFieldSerializer类的具体用法?Java CompatibleFieldSerializer怎么用?Java CompatibleFieldSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CompatibleFieldSerializer类属于com.esotericsoftware.kryo.serializers包,在下文中一共展示了CompatibleFieldSerializer类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createKryoInstance

import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的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;
}
 
开发者ID:isfaaghyth,项目名称:Rak,代码行数:24,代码来源:PlainData.java


示例2: testAddedField

import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
public void testAddedField () throws FileNotFoundException {
	TestClass object1 = new TestClass();
	object1.child = new TestClass();
	object1.other = new AnotherClass();
	object1.other.value = "meow";

	CompatibleFieldSerializer serializer = new CompatibleFieldSerializer(kryo, TestClass.class);
	serializer.removeField("text");
	kryo.register(TestClass.class, serializer);
	kryo.register(AnotherClass.class, new CompatibleFieldSerializer(kryo, AnotherClass.class));
	roundTrip(74, 74, object1);

	kryo.register(TestClass.class, new CompatibleFieldSerializer(kryo, TestClass.class));
	Object object2 = kryo.readClassAndObject(input);
	assertEquals(object1, object2);
}
 
开发者ID:esialb,项目名称:kryo-mavenized,代码行数:17,代码来源:CompatibleFieldSerializerTest.java


示例3: createKryoInstance

import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
private Kryo createKryoInstance() {
    Kryo kryo = new Kryo();

    kryo.register(IronTable.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

    kryo.setInstantiatorStrategy(
            new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
    return kryo;
}
 
开发者ID:FabianTerhorst,项目名称:Iron,代码行数:25,代码来源:DbStoragePlainFile.java


示例4: createKryoInstance

import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的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;
}
 
开发者ID:pilgr,项目名称:Paper,代码行数:36,代码来源:DbStoragePlainFile.java


示例5: KryoConverter

import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
public KryoConverter(Class<T> clazz) {
    this.clazz = clazz;
    this.kryo = new Kryo();
    this.kryo.register(clazz);
    this.kryo.register(Date.class, new DateSerializer());
    this.kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
    this.kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
    //
    this.input = new Input();
    this.output = new Output(new ByteArrayOutputStream());
}
 
开发者ID:techery,项目名称:snapper,代码行数:12,代码来源:KryoConverter.java


示例6: init

import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
public static void init () {
	PROFILE_DIRECTORY.mkdirs();
	kryo = new Kryo();
	kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
	kryo.register(ContactInfo.class);
	kryo.register(ServerDescriptor.class);
	kryo.register(ArrayList.class);
	kryo.register(byte[].class);
	kryo.register(BigInteger.class);
	kryo.register(ProfileWrapper.class);
	kryo.register(ProfileOptions.class);
	kryo.register(Profile.class);
}
 
开发者ID:kotcrab,项目名称:arget,代码行数:14,代码来源:ProfileIO.java


示例7: create

import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
/**
 * Creates a Kryo instance.
 *
 * @return Kryo instance
 */
@Override
public Kryo create() {
  log.trace("Creating Kryo instance for {}", this);
  Kryo kryo = new Kryo();
  kryo.setRegistrationRequired(registrationRequired);

  // If compatible serialization is enabled, override the default serializer.
  if (compatible) {
    kryo.setDefaultSerializer(CompatibleFieldSerializer::new);
  }

  // TODO rethink whether we want to use StdInstantiatorStrategy
  kryo.setInstantiatorStrategy(
      new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));

  for (RegistrationBlock block : registeredBlocks) {
    int id = block.begin();
    if (id == FLOATING_ID) {
      id = kryo.getNextRegistrationId();
    }
    for (Pair<Class<?>[], Serializer<?>> entry : block.types()) {
      register(kryo, entry.getLeft(), entry.getRight(), id++);
    }
  }
  return kryo;
}
 
开发者ID:atomix,项目名称:atomix,代码行数:32,代码来源:KryoNamespace.java


示例8: create

import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
/**
 * Creates a Kryo instance.
 *
 * @return Kryo instance
 */
@Override
public Kryo create() {
    log.trace("Creating Kryo instance for {}", this);
    Kryo kryo = new Kryo();
    kryo.setRegistrationRequired(registrationRequired);

    // If compatible serialization is enabled, override the default serializer.
    if (compatible) {
        kryo.setDefaultSerializer(CompatibleFieldSerializer::new);
    }

    // TODO rethink whether we want to use StdInstantiatorStrategy
    kryo.setInstantiatorStrategy(
            new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));

    for (RegistrationBlock block : registeredBlocks) {
        int id = block.begin();
        if (id == FLOATING_ID) {
            id = kryo.getNextRegistrationId();
        }
        for (Pair<Class<?>[], Serializer<?>> entry : block.types()) {
            register(kryo, entry.getLeft(), entry.getRight(), id++);
        }
    }
    return kryo;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:32,代码来源:KryoNamespace.java


示例9: initialValue

import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
@Override
protected Kryo initialValue() {
	final Kryo kryo = new Kryo();
	kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
	kryo.register(File.class, fileSerializer);
	kryo.register(DateTime.class, dateTimeSerializer);
	return kryo;
}
 
开发者ID:dennisfischer,项目名称:simplejavayoutubeuploader,代码行数:9,代码来源:PersistenceService.java


示例10: newKryo

import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
private static Kryo newKryo() {
	Kryo kryo = new Kryo();
    kryo.register(RpcBody.class);
    kryo.register(RpcMethod.class);
    kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
    return kryo;
}
 
开发者ID:mindwind,项目名称:craft-atom,代码行数:8,代码来源:KryoSerialization.java


示例11: testCompatibleFieldSerializer

import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
public void testCompatibleFieldSerializer () throws FileNotFoundException {
	TestClass object1 = new TestClass();
	object1.child = new TestClass();
	object1.other = new AnotherClass();
	object1.other.value = "meow";
	kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
	kryo.register(TestClass.class);
	kryo.register(AnotherClass.class);
	roundTrip(100, 100, object1);
}
 
开发者ID:esialb,项目名称:kryo-mavenized,代码行数:11,代码来源:CompatibleFieldSerializerTest.java


示例12: testRemovedField

import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
public void testRemovedField () throws FileNotFoundException {
	TestClass object1 = new TestClass();
	object1.child = new TestClass();

	kryo.register(TestClass.class, new CompatibleFieldSerializer(kryo, TestClass.class));
	roundTrip(88, 88, object1);

	CompatibleFieldSerializer serializer = new CompatibleFieldSerializer(kryo, TestClass.class);
	serializer.removeField("text");
	kryo.register(TestClass.class, serializer);
	Object object2 = kryo.readClassAndObject(input);
	assertEquals(object1, object2);
}
 
开发者ID:esialb,项目名称:kryo-mavenized,代码行数:14,代码来源:CompatibleFieldSerializerTest.java


示例13: init

import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
public static void init () {
	SERVERS_DIRECTORY.mkdirs();
	kryo = new Kryo();
	kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
	kryo.register(ServerInfo.class);
}
 
开发者ID:kotcrab,项目名称:arget,代码行数:7,代码来源:ServerInfoIO.java


示例14: createKryo

import com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer; //导入依赖的package包/类
/**
 * Override this method to change serialization rule.
 *
 * @return Kryo serializer instance.
 */
protected Kryo createKryo() {
    Kryo kryo = new KryoReflectionFactorySupport();
    kryo.setDefaultSerializer(CompatibleFieldSerializer.class);
    return kryo;
}
 
开发者ID:kwon37xi,项目名称:hibernate4-memcached,代码行数:11,代码来源:KryoTranscoder.java



注:本文中的com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Presenter类代码示例发布时间:2022-05-21
下一篇:
Java XmlRpcRequest类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap