当前位置: 首页>>代码示例>>Java>>正文


Java KryoPool类代码示例

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


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

示例1: serialize

import com.esotericsoftware.kryo.pool.KryoPool; //导入依赖的package包/类
public ByteBuf serialize(Registry registry, ByteBufAllocator bufAllocator, Object value) throws Exception {
  Objects.requireNonNull(value);
  KryoPool kryoPool = registry.get(KryoPool.class);
  Kryo kryo = kryoPool.borrow();
  try {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    Output output = new Output(stream);
    kryo.writeClassAndObject(output, value);
    output.close();
    byte[] bytes = stream.toByteArray();
    String encoded = ENCODER.encodeToString(bytes);
    return ByteBufUtil.encodeString(bufAllocator, CharBuffer.wrap(encoded), CharsetUtil.UTF_8);
  } catch (Exception ex) {
    throw ex;
  } finally {
    kryoPool.release(kryo);
  }
}
 
开发者ID:zedar,项目名称:ratpack-examples,代码行数:19,代码来源:KryoValueSerializer.java

示例2: deserialize

import com.esotericsoftware.kryo.pool.KryoPool; //导入依赖的package包/类
public Object deserialize(Registry registry, String value) throws Exception {
  if (value == null || value.isEmpty()) {
    return null;
  }
  KryoPool kryoPool = registry.get(KryoPool.class);
  Kryo kryo = kryoPool.borrow();
  try {
    byte[] bytes = DECODER.decode(value);
    ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
    Input input = new Input(stream);
    Object obj = kryo.readClassAndObject(input);
    input.close();
    return obj;
  } catch (Exception ex) {
    throw ex;
  } finally {
    kryoPool.release(kryo);
  }
}
 
开发者ID:zedar,项目名称:ratpack-examples,代码行数:20,代码来源:KryoValueSerializer.java

示例3: getKryoPoolInstance

import com.esotericsoftware.kryo.pool.KryoPool; //导入依赖的package包/类
public static KryoPool getKryoPoolInstance() {
    if (poolFactory == null) {
        synchronized (KryoPoolFactory.class) {
            if (poolFactory == null) {
                poolFactory = new KryoPoolFactory();
            }
        }
    }
    return poolFactory.getPool();
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:11,代码来源:KryoPoolFactory.java

示例4: KryoMessageSerialization

import com.esotericsoftware.kryo.pool.KryoPool; //导入依赖的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();
}
 
开发者ID:Telecooperation,项目名称:assistance-platform-server,代码行数:14,代码来源:KryoMessageSerialization.java

示例5: onCreate

import com.esotericsoftware.kryo.pool.KryoPool; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    mRequestQueue = Volley.newRequestQueue(this);
    onSharedPreferenceKeyChangedListeners = new LinkedList<>();
    pauseableListeners = new LinkedList<>();
    keyModificationCounts = new HashMap<>();
    kryoPool = new KryoPool.Builder(new KryoUtil.KryoRegistrationFactory()).softReferences().build();

    calendarEvents = new TreeSet<>();
    loadedCalendarDataSources = EnumSet.noneOf(DataSource.class);
    runningCalendarAsyncTasks = Collections.synchronizedSet(new HashSet<RetrieveCalendarDataAsyncTask>());

    directoryData = new ConcurrentHashMap<>();
    runningDirectoryAsyncTasks = Collections.synchronizedSet(new HashSet<DirectoryAsyncTask>());

    newsData = new ConcurrentHashMap<>();
    runningNewsAsyncTasks = Collections.synchronizedSet(new HashSet<NewsParsingAsyncTask>());

    SharedPreferences sharedPreferences = PreferenceUtils.getSharedPreferences(this);
    sharedPreferences.registerOnSharedPreferenceChangeListener(this);

    setupFirebaseTopics();
    setUpCalendarParsing();
    setUpNewsParsing();
    setUpDirectoryParsing();
    enableHttpResponseCache();
}
 
开发者ID:Pattonville-App-Development-Team,项目名称:Android-App,代码行数:29,代码来源:PattonvilleApplication.java

示例6: getPool

import com.esotericsoftware.kryo.pool.KryoPool; //导入依赖的package包/类
private KryoPool getPool() {
  Preconditions.checkState(factory != null || factoryType != null, "KryFactory not initialized");
  if (factory == null) {
    return pools.computeIfAbsent(factoryType,
        ft -> new KryoPool.Builder(getFactory(ft)).softReferences().build());
  } else {
    return pools.computeIfAbsent(factory.getClass().getName(),
        ft -> new KryoPool.Builder(factory).softReferences().build());
  }
}
 
开发者ID:apache,项目名称:fluo-recipes,代码行数:11,代码来源:KryoSimplerSerializer.java

示例7: KryoMessageConverter

import com.esotericsoftware.kryo.pool.KryoPool; //导入依赖的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));
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:13,代码来源:KryoMessageConverter.java

示例8: provideKryoPool

import com.esotericsoftware.kryo.pool.KryoPool; //导入依赖的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;
}
 
开发者ID:zedar,项目名称:ratpack-examples,代码行数:16,代码来源:KryoSerializerModule.java

示例9: KryoUtils

import com.esotericsoftware.kryo.pool.KryoPool; //导入依赖的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();
}
 
开发者ID:apache,项目名称:reef,代码行数:13,代码来源:KryoUtils.java

示例10: getPool

import com.esotericsoftware.kryo.pool.KryoPool; //导入依赖的package包/类
public KryoPool getPool() {
    return pool;
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:4,代码来源:KryoPoolFactory.java

示例11: KryoCodecServiceImpl

import com.esotericsoftware.kryo.pool.KryoPool; //导入依赖的package包/类
public KryoCodecServiceImpl(KryoPool pool) {
    this.pool = pool;
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:4,代码来源:KryoCodecServiceImpl.java

示例12: KryoSerialize

import com.esotericsoftware.kryo.pool.KryoPool; //导入依赖的package包/类
public KryoSerialize(final KryoPool pool) {
    this.pool = pool;
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:4,代码来源:KryoSerialize.java

示例13: MessageDecoder

import com.esotericsoftware.kryo.pool.KryoPool; //导入依赖的package包/类
public MessageDecoder(Class<?> clazz){
    this.clazz = clazz;
    pool = new KryoPool.Builder(new MyKryoFactory()).build();
}
 
开发者ID:islittlechen,项目名称:lionrpc,代码行数:5,代码来源:MessageDecoder.java

示例14: MessageEncoder

import com.esotericsoftware.kryo.pool.KryoPool; //导入依赖的package包/类
public MessageEncoder(Class<?> clazz){
    this.clazz = clazz;
    pool = new KryoPool.Builder(new MyKryoFactory()).build();
}
 
开发者ID:islittlechen,项目名称:lionrpc,代码行数:5,代码来源:MessageEncoder.java

示例15: KryoCodecUtil

import com.esotericsoftware.kryo.pool.KryoPool; //导入依赖的package包/类
public KryoCodecUtil(KryoPool pool) {
    this.pool = pool;
}
 
开发者ID:craware,项目名称:webapp-tyust,代码行数:4,代码来源:KryoCodecUtil.java


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