Search in sources :

Example 1 with ResponseHandlerProvider

use of com.canoo.platform.core.http.spi.ResponseHandlerProvider in project dolphin-platform by canoo.

the class HttpClientProvider method createService.

@Override
protected HttpClient createService(ClientConfiguration configuration) {
    final HttpURLConnectionFactory connectionFactory = configuration.getHttpURLConnectionFactory();
    final HttpClientImpl client = new HttpClientImpl(PlatformClient.getService(Gson.class), connectionFactory, configuration);
    final ServiceLoader<RequestHandlerProvider> requestLoader = ServiceLoader.load(RequestHandlerProvider.class);
    final Iterator<RequestHandlerProvider> requestIterator = requestLoader.iterator();
    while (requestIterator.hasNext()) {
        client.addRequestHandler(requestIterator.next().getHandler(configuration));
    }
    final ServiceLoader<ResponseHandlerProvider> responseLoader = ServiceLoader.load(ResponseHandlerProvider.class);
    final Iterator<ResponseHandlerProvider> responseIterator = responseLoader.iterator();
    while (responseIterator.hasNext()) {
        client.addResponseHandler(responseIterator.next().getHandler(configuration));
    }
    return client;
}
Also used : RequestHandlerProvider(com.canoo.platform.core.http.spi.RequestHandlerProvider) ResponseHandlerProvider(com.canoo.platform.core.http.spi.ResponseHandlerProvider) Gson(com.google.gson.Gson) HttpURLConnectionFactory(com.canoo.platform.core.http.HttpURLConnectionFactory)

Aggregations

HttpURLConnectionFactory (com.canoo.platform.core.http.HttpURLConnectionFactory)1 RequestHandlerProvider (com.canoo.platform.core.http.spi.RequestHandlerProvider)1 ResponseHandlerProvider (com.canoo.platform.core.http.spi.ResponseHandlerProvider)1 Gson (com.google.gson.Gson)1