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


Java FSTConfiguration.createDefaultConfiguration方法代码示例

本文整理汇总了Java中org.nustaq.serialization.FSTConfiguration.createDefaultConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java FSTConfiguration.createDefaultConfiguration方法的具体用法?Java FSTConfiguration.createDefaultConfiguration怎么用?Java FSTConfiguration.createDefaultConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.nustaq.serialization.FSTConfiguration的用法示例。


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

示例1: createFSTConfiguration

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
public static FSTConfiguration createFSTConfiguration() {
	final FSTConfiguration result = FSTConfiguration.createDefaultConfiguration();
	result.registerClass(Landscape.class);
	result.registerClass(System.class);
	result.registerClass(NodeGroup.class);
	result.registerClass(Node.class);
	result.registerClass(Communication.class);
	result.registerClass(CommunicationTileAccumulator.class);
	result.registerClass(CommunicationAccumulator.class);
	result.registerClass(Application.class);
	result.registerClass(ELanguage.class);
	result.registerClass(Component.class);
	result.registerClass(Clazz.class);
	result.registerClass(RuntimeInformation.class);
	result.registerClass(DatabaseQuery.class);
	result.registerClass(CommunicationClazz.class);
	result.registerClass(Point.class);

	return result;
}
 
开发者ID:ExplorViz,项目名称:explorviz-backend,代码行数:21,代码来源:RepositoryStorage.java

示例2: getFST

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
public static FSTConfiguration getFST() {
  if (fst != null) {
    return fst;
  }
  FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();
  conf.registerClass(
      Project.class,
      ProjectDependency.class,
      GradleProject.class,
      MavenProject.class,
      MeghanadaProject.class,
      ParameterName.class,
      MethodParameterNames.class,
      Scope.class,
      LineRange.class,
      Position.class,
      Variable.class,
      Range.class,
      Source.class,
      MethodParameter.class,
      ClassIndex.class,
      MemberDescriptor.class);
  fst = conf;
  return fst;
}
 
开发者ID:mopemope,项目名称:meghanada-server,代码行数:26,代码来源:Serializer.java

示例3: main

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();

    SomeMediumClass mediumClass = new SomeMediumClass();
    byte barray[] = conf.asByteArray(mediumClass);
    System.out.println(barray.length);
    SomeMediumClass object = (SomeMediumClass)conf.asObject(barray);
    System.out.println(object);


    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    FSTObjectOutput output = new FSTObjectOutput(outputStream);
    output.writeObject(mediumClass);
    output.close();

    FSTObjectInput input = new FSTObjectInput(new ByteArrayInputStream(outputStream.toByteArray()));
    object = (SomeMediumClass)input.readObject(SomeMediumClass.class);
    System.out.println(object);
}
 
开发者ID:chuidiang,项目名称:chuidiang-ejemplos,代码行数:20,代码来源:FstExample.java

示例4: main

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    FSTConfiguration config = FSTConfiguration.createDefaultConfiguration();
    FSTObjectOutput out = config.getObjectOutput();
    out.writeObject("foobar");
    byte[] savedBuffer = out.getCopyOfWrittenBuffer();
    byte[] reallySavedBuffer = Arrays.copyOf(savedBuffer, savedBuffer.length);

    System.out.println(Arrays.equals(savedBuffer, reallySavedBuffer));

    out.resetForReUse();
    out.writeObject("blah");
    byte[] secondBuffer = out.getCopyOfWrittenBuffer();

    System.out.println(Arrays.equals(savedBuffer, reallySavedBuffer));

    config.getObjectInput(savedBuffer);
    config.getObjectInputCopyFrom(secondBuffer, 0, secondBuffer.length);
    System.out.println(Arrays.equals(savedBuffer, reallySavedBuffer));
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:20,代码来源:Issue91.java

