Spring Framework HttpMessageConverterExtractor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework HttpMessageConverterExtractor class.

This code example shows how to use the following methods:
   private List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
   private final HttpMessageConverterExtractor<BddErrorMessage> delegate;
 
   RestErrorHandler() { 
      messageConverters.add(new MappingJacksonHttpMessageConverter());
      delegate = new HttpMessageConverterExtractor<BddErrorMessage>(BddErrorMessage.class, messageConverters);
   } 
 
   public boolean hasError(ClientHttpResponse response) throws IOException {
      HttpStatus statusCode = response.getStatusCode();
      if (statusCode.series() == Series.CLIENT_ERROR || statusCode.series() == Series.SERVER_ERROR) {
         return true; 
      } else { 
         return false; 
      } 
   } 
 
   public void handleError(ClientHttpResponse response) throws IOException {
      MediaType contentType = response.getHeaders().getContentType();
      if (contentType.equals(MediaType.APPLICATION_JSON)) {
4
CodeRank
This code example shows how to use the following methods:
 
	@Override 
	public Object decode(final Response response, Type type) throws IOException, FeignException {
		if (type instanceof Class || type instanceof ParameterizedType) {
            @SuppressWarnings({ "unchecked", "rawtypes" }) 
            HttpMessageConverterExtractor<?> extractor = new HttpMessageConverterExtractor(
                    type, messageConverters.getConverters());
 
            return extractor.extractData(new FeignResponseAdapter(response));
        } 
		throw new DecodeException("type is not an instance of Class or ParameterizedType: " + type);
	} 
 
    private class FeignResponseAdapter implements ClientHttpResponse {
		private final Response response;
 
		private FeignResponseAdapter(Response response) {
			this.response = response;
		} 
 
3
CodeRank
This code example shows how to use the following methods:
public class VndErrorResponseErrorHandler extends DefaultResponseErrorHandler { 
 
	private ResponseExtractor<VndErrors> errorExtractor; 
 
	public VndErrorResponseErrorHandler(List<HttpMessageConverter<?>> messageConverters) { 
		errorExtractor = new HttpMessageConverterExtractor<VndErrors>(VndErrors.class, messageConverters); 
	} 
 
	@Override 
	public void handleError(ClientHttpResponse response) throws IOException { 
		VndErrors error = null; 
		try { 
			error = errorExtractor.extractData(response); 
		} 
		catch (Exception e) { 
			super.handleError(response); 
		} 
		throw new SpringXDException(error); 
	} 
} 
4
CodeRank