use of core.framework.http.HTTPClient in project core-ng-project by neowu.
the class APIConfig method httpClient.
private HTTPClient httpClient() {
if (state.httpClient == null) {
HTTPClient httpClient = new HTTPClientBuilder().userAgent("APIClient").timeout(state.timeout).slowOperationThreshold(state.slowOperationThreshold).build();
context.shutdownHook.add(httpClient::close);
state.httpClient = httpClient;
}
return state.httpClient;
}
use of core.framework.http.HTTPClient in project core-ng-project by neowu.
the class APIConfig method client.
public <T> APIClientConfig client(Class<T> serviceInterface, String serviceURL) {
logger.info("create api service client, interface={}, serviceURL={}", serviceInterface.getCanonicalName(), serviceURL);
RequestBeanMapper requestBeanMapper = context.httpServer.handler.requestBeanMapper;
new WebServiceInterfaceValidator(serviceInterface, requestBeanMapper, context.httpServer.handler.responseBeanTypeValidator).validate();
HTTPClient httpClient = httpClient();
WebServiceClient webServiceClient = new WebServiceClient(serviceURL, httpClient, requestBeanMapper, context.logManager);
T client = createWebServiceClient(serviceInterface, webServiceClient);
context.beanFactory.bind(serviceInterface, null, client);
return new APIClientConfig(webServiceClient);
}
Aggregations