本文整理汇总了Java中com.esotericsoftware.kryo.pool.KryoFactory类的典型用法代码示例。如果您正苦于以下问题:Java KryoFactory类的具体用法?Java KryoFactory怎么用?Java KryoFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KryoFactory类属于com.esotericsoftware.kryo.pool包,在下文中一共展示了KryoFactory类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: KryoMessageSerialization
import com.esotericsoftware.kryo.pool.KryoFactory; //导入依赖的package包/类
public KryoMessageSerialization() {
KryoFactory factory = new KryoFactory() {
public Kryo create() {
Kryo kryo = new Kryo();
kryo.addDefaultSerializer(UUID.class, UUIDSerializer.class);
kryo.addDefaultSerializer(Instant.class, InstantSerializer.class);
// configure kryo instance, customize settings
return kryo;
}
};
// Build pool with SoftReferences enabled (optional)
pool = new KryoPool.Builder(factory).softReferences().build();
}
示例2: getFactory
import com.esotericsoftware.kryo.pool.KryoFactory; //导入依赖的package包/类
private static KryoFactory getFactory(String factoryType) {
try {
return KryoSimplerSerializer.class.getClassLoader().loadClass(factoryType)
.asSubclass(KryoFactory.class).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
示例3: KryoMessageConverter
import com.esotericsoftware.kryo.pool.KryoFactory; //导入依赖的package包/类
public KryoMessageConverter(List<KryoRegistrar> kryoRegistrars, boolean useReferences) {
this.useReferences = useReferences;
this.kryoRegistrar = CollectionUtils.isEmpty(kryoRegistrars) ? null :
new CompositeKryoRegistrar(kryoRegistrars);
KryoFactory factory = () -> {
Kryo kryo = new Kryo();
configureKryoInstance(kryo);
return kryo;
};
this.pool = new KryoPool.Builder(factory).softReferences().build();
this.supportedMimeTypes = Collections.singletonList(MimeType.valueOf(KRYO_MIME_TYPE));
}
示例4: provideKryoPool
import com.esotericsoftware.kryo.pool.KryoFactory; //导入依赖的package包/类
@Provides
@Singleton
KryoPool provideKryoPool() {
KryoFactory kryoFactory = new KryoFactory() {
@Override
public Kryo create() {
Kryo kryo = new Kryo();
// configuration comes here
return kryo;
}
};
// build pool with soft references
KryoPool kryoPool = new KryoPool.Builder(kryoFactory).softReferences().build();
return kryoPool;
}
示例5: KryoUtils
import com.esotericsoftware.kryo.pool.KryoFactory; //导入依赖的package包/类
@Inject
private KryoUtils() {
final KryoFactory factory = new KryoFactory() {
@Override
public Kryo create() {
final Kryo kryo = new Kryo();
UnmodifiableCollectionsSerializer.registerSerializers(kryo); // Required to serialize/deserialize Throwable
return kryo;
}
};
kryoPool = new KryoPool.Builder(factory).softReferences().build();
}
示例6: KryoPoolQueueImpl
import com.esotericsoftware.kryo.pool.KryoFactory; //导入依赖的package包/类
public KryoPoolQueueImpl(Queue<Kryo> queue, KryoFactory factory) {
this.queue = queue;
this.factory = factory;
}
示例7: QueueBuilder
import com.esotericsoftware.kryo.pool.KryoFactory; //导入依赖的package包/类
public QueueBuilder(KryoFactory factory) {
if (factory == null) {
throw new IllegalArgumentException("factory must not be null");
}
this.factory = factory;
}
示例8: setKryoFactory
import com.esotericsoftware.kryo.pool.KryoFactory; //导入依赖的package包/类
public void setKryoFactory(KryoFactory kryoFactory) {
this.kryoFactory = kryoFactory;
}
示例9: getKryoFactory
import com.esotericsoftware.kryo.pool.KryoFactory; //导入依赖的package包/类
public KryoFactory getKryoFactory() {
return kryoFactory;
}
示例10: KryoSimplerSerializer
import com.esotericsoftware.kryo.pool.KryoFactory; //导入依赖的package包/类
/**
* Can call this method to create a serializer w/o calling {@link #init(SimpleConfiguration)}
*/
public KryoSimplerSerializer(KryoFactory factory) {
factoryType = factory.getClass().getName();
this.factory = factory;
}
示例11: setKryoFactory
import com.esotericsoftware.kryo.pool.KryoFactory; //导入依赖的package包/类
/**
* Call this to configure a KryoFactory type before initializing Fluo.
*/
public static void setKryoFactory(FluoConfiguration config,
Class<? extends KryoFactory> factoryType) {
config.getAppConfiguration().setProperty(KRYO_FACTORY_PROP, factoryType.getName());
}
示例12: MapDbObjectSerializer
import com.esotericsoftware.kryo.pool.KryoFactory; //导入依赖的package包/类
public MapDbObjectSerializer(Class<T> clazz, KryoFactory kryoFactory) {
this(clazz, new KryoPool.Builder(kryoFactory).softReferences().build(), 256);
}