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;
}
Aggregations