Results 1 to 7 of 7

Thread: RestTemplate and generics

Threaded View

  1. #1
    Join Date
    Dec 2011
    Posts
    10

    Default RestTemplate and generics

    This issue was resolved in Spring 3.2 https://jira.springsource.org/browse/SPR-7023 but it wasn't ported to spring for android. To clarify, it isn't possibile to do something like this at the moment using the version of RestTemplate in spring for android

    Code:
    ResponseEntity<MyWrapper<SomeType>> response = restTemplate.exchange(...)
    It's possible in Spring 3.2

    Code:
    public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
    			ParameterizedTypeReference<T> responseType, Map<String, ?> uriVariables) throws RestClientException {
    
    		Type type = responseType.getType();
    		HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, type);
    		ResponseEntityResponseExtractor<T> responseExtractor = new ResponseEntityResponseExtractor<T>(type);
    		return execute(url, method, requestCallback, responseExtractor, uriVariables);
    	}
    Is it possible to port the Spring 3.2 code as is to Android? or if not, what workaround could I use?
    Last edited by alexmaz; Feb 1st, 2013 at 09:43 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •