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


Java StdInstantiatorStrategy类代码示例

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


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

示例1: createKryoInstance

import org.objenesis.strategy.StdInstantiatorStrategy; //导入依赖的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: create

import org.objenesis.strategy.StdInstantiatorStrategy; //导入依赖的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);

    // 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:shlee89,项目名称:athena,代码行数:27,代码来源:KryoNamespace.java

示例3: forSerialization

import org.objenesis.strategy.StdInstantiatorStrategy; //导入依赖的package包/类
/**
 * Returns a new {@link LogicalPlanSerializer}
 * @param cluster cluster to used during serialization
 */
public static LogicalPlanSerializer forSerialization(final RelOptCluster cluster) {
  final Kryo kryo = new Kryo();
  // use objenesis for creating mock objects
  kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));

  final CalciteCatalogReader catalog = kryo.newInstance(CalciteCatalogReader.class);
  final StoragePluginRegistry registry = kryo.newInstance(StoragePluginRegistryImpl.class);
  final RelSerializer serializer = RelSerializer.newBuilder(kryo, cluster, catalog, registry).build();

  return new LogicalPlanSerializer() {

    @Override
    public byte[] serialize(final RelNode plan) {
      return serializer.serialize(plan);
    }

  };
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:KryoLogicalPlanSerializers.java

示例4: testSerializationRoundTrip

import org.objenesis.strategy.StdInstantiatorStrategy; //导入依赖的package包/类
@Test
@Ignore
public void testSerializationRoundTrip() throws FileNotFoundException {
    // this test to see if can use kryo to serialize RTree instance
    List<Entry<Object, Point>> entries = GreekEarthquakes.entriesList();
    int maxChildren = 8;
    RTree<Object, Point> tree = RTree.maxChildren(maxChildren).<Object, Point> create()
            .add(entries);

    File file = new File("target/greek-serialized.kryo");
    file.delete();

    Kryo kryo = new Kryo();
    Output output = new Output(new FileOutputStream(file));
    kryo.writeObject(output, tree);
    output.close();

    Input input = new Input(new FileInputStream(file));
    kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
    @SuppressWarnings("unchecked")
    RTree<Object, Point> tree2 = kryo.readObject(input, RTree.class);
    assertNotNull(tree2);

}
 
开发者ID:davidmoten,项目名称:rtree-3d,代码行数:25,代码来源:SerializationTest.java

示例5: createKryo

import org.objenesis.strategy.StdInstantiatorStrategy; //导入依赖的package包/类
public Kryo createKryo() {
    Kryo kryo = new Kryo(new DefaultClassResolver(), new MapReferenceResolver() {
        @Override
        public boolean useReferences(Class type) {
            // avoid calling System.identityHashCode
            if (type == String.class || type == Date.class) {
                return false;
            }
            return super.useReferences(type);
        }
    });
    registerClasses(kryo);

    kryo.setAutoReset(true);
    kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));

    return kryo;
}
 
开发者ID:visallo,项目名称:vertexium,代码行数:19,代码来源:KryoFactory.java

示例6: createKryoInstance

import org.objenesis.strategy.StdInstantiatorStrategy; //导入依赖的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

示例7: newClientConfig

import org.objenesis.strategy.StdInstantiatorStrategy; //导入依赖的package包/类
public Config newClientConfig() {
		ThreadLocal<Kryo> kryos =  new ThreadLocal<Kryo>() {
			protected Kryo initialValue() {
				Kryo kryo = new Kryo();
				kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
				customizeKryo(kryo);
				return kryo;
			}
		};
		Config config = new Config();
		config.host = "localhost";
		config.port = 15150;
		config.bindPort = 0;
		config.connectTimeout = 10000;
		config.serialiser = new KryoSerialiser(new SerialiserConfig(), kryos);
		config.udpPeerClass = JavaNetPeer.class;
//		config.udpPeer = new KryoNettyPeer(config);
		config.externalReceiver = message1 ->  message1.process(null);
		config.keepAliveInterval = 700;
		config.getAdditionalConfig(MessageLogProcessor.ProcessorConfig.class).messageLogReceiveFilter = message -> true;
		config.compressBigMessages = true;
		config.autoSplitTooBigMessages = true;

		return (config);
	}
 
开发者ID:klaus7,项目名称:jfastnet,代码行数:26,代码来源:AbstractTest.java

示例8: createKryoInstance

import org.objenesis.strategy.StdInstantiatorStrategy; //导入依赖的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

示例9: read

import org.objenesis.strategy.StdInstantiatorStrategy; //导入依赖的package包/类
/**
 * Utility method to read any object written with
 * {@link #write(Object, DataOutput)}.
 * 
 * @param <T>
 *            type of object
 * @param in
 *            input
 * @return the object
 * @throws IOException
 */
