ProtobufRpcMethodInfo extends RpcMethodInfo { public ProtobufRpcMethodInfo(Method method) { super(method); try { this.inputGetDefaultInstanceMethod = ((Class) inputClasses[0]).getMethod("getDefaultInstance"); this.inputInstance = (Message) inputGetDefaultInstanceMethod.invoke(null); this.inputParseFromMethod = ((Class) inputClasses[0]).getMethod("parseFrom", byte[].class); this.outputGetDefaultInstanceMethod = ((Class) outputClass).getMethod("getDefaultInstance"); this.outputInstance = (Message) outputGetDefaultInstanceMethod.invoke(null); this.outputParseFromMethod = ((Class) outputClass).getMethod("parseFrom", byte[].class); } catch (Exception ex) { throw new IllegalArgumentException(ex); } } ProtobufRpcMethodInfo(Method method); @Override byte[] inputEncode(Object input); @Override void inputWriteToStream(Object input, CodedOutputStream stream); @Override Object outputDecode(byte[] output); @Override Object outputDecode(ByteBuf output); @Override Object outputDecode(DynamicCompositeByteBuf output); Object outputDecode(InputStream stream); Object inputDecode(byte[] input); Object inputDecode(byte[] input, int offset, int len); Object inputDecode(ByteBuf input); Object inputDecode(DynamicCompositeByteBuf input); Object inputDecode(InputStream stream); byte[] outputEncode(Object output); @Override void outputWriteToStream(Object output, CodedOutputStream stream); @Override int getInputSerializedSize(Object input); @Override int getOutputSerializedSize(Object output);  }
@Test public void testProtobufRpcMethodInfo() throws Exception { Method method = EchoService.class.getMethod("echo", Echo.EchoRequest.class); ProtobufRpcMethodInfo rpcMethodInfo = new ProtobufRpcMethodInfo(method); Assert.assertTrue(rpcMethodInfo.getInputInstance() != null); Assert.assertTrue(rpcMethodInfo.getInputGetDefaultInstanceMethod() != null); }