示例5: testStreamReuse

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
@Test
public void testStreamReuse() throws Exception {
    FSTConfiguration configuration = FSTConfiguration.createDefaultConfiguration();

    String expected = "Hello, World!";
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    FSTObjectOutput fstObjectOutput = configuration.getObjectOutput(baos);
    try {
        fstObjectOutput.writeObject(expected);
    } finally {
        fstObjectOutput.flush();
    }
    byte[] serializedData = baos.toByteArray();
    FSTObjectInput input = configuration.getObjectInput(new ByteArrayInputStream(serializedData));
    Object read = input.readObject();
    Assert.assertEquals(expected, read);

    FSTObjectInput secondInput = configuration.getObjectInput(new ByteArrayInputStream(new byte[0]));
    expectedException.expect(IOException.class);
    expectedException.expectMessage("Failed to read");
    secondInput.readObject();
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:23,代码来源:BasicReuseTest.java

示例6: test

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
@Test
@Ignore
public void test() throws Throwable {
    FSTConfiguration fc = FSTConfiguration.createDefaultConfiguration();

    byte[] b;
    int len;
    try (FSTObjectOutput foo = new FSTObjectOutput(fc)) {
        foo.writeObject(new Outer());
        b = foo.getBuffer();
        len = foo.getWritten();
    }
    ByteArrayInputStream bais = new ByteArrayInputStream(b, 0, len);
    FSTObjectInput foi = fc.getObjectInput(bais);
    foi.readObject();
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:17,代码来源:OverflowTest.java

示例7: testReadResolve

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
@Test
public void testReadResolve() throws Exception {
    FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();

    Holder holder = new Holder();
    holder.o = new ToRead("foo");
    holder.o2 = holder.o;

    byte[] b = null;
    FSTObjectOutput out = new FSTObjectOutput(conf);
    out.writeObject(holder);
    out.flush();
    b = out.getBuffer();

    FSTObjectInput in = new FSTObjectInput(conf);
    in.resetForReuseUseArray(b,b.length);
    Object res = in.readObject();

    checkEquals(Holder.class, res.getClass());
    checkEquals(String.class, ((Holder) res).o.getClass());
    checkEquals("foo", ((Holder) res).o);

    checkEquals(String.class, ((Holder) res).o2.getClass());
    checkEquals("foo", ((Holder) res).o2);
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:26,代码来源:ReadResolve.java

示例8: testHM

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
@Test
public void testHM() throws IOException, ClassNotFoundException {
    FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();
    HashMap hm = createHM();
    HashMap hm1 = createHM1(hm);
    FSTObjectOutput oo = conf.getObjectOutput();
    oo.writeObject(hm);
    oo.writeObject(hm1);
    byte[] copyOfWrittenBuffer = oo.getCopyOfWrittenBuffer();

    FSTObjectInput in = conf.getObjectInput(copyOfWrittenBuffer);
    Object o1 = in.readObject();
    Object o2 = in.readObject();
    Assert.assertTrue(DeepEquals.deepEquals(o1,hm));
    Assert.assertTrue(DeepEquals.deepEquals(o2,hm1));
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:17,代码来源:BigObjTest.java

示例9: test

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
    // install BouncyCastle provider
    Security.addProvider(new BouncyCastleProvider());

    // generate a keypair
    KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA", "BC");
    RSAKeyGenParameterSpec params = new RSAKeyGenParameterSpec(STRENGTH, PUBLIC_EXP);
    gen.initialize(params, new SecureRandom());
    KeyPair keyPair = gen.generateKeyPair();

    FSTConfiguration fst = FSTConfiguration.createDefaultConfiguration();

    // serialize
    byte[] serialized = fst.asByteArray(keyPair);

    // deserialize --> crash
    KeyPair deserialized = (KeyPair) fst.asObject(serialized);
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:20,代码来源:I52.java

示例10: createCodec

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
@Override
public Codec<T> createCodec() {
    Class<?>[] preRegister;

    if (knownTypes == null || knownTypes.isEmpty()) {
        preRegister = null;
    } else {
        preRegister = new TreeMap<>(knownTypes).values().toArray(new Class[knownTypes.size()]);
    }

    FSTConfiguration cfg;

    if (useUnsafe) {
        cfg = FSTConfiguration.createUnsafeBinaryConfiguration();
    } else {
        cfg = FSTConfiguration.createDefaultConfiguration();
    }

    if (preRegister != null) {
        for (Class<?> type : preRegister) {
            cfg.registerClass(type);
        }
    }

    if (sharedReferences != null) {
        cfg.setShareReferences(sharedReferences);
    }

    return newCodec(cfg);
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:31,代码来源:FstCodecFactory.java

示例11: FileAccessor

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
/**
 * Constructs a FileAccessor object with the default file path to store contents on disk
 */
public FileAccessor()
{
	memoryPath = DEFAULT_MEMORY_FILE_PATH;
	memoryExtension = DEFAULT_MEMORY_FILE_EXTENSION;
	memoryFolder = new File(memoryPath);

	try
	{
		if(!memoryFolder.exists())
		{
			memoryFolder.mkdir();
		}

		memoryInstance = findMemoryInstance();
	}
	catch(Exception e)
	{
		e.printStackTrace();
		System.exit(-1);
	}
	
	if(fstConfiguration == null)
	{
		fstConfiguration = FSTConfiguration.createDefaultConfiguration();
	}

}
 
开发者ID:dselent,项目名称:BigArrayList,代码行数:31,代码来源:FileAccessor.java

示例12: initFST

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
/**
 * Initializes the delegate serializer
 */
private void initFST() {
    fastSerialConfig = FSTConfiguration.createDefaultConfiguration();
    if(classes != null) {
        fastSerialConfig.registerClass(classes);
    }
}
 
开发者ID:numenta,项目名称:htm.java,代码行数:10,代码来源:SerializerCore.java

示例13: testUnshared

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
@Test
public void testUnshared() {
    Set<Long> obj = new LinkedHashSet<>();
    obj.add(11373L);
    FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();
    conf.setShareReferences(false);
    conf.registerSerializer(LinkedHashSet.class,new FSTCollectionSerializer(),true);
    byte[] bytes = conf.asByteArray(obj);
    Object o = conf.asObject(bytes);
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:11,代码来源:Git67.java

示例14: FSTSerializer

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
/**
 * Create a FST serializer (faster and more efficient than Java default serialization).
 * 
 * @param useUnsafe <code>true</code> to use <code>sun.misc.Unsafe</code> class, otherwise, a fallback is
 *            used.
 * @param securityProvider the security provider, needed to decode key pairs correctly
 */
public FSTSerializer(boolean useUnsafe, ISecurityClassProvider securityProvider) {
	if (!useUnsafe) {
		// don't use sun.misc.Unsafe class
		FSTUtil.unFlaggedUnsafe = null;
		logger.debug("Disabled the use of 'sun.misc.Unsafe' for the serialization");
	}

	fst = FSTConfiguration.createDefaultConfiguration();

	// register all often serialized classes for speedup. Note that every peer should have the same
	// configuration, which also depends on the order! Changing these registrations might break backward
	// compatibility!
	fst.registerClass(UserProfile.class, FolderIndex.class, FileIndex.class, UserPermission.class, Locations.class,
			UserPublicKey.class, MetaFileSmall.class, MetaFileLarge.class, FileVersion.class, MetaChunk.class,
			Chunk.class, EncryptedNetworkContent.class, ContactPeerMessage.class, ResponseMessage.class);

	// for all public / private keys for full compatibility among multiple security providers
	fst.registerClass(securityProvider.getRSAPublicKeyClass(), securityProvider.getRSAPrivateKeyClass(),
			securityProvider.getRSAPrivateCrtKeyClass());

	// for performance improvements, native TomP2P classes which are serialized quite often
	fst.registerClass(PeerAddress.class, PeerSocketAddress.class, Number160.class);

	// Since PeerAddresses are serialized very often, this is just an efficiency improvement
	fst.registerSerializer(PeerAddress.class, new FSTPeerAddressSerializer(), false);

	// register the acceptance reply enum
	fst.registerClass(AcceptanceReply.class);
}
 
开发者ID:Hive2Hive,项目名称:Hive2Hive,代码行数:37,代码来源:FSTSerializer.java

示例15: test

import org.nustaq.serialization.FSTConfiguration; //导入方法依赖的package包/类
@Test
public void test() throws IOException {
    FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();
    Object[] x = { Duration.ofDays(1), Duration.ofDays(2) };
    Object[] res = (Object[]) conf.asObject(conf.asByteArray(x));
    Assert.assertTrue( x[0].equals(res[0]) && x[1].equals(res[1]));
}
 
开发者ID:RuedigerMoeller,项目名称:fast-serialization,代码行数:8,代码来源:I177.java


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