Package com.esotericsoftware.kryo

Examples of com.esotericsoftware.kryo.Kryo.writeClassAndObject()


    {
      Output output = new Output(1024);
      final AdapterWfLaunchInfo object = new AdapterWfLaunchInfo();
      object.setAdapterName("abc");
      kryo.writeClassAndObject(output, object);
      kryo.writeClassAndObject(output, new LogEvent());
      assertTrue(output.getBuffer().length>0);
     
      Input input = new Input(output.getBuffer());
      assertEquals(AdapterWfLaunchInfo.class, kryo.readClassAndObject(input).getClass());
      assertEquals(LogEvent.class, kryo.readClassAndObject(input).getClass());
View Full Code Here


     
      byte[] bytes = null;
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      Output out = new Output(bos);
      try {
         kryo.writeClassAndObject(out, m);
         out.flush();
         bytes = bos.toByteArray();
         bos.close();
      } catch (IOException e) {
         e.printStackTrace();
View Full Code Here

        Kryo kryo = null;
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            Output output = new Output(baos);
            kryo = kryoPool.get();
            kryo.writeClassAndObject(output, value);
            output.close();
            return baos.toByteArray();
        } catch (Exception e) {
            if (e instanceof RuntimeException) {
                throw (RuntimeException) e;
View Full Code Here

    ByteBuffer buffer = ByteBuffer.allocate(4096);
    Output output = new ByteBufferOutput(buffer);
    Input input = new ByteBufferInput(buffer);
    Class<? extends Serializer> serializer = entryType.getAnnotation(EntryType.class).serializer();
    kryo.register(entryType, serializer.newInstance(), entryType.getAnnotation(EntryType.class) .id());
    kryo.writeClassAndObject(output, entry);
    T result = (T) kryo.readClassAndObject(input);
    Assert.assertEquals(entry, result);
  }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.