diff --git a/spring-web/src/main/java/org/springframework/web/client/RequestCallback.java b/spring-web/src/main/java/org/springframework/web/client/RequestCallback.java
index 9c4f3dff2d6..dd03761459c 100644
--- a/spring-web/src/main/java/org/springframework/web/client/RequestCallback.java
+++ b/spring-web/src/main/java/org/springframework/web/client/RequestCallback.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,14 +17,21 @@
package org.springframework.web.client;
import java.io.IOException;
+import java.lang.reflect.Type;
import org.springframework.http.client.ClientHttpRequest;
/**
- * Callback interface for code that operates on a {@link ClientHttpRequest}. Allows to manipulate the request
- * headers, and write to the request body.
+ * Callback interface for code that operates on a {@link ClientHttpRequest}.
+ * Allows manipulating the request headers, and write to the request body.
*
- *
Used internally by the {@link RestTemplate}, but also useful for application code.
+ *
Used internally by the {@link RestTemplate}, but also useful for
+ * application code. There several available factory methods:
+ *
+ * - {@link RestTemplate#acceptHeaderRequestCallback(Class)}
+ *
- {@link RestTemplate#httpEntityCallback(Object)}
+ *
- {@link RestTemplate#httpEntityCallback(Object, Type)}
+ *
*
* @author Arjen Poutsma
* @see RestTemplate#execute
diff --git a/spring-web/src/main/java/org/springframework/web/client/ResponseExtractor.java b/spring-web/src/main/java/org/springframework/web/client/ResponseExtractor.java
index e77e6c91b1c..02a27812ef2 100644
--- a/spring-web/src/main/java/org/springframework/web/client/ResponseExtractor.java
+++ b/spring-web/src/main/java/org/springframework/web/client/ResponseExtractor.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 the original author or authors.
+ * Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
package org.springframework.web.client;
import java.io.IOException;
+import java.lang.reflect.Type;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.lang.Nullable;
@@ -27,7 +28,9 @@ import org.springframework.lang.Nullable;
* from a {@link ClientHttpResponse}, but don't need to worry about exception
* handling or closing resources.
*
- * Used internally by the {@link RestTemplate}, but also useful for application code.
+ *
Used internally by the {@link RestTemplate}, but also useful for
+ * application code. There is one available factory method, see
+ * {@link RestTemplate#responseEntityExtractor(Type)}.
*
* @author Arjen Poutsma
* @since 3.0
diff --git a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java
index 485db649b65..2aaa67fd158 100644
--- a/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java
+++ b/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java
@@ -673,6 +673,17 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
// general execution
+ /**
+ * {@inheritDoc}
+ *
To provide a {@code RequestCallback} or {@code ResponseExtractor} only,
+ * but not both, consider using:
+ *
+ * - {@link #acceptHeaderRequestCallback(Class)}
+ *
- {@link #httpEntityCallback(Object)}
+ *
- {@link #httpEntityCallback(Object, Type)}
+ *
- {@link #responseEntityExtractor(Type)}
+ *
+ */
@Override
@Nullable
public T execute(String url, HttpMethod method, @Nullable RequestCallback requestCallback,
@@ -682,6 +693,17 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
return doExecute(expanded, method, requestCallback, responseExtractor);
}
+ /**
+ * {@inheritDoc}
+ * To provide a {@code RequestCallback} or {@code ResponseExtractor} only,
+ * but not both, consider using:
+ *
+ * - {@link #acceptHeaderRequestCallback(Class)}
+ *
- {@link #httpEntityCallback(Object)}
+ *
- {@link #httpEntityCallback(Object, Type)}
+ *
- {@link #responseEntityExtractor(Type)}
+ *
+ */
@Override
@Nullable
public T execute(String url, HttpMethod method, @Nullable RequestCallback requestCallback,
@@ -692,6 +714,17 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
return doExecute(expanded, method, requestCallback, responseExtractor);
}
+ /**
+ * {@inheritDoc}
+ * To provide a {@code RequestCallback} or {@code ResponseExtractor} only,
+ * but not both, consider using:
+ *
+ * - {@link #acceptHeaderRequestCallback(Class)}
+ *
- {@link #httpEntityCallback(Object)}
+ *
- {@link #httpEntityCallback(Object, Type)}
+ *
- {@link #responseEntityExtractor(Type)}
+ *
+ */
@Override
@Nullable
public T execute(URI url, HttpMethod method, @Nullable RequestCallback requestCallback,
@@ -770,34 +803,38 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
}
/**
- * Returns a request callback implementation that prepares the request {@code Accept}
- * headers based on the given response type and configured
- * {@linkplain #getMessageConverters() message converters}.
+ * Return a {@code RequestCallback} that sets the request {@code Accept}
+ * header based on the given response type, cross-checked against the
+ * configured message converters.
*/
- protected RequestCallback acceptHeaderRequestCallback(Class responseType) {
+ public RequestCallback acceptHeaderRequestCallback(Class responseType) {
return new AcceptHeaderRequestCallback(responseType);
}
/**
- * Returns a request callback implementation that writes the given object to the
- * request stream.
+ * Return a {@code RequestCallback} implementation that writes the given
+ * object to the request stream.
*/
- protected RequestCallback httpEntityCallback(@Nullable Object requestBody) {
+ public RequestCallback httpEntityCallback(@Nullable Object requestBody) {
return new HttpEntityRequestCallback(requestBody);
}
/**
- * Returns a request callback implementation that writes the given object to the
- * request stream.
+ * Return a {@code RequestCallback} implementation that:
+ *
+ * - Sets the request {@code Accept} header based on the given response
+ * type, cross-checked against the configured message converters.
+ *
- Writes the given object to the request stream.
+ *
*/
- protected RequestCallback httpEntityCallback(@Nullable Object requestBody, Type responseType) {
+ public RequestCallback httpEntityCallback(@Nullable Object requestBody, Type responseType) {
return new HttpEntityRequestCallback(requestBody, responseType);
}
/**
- * Returns a response extractor for {@link ResponseEntity}.
+ * Return a {@code ResponseExtractor} that prepares a {@link ResponseEntity}.
*/
- protected ResponseExtractor> responseEntityExtractor(Type responseType) {
+ public ResponseExtractor> responseEntityExtractor(Type responseType) {
return new ResponseEntityResponseExtractor<>(responseType);
}