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


Java UnmodifiableCollectionsSerializer类代码示例

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


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

示例1: createKryoInstance

import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer; //导入依赖的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: createKryoInstance

import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer; //导入依赖的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;
}
 
开发者ID:olehmberg,项目名称:T2KMatch,代码行数:23,代码来源:KryoFactory.java

示例3: createKryo

import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer; //导入依赖的package包/类
private Kryo createKryo() {
    Kryo result = new KryoReflectionFactorySupport() {
        
        @Override
        public Serializer<?> getDefaultSerializer(@SuppressWarnings("rawtypes") final Class clazz) {
            if (EnumMap.class.isAssignableFrom(clazz)) {
                return new EnumMapSerializer();
            }
            if (SubListSerializers.ArrayListSubListSerializer.canSerialize(clazz) || SubListSerializers.JavaUtilSubListSerializer.canSerialize(clazz)) {
                return SubListSerializers.createFor(clazz);
            }
            return super.getDefaultSerializer(clazz);
        }
    };
    result.register(Collections.singletonList("").getClass(), new ArraysAsListSerializer());
    UnmodifiableCollectionsSerializer.registerSerializers(result);
    return result;
}
 
开发者ID:terrymanu,项目名称:miracle-remote,代码行数:19,代码来源:PooledKryoFactory.java

示例4: getKryoInstance

import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer; //导入依赖的package包/类
public static Kryo getKryoInstance() {

    Track.pushInfo("CreateKryoInstance");
    try {
      Kryo lKryo = new Kryo();

      //Note: Doco says all strategies are thread safe: http://objenesis.org/tutorial.html
      //Note: This introduces a dependency on the JVMs supported by Objenesis: http://code.google.com/p/objenesis/wiki/ListOfCurrentlySupportedVMs
      lKryo.setInstantiatorStrategy(INSTANTIATOR_STRATEGY);

      //Use the kryo-serializers library to handle unmodifiable collections (not supported by kryo out of the box).
      UnmodifiableCollectionsSerializer.registerSerializers(lKryo);
      lKryo.register(EnumMap.class, new EnumMapSerializer());

      //Register our custom DOM serialiser
      lKryo.register(DOM.class, new DOMSerializer());

      return lKryo;
    }
    finally {
      Track.pop("CreateKryoInstance");
    }
  }
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:24,代码来源:KryoManager.java

示例5: createKryoInstance

import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer; //导入依赖的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

示例6: createKryo

import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer; //导入依赖的package包/类
private Kryo createKryo() {
	Kryo kryo = new KryoReflectionFactorySupport() {
		
		@Override
		public Serializer<?> getDefaultSerializer(@SuppressWarnings("rawtypes") final Class clazz) {
			if (EnumMap.class.isAssignableFrom(clazz)) {
				return new EnumMapSerializer();
			}
			if (SubListSerializers.ArrayListSubListSerializer.canSerialize(clazz) || SubListSerializers.JavaUtilSubListSerializer.canSerialize(clazz)) {
				return SubListSerializers.createFor(clazz);
			}
			return super.getDefaultSerializer(clazz);
		}
	};
	kryo.register(Arrays.asList("").getClass(), new ArraysAsListSerializer());
	UnmodifiableCollectionsSerializer.registerSerializers(kryo);
	return kryo;
}
 
开发者ID:terrymanu,项目名称:miracle-framework,代码行数:19,代码来源:PooledKryoFactory.java

示例7: tryRegister

import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer; //导入依赖的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);
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:12,代码来源:JavaKaffeeSerializersRegistrar.java

示例8: treeNode

