Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Commit

Permalink
Re-arranging basic components. Created port of RestOperations to use …
Browse files Browse the repository at this point in the history
…a Promise-wrapped result for doing async work.
  • Loading branch information
jbrisbin committed Jul 12, 2011
1 parent a77f8f2 commit c114a41
Showing 1 changed file with 34 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ public interface AsyncRestOperations {
* @param uriVariables the variables to expand the template
* @return the converted object
*/
<T> Promise<T> getForObject(String url,
Class<T> responseType,
Object... uriVariables) throws RestClientException;
<T> Promise<T> getForObject(String url, Class<T> responseType, Object... uriVariables) throws RestClientException;

/**
* Retrieve a representation by doing a GET on the URI template.
Expand All @@ -44,9 +42,7 @@ <T> Promise<T> getForObject(String url,
* @param uriVariables the map containing variables for the URI template
* @return the converted object
*/
<T> Promise<T> getForObject(String url,
Class<T> responseType,
Map<String, ?> uriVariables) throws RestClientException;
<T> Promise<T> getForObject(String url, Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException;

/**
* Retrieve a representation by doing a GET on the URL .
Expand All @@ -56,8 +52,7 @@ <T> Promise<T> getForObject(String url,
* @param responseType the type of the return value
* @return the converted object
*/
<T> Promise<T> getForObject(URI url,
Class<T> responseType) throws RestClientException;
<T> Promise<T> getForObject(URI url, Class<T> responseType) throws RestClientException;

/**
* Retrieve an entity by doing a GET on the specified URL.
Expand All @@ -70,8 +65,7 @@ <T> Promise<T> getForObject(URI url,
* @return the entity
* @since 3.0.2
*/
<T> Promise<ResponseEntity<T>> getForEntity(String url,
Class<T> responseType,
<T> Promise<ResponseEntity<T>> getForEntity(String url, Class<T> responseType,
Object... uriVariables) throws RestClientException;

/**
Expand All @@ -85,8 +79,7 @@ <T> Promise<ResponseEntity<T>> getForEntity(String url,
* @return the converted object
* @since 3.0.2
*/
<T> Promise<ResponseEntity<T>> getForEntity(String url,
Class<T> responseType,
<T> Promise<ResponseEntity<T>> getForEntity(String url, Class<T> responseType,
Map<String, ?> uriVariables) throws RestClientException;

/**
Expand All @@ -98,8 +91,7 @@ <T> Promise<ResponseEntity<T>> getForEntity(String url,
* @return the converted object
* @since 3.0.2
*/
<T> Promise<ResponseEntity<T>> getForEntity(URI url,
Class<T> responseType) throws RestClientException;
<T> Promise<ResponseEntity<T>> getForEntity(URI url, Class<T> responseType) throws RestClientException;

// HEAD

Expand All @@ -111,8 +103,7 @@ <T> Promise<ResponseEntity<T>> getForEntity(URI url,
* @param uriVariables the variables to expand the template
* @return all HTTP headers of that resource
*/
Promise<HttpHeaders> headForHeaders(String url,
Object... uriVariables) throws RestClientException;
Promise<HttpHeaders> headForHeaders(String url, Object... uriVariables) throws RestClientException;

/**
* Retrieve all headers of the resource specified by the URI template.
Expand All @@ -122,8 +113,7 @@ Promise<HttpHeaders> headForHeaders(String url,
* @param uriVariables the map containing variables for the URI template
* @return all HTTP headers of that resource
*/
Promise<HttpHeaders> headForHeaders(String url,
Map<String, ?> uriVariables) throws RestClientException;
Promise<HttpHeaders> headForHeaders(String url, Map<String, ?> uriVariables) throws RestClientException;

/**
* Retrieve all headers of the resource specified by the URL.
Expand All @@ -148,9 +138,7 @@ Promise<HttpHeaders> headForHeaders(String url,
* @return the value for the <code>Location</code> header
* @see HttpEntity
*/
Promise<URI> postForLocation(String url,
Object request,
Object... uriVariables) throws RestClientException;
Promise<URI> postForLocation(String url, Object request, Object... uriVariables) throws RestClientException;

/**
* Create a new resource by POSTing the given object to the URI template, and returns the value of the
Expand All @@ -165,9 +153,7 @@ Promise<URI> postForLocation(String url,
* @return the value for the <code>Location</code> header
* @see HttpEntity
*/
Promise<URI> postForLocation(String url,
Object request,
Map<String, ?> uriVariables) throws RestClientException;
Promise<URI> postForLocation(String url, Object request, Map<String, ?> uriVariables) throws RestClientException;

/**
* Create a new resource by POSTing the given object to the URL, and returns the value of the
Expand All @@ -180,8 +166,7 @@ Promise<URI> postForLocation(String url,
* @return the value for the <code>Location</code> header
* @see HttpEntity
*/
Promise<URI> postForLocation(URI url,
Object request) throws RestClientException;
Promise<URI> postForLocation(URI url, Object request) throws RestClientException;

/**
* Create a new resource by POSTing the given object to the URI template,
Expand All @@ -197,9 +182,7 @@ Promise<URI> postForLocation(URI url,
* @return the converted object
* @see HttpEntity
*/
<T> Promise<T> postForObject(String url,
Object request,
Class<T> responseType,
<T> Promise<T> postForObject(String url, Object request, Class<T> responseType,
Object... uriVariables) throws RestClientException;

/**
Expand All @@ -216,9 +199,7 @@ <T> Promise<T> postForObject(String url,
* @return the converted object
* @see HttpEntity
*/
<T> Promise<T> postForObject(String url,
Object request,
Class<T> responseType,
<T> Promise<T> postForObject(String url, Object request, Class<T> responseType,
Map<String, ?> uriVariables) throws RestClientException;

/**
Expand All @@ -233,9 +214,7 @@ <T> Promise<T> postForObject(String url,
* @return the converted object
* @see HttpEntity
*/
<T> Promise<T> postForObject(URI url,
Object request,
Class<T> responseType) throws RestClientException;
<T> Promise<T> postForObject(URI url, Object request, Class<T> responseType) throws RestClientException;

/**
* Create a new resource by POSTing the given object to the URI template,
Expand All @@ -251,9 +230,7 @@ <T> Promise<T> postForObject(URI url,
* @see HttpEntity
* @since 3.0.2
*/
<T> Promise<ResponseEntity<T>> postForEntity(String url,
Object request,
Class<T> responseType,
<T> Promise<ResponseEntity<T>> postForEntity(String url, Object request, Class<T> responseType,
Object... uriVariables) throws RestClientException;

/**
Expand All @@ -270,9 +247,7 @@ <T> Promise<ResponseEntity<T>> postForEntity(String url,
* @see HttpEntity
* @since 3.0.2
*/
<T> Promise<ResponseEntity<T>> postForEntity(String url,
Object request,
Class<T> responseType,
<T> Promise<ResponseEntity<T>> postForEntity(String url, Object request, Class<T> responseType,
Map<String, ?> uriVariables) throws RestClientException;

/**
Expand All @@ -287,9 +262,7 @@ <T> Promise<ResponseEntity<T>> postForEntity(String url,
* @see HttpEntity
* @since 3.0.2
*/
<T> Promise<ResponseEntity<T>> postForEntity(URI url,
Object request,
Class<T> responseType) throws RestClientException;
<T> Promise<ResponseEntity<T>> postForEntity(URI url, Object request, Class<T> responseType) throws RestClientException;

// PUT

Expand All @@ -304,9 +277,7 @@ <T> Promise<ResponseEntity<T>> postForEntity(URI url,
* @param uriVariables the variables to expand the template
* @see HttpEntity
*/
void put(String url,
Object request,
Object... uriVariables) throws RestClientException;
void put(String url, Object request, Object... uriVariables) throws RestClientException;

/**
* Creates a new resource by PUTting the given object to URI template.
Expand All @@ -319,9 +290,7 @@ void put(String url,
* @param uriVariables the variables to expand the template
* @see HttpEntity
*/
void put(String url,
Object request,
Map<String, ?> uriVariables) throws RestClientException;
void put(String url, Object request, Map<String, ?> uriVariables) throws RestClientException;

/**
* Creates a new resource by PUTting the given object to URL.
Expand All @@ -332,8 +301,7 @@ void put(String url,
* @param request the Object to be PUT, may be <code>null</code>
* @see HttpEntity
*/
void put(URI url,
Object request) throws RestClientException;
void put(URI url, Object request) throws RestClientException;

// DELETE

Expand All @@ -344,8 +312,7 @@ void put(URI url,
* @param url the URL
* @param uriVariables the variables to expand in the template
*/
void delete(String url,
Object... uriVariables) throws RestClientException;
void delete(String url, Object... uriVariables) throws RestClientException;

/**
* Delete the resources at the specified URI.
Expand All @@ -354,8 +321,7 @@ void delete(String url,
* @param url the URL
* @param uriVariables the variables to expand the template
*/
void delete(String url,
Map<String, ?> uriVariables) throws RestClientException;
void delete(String url, Map<String, ?> uriVariables) throws RestClientException;

/**
* Delete the resources at the specified URL.
Expand All @@ -374,8 +340,7 @@ void delete(String url,
* @param uriVariables the variables to expand in the template
* @return the value of the allow header
*/
Promise<Set<HttpMethod>> optionsForAllow(String url,
Object... uriVariables) throws RestClientException;
Promise<Set<HttpMethod>> optionsForAllow(String url, Object... uriVariables) throws RestClientException;

/**
* Return the value of the Allow header for the given URI.
Expand All @@ -385,8 +350,7 @@ Promise<Set<HttpMethod>> optionsForAllow(String url,
* @param uriVariables the variables to expand in the template
* @return the value of the allow header
*/
Promise<Set<HttpMethod>> optionsForAllow(String url,
Map<String, ?> uriVariables) throws RestClientException;
Promise<Set<HttpMethod>> optionsForAllow(String url, Map<String, ?> uriVariables) throws RestClientException;

/**
* Return the value of the Allow header for the given URL.
Expand All @@ -411,11 +375,8 @@ Promise<Set<HttpMethod>> optionsForAllow(String url,
* @return the response as entity
* @since 3.0.2
*/
<T> Promise<ResponseEntity<T>> exchange(String url,
HttpMethod method,
HttpEntity<?> requestEntity,
Class<T> responseType,
Object... uriVariables) throws RestClientException;
<T> Promise<ResponseEntity<T>> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
Class<T> responseType, Object... uriVariables) throws RestClientException;

/**
* Execute the HTTP method to the given URI template, writing the given request entity to the request, and
Expand All @@ -430,11 +391,8 @@ <T> Promise<ResponseEntity<T>> exchange(String url,
* @return the response as entity
* @since 3.0.2
*/
<T> Promise<ResponseEntity<T>> exchange(String url,
HttpMethod method,
HttpEntity<?> requestEntity,
Class<T> responseType,
Map<String, ?> uriVariables) throws RestClientException;
<T> Promise<ResponseEntity<T>> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity,
Class<T> responseType, Map<String, ?> uriVariables) throws RestClientException;

/**
* Execute the HTTP method to the given URI template, writing the given request entity to the request, and
Expand All @@ -447,9 +405,7 @@ <T> Promise<ResponseEntity<T>> exchange(String url,
* @return the response as entity
* @since 3.0.2
*/
<T> Promise<ResponseEntity<T>> exchange(URI url,
HttpMethod method,
HttpEntity<?> requestEntity,
<T> Promise<ResponseEntity<T>> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity,
Class<T> responseType) throws RestClientException;

// general execution
Expand All @@ -466,11 +422,8 @@ <T> Promise<ResponseEntity<T>> exchange(URI url,
* @param uriVariables the variables to expand in the template
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
*/
<T> Promise<T> execute(String url,
HttpMethod method,
RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor,
Object... uriVariables) throws RestClientException;
<T> Promise<T> execute(String url, HttpMethod method, RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor, Object... uriVariables) throws RestClientException;

/**
* Execute the HTTP method to the given URI template, preparing the request with the
Expand All @@ -484,11 +437,8 @@ <T> Promise<T> execute(String url,
* @param uriVariables the variables to expand in the template
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
*/
<T> Promise<T> execute(String url,
HttpMethod method,
RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor,
Map<String, ?> uriVariables) throws RestClientException;
<T> Promise<T> execute(String url, HttpMethod method, RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor, Map<String, ?> uriVariables) throws RestClientException;

/**
* Execute the HTTP method to the given URL, preparing the request with the
Expand All @@ -500,9 +450,7 @@ <T> Promise<T> execute(String url,
* @param responseExtractor object that extracts the return value from the response
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
*/
<T> Promise<T> execute(URI url,
HttpMethod method,
RequestCallback requestCallback,
<T> Promise<T> execute(URI url, HttpMethod method, RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor) throws RestClientException;

}

0 comments on commit c114a41

Please sign in to comment.