@SuppressWarnings("unchecked")
public static <T> T read(DataInput in) throws IOException {
	final int length = in.readInt();

	final byte[] bytes = new byte[length];
	in.readFully(bytes);

	final Kryo kryo = new Kryo();
	Object obj;
	try {
		obj = kryo.readClassAndObject(new Input(bytes));
	} catch (final KryoException e) {
		kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
		obj = kryo.readClassAndObject(new Input(bytes));
	}
	return (T) obj;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:29,代码来源:IOUtils.java

示例10: tesstByteBuf

import org.objenesis.strategy.StdInstantiatorStrategy; //导入依赖的package包/类
public void tesstByteBuf() throws InterruptedException, IOException {
    ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
    ClassPath from = ClassPath.from(systemClassLoader);
    StdInstantiatorStrategy instantiator = new StdInstantiatorStrategy();

    Class<Request> requestClazz = Request.class;
    for (ClassPath.ClassInfo clazz : from.getAllClasses()) {
        Class<?> load;
        try {
            load = clazz.load();
        } catch (NoClassDefFoundError e) {
            continue;
        }

        for (Class<?> aClass : load.getInterfaces()) {
            if (aClass.equals(requestClazz)) {
                Object o = instantiator.newInstantiatorOf(aClass).newInstance();
                testByteBuf((Request) o);
            }
        }
    }
}
 
开发者ID:buremba,项目名称:kume,代码行数:23,代码来源:SerializationTest.java

示例11: initKryo

import org.objenesis.strategy.StdInstantiatorStrategy; //导入依赖的package包/类
/**
 * 根据所注册的Class,初始化Kryo实例
 * 
 * @return
 */
protected Kryo initKryo() {
	Kryo kryo = new Kryo();
	kryo.setReferences(true); 
	kryo.setRegistrationRequired(true); 
	kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
	Set<Class<?>> keys = propertyMap.keySet();
	for(Class<?> key : keys){
		if(propertyMap.get(key) != null){
			kryo.register(key, propertyMap.get(key));
		} else {
			kryo.register(key);
		}
	}
	
	return kryo;
}
 
开发者ID:yiyongfei,项目名称:jea,代码行数:22,代码来源:AbstractSerializer.java

示例12: _Serialize

import org.objenesis.strategy.StdInstantiatorStrategy; //导入依赖的package包/类
private ByteArrayOutputStream _Serialize(Object obj) throws Exception {
	// TODO Auto-generated method stub
	if(obj instanceof Serializable){
		this.className = obj.getClass();
		Kryo kryo = new Kryo();
		kryo.setReferences(true); 
		kryo.setRegistrationRequired(true); 
		kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
		kryo.register(obj.getClass(), this.serializer);
		kryo.register(this.serializer.getClass());
		Output output = null; 
		ByteArrayOutputStream outStream = new ByteArrayOutputStream();
		try{
			output = new Output(outStream);
			kryo.writeClassAndObject(output, obj);
			output.flush();
			return outStream;
		} finally {
			output.close();
			kryo = null;
		}
	} else {
		throw new Exception("欲序列化的对象请实现Serializable接口");
	}
	
}
 
开发者ID:yiyongfei,项目名称:jea,代码行数:27,代码来源:JavaSerializer.java

示例13: Deserialize

import org.objenesis.strategy.StdInstantiatorStrategy; //导入依赖的package包/类
@Override
public Object Deserialize(byte[] aryByte) throws Exception {
	Kryo kryo = new Kryo();
	kryo.setReferences(true); 
	kryo.setRegistrationRequired(true); 
	kryo.setInstantiatorStrategy(new StdInstantiatorStrategy());
	kryo.register(this.className, this.serializer);
	Input input = null;
       try {
           input = new Input(new ByteArrayInputStream(aryByte));
           Object obj = kryo.readClassAndObject(input);
           return obj;
       } finally {
       	if(input != null){
       		input.close(); 
       	}
       	kryo = null;
       }
}
 
开发者ID:yiyongfei,项目名称:jea,代码行数:20,代码来源:JavaSerializer.java

示例14: readObject

import org.objenesis.strategy.StdInstantiatorStrategy; //导入依赖的package包/类
public static Object readObject(InputStream inputStream) {
  Kryo kryo = new Kryo();
  kryo.register(java.lang.invoke.SerializedLambda.class);
  kryo.register(ClosureSerializer.Closure.class, new ClosureSerializer());
  kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));

  Input input = new Input(inputStream);
  return kryo.readClassAndObject(input);
}
 
开发者ID:spotify,项目名称:hype,代码行数:10,代码来源:SerializationUtil.java

示例15: initialValue

import org.objenesis.strategy.StdInstantiatorStrategy; //导入依赖的package包/类
@Override
protected Kryo initialValue() {

    Kryo kryo = new Kryo();
    kryo.setInstantiatorStrategy(new Kryo.DefaultInstantiatorStrategy(new StdInstantiatorStrategy()));
    return kryo;
}
 
开发者ID:TFdream,项目名称:mango,代码行数:8,代码来源:KryoSerializer.java


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