import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer; //导入依赖的package包/类
@Test
public void treeNode() {
    final Result<DecisionTreeRuleSet> result = (new CommisionRuleSetSupplier()).get();
    EhSupport.ensure(result.isSuccess(), "Could not create decision tree");
    final DecisionTreeRuleSet ruleSet = result.getData();

    final TreeNode node = DecisionTreeFactory.constructDecisionTree(ruleSet, DecisionTreeType.SINGLE);

    final Kryo kryo = new Kryo();
    // no default no-arg constructors
    kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());

    final InstantiatorStrategy defaultInstantiatorStrategy = new Kryo.DefaultInstantiatorStrategy();
    kryo.getRegistration(ArrayList.class)
            .setInstantiator(defaultInstantiatorStrategy.newInstantiatorOf(ArrayList.class));
    kryo.getRegistration(HashSet.class)
            .setInstantiator(defaultInstantiatorStrategy.newInstantiatorOf(HashSet.class));
    UnmodifiableCollectionsSerializer.registerSerializers(kryo);

    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    final Output output = new Output(out);
    kryo.writeObject(output, node);
    output.flush();
    output.close();

    final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray());
    final Input kryoInput = new Input(inputStream);
    final TreeNode tree = kryo.readObject(kryoInput, BaseTreeNode.class);

    final SingleDecisionTreeFactoryTest test = new SingleDecisionTreeFactoryTest();
    test.checkTreeNode(tree, ruleSet);

    assertEquals(node, tree);
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:35,代码来源:TreeSerializationTest.java

示例9: createKryo

import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer; //导入依赖的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;
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:23,代码来源:KryoSerializer.java

示例10: initialValue

import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer; //导入依赖的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;
    }
 
开发者ID:apache,项目名称:metron,代码行数:33,代码来源:SerDeUtils.java

示例11: registerClasses

import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void registerClasses(Kryo kryo) {
    kryo.register(Cell.class);
    kryo.register(Cells.class);
    kryo.register(IDeepType.class);
    UnmodifiableCollectionsSerializer.registerSerializers(kryo);
}
 
开发者ID:Stratio,项目名称:deep-spark,代码行数:11,代码来源:DeepKryoRegistrator.java

示例12: KryoUtils

import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer; //导入依赖的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

示例13: registerClasses

import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer; //导入依赖的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);
}
 
开发者ID:deeplearning4j,项目名称:nd4j,代码行数:11,代码来源:Nd4jRegistrator.java

示例14: initialize

import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer; //导入依赖的package包/类
/**
 * Initialize and register classes with kryo.
 */
