}
/** Called by a server to deserialize a request, compute and serialize
* a response or error. */
public List<ByteBuffer> respond(List<ByteBuffer> buffers) throws IOException {
Decoder in = DecoderFactory.defaultFactory().createBinaryDecoder(
new ByteBufferInputStream(buffers), null);
ByteBufferOutputStream bbo = new ByteBufferOutputStream();
Encoder out = new BinaryEncoder(bbo);
Exception error = null;
RPCContext context = new RPCContext();
try {
Protocol remote = handshake(in, out);
if (remote == null) // handshake failed
return bbo.getBufferList();
// read request using remote protocol specification
context.setRequestCallMeta(META_READER.read(null, in));
String messageName = in.readString(null).toString();
Message m = remote.getMessages().get(messageName);
if (m == null)
throw new AvroRuntimeException("No such remote message: "+messageName);
context.setMessage(m);