共计 971 个字符,预计需要花费 3 分钟才能阅读完成。
Consumer 的 rest client
consumer 发送申请,次要是用 Spring 的 RestTemplate,ServiceComb 做了一层包装,兼容 ServiceComb 格局的 uri,如 cse://business/business/v1/channel/news/subscribe。包装类次要的类图如下,
以 servicecomb-java-chassis 我的项目下的 demo 例子,
如下是把 cse:// 格局的 uri 调用过程中要害办法,
class ConsumerMain:
new Consumer().invokeBusiness("cse://business/business/v1", new ChannelRequestBase());
...
class Consumer:
ResponseEntity<AppClientDataRsp> response = template.postForEntity(url, entity, AppClientDataRsp.class);
...
class RestTemplateWrapper:
getRestTemplate(url).postForEntity(url, request, responseType, uriVariables);
...
class RestTemplate:
(ResponseEntity)nonNull(this.execute(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables));
this.getUriTemplateHandler().expand(url, uriVariables);
...
abstract class AbstractUriTemplateHandler:
public URI expand(String uriTemplate, Object... uriVariables) {URI url = this.expandInternal(uriTemplate, uriVariables);
return this.insertBaseUrl(url);
}
...
class CseUriTemplateHandler:
createUri(uriTemplate, uriComponents);
正文完