當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。