Search in sources :

Example 1 with HTTPClient

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;
}
Also used : HTTPClientBuilder(core.framework.http.HTTPClientBuilder) HTTPClient(core.framework.http.HTTPClient)

Example 2 with 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);
}
Also used : HTTPClient(core.framework.http.HTTPClient) RequestBeanMapper(core.framework.impl.web.bean.RequestBeanMapper) WebServiceInterfaceValidator(core.framework.impl.web.service.WebServiceInterfaceValidator) WebServiceClient(core.framework.impl.web.service.WebServiceClient)

Aggregations

HTTPClient (core.framework.http.HTTPClient)2 HTTPClientBuilder (core.framework.http.HTTPClientBuilder)1 RequestBeanMapper (core.framework.impl.web.bean.RequestBeanMapper)1 WebServiceClient (core.framework.impl.web.service.WebServiceClient)1 WebServiceInterfaceValidator (core.framework.impl.web.service.WebServiceInterfaceValidator)1