public void initialize() {
    // Register types we know about and do not require external configuration
    kryo.register(ArrayList.class);
    kryo.register(BasicCredentialMetaData.class);
    kryo.register(Class.class, new DefaultSerializers.ClassSerializer());
    kryo.register(Date.class, new DefaultSerializers.DateSerializer());
    kryo.register(HardTimeoutExpirationPolicy.class);
    kryo.register(HashMap.class);
    kryo.register(LinkedHashMap.class);
    kryo.register(HashSet.class);
    kryo.register(DefaultHandlerResult.class);
    kryo.register(ImmutableAuthentication.class);
    kryo.register(MultiTimeUseOrTimeoutExpirationPolicy.class);
    kryo.register(NeverExpiresExpirationPolicy.class);
    kryo.register(RememberMeDelegatingExpirationPolicy.class);
    kryo.register(ServiceTicketImpl.class);
    kryo.register(SimpleWebApplicationServiceImpl.class, new SimpleWebApplicationServiceSerializer());
    kryo.register(ThrottledUseAndTimeoutExpirationPolicy.class);
    kryo.register(TicketGrantingTicketExpirationPolicy.class);
    kryo.register(TicketGrantingTicketImpl.class);
    kryo.register(TimeoutExpirationPolicy.class);
    kryo.register(UsernamePasswordCredential.class);
    kryo.register(SimplePrincipal.class);
    kryo.register(URL.class, new URLSerializer());
    kryo.register(URI.class, new URISerializer());
    kryo.register(Pattern.class, new RegexSerializer());
    kryo.register(UUID.class, new UUIDSerializer());
    kryo.register(EnumMap.class, new EnumMapSerializer());
    kryo.register(EnumSet.class, new EnumSetSerializer());

    // we add these ones for tests only
    kryo.register(RegisteredServiceImpl.class, new RegisteredServiceSerializer());
    kryo.register(RegexRegisteredService.class, new RegisteredServiceSerializer());

    // new serializers to manage Joda dates and immutable collections
    kryo.register(DateTime.class, new JodaDateTimeSerializer());
    kryo.register(CasDelegatingLogger.class, new DefaultSerializers.VoidSerializer());

    // from the kryo-serializers library (https://github.com/magro/kryo-serializers)
    UnmodifiableCollectionsSerializer.registerSerializers(kryo);
    ImmutableListSerializer.registerSerializers(kryo);
    ImmutableSetSerializer.registerSerializers(kryo);
    ImmutableMapSerializer.registerSerializers(kryo);
    ImmutableMultimapSerializer.registerSerializers(kryo);
    
    kryo.register(Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer());
    kryo.register(Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer());
    kryo.register(Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer());

    // Register other types
    if (serializerMap != null) {
        for (final Map.Entry<Class<?>, Serializer> clazz : serializerMap.entrySet()) {
            kryo.register(clazz.getKey(), clazz.getValue());
        }
    }

    // don't reinit the registered classes after every write or read
    kryo.setAutoReset(false);
    // don't replace objects by references
    kryo.setReferences(false);
    // Catchall for any classes not explicitly registered
    kryo.setRegistrationRequired(false);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:67,代码来源:KryoTranscoder.java

示例15: initialize

import de.javakaffee.kryoserializers.UnmodifiableCollectionsSerializer; //导入依赖的package包/类
/**
 * Initialize and register classes with kryo.
 */
public void initialize() {
    // Register types we know about and do not require external configuration
    kryo.register(ArrayList.class);
    kryo.register(BasicCredentialMetaData.class);
    kryo.register(Class.class, new DefaultSerializers.ClassSerializer());
    kryo.register(Date.class, new DefaultSerializers.DateSerializer());
    kryo.register(HardTimeoutExpirationPolicy.class);
    kryo.register(HashMap.class);
    kryo.register(DefaultHandlerResult.class);
    kryo.register(ImmutableAuthentication.class);
    kryo.register(MultiTimeUseOrTimeoutExpirationPolicy.class);
    kryo.register(NeverExpiresExpirationPolicy.class);
    kryo.register(RememberMeDelegatingExpirationPolicy.class);
    kryo.register(ServiceTicketImpl.class);
    kryo.register(SimpleWebApplicationServiceImpl.class, new SimpleWebApplicationServiceSerializer());
    kryo.register(ThrottledUseAndTimeoutExpirationPolicy.class);
    kryo.register(TicketGrantingTicketExpirationPolicy.class);
    kryo.register(TicketGrantingTicketImpl.class);
    kryo.register(TimeoutExpirationPolicy.class);
    kryo.register(URL.class, new URLSerializer());

    // we add these ones for tests only
    kryo.register(RegisteredServiceImpl.class, new RegisteredServiceSerializer());
    kryo.register(RegexRegisteredService.class, new RegisteredServiceSerializer());

    // new serializers to manage Joda dates and immutable collections
    kryo.register(DateTime.class, new JodaDateTimeSerializer());
    kryo.register(CasDelegatingLogger.class, new DefaultSerializers.VoidSerializer());

    // from the kryo-serializers library (https://github.com/magro/kryo-serializers)
    UnmodifiableCollectionsSerializer.registerSerializers(kryo);

    // Register other types
    if (serializerMap != null) {
        for (final Map.Entry<Class<?>, Serializer> clazz : serializerMap.entrySet()) {
            kryo.register(clazz.getKey(), clazz.getValue());
        }
    }

    // don't reinit the registered classes after every write or read
    kryo.setAutoReset(false);
    // don't replace objects by references
    kryo.setReferences(false);
    // Catchall for any classes not explicitly registered
    kryo.setRegistrationRequired(false);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:50,代码来源:KryoTranscoder.java


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