Java 类com.esotericsoftware.kryo.io.KryoObjectInput 实例源码

项目:jnetrobust    文件:ProtocolHost.java   
public ProtocolHost(String hostName, Class<T> dataClass, SocketAddress localAddress) throws IOException {
    // setup network communication
    channel = DatagramChannel.open();
    channel.configureBlocking(false);
    channel.socket().bind(localAddress);

    // setup serialization
    kryo = new Kryo();
    kryo.register(Packet.class); // add argument `new ExternalizableSerializer()` if needed
    kryo.register(Metadata.class); // add argument `new ExternalizableSerializer()` if needed
    kryo.register(dataClass);
    objectInput = new KryoObjectInput(kryo, bufferInput);
    objectOutput = new KryoObjectOutput(kryo, bufferOutput);

    this.hostName = hostName;
}
项目:rpc    文件:KryoSerialization.java   
@Override
public <T> T deserialize(byte[] data, Class<T> clz) throws IOException, ClassNotFoundException {
    Kryo kryo = kryoThreadMap.get();
    kryo.register(clz);
    KryoObjectInput input = new KryoObjectInput(kryo, new FastInput(new ByteArrayInputStream(data)));
    return (T) input.readObject();
}