@RequestMapping(value = "testLocal", method = RequestMethod.POST)
public Object testLocalService(
@RequestParam(value = "routerRule", required = true) String routerRule,
@RequestBody GrpcServiceTestModel model) throws ClassNotFoundException {
try {
Class<?> requestClass = ReflectUtils.name2class(model.getParameterType());
Object request = gson.fromJson(model.getParameter(), requestClass);
Object[] args = new Object[] {request};
if (StringUtils.isNotBlank(routerRule)) {
RpcContext.getContext().setAttachment("routerRule", routerRule);
} else {
RpcContext.getContext().removeAttachment("routerRule");
}
Object reply =
genricService.$invoke(model.getService(), getAnnotation(model.getService()).getLeft(),
getAnnotation(model.getService()).getRight(), model.getMethod(), args);
return reply;
} catch (ClassNotFoundException e) {
throw e;
}
}