Invocation是远程调用过程的抽象类,了解其数据结构很有必要
1.总体属性概览
1.1 Invocation的构建
以客户端调用为例,使用ConsumerMethodModel作为参数进行赋值
public static Invocation buildInvocation(ConsumerMethodModel methodModel, Object... args) {
String serviceUniqueName = methodModel.getUniqueName();
String methodName = methodModel.getMethodName();
args = null == args ? new Object[0] : args;
String[] parameterTypes = methodModel.getParameterTypes();
Invocation invocation = new Invocation();
invocation.setTargetServiceUniqueName(serviceUniqueName);
invocation.setMethodName(methodName);
invocation.setMethodArgSigs(parameterTypes);
invocation.setMethodArgs(args);
invocation.setReturnClass(methodModel.getReturnClass());
invocation.setParameterClasses(methodModel.getParameterClasses());
invocation.getClientInvocationContext().setMethodModel(methodModel);
return invocation;
}
1.2 HSFRequest
Invocation大部分属性的赋值都是HSFRequest对象的代理
public byte getSerializeType() {
return this.hsfRequest.getSerializeType();
}
public void setSerializeType(byte serializeType) {
this.hsfRequest.setSerializeType(serializeType);
}
public String getTargetServiceUniqueName() {
return this.hsfRequest.getTargetServiceUniqueName();
}
public void setTargetServiceUniqueName(String targetServiceUniqueName) {
this.hsfRequest.setTargetServiceUniqueName(targetServiceUniqueName);
}
//...
1.3 ClientInvocationContext
Client端远程调用上下文,将ConsumerMethodModel作为变量传入作为上下参数
public static class ClientInvocationContext {
private ConsumerMethodModel methodModel;
public ClientInvocationContext() {
}
public ConsumerMethodModel getMethodModel() {
return this.methodModel;
}
public void setMethodModel(ConsumerMethodModel methodModel) {
this.methodModel = methodModel;
}
public boolean isConsistentEnable() {
ServiceMetadata metadata = this.methodModel.getMetadata();
if (metadata == null) {
return false;
} else {
String consistent = metadata.getConsistent();
return null != consistent && !consistent.equals(Boolean.FALSE.toString());
}
}
}
网友评论