You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2018/08/18 16:52:24 UTC
[juneau] branch master updated: Javadocs and tests.
This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new a86a2d2 Javadocs and tests.
a86a2d2 is described below
commit a86a2d2caf6cedcc36029c00a565eba0491b833c
Author: JamesBognar <ja...@apache.org>
AuthorDate: Sat Aug 18 12:52:10 2018 -0400
Javadocs and tests.
---
.../org/apache/juneau/http/annotation/Body.java | 4 +-
.../apache/juneau/http/annotation/FormData.java | 6 +-
.../org/apache/juneau/http/annotation/Header.java | 4 +-
.../org/apache/juneau/http/annotation/Path.java | 4 +-
.../org/apache/juneau/http/annotation/Query.java | 4 +-
.../org/apache/juneau/http/annotation/Request.java | 2 +-
.../apache/juneau/http/annotation/Response.java | 2 +-
.../juneau/http/annotation/ResponseBody.java | 2 +-
.../juneau/http/annotation/ResponseHeader.java | 2 +-
.../juneau/http/annotation/ResponseStatus.java | 2 +-
.../org/apache/juneau/internal/StringUtils.java | 13 +
juneau-doc/docs.txt | 21 +-
juneau-doc/src/main/javadoc/overview.html | 166 +++++++-----
.../09.HttpPartAnnotations.html | 1 +
.../resources/Topics/09.juneau-rest-client.html | 4 +-
.../01.RemoteResources/03.MethodReturnTypes.html | 43 ----
...01.RemoteResources.html => 01.RestProxies.html} | 38 ++-
.../01.RemoteResource.html | 0
.../02.RemoteMethod.html | 69 ++++-
.../04.Body.html => 01.RestProxies/03.Body.html} | 0
.../04.FormData.html} | 0
.../06.Query.html => 01.RestProxies/05.Query.html} | 0
.../06.Header.html} | 0
.../08.Path.html => 01.RestProxies/07.Path.html} | 0
.../08.Request.html} | 0
.../09.Response.html} | 0
.../rest/test/client/ThirdPartyProxyTest.java | 16 +-
juneau-rest/juneau-rest-client/pom.xml | 16 ++
.../org/apache/juneau/rest/client/RestCall.java | 3 +
.../org/apache/juneau/rest/client/RestClient.java | 25 +-
.../juneau/rest/client/remote/RemoteMethod.java | 37 ++-
.../juneau/rest/client/remote/RemoteMethodArg.java | 2 +-
.../rest/client/remote/RemoteMethodBeanArg.java | 2 +-
.../rest/client/remote/RemoteMethodMeta.java | 25 +-
.../rest/client/remote/RemoteMethodReturn.java | 2 +-
.../juneau/rest/client/remote/RemoteResource.java | 2 +-
.../rest/client/remote/RemoteResourceMeta.java | 7 +-
.../juneau/rest/client/remote/RemoteReturn.java | 2 +-
.../client/remote/RemoteMethodAnnotationTest.java | 132 ++++++++++
.../remote/RemoteResourceAnnotationTest.java | 283 +++++++++++++++++++++
40 files changed, 733 insertions(+), 208 deletions(-)
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Body.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Body.java
index 7189a47..584ee7a 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Body.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Body.java
@@ -109,7 +109,7 @@ import org.apache.juneau.jsonschema.*;
*
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.Body}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies.Body}
* </ul>
*
* <h5 class='topic'>Methods and return types of server-side and client-side @Request-annotated interfaces</h5>
@@ -117,7 +117,7 @@ import org.apache.juneau.jsonschema.*;
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
* <li class='link'>{@doc juneau-rest-server.HttpPartAnnotations.Request}
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.Request}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies.Request}
* </ul>
*/
@Documented
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormData.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormData.java
index a2f1bf8..c9ee6a1 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormData.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormData.java
@@ -87,8 +87,8 @@ import org.apache.juneau.jsonschema.*;
*
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.FormData}
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.Request}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies.FormData}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies.Request}
* </ul>
*
* <h5 class='topic'>Methods and return types of server-side and client-side @Request-annotated interfaces</h5>
@@ -96,7 +96,7 @@ import org.apache.juneau.jsonschema.*;
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
* <li class='link'>{@doc juneau-rest-server.HttpPartAnnotations.Request}
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.Request}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies.Request}
* </ul>
*/
@Documented
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Header.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Header.java
index 6ead2b9..04ee0d1 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Header.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Header.java
@@ -163,7 +163,7 @@ import org.apache.juneau.jsonschema.*;
*
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.Header}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies.Header}
* </ul>
*
* <h5 class='topic'>Methods and return types of server-side and client-side @Request-annotated interfaces</h5>
@@ -171,7 +171,7 @@ import org.apache.juneau.jsonschema.*;
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
* <li class='link'>{@doc juneau-rest-server.HttpPartAnnotations.Request}
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.Request}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies.Request}
* </ul>
*/
@Documented
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Path.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Path.java
index 5943fa1..be750a9 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Path.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Path.java
@@ -158,7 +158,7 @@ import org.apache.juneau.jsonschema.*;
*
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.Path}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies.Path}
* </ul>
*
* <h5 class='topic'>Methods and return types of server-side and client-side @Request-annotated interfaces</h5>
@@ -166,7 +166,7 @@ import org.apache.juneau.jsonschema.*;
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
* <li class='link'>{@doc juneau-rest-server.HttpPartAnnotations.Request}
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.Request}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies.Request}
* </ul>
*/
@Documented
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
index a2fa851..6cb386b 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Query.java
@@ -81,7 +81,7 @@ import org.apache.juneau.jsonschema.*;
*
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.Query}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies.Query}
* </ul>
*
* <h5 class='topic'>Methods and return types of server-side and client-side @Request-annotated interfaces</h5>
@@ -89,7 +89,7 @@ import org.apache.juneau.jsonschema.*;
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
* <li class='link'>{@doc juneau-rest-server.HttpPartAnnotations.Request}
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.Request}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies.Request}
* </ul>
*/
@Documented
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Request.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Request.java
index e703e93..4eed973 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Request.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Request.java
@@ -133,7 +133,7 @@ import org.apache.juneau.httppart.*;
*
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.Request}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies.Request}
* </ul>
*/
@Documented
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Response.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Response.java
index 4cfe2ae..df7f15d 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Response.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/Response.java
@@ -45,7 +45,7 @@ import org.apache.juneau.jsonschema.*;
* <h5 class='section'>See Also:</h5>
* <ul>
* <li class='link'>{@doc juneau-rest-server.HttpPartAnnotations.Response}
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.Response}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies.Response}
* <li class='link'>{@doc juneau-rest-server.Swagger}
* <li class='extlink'>{@doc SwaggerResponseObject}
* </ul>
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseBody.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseBody.java
index ed5946a..05f8161 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseBody.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseBody.java
@@ -83,7 +83,7 @@ import java.lang.annotation.*;
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
* <li class='link'>{@doc juneau-rest-server.HttpPartAnnotations.Response}
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.Response}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies.Response}
* </ul>
*/
@Documented
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeader.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeader.java
index 6c2e247..a66a020 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeader.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeader.java
@@ -122,7 +122,7 @@ import org.apache.juneau.httppart.*;
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
* <li class='link'>{@doc juneau-rest-server.HttpPartAnnotations.Response}
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.Response}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies.Response}
* </ul>
*/
@Documented
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseStatus.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseStatus.java
index 2ec8999..de3a695 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseStatus.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseStatus.java
@@ -95,7 +95,7 @@ import org.apache.juneau.*;
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
* <li class='link'>{@doc juneau-rest-server.HttpPartAnnotations.Response}
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.Response}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies.Response}
* </ul>
*/
@Documented
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
index 16c4897..dc88cfa 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/internal/StringUtils.java
@@ -911,6 +911,19 @@ public final class StringUtils {
}
/**
+ * Returns an empty string if the specified object is <jk>null</jk>.
+ *
+ * @param o The object to check.
+ * @return An empty string if the specified object is <jk>null</jk>, or the object converted to a string using {@link String#toString()}.
+ */
+ public static String emptyIfNull(Object o) {
+ if (o == null)
+ return "";
+ return o.toString();
+ }
+
+
+ /**
* Removes escape characters from the specified characters.
*
* @param s The string to remove escape characters from.
diff --git a/juneau-doc/docs.txt b/juneau-doc/docs.txt
index 46356a4..5561987 100644
--- a/juneau-doc/docs.txt
+++ b/juneau-doc/docs.txt
@@ -223,18 +223,17 @@ juneau-rest-client.Interceptors = #juneau-rest-client.Interceptors, Overview > j
juneau-rest-client.Logging = #juneau-rest-client.Logging, Overview > juneau-rest-client > Logging
juneau-rest-client.Other = #juneau-rest-client.Other, Overview > juneau-rest-client > Other Useful Methods
juneau-rest-client.PipingOutput = #juneau-rest-client.PipingOutput, Overview > juneau-rest-client > Piping Response Output
-juneau-rest-client.RemoteResources = #juneau-rest-client.RemoteResources, Overview > juneau-rest-client > Remote Resources
-juneau-rest-client.RemoteResources.Body = #juneau-rest-client.RemoteResources.Body, Overview > juneau-rest-client > Remote Resources > @Body
-juneau-rest-client.RemoteResources.FormData = #juneau-rest-client.RemoteResources.FormData, Overview > juneau-rest-client > Remote Resources > @FormData
-juneau-rest-client.RemoteResources.Header = #juneau-rest-client.RemoteResources.Header, Overview > juneau-rest-client > Remote Resources > @Header
-juneau-rest-client.RemoteResources.MethodReturnTypes = #juneau-rest-client.RemoteResources.MethodReturnTypes, Overview > juneau-rest-client > Remote Resources > Method Return Types
-juneau-rest-client.RemoteResources.Path = #juneau-rest-client.RemoteResources.Path, Overview > juneau-rest-client > Remote Resources > @Path
-juneau-rest-client.RemoteResources.Query = #juneau-rest-client.RemoteResources.Query, Overview > juneau-rest-client > Remote Resources > @Query
-juneau-rest-client.RemoteResources.RemoteMethod = #juneau-rest-client.RemoteResources.RemoteMethod, Overview > juneau-rest-client > Remote Resources > @RemoteMethod
-juneau-rest-client.RemoteResources.RemoteResource = #juneau-rest-client.RemoteResources.RemoteResource, Overview > juneau-rest-client > Remote Resources > @RemoteResource
-juneau-rest-client.RemoteResources.Request = #juneau-rest-client.RemoteResources.Request, Overview > juneau-rest-client > Remote Resources > @Request
-juneau-rest-client.RemoteResources.Response = #juneau-rest-client.RemoteResources.Response, Overview > juneau-rest-client > Remote Resources > @Request
juneau-rest-client.ResponsePatterns = #juneau-rest-client.ResponsePatterns, Overview > juneau-rest-client > Using Response Patterns
+juneau-rest-client.RestProxies = #juneau-rest-client.RestProxies, Overview > juneau-rest-client > REST Proxies
+juneau-rest-client.RestProxies.Body = #juneau-rest-client.RestProxies.Body, Overview > juneau-rest-client > REST Proxies > @Body
+juneau-rest-client.RestProxies.FormData = #juneau-rest-client.RestProxies.FormData, Overview > juneau-rest-client > REST Proxies > @FormData
+juneau-rest-client.RestProxies.Header = #juneau-rest-client.RestProxies.Header, Overview > juneau-rest-client > REST Proxies > @Header
+juneau-rest-client.RestProxies.Path = #juneau-rest-client.RestProxies.Path, Overview > juneau-rest-client > REST Proxies > @Path
+juneau-rest-client.RestProxies.Query = #juneau-rest-client.RestProxies.Query, Overview > juneau-rest-client > REST Proxies > @Query
+juneau-rest-client.RestProxies.RemoteMethod = #juneau-rest-client.RestProxies.RemoteMethod, Overview > juneau-rest-client > REST Proxies > @RemoteMethod
+juneau-rest-client.RestProxies.RemoteResource = #juneau-rest-client.RestProxies.RemoteResource, Overview > juneau-rest-client > REST Proxies > @RemoteResource
+juneau-rest-client.RestProxies.Request = #juneau-rest-client.RestProxies.Request, Overview > juneau-rest-client > REST Proxies > @Request
+juneau-rest-client.RestProxies.Response = #juneau-rest-client.RestProxies.Response, Overview > juneau-rest-client > REST Proxies > @Request
juneau-rest-client.SSL = #juneau-rest-client.SSL, Overview > juneau-rest-client > SSL Support
juneau-rest-client.UnitTesting = #juneau-rest-client.UnitTesting, Overview > juneau-rest-client > Serverless Unit Testing
juneau-rest-server = #juneau-rest-server, Overview > juneau-rest-server
diff --git a/juneau-doc/src/main/javadoc/overview.html b/juneau-doc/src/main/javadoc/overview.html
index da06673..3f94217 100644
--- a/juneau-doc/src/main/javadoc/overview.html
+++ b/juneau-doc/src/main/javadoc/overview.html
@@ -365,18 +365,17 @@
</ol>
<li><p class='toc2 updated'><a class='doclink' href='#juneau-rest-client'>juneau-rest-client</a></p>
<ol>
- <li><p class='new'><a class='doclink' href='#juneau-rest-client.RemoteResources'>Remote Resources</a></p>
+ <li><p class='new'><a class='doclink' href='#juneau-rest-client.RestProxies'>REST Proxies</a></p>
<ol>
- <li><p class='new'><a class='doclink' href='#juneau-rest-client.RemoteResources.RemoteResource'>@RemoteResource</a></p>
- <li><p class='new'><a class='doclink' href='#juneau-rest-client.RemoteResources.RemoteMethod'>@RemoteMethod</a></p>
- <li><p class='todo'><a class='doclink' href='#juneau-rest-client.RemoteResources.MethodReturnTypes'>Method Return Types</a></p>
- <li><p class='new'><a class='doclink' href='#juneau-rest-client.RemoteResources.Body'>@Body</a></p>
- <li><p class='new'><a class='doclink' href='#juneau-rest-client.RemoteResources.FormData'>@FormData</a></p>
- <li><p class='new'><a class='doclink' href='#juneau-rest-client.RemoteResources.Query'>@Query</a></p>
- <li><p class='todo'><a class='doclink' href='#juneau-rest-client.RemoteResources.Header'>@Header</a></p>
- <li><p class='todo'><a class='doclink' href='#juneau-rest-client.RemoteResources.Path'>@Path</a></p>
- <li><p class='todo'><a class='doclink' href='#juneau-rest-client.RemoteResources.Request'>@Request</a></p>
- <li><p class='todo'><a class='doclink' href='#juneau-rest-client.RemoteResources.Response'>@Request</a></p>
+ <li><p class='new'><a class='doclink' href='#juneau-rest-client.RestProxies.RemoteResource'>@RemoteResource</a></p>
+ <li><p class='new'><a class='doclink' href='#juneau-rest-client.RestProxies.RemoteMethod'>@RemoteMethod</a></p>
+ <li><p class='new'><a class='doclink' href='#juneau-rest-client.RestProxies.Body'>@Body</a></p>
+ <li><p class='new'><a class='doclink' href='#juneau-rest-client.RestProxies.FormData'>@FormData</a></p>
+ <li><p class='new'><a class='doclink' href='#juneau-rest-client.RestProxies.Query'>@Query</a></p>
+ <li><p class='todo'><a class='doclink' href='#juneau-rest-client.RestProxies.Header'>@Header</a></p>
+ <li><p class='todo'><a class='doclink' href='#juneau-rest-client.RestProxies.Path'>@Path</a></p>
+ <li><p class='todo'><a class='doclink' href='#juneau-rest-client.RestProxies.Request'>@Request</a></p>
+ <li><p class='todo'><a class='doclink' href='#juneau-rest-client.RestProxies.Response'>@Request</a></p>
</ol>
<li><p class=''><a class='doclink' href='#juneau-rest-client.SSL'>SSL Support</a></p>
<li><p class='new'><a class='doclink' href='#juneau-rest-client.Authentication'>Authentication</a></p>
@@ -14981,6 +14980,7 @@
<li class='ja'>{@link org.apache.juneau.http.annotation.Path Path}
<li class='ja'>{@link org.apache.juneau.http.annotation.HasFormData HasFormData}
<li class='ja'>{@link org.apache.juneau.http.annotation.HasQuery HasQuery}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.Request Request}
</ul>
<p>
The annotations used for defining the schema for response HTTP parts are:
@@ -20135,8 +20135,8 @@ TODO(7.2.0)
<!-- ==================================================================================================== -->
-<h3 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-client.RemoteResources' id='juneau-rest-client.RemoteResources'>9.1 - Remote Resources</a></h3>
-<div class='topic'><!-- START: 9.1 - juneau-rest-client.RemoteResources -->
+<h3 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-client.RestProxies' id='juneau-rest-client.RestProxies'>9.1 - REST Proxies</a></h3>
+<div class='topic'><!-- START: 9.1 - juneau-rest-client.RestProxies -->
<p>
The <code>juneau-rest-client</code> library can also be used to define interface proxies against 3rd-party REST interfaces.
<br>This is an extremely powerful feature that allows you to quickly define easy-to-use interfaces against
@@ -20154,17 +20154,37 @@ TODO(7.2.0)
</ul>
</ul>
<p>
- Similar in concept to remote interfaces defined previously, but in this case we simply define our interface with
- special annotations that tell us how to convert input and output to HTTP headers, query parameters, form
+ Annotations are used on the interface and interface methods to specify how to convert input and output to HTTP headers, query parameters, form
post parameters, or request/response bodies.
</p>
+<ul class='doctree'>
+ <li class='jp'>{@link org.apache.juneau.rest.client.remote}
+ <ul>
+ <li class='ja'>{@link org.apache.juneau.rest.client.remote.RemoteResource}
+ <li class='ja'>{@link org.apache.juneau.rest.client.remote.RemoteMethod}
+ </ul>
+ <li class='jp'>{@link org.apache.juneau.http.annotation}
+ <ul>
+ <li class='ja'>{@link org.apache.juneau.http.annotation.Body Body}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.Header Header}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.FormData FormData}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.Query Query}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.Path Path}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.HasFormData HasFormData}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.HasQuery HasQuery}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.Request Request}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.Response Response}
+ </ul>
+</ul>
+
+<h5 class='figure'>Example:</h5>
<p class='bpcode w800'>
- <ja>@RemoteResource</ja>
+ <ja>@RemoteResource</ja>(path=<js>"/petstore"</js>)
<jk>public interface</jk> PetStore {
<ja>@RemoteMethod</ja>(httpMethod=<jsf>POST</jsf>, path=<js>"/pets"</js>)
String addPet(
- <ja>@Body</ja> PetCreate pet,
+ <ja>@Body</ja> CreatePet pet,
<ja>@Header</ja>(<js>"E-Tag"</js>) UUID etag,
<ja>@Query</ja>(<js>"debug"</js>) <jk>boolean</jk> debug
);
@@ -20172,10 +20192,10 @@ TODO(7.2.0)
</p>
<p class='bpcode w800'>
<jc>// Use a RestClient with default Simple JSON support.</jc>
- <jk>try</jk> (RestClient c = RestClient.<jsm>create</jsm>().simpleJson().build()) {
- PetStore p = c.getRemoteResource(PetStore.<jk>class</jk>, <js>"http://localhost:10000/petstore"</js>);
- PetCreate pet = <jk>new</jk> PetCreate(<js>"Fluffy"</js>, 9.99);
- String response = p.createPet(pet, UUID.<jsm>randomUUID</jsm>(), <jk>true</jk>);
+ <jk>try</jk> (RestClient client = RestClient.<jsm>create</jsm>().simpleJson().build()) {
+ PetStore store = client.getRemoteResource(PetStore.<jk>class</jk>, <js>"http://localhost:10000"</js>);
+ CreatePet pet = <jk>new</jk> CreatePet(<js>"Fluffy"</js>, 9.99);
+ String response = store.createPet(pet, UUID.<jsm>randomUUID</jsm>(), <jk>true</jk>);
}
</p>
<p>
@@ -20195,8 +20215,8 @@ TODO(7.2.0)
<!-- ==================================================================================================== -->
-<h4 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-client.RemoteResources.RemoteResource' id='juneau-rest-client.RemoteResources.RemoteResource'>9.1.1 - @RemoteResource</a></h4>
-<div class='topic'><!-- START: 9.1.1 - juneau-rest-client.RemoteResources.RemoteResource -->
+<h4 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-client.RestProxies.RemoteResource' id='juneau-rest-client.RestProxies.RemoteResource'>9.1.1 - @RemoteResource</a></h4>
+<div class='topic'><!-- START: 9.1.1 - juneau-rest-client.RestProxies.RemoteResource -->
<p>
The {@link org.apache.juneau.rest.client.remote.RemoteResource @RemoteResource} annotation is used on your interface class
to identify it as a REST proxy interface.
@@ -20251,15 +20271,15 @@ TODO(7.2.0)
RestClient client = RestClient.<jsm>create</jsm>().json().rootUrl(<js>"http://localhost:10000/petstore"</js>).build();
PetStore p = client.getRemoteResource(PetStore.<jk>class</jk>);
</p>
-</div><!-- END: 9.1.1 - juneau-rest-client.RemoteResources.RemoteResource -->
+</div><!-- END: 9.1.1 - juneau-rest-client.RestProxies.RemoteResource -->
<!-- ==================================================================================================== -->
-<h4 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-client.RemoteResources.RemoteMethod' id='juneau-rest-client.RemoteResources.RemoteMethod'>9.1.2 - @RemoteMethod</a></h4>
-<div class='topic'><!-- START: 9.1.2 - juneau-rest-client.RemoteResources.RemoteMethod -->
+<h4 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-client.RestProxies.RemoteMethod' id='juneau-rest-client.RestProxies.RemoteMethod'>9.1.2 - @RemoteMethod</a></h4>
+<div class='topic'><!-- START: 9.1.2 - juneau-rest-client.RestProxies.RemoteMethod -->
<p>
The {@link org.apache.juneau.rest.client.remote.RemoteMethod @RemoteMethod} annotation is applied to methods
- of {@link org.apache.juneau.rest.client.remote.RemoteResource}-annotated interfaces to identify REST endpoints.
+ of {@link org.apache.juneau.rest.client.remote.RemoteResource @RemoteResource}-annotated interfaces to identify REST endpoints.
</p>
<ul class='doctree'>
<li class='ja'>{@link org.apache.juneau.rest.client.remote.RemoteMethod}
@@ -20269,8 +20289,9 @@ TODO(7.2.0)
<li class='jf'>{@link org.apache.juneau.rest.client.remote.RemoteMethod#returns returns}
</ul>
</ul>
+<h5 class='topic w800'>@RemoteMethod(method/path)</h5>
<p>
- The HTTP method and path are mapped to a Java method using the <code>httpMethod</code> and <code>path</code> annotations.
+ The HTTP method and path are mapped to a Java method using the <code>method</code> and <code>path</code> annotations.
</p>
<h5 class='figure'>Example:</h5>
<p class='bpcode w800'>
@@ -20278,15 +20299,18 @@ TODO(7.2.0)
<jk>public interface</jk> PetStore {
<jc>// GET /pets/{petId}</jc>
- <ja>@RemoteMethod(httpMethod="GET", path="/pets/{petId}")</ja>
- Pet getPet(@Path(<js>"petId"</js>) <jk>int</jk> id);
+ <ja>@RemoteMethod</ja>(method=<js>"GET"</js>, path=<js>"/pets/{petId}"</js>)
+ Pet getPet(<ja>@Path</ja>(<js>"petId"</js>) <jk>int</jk> id);
}
</p>
<p>
- The method names used in 3rd-party proxies can be anything.
- However, the method names can also be used to infer the HTTP method and path if not explicitly specified
- via the {@link org.apache.juneau.rest.client.remote.RemoteMethod#method() @RemoteMethod(method)} and
- {@link org.apache.juneau.rest.client.remote.RemoteMethod#path() @RemoteMethod(path)} annotations.
+ The method names can be anything.
+</p>
+
+<h5 class='topic w800'>Inferred method/path</h5>
+<p>
+ The <code>method</code> and <code>path</code> annotations are optional if you follow certain naming
+ conventions on your method that identify the method and path.
</p>
<p>
For example, the <code>getPet</code> method below defaults to <code>GET /pet</code>:
@@ -20297,7 +20321,7 @@ TODO(7.2.0)
<jc>// GET /pet</jc>
<ja>@RemoteMethod</ja>
- Pet getPet(@Query(<js>"id"</js>) <jk>int</jk> id);
+ Pet getPet(...);
}
</p>
<p>
@@ -20353,14 +20377,10 @@ TODO(7.2.0)
<td class='code'>/doFoo</td>
</tr>
</table>
-</div><!-- END: 9.1.2 - juneau-rest-client.RemoteResources.RemoteMethod -->
-<!-- ==================================================================================================== -->
-
-<h4 class='topic todo' onclick='toggle(this)'><a href='#juneau-rest-client.RemoteResources.MethodReturnTypes' id='juneau-rest-client.RemoteResources.MethodReturnTypes'>9.1.3 - Method Return Types</a></h4>
-<div class='topic'><!-- START: 9.1.3 - juneau-rest-client.RemoteResources.MethodReturnTypes -->
+<h5 class='topic w800'>@RemoteMethod(returns)</h5>
<p>
- The return type of the Java methods of 3rd-party proxies can be any of the following:
+ By default, the return type of the Java methods of can be any of the following:
</p>
<ul class='spaced-list'>
<li>
@@ -20372,7 +20392,7 @@ TODO(7.2.0)
- The body of the response will be converted to the POJO using the parser defined on the
<code>RestClient</code> based on the <code>Content-Type</code> of the response.
<li>
- Any {@link org.apache.juneau.http.annotation.Response @Response}-annotated type. (described below)
+ Any {@link org.apache.juneau.http.annotation.Response @Response}-annotated type. (described later)
<li>
<code>HttpResponse</code>
- Returns the raw <code>HttpResponse</code> returned by the inner <code>HttpClient</code>.
@@ -20385,12 +20405,28 @@ TODO(7.2.0)
{@link java.io.InputStream}
- Returns access to the raw input stream of the response.
</ul>
-</div><!-- END: 9.1.3 - juneau-rest-client.RemoteResources.MethodReturnTypes -->
+
+<p>
+ If you're only interested in the HTTP status code of the response, you can use the {@link org.apache.juneau.rest.client.remote.RemoteMethod#returns() returns}
+ annotation with a value of {@link org.apache.juneau.rest.client.remote.RemoteReturn#STATUS STATUS}:
+</p>
+<h5 class='figure'>Example:</h5>
+<p class='bpcode w800'>
+ <ja>@RemoteResource</ja>
+ <jk>public interface</jk> PetStore {
+
+ <jc>// POST /pets</jc>
+ <jc>// Returns HTTP status code.
+ <ja>@RemoteMethod</ja>(returns=<jsf>STATUS</jsf>)
+ <jk>int</jk> postPets(...);
+ }
+</p>
+</div><!-- END: 9.1.2 - juneau-rest-client.RestProxies.RemoteMethod -->
<!-- ==================================================================================================== -->
-<h4 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-client.RemoteResources.Body' id='juneau-rest-client.RemoteResources.Body'>9.1.4 - @Body</a></h4>
-<div class='topic'><!-- START: 9.1.4 - juneau-rest-client.RemoteResources.Body -->
+<h4 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-client.RestProxies.Body' id='juneau-rest-client.RestProxies.Body'>9.1.3 - @Body</a></h4>
+<div class='topic'><!-- START: 9.1.3 - juneau-rest-client.RestProxies.Body -->
<p>
The {@link org.apache.juneau.http.annotation.Body @Body} annotation can be applied to arguments of <ja>@RemoteMethod</ja>-annotated methods
to denote that they are the HTTP body of the request.
@@ -20480,12 +20516,12 @@ TODO(7.2.0)
<ul>
<li class='link'>{@doc juneau-marshall.OpenApiDetails.Serializers}
</ul>
-</div><!-- END: 9.1.4 - juneau-rest-client.RemoteResources.Body -->
+</div><!-- END: 9.1.3 - juneau-rest-client.RestProxies.Body -->
<!-- ==================================================================================================== -->
-<h4 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-client.RemoteResources.FormData' id='juneau-rest-client.RemoteResources.FormData'>9.1.5 - @FormData</a></h4>
-<div class='topic'><!-- START: 9.1.5 - juneau-rest-client.RemoteResources.FormData -->
+<h4 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-client.RestProxies.FormData' id='juneau-rest-client.RestProxies.FormData'>9.1.4 - @FormData</a></h4>
+<div class='topic'><!-- START: 9.1.4 - juneau-rest-client.RestProxies.FormData -->
<p>
The {@link org.apache.juneau.http.annotation.FormData @FormData} annotation can be applied to arguments of <ja>@RemoteMethod</ja>-annotated methods
to denote that they are form-data parameters on the request.
@@ -20589,12 +20625,12 @@ TODO(7.2.0)
<ul>
<li class='link'>{@doc juneau-marshall.OpenApiDetails.Serializers}
</ul>
-</div><!-- END: 9.1.5 - juneau-rest-client.RemoteResources.FormData -->
+</div><!-- END: 9.1.4 - juneau-rest-client.RestProxies.FormData -->
<!-- ==================================================================================================== -->
-<h4 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-client.RemoteResources.Query' id='juneau-rest-client.RemoteResources.Query'>9.1.6 - @Query</a></h4>
-<div class='topic'><!-- START: 9.1.6 - juneau-rest-client.RemoteResources.Query -->
+<h4 class='topic new' onclick='toggle(this)'><a href='#juneau-rest-client.RestProxies.Query' id='juneau-rest-client.RestProxies.Query'>9.1.5 - @Query</a></h4>
+<div class='topic'><!-- START: 9.1.5 - juneau-rest-client.RestProxies.Query -->
<p>
The {@link org.apache.juneau.http.annotation.Query @Query} annotation can be applied to arguments of <ja>@RemoteMethod</ja>-annotated methods
to denote that they are query parameters on the request.
@@ -20700,12 +20736,12 @@ TODO(7.2.0)
<ul>
<li class='link'>{@doc juneau-marshall.OpenApiDetails.Serializers}
</ul>
-</div><!-- END: 9.1.6 - juneau-rest-client.RemoteResources.Query -->
+</div><!-- END: 9.1.5 - juneau-rest-client.RestProxies.Query -->
<!-- ==================================================================================================== -->
-<h4 class='topic todo' onclick='toggle(this)'><a href='#juneau-rest-client.RemoteResources.Header' id='juneau-rest-client.RemoteResources.Header'>9.1.7 - @Header</a></h4>
-<div class='topic'><!-- START: 9.1.7 - juneau-rest-client.RemoteResources.Header -->
+<h4 class='topic todo' onclick='toggle(this)'><a href='#juneau-rest-client.RestProxies.Header' id='juneau-rest-client.RestProxies.Header'>9.1.6 - @Header</a></h4>
+<div class='topic'><!-- START: 9.1.6 - juneau-rest-client.RestProxies.Header -->
<p>
The {@link org.apache.juneau.http.annotation.Header @Header} annotation can be applied to arguments of <ja>@RemoteMethod</ja>-annotated methods
to denote that they are header parameters on the request.
@@ -20760,12 +20796,12 @@ TODO(7.2.0)
<ul>
<li class='link'>{@doc juneau-marshall.OpenApiDetails.Serializers}
</ul>
-</div><!-- END: 9.1.7 - juneau-rest-client.RemoteResources.Header -->
+</div><!-- END: 9.1.6 - juneau-rest-client.RestProxies.Header -->
<!-- ==================================================================================================== -->
-<h4 class='topic todo' onclick='toggle(this)'><a href='#juneau-rest-client.RemoteResources.Path' id='juneau-rest-client.RemoteResources.Path'>9.1.8 - @Path</a></h4>
-<div class='topic'><!-- START: 9.1.8 - juneau-rest-client.RemoteResources.Path -->
+<h4 class='topic todo' onclick='toggle(this)'><a href='#juneau-rest-client.RestProxies.Path' id='juneau-rest-client.RestProxies.Path'>9.1.7 - @Path</a></h4>
+<div class='topic'><!-- START: 9.1.7 - juneau-rest-client.RestProxies.Path -->
<p>
The {@link org.apache.juneau.http.annotation.Path @Path} annotation can be applied to arguments of <ja>@RemoteMethod</ja>-annotated methods
to denote that they are path parameters on the request.
@@ -20800,12 +20836,12 @@ TODO(7.2.0)
<ul>
<li class='link'>{@doc juneau-marshall.OpenApiDetails.Serializers}
</ul>
-</div><!-- END: 9.1.8 - juneau-rest-client.RemoteResources.Path -->
+</div><!-- END: 9.1.7 - juneau-rest-client.RestProxies.Path -->
<!-- ==================================================================================================== -->
-<h4 class='topic todo' onclick='toggle(this)'><a href='#juneau-rest-client.RemoteResources.Request' id='juneau-rest-client.RemoteResources.Request'>9.1.9 - @Request</a></h4>
-<div class='topic'><!-- START: 9.1.9 - juneau-rest-client.RemoteResources.Request -->
+<h4 class='topic todo' onclick='toggle(this)'><a href='#juneau-rest-client.RestProxies.Request' id='juneau-rest-client.RestProxies.Request'>9.1.8 - @Request</a></h4>
+<div class='topic'><!-- START: 9.1.8 - juneau-rest-client.RestProxies.Request -->
TODO(7.2.0)
@@ -20923,15 +20959,15 @@ TODO(7.2.0)
Reader getReader();
}
</p>
-</div><!-- END: 9.1.9 - juneau-rest-client.RemoteResources.Request -->
+</div><!-- END: 9.1.8 - juneau-rest-client.RestProxies.Request -->
<!-- ==================================================================================================== -->
-<h4 class='topic todo' onclick='toggle(this)'><a href='#juneau-rest-client.RemoteResources.Response' id='juneau-rest-client.RemoteResources.Response'>9.1.10 - @Request</a></h4>
-<div class='topic'><!-- START: 9.1.10 - juneau-rest-client.RemoteResources.Response -->
+<h4 class='topic todo' onclick='toggle(this)'><a href='#juneau-rest-client.RestProxies.Response' id='juneau-rest-client.RestProxies.Response'>9.1.9 - @Request</a></h4>
+<div class='topic'><!-- START: 9.1.9 - juneau-rest-client.RestProxies.Response -->
TODO(7.2.0)
-</div><!-- END: 9.1.10 - juneau-rest-client.RemoteResources.Response -->
-</div><!-- END: 9.1 - juneau-rest-client.RemoteResources -->
+</div><!-- END: 9.1.9 - juneau-rest-client.RestProxies.Response -->
+</div><!-- END: 9.1 - juneau-rest-client.RestProxies -->
<!-- ==================================================================================================== -->
diff --git a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations.html b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations.html
index 7d9f2bf..bf25d51 100644
--- a/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations.html
+++ b/juneau-doc/src/main/resources/Topics/07.juneau-rest-server/09.HttpPartAnnotations.html
@@ -26,6 +26,7 @@
<li class='ja'>{@link org.apache.juneau.http.annotation.Path Path}
<li class='ja'>{@link org.apache.juneau.http.annotation.HasFormData HasFormData}
<li class='ja'>{@link org.apache.juneau.http.annotation.HasQuery HasQuery}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.Request Request}
</ul>
<p>
The annotations used for defining the schema for response HTTP parts are:
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client.html
index b29935f..c6a338a 100644
--- a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client.html
+++ b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client.html
@@ -44,7 +44,7 @@
</p>
<p class='bpcode w800'>
<jc>// Create a reusable JSON client.</jc>
- <jk>try</jk> (RestClient client = RestClient.<jsm>create</jsm>().build()) {
+ <jk>try</jk> (RestClient client = RestClient.<jsm>create</jsm>().json().build()) {
<jc>// The address of the root resource.</jc>
String url = <js>"http://localhost:10000/addressBook"</js>;
@@ -104,7 +104,7 @@
<jc>// Examples below use the Juneau Address Book resource example</jc>
<jc>// Create a reusable client with JSON support</jc>
- <jk>try</jk> (RestClient client = RestClient.<jsm>create</jsm>().build()) {
+ <jk>try</jk> (RestClient client = RestClient.<jsm>create</jsm>().json().build()) {
<jc>// GET request, ignoring output</jc>
<jk>try</jk> {
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/03.MethodReturnTypes.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/03.MethodReturnTypes.html
deleted file mode 100644
index bb48ea7..0000000
--- a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/03.MethodReturnTypes.html
+++ /dev/null
@@ -1,43 +0,0 @@
-<!--
-/***************************************************************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations under the License.
- ***************************************************************************************************************************/
- -->
-
-{todo} Method Return Types
-
-<p>
- The return type of the Java methods of 3rd-party proxies can be any of the following:
-</p>
-<ul class='spaced-list'>
- <li>
- <jk>void</jk>
- - Don't parse any response.
- <br>Note that the method will still throw a runtime exception if an error HTTP status is returned.
- <li>
- Any {@doc PojoCategories parsable} POJO
- - The body of the response will be converted to the POJO using the parser defined on the
- <code>RestClient</code> based on the <code>Content-Type</code> of the response.
- <li>
- Any {@link org.apache.juneau.http.annotation.Response @Response}-annotated type. (described below)
- <li>
- <code>HttpResponse</code>
- - Returns the raw <code>HttpResponse</code> returned by the inner <code>HttpClient</code>.
- <li>
- {@link java.io.Reader}
- - Returns access to the raw reader of the response.
- <br>Note that if you don't want your response parsed as a POJO, you'll want to get the response reader
- directly.
- <li>
- {@link java.io.InputStream}
- - Returns access to the raw input stream of the response.
-</ul>
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies.html
similarity index 62%
rename from juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources.html
rename to juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies.html
index 3a89cfd..84298ad 100644
--- a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources.html
+++ b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies.html
@@ -13,7 +13,7 @@
***************************************************************************************************************************/
-->
-{new} Remote Resources
+{new} REST Proxies
<p>
The <code>juneau-rest-client</code> library can also be used to define interface proxies against 3rd-party REST interfaces.
@@ -32,17 +32,37 @@
</ul>
</ul>
<p>
- Similar in concept to remote interfaces defined previously, but in this case we simply define our interface with
- special annotations that tell us how to convert input and output to HTTP headers, query parameters, form
+ Annotations are used on the interface and interface methods to specify how to convert input and output to HTTP headers, query parameters, form
post parameters, or request/response bodies.
</p>
+<ul class='doctree'>
+ <li class='jp'>{@link org.apache.juneau.rest.client.remote}
+ <ul>
+ <li class='ja'>{@link org.apache.juneau.rest.client.remote.RemoteResource}
+ <li class='ja'>{@link org.apache.juneau.rest.client.remote.RemoteMethod}
+ </ul>
+ <li class='jp'>{@link org.apache.juneau.http.annotation}
+ <ul>
+ <li class='ja'>{@link org.apache.juneau.http.annotation.Body Body}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.Header Header}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.FormData FormData}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.Query Query}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.Path Path}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.HasFormData HasFormData}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.HasQuery HasQuery}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.Request Request}
+ <li class='ja'>{@link org.apache.juneau.http.annotation.Response Response}
+ </ul>
+</ul>
+
+<h5 class='figure'>Example:</h5>
<p class='bpcode w800'>
- <ja>@RemoteResource</ja>
+ <ja>@RemoteResource</ja>(path=<js>"/petstore"</js>)
<jk>public interface</jk> PetStore {
<ja>@RemoteMethod</ja>(httpMethod=<jsf>POST</jsf>, path=<js>"/pets"</js>)
String addPet(
- <ja>@Body</ja> PetCreate pet,
+ <ja>@Body</ja> CreatePet pet,
<ja>@Header</ja>(<js>"E-Tag"</js>) UUID etag,
<ja>@Query</ja>(<js>"debug"</js>) <jk>boolean</jk> debug
);
@@ -50,10 +70,10 @@
</p>
<p class='bpcode w800'>
<jc>// Use a RestClient with default Simple JSON support.</jc>
- <jk>try</jk> (RestClient c = RestClient.<jsm>create</jsm>().simpleJson().build()) {
- PetStore p = c.getRemoteResource(PetStore.<jk>class</jk>, <js>"http://localhost:10000/petstore"</js>);
- PetCreate pet = <jk>new</jk> PetCreate(<js>"Fluffy"</js>, 9.99);
- String response = p.createPet(pet, UUID.<jsm>randomUUID</jsm>(), <jk>true</jk>);
+ <jk>try</jk> (RestClient client = RestClient.<jsm>create</jsm>().simpleJson().build()) {
+ PetStore store = client.getRemoteResource(PetStore.<jk>class</jk>, <js>"http://localhost:10000"</js>);
+ CreatePet pet = <jk>new</jk> CreatePet(<js>"Fluffy"</js>, 9.99);
+ String response = store.createPet(pet, UUID.<jsm>randomUUID</jsm>(), <jk>true</jk>);
}
</p>
<p>
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/01.RemoteResource.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/01.RemoteResource.html
similarity index 100%
rename from juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/01.RemoteResource.html
rename to juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/01.RemoteResource.html
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/02.RemoteMethod.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/02.RemoteMethod.html
similarity index 57%
rename from juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/02.RemoteMethod.html
rename to juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/02.RemoteMethod.html
index 7245275..ae5ca80 100644
--- a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/02.RemoteMethod.html
+++ b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/02.RemoteMethod.html
@@ -17,7 +17,7 @@
<p>
The {@link org.apache.juneau.rest.client.remote.RemoteMethod @RemoteMethod} annotation is applied to methods
- of {@link org.apache.juneau.rest.client.remote.RemoteResource}-annotated interfaces to identify REST endpoints.
+ of {@link org.apache.juneau.rest.client.remote.RemoteResource @RemoteResource}-annotated interfaces to identify REST endpoints.
</p>
<ul class='doctree'>
<li class='ja'>{@link org.apache.juneau.rest.client.remote.RemoteMethod}
@@ -27,8 +27,9 @@
<li class='jf'>{@link org.apache.juneau.rest.client.remote.RemoteMethod#returns returns}
</ul>
</ul>
+<h5 class='topic w800'>@RemoteMethod(method/path)</h5>
<p>
- The HTTP method and path are mapped to a Java method using the <code>httpMethod</code> and <code>path</code> annotations.
+ The HTTP method and path are mapped to a Java method using the <code>method</code> and <code>path</code> annotations.
</p>
<h5 class='figure'>Example:</h5>
<p class='bpcode w800'>
@@ -36,15 +37,18 @@
<jk>public interface</jk> PetStore {
<jc>// GET /pets/{petId}</jc>
- <ja>@RemoteMethod(httpMethod="GET", path="/pets/{petId}")</ja>
- Pet getPet(@Path(<js>"petId"</js>) <jk>int</jk> id);
+ <ja>@RemoteMethod</ja>(method=<js>"GET"</js>, path=<js>"/pets/{petId}"</js>)
+ Pet getPet(<ja>@Path</ja>(<js>"petId"</js>) <jk>int</jk> id);
}
</p>
<p>
- The method names used in 3rd-party proxies can be anything.
- However, the method names can also be used to infer the HTTP method and path if not explicitly specified
- via the {@link org.apache.juneau.rest.client.remote.RemoteMethod#method() @RemoteMethod(method)} and
- {@link org.apache.juneau.rest.client.remote.RemoteMethod#path() @RemoteMethod(path)} annotations.
+ The method names can be anything.
+</p>
+
+<h5 class='topic w800'>Inferred method/path</h5>
+<p>
+ The <code>method</code> and <code>path</code> annotations are optional if you follow certain naming
+ conventions on your method that identify the method and path.
</p>
<p>
For example, the <code>getPet</code> method below defaults to <code>GET /pet</code>:
@@ -55,10 +59,13 @@
<jc>// GET /pet</jc>
<ja>@RemoteMethod</ja>
- Pet getPet(@Query(<js>"id"</js>) <jk>int</jk> id);
+ Pet getPet(...);
}
</p>
<p>
+ In such cases, the <ja>@RemoteMethod</ja> annotation is optional.
+</p>
+<p>
Method names matching the following pattern are assumed to be implying the HTTP method name:
</p>
<p class='bpcode w800'>
@@ -111,3 +118,47 @@
<td class='code'>/doFoo</td>
</tr>
</table>
+
+<h5 class='topic w800'>@RemoteMethod(returns)</h5>
+<p>
+ The return type of the Java methods of can be any of the following:
+</p>
+<ul class='spaced-list'>
+ <li>
+ <jk>void</jk>
+ - Don't parse any response.
+ <br>Note that the method will still throw a runtime exception if an error HTTP status is returned.
+ <li>
+ Any {@doc PojoCategories parsable} POJO
+ - The body of the response will be converted to the POJO using the parser defined on the
+ <code>RestClient</code> based on the <code>Content-Type</code> of the response.
+ <li>
+ Any {@link org.apache.juneau.http.annotation.Response @Response}-annotated type. (described later)
+ <li>
+ <code>HttpResponse</code>
+ - Returns the raw <code>HttpResponse</code> returned by the inner <code>HttpClient</code>.
+ <li>
+ {@link java.io.Reader}
+ - Returns access to the raw reader of the response.
+ <br>Note that if you don't want your response parsed as a POJO, you'll want to get the response reader
+ directly.
+ <li>
+ {@link java.io.InputStream}
+ - Returns access to the raw input stream of the response.
+</ul>
+
+<p>
+ If you're only interested in the HTTP status code of the response, you can use the {@link org.apache.juneau.rest.client.remote.RemoteMethod#returns() returns}
+ annotation with a value of {@link org.apache.juneau.rest.client.remote.RemoteReturn#STATUS STATUS}:
+</p>
+<h5 class='figure'>Example:</h5>
+<p class='bpcode w800'>
+ <ja>@RemoteResource</ja>
+ <jk>public interface</jk> PetStore {
+
+ <jc>// POST /pets</jc>
+ <jc>// Returns HTTP status code.</jc>
+ <ja>@RemoteMethod</ja>(returns=<jsf>STATUS</jsf>)
+ <jk>int</jk> postPets(...);
+ }
+</p>
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/04.Body.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/03.Body.html
similarity index 100%
rename from juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/04.Body.html
rename to juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/03.Body.html
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/05.FormData.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/04.FormData.html
similarity index 100%
rename from juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/05.FormData.html
rename to juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/04.FormData.html
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/06.Query.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/05.Query.html
similarity index 100%
rename from juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/06.Query.html
rename to juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/05.Query.html
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/07.Header.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/06.Header.html
similarity index 100%
rename from juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/07.Header.html
rename to juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/06.Header.html
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/08.Path.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/07.Path.html
similarity index 100%
rename from juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/08.Path.html
rename to juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/07.Path.html
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/09.Request.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/08.Request.html
similarity index 100%
rename from juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/09.Request.html
rename to juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/08.Request.html
diff --git a/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/10.Response.html b/juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/09.Response.html
similarity index 100%
rename from juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RemoteResources/10.Response.html
rename to juneau-doc/src/main/resources/Topics/09.juneau-rest-client/01.RestProxies/09.Response.html
diff --git a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyTest.java b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyTest.java
index 486aef6..53dc18e 100644
--- a/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyTest.java
+++ b/juneau-microservice/juneau-microservice-test/src/test/java/org/apache/juneau/rest/test/client/ThirdPartyProxyTest.java
@@ -2567,28 +2567,28 @@ public class ThirdPartyProxyTest extends RestTestcase {
// Method returns status code
- @RemoteMethod(method="GET", path="/httpStatusReturn200", returns=RemoteReturn.HTTP_STATUS)
+ @RemoteMethod(method="GET", path="/httpStatusReturn200", returns=RemoteReturn.STATUS)
int httpStatusReturnInt200();
- @RemoteMethod(method="GET", path="/httpStatusReturn200", returns=RemoteReturn.HTTP_STATUS)
+ @RemoteMethod(method="GET", path="/httpStatusReturn200", returns=RemoteReturn.STATUS)
Integer httpStatusReturnInteger200();
- @RemoteMethod(method="GET", path="/httpStatusReturn404", returns=RemoteReturn.HTTP_STATUS)
+ @RemoteMethod(method="GET", path="/httpStatusReturn404", returns=RemoteReturn.STATUS)
int httpStatusReturnInt404();
- @RemoteMethod(method="GET", path="/httpStatusReturn404", returns=RemoteReturn.HTTP_STATUS)
+ @RemoteMethod(method="GET", path="/httpStatusReturn404", returns=RemoteReturn.STATUS)
Integer httpStatusReturnInteger404();
- @RemoteMethod(method="GET", path="/httpStatusReturn200", returns=RemoteReturn.HTTP_STATUS)
+ @RemoteMethod(method="GET", path="/httpStatusReturn200", returns=RemoteReturn.STATUS)
boolean httpStatusReturnBool200();
- @RemoteMethod(method="GET", path="/httpStatusReturn200", returns=RemoteReturn.HTTP_STATUS)
+ @RemoteMethod(method="GET", path="/httpStatusReturn200", returns=RemoteReturn.STATUS)
Boolean httpStatusReturnBoolean200();
- @RemoteMethod(method="GET", path="/httpStatusReturn404", returns=RemoteReturn.HTTP_STATUS)
+ @RemoteMethod(method="GET", path="/httpStatusReturn404", returns=RemoteReturn.STATUS)
boolean httpStatusReturnBool404();
- @RemoteMethod(method="GET", path="/httpStatusReturn404", returns=RemoteReturn.HTTP_STATUS)
+ @RemoteMethod(method="GET", path="/httpStatusReturn404", returns=RemoteReturn.STATUS)
Boolean httpStatusReturnBoolean404();
}
diff --git a/juneau-rest/juneau-rest-client/pom.xml b/juneau-rest/juneau-rest-client/pom.xml
index 62306d0..553af51 100644
--- a/juneau-rest/juneau-rest-client/pom.xml
+++ b/juneau-rest/juneau-rest-client/pom.xml
@@ -38,6 +38,22 @@
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.juneau</groupId>
+ <artifactId>juneau-rest-server</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<properties>
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestCall.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestCall.java
index b55074f..8d4a2f7 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestCall.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestCall.java
@@ -2148,6 +2148,9 @@ public final class RestCall extends BeanSession implements Closeable {
<T> T getResponseInner(HttpPartParser partParser, HttpPartSchema schema, ClassMeta<T> type) throws IOException, ParseException {
try {
+ if (response == null)
+ connect();
+
if (partParser == null)
partParser = this.partParser;
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
index 9919dd2..348fa96 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
@@ -1018,18 +1018,10 @@ public class RestClient extends BeanContext implements Closeable {
@SuppressWarnings({ "unchecked" })
public <T> T getRemoteResource(final Class<T> interfaceClass, Object restUrl, final Serializer serializer, final Parser parser) {
- if (restUrl == null) {
- RemoteResourceMeta rm = new RemoteResourceMeta(interfaceClass, asString(restUrl));
- String path = rm.getPath();
- if (path.indexOf("://") == -1) {
- if (rootUrl == null)
- throw new RemoteMetadataException(interfaceClass, "Root URI has not been specified. Cannot construct absolute path to remote resource.");
- path = trimSlashes(rootUrl) + '/' + path;
- }
- restUrl = path;
- }
+ if (restUrl == null)
+ restUrl = rootUrl;
- final String restUrl2 = restUrl.toString();
+ final String restUrl2 = trimSlashes(emptyIfNull(restUrl));
try {
return (T)Proxy.newProxyInstance(
@@ -1037,7 +1029,7 @@ public class RestClient extends BeanContext implements Closeable {
new Class[] { interfaceClass },
new InvocationHandler() {
- final RemoteResourceMeta rm = new RemoteResourceMeta(interfaceClass, restUrl2);
+ final RemoteResourceMeta rm = new RemoteResourceMeta(interfaceClass);
@Override /* InvocationHandler */
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
@@ -1046,7 +1038,12 @@ public class RestClient extends BeanContext implements Closeable {
if (rmm == null)
throw new RuntimeException("Method is not exposed as a remote method.");
- String url = rmm.getUrl();
+ String url = rmm.getFullPath();
+ if (url.indexOf("://") == -1)
+ url = restUrl2 + '/' + url;
+ if (url.indexOf("://") == -1)
+ throw new RemoteMetadataException(interfaceClass, "Root URI has not been specified. Cannot construct absolute path to remote resource.");
+
String httpMethod = rmm.getHttpMethod();
HttpPartSerializer s = getPartSerializer();
@@ -1108,7 +1105,7 @@ public class RestClient extends BeanContext implements Closeable {
if (rmr.getReturnValue() == RemoteReturn.NONE) {
rc.run();
return null;
- } else if (rmr.getReturnValue() == RemoteReturn.HTTP_STATUS) {
+ } else if (rmr.getReturnValue() == RemoteReturn.STATUS) {
rc.ignoreErrors();
int returnCode = rc.run();
Class<?> rt = method.getReturnType();
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethod.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethod.java
index 78f760d..4436650 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethod.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethod.java
@@ -25,7 +25,7 @@ import org.apache.juneau.http.annotation.*;
*
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
- * <li class='link'>{@doc juneau-rest-client.RemoteResources}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies}
* </ul>
*/
@Documented
@@ -35,15 +35,25 @@ import org.apache.juneau.http.annotation.*;
public @interface RemoteMethod {
/**
- * The path to the REST service for this Java method relative to the parent proxy interface URL.
+ * REST service path.
*
* <p>
- * If you do not specify a value, then the path is inferred from the Java method name.
- *
- * <h5 class='section'>See Also:</h5>
- * <ul class='doctree'>
- * <li class='link'>{@doc juneau-rest-client.RemoteResources.RemoteMethod}
+ * The possible values are:
+ * <ul class='spaced-list'>
+ * <li>An absolute URL.
+ * <li>A relative URL interpreted as relative to the root URL defined on the <code>RestClient</code> and/or {@link RemoteResource#path()}.
+ * <li>No path.
* </ul>
+ *
+ * <p>
+ * If you do not specify a path, then the path is inferred from the Java method name.
+ *
+ * <h5 class='figure'>Example:</h5>
+ * <p class='bcode'>
+ * <jc>// POST /pet</jc>
+ * <ja>@RestMethod</ja>
+ * <jk>public void</jk> postPet(...) {...}
+ * </p>
*/
String path() default "";
@@ -51,7 +61,16 @@ public @interface RemoteMethod {
* Defines the HTTP method to use for REST calls.
*
* <p>
- * The default value is <js>"GET"</js> although any valid HTTP method is possible.
+ * If not specified, then the method is inferred from the Java method name.
+ *
+ * <h5 class='figure'>Example:</h5>
+ * <p class='bcode'>
+ * <jc>// POST /pet</jc>
+ * <ja>@RestMethod</ja>
+ * <jk>public void</jk> postPet(...) {...}
+ * </p>
+ *
+ * <br>If the method cannot be inferred, then the default is <js>"GET"</js>.
*/
String method() default "";
@@ -83,7 +102,7 @@ public @interface RemoteMethod {
* {@link InputStream} - Returns access to the raw input stream of the response.
* </ul>
* <li>
- * {@link RemoteReturn#HTTP_STATUS} - The HTTP status code on the response.
+ * {@link RemoteReturn#STATUS} - The HTTP status code on the response.
* <br>The return type on the Java method can be any of the following:
* <ul>
* <li><jk>int</jk>/<code>Integer</code> - The HTTP response code.
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodArg.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodArg.java
index 9cf2f18..2cc95ea 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodArg.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodArg.java
@@ -25,7 +25,7 @@ import org.apache.juneau.httppart.*;
*
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
- * <li class='link'>{@doc juneau-rest-client.RemoteResources}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies}
* </ul>
*/
public final class RemoteMethodArg {
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodBeanArg.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodBeanArg.java
index 7e407d1..1774291 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodBeanArg.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodBeanArg.java
@@ -23,7 +23,7 @@ import org.apache.juneau.httppart.bean.*;
*
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
- * <li class='link'>{@doc juneau-rest-client.RemoteResources}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies}
* </ul>
*/
public final class RemoteMethodBeanArg {
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodMeta.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodMeta.java
index 8b4665e..e7d2c84 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodMeta.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodMeta.java
@@ -32,13 +32,13 @@ import org.apache.juneau.internal.*;
*
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
- * <li class='link'>{@doc juneau-rest-client.RemoteResources}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies}
* </ul>
*/
public class RemoteMethodMeta {
private final String httpMethod;
- private final String url, path;
+ private final String fullPath, path;
private final RemoteMethodArg[] pathArgs, queryArgs, headerArgs, formDataArgs, otherArgs;
private final RemoteMethodBeanArg[] requestArgs;
private final RemoteMethodArg bodyArg;
@@ -48,17 +48,17 @@ public class RemoteMethodMeta {
/**
* Constructor.
*
- * @param restUrl The absolute URL of the REST interface backing the interface proxy.
+ * @param parentPath The absolute URL of the REST interface backing the interface proxy.
* @param m The Java method.
* @param useMethodSignatures If <jk>true</jk> then the default path for the method should be the full method signature.
* @param defaultMethod The default HTTP method if not specified through annotation.
*/
- public RemoteMethodMeta(final String restUrl, Method m, boolean useMethodSignatures, String defaultMethod) {
- Builder b = new Builder(restUrl, m, useMethodSignatures, defaultMethod);
+ public RemoteMethodMeta(final String parentPath, Method m, boolean useMethodSignatures, String defaultMethod) {
+ Builder b = new Builder(parentPath, m, useMethodSignatures, defaultMethod);
this.method = m;
this.httpMethod = b.httpMethod;
this.path = b.path;
- this.url = b.url;
+ this.fullPath = b.fullPath;
this.pathArgs = b.pathArgs.toArray(new RemoteMethodArg[b.pathArgs.size()]);
this.queryArgs = b.queryArgs.toArray(new RemoteMethodArg[b.queryArgs.size()]);
this.formDataArgs = b.formDataArgs.toArray(new RemoteMethodArg[b.formDataArgs.size()]);
@@ -70,7 +70,7 @@ public class RemoteMethodMeta {
}
private static final class Builder {
- String httpMethod, url, path;
+ String httpMethod, fullPath, path;
List<RemoteMethodArg>
pathArgs = new LinkedList<>(),
queryArgs = new LinkedList<>(),
@@ -82,7 +82,7 @@ public class RemoteMethodMeta {
RemoteMethodArg bodyArg;
RemoteMethodReturn methodReturn;
- Builder(String restUrl, Method m, boolean useMethodSignatures, String defaultMethod) {
+ Builder(String parentPath, Method m, boolean useMethodSignatures, String defaultMethod) {
RemoteMethod rm = m.getAnnotation(RemoteMethod.class);
@@ -97,8 +97,7 @@ public class RemoteMethodMeta {
if (httpMethod.isEmpty())
httpMethod = HttpUtils.detectHttpMethod(m, ! useMethodSignatures, defaultMethod);
- if (path.startsWith("/"))
- path = path.substring(1);
+ path = trimSlashes(path);
if (! isOneOf(httpMethod, "DELETE", "GET", "POST", "PUT", "OPTIONS", "HEAD", "CONNECT", "TRACE", "PATCH"))
throw new RemoteMetadataException(m,
@@ -108,7 +107,7 @@ public class RemoteMethodMeta {
methodReturn = new RemoteMethodReturn(m, rv);
- url = trimSlashes(restUrl) + '/' + urlEncode(path);
+ fullPath = path.indexOf("://") != -1 ? path : (parentPath.isEmpty() ? urlEncode(path) : (trimSlashes(parentPath) + '/' + urlEncode(path)));
for (int i = 0; i < m.getParameterTypes().length; i++) {
RemoteMethodArg rma = RemoteMethodArg.create(m, i);
@@ -155,8 +154,8 @@ public class RemoteMethodMeta {
*
* @return The absolute URL of the REST interface, never <jk>null</jk>.
*/
- public String getUrl() {
- return url;
+ public String getFullPath() {
+ return fullPath;
}
/**
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodReturn.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodReturn.java
index c949751..3a76523 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodReturn.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteMethodReturn.java
@@ -25,7 +25,7 @@ import org.apache.juneau.httppart.*;
*
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
- * <li class='link'>{@doc juneau-rest-client.RemoteResources}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies}
* </ul>
*/
public final class RemoteMethodReturn {
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteResource.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteResource.java
index 6e9afb6..223a7ee 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteResource.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteResource.java
@@ -22,7 +22,7 @@ import java.lang.annotation.*;
*
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
- * <li class='link'>{@doc juneau-rest-client.RemoteResources}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies}
* </ul>
*/
@Documented
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteResourceMeta.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteResourceMeta.java
index eef8d56..9c786cd 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteResourceMeta.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteResourceMeta.java
@@ -28,7 +28,7 @@ import java.util.*;
*
* <h5 class='section'>See Also:</h5>
* <ul class='doctree'>
- * <li class='link'>{@doc juneau-rest-client.RemoteResources}
+ * <li class='link'>{@doc juneau-rest-client.RestProxies}
* </ul>
*/
public class RemoteResourceMeta {
@@ -40,9 +40,8 @@ public class RemoteResourceMeta {
* Constructor.
*
* @param c The interface class annotated with a {@link RemoteResource @RemoteResource} annotation (optional).
- * @param restUrl The absolute URL of the remote REST interface that implements this proxy interface.
*/
- public RemoteResourceMeta(Class<?> c, String restUrl) {
+ public RemoteResourceMeta(Class<?> c) {
String path = "";
for (RemoteResource r : getAnnotationsParentFirst(RemoteResource.class, c))
@@ -52,7 +51,7 @@ public class RemoteResourceMeta {
Map<Method,RemoteMethodMeta> methods = new LinkedHashMap<>();
for (Method m : c.getMethods())
if (isPublic(m))
- methods.put(m, new RemoteMethodMeta(restUrl, m, false, "GET"));
+ methods.put(m, new RemoteMethodMeta(path, m, false, "GET"));
this.methods = unmodifiableMap(methods);
this.path = path;
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteReturn.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteReturn.java
index b521878..92b25ea 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteReturn.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/remote/RemoteReturn.java
@@ -21,7 +21,7 @@ public enum RemoteReturn {
BODY,
/** HTTP status code */
- HTTP_STATUS,
+ STATUS,
/** Ignore (used for void methods) */
NONE;
diff --git a/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/RemoteMethodAnnotationTest.java b/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/RemoteMethodAnnotationTest.java
new file mode 100644
index 0000000..53bcc4c
--- /dev/null
+++ b/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/RemoteMethodAnnotationTest.java
@@ -0,0 +1,132 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.client.remote;
+
+import static org.junit.Assert.*;
+
+import java.io.*;
+
+import org.apache.http.*;
+import org.apache.juneau.internal.*;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client.*;
+import org.apache.juneau.rest.mock.*;
+import org.junit.*;
+import org.junit.runners.*;
+
+/**
+ * Tests the @RemoteResource annotation.
+ */
+@SuppressWarnings({"javadoc"})
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class RemoteMethodAnnotationTest {
+
+ //=================================================================================================================
+ // Inferred methods/paths
+ //=================================================================================================================
+
+ @RestResource
+ public static class A {
+ @RestMethod
+ public String get() {
+ return "foo";
+ }
+
+ @RestMethod
+ public String a01() {
+ return "bar";
+ }
+
+ @RestMethod
+ public String postA02() {
+ return "baz";
+ }
+
+ @RestMethod(path="/doFoo")
+ public String doFoo() {
+ return "qux";
+ }
+ }
+ private static MockRest a = MockRest.create(A.class);
+ private static RestClient ra = RestClient.create().mockHttpConnection(a).build();
+
+ @RemoteResource
+ public static interface A01 {
+ public String doGet();
+ public String doGET();
+ public String doFoo();
+ public String getA01();
+ public String postA02();
+ }
+
+ @Test
+ public void a01_inferredMethodsAndPaths() throws Exception {
+ A01 t = ra.getRemoteResource(A01.class);
+ assertEquals("foo", t.doGet());
+ assertEquals("foo", t.doGET());
+ assertEquals("qux", t.doFoo());
+ assertEquals("bar", t.getA01());
+ assertEquals("baz", t.postA02());
+ }
+
+ //=================================================================================================================
+ // Return types
+ //=================================================================================================================
+
+ @RestResource
+ public static class B {
+
+ @RestMethod
+ public void b01() {
+ }
+
+ @RestMethod
+ public String b02() {
+ return "foo";
+ }
+ @RestMethod
+ public String b02a() {
+ return "bar";
+ }
+ @RestMethod
+ public String b02b() {
+ return "baz";
+ }
+ @RestMethod
+ public String b02c() {
+ return "qux";
+ }
+ }
+ private static MockRest b = MockRest.create(B.class);
+ private static RestClient rb = RestClient.create().mockHttpConnection(b).build();
+
+ @RemoteResource
+ public static interface B01 {
+ public void b01();
+
+ public String b02();
+ public HttpResponse b02a();
+ public Reader b02b();
+ public InputStream b02c();
+ }
+
+ @Test
+ public void b01_returnTypes() throws Exception {
+ B01 t = rb.getRemoteResource(B01.class);
+ t.b01();
+// assertEquals("foo", t.b02());
+ assertEquals("bar", IOUtils.read(t.b02a().getEntity().getContent()));
+ assertEquals("baz", IOUtils.read(t.b02b()));
+ assertEquals("qux", IOUtils.read(t.b02c()));
+ }
+}
diff --git a/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/RemoteResourceAnnotationTest.java b/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/RemoteResourceAnnotationTest.java
new file mode 100644
index 0000000..bd8edac
--- /dev/null
+++ b/juneau-rest/juneau-rest-client/src/test/java/org/apache/juneau/rest/client/remote/RemoteResourceAnnotationTest.java
@@ -0,0 +1,283 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest.client.remote;
+
+import static org.junit.Assert.*;
+
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.client.*;
+import org.apache.juneau.rest.mock.*;
+import org.junit.*;
+import org.junit.runners.*;
+
+/**
+ * Tests the @RemoteResource annotation.
+ */
+@SuppressWarnings({"javadoc"})
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class RemoteResourceAnnotationTest {
+
+ //=================================================================================================================
+ // @RemoteResource(path), relative paths
+ //=================================================================================================================
+
+ @RestResource
+ public static class A {
+
+ @RestMethod
+ public String a01() {
+ return "foo";
+ }
+
+ @RestMethod(path="/A/a02")
+ public String a02() {
+ return "foo";
+ }
+
+ @RestMethod(path="/A/A/a03")
+ public String a03() {
+ return "foo";
+ }
+ }
+ private static MockRest a = MockRest.create(A.class);
+ private static RestClient ra = RestClient.create().mockHttpConnection(a).build();
+
+ @RemoteResource
+ public static interface A01a {
+ @RemoteMethod
+ public String a01();
+ @RemoteMethod(path="a01")
+ public String a01a();
+ @RemoteMethod(path="/a01/")
+ public String a01b();
+ }
+
+ @Test
+ public void a01_noPath() throws Exception {
+ A01a t = ra.getRemoteResource(A01a.class);
+ assertEquals("foo", t.a01());
+ assertEquals("foo", t.a01a());
+ assertEquals("foo", t.a01b());
+ }
+
+ @RemoteResource(path="A")
+ public static interface A02a {
+ @RemoteMethod
+ public String a02();
+ @RemoteMethod(path="a02")
+ public String a02a();
+ @RemoteMethod(path="/a02/")
+ public String a02b();
+ }
+
+ @Test
+ public void a02a_normalPath() throws Exception {
+ A02a t = ra.getRemoteResource(A02a.class);
+ assertEquals("foo", t.a02());
+ assertEquals("foo", t.a02a());
+ assertEquals("foo", t.a02b());
+ }
+
+ @RemoteResource(path="/A/")
+ public static interface A02b {
+ @RemoteMethod
+ public String a02();
+ @RemoteMethod(path="a02")
+ public String a02a();
+ @RemoteMethod(path="/a02/")
+ public String a02b();
+ }
+
+ @Test
+ public void a02b_normalPathWithSlashes() throws Exception {
+ A02b t = ra.getRemoteResource(A02b.class);
+ assertEquals("foo", t.a02());
+ assertEquals("foo", t.a02a());
+ assertEquals("foo", t.a02b());
+ }
+
+ @RemoteResource
+ public static interface A02c {
+ @RemoteMethod
+ public String a02();
+ @RemoteMethod(path="a02")
+ public String a02a();
+ @RemoteMethod(path="/a02/")
+ public String a02b();
+ }
+
+ @Test
+ public void a02c_pathOnClient() throws Exception {
+ try (RestClient rc = RestClient.create().mockHttpConnection(a).rootUrl("http://localhost/A").build()) {
+ A02c t = rc.getRemoteResource(A02c.class);
+ assertEquals("foo", t.a02());
+ assertEquals("foo", t.a02a());
+ assertEquals("foo", t.a02b());
+ }
+ }
+
+ @RemoteResource(path="A/A")
+ public static interface A03a {
+ @RemoteMethod
+ public String a03();
+ @RemoteMethod(path="a03")
+ public String a03a();
+ @RemoteMethod(path="/a03/")
+ public String a03b();
+ }
+
+ @Test
+ public void a03a_normalPath() throws Exception {
+ A03a t = ra.getRemoteResource(A03a.class);
+ assertEquals("foo", t.a03());
+ assertEquals("foo", t.a03a());
+ assertEquals("foo", t.a03b());
+ }
+
+ @RemoteResource(path="/A/A/")
+ public static interface A03b {
+ @RemoteMethod
+ public String a03();
+ @RemoteMethod(path="a03")
+ public String a03a();
+ @RemoteMethod(path="/a03/")
+ public String a03b();
+ }
+
+ @Test
+ public void a03b_normalPathWithSlashes() throws Exception {
+ A03b t = ra.getRemoteResource(A03b.class);
+ assertEquals("foo", t.a03());
+ assertEquals("foo", t.a03a());
+ assertEquals("foo", t.a03b());
+ }
+
+ @RemoteResource(path="A")
+ public static interface A03c {
+ @RemoteMethod
+ public String a03();
+ @RemoteMethod(path="a03")
+ public String a03a();
+ @RemoteMethod(path="/a03/")
+ public String a03b();
+ }
+
+ @Test
+ public void a03c_partialPath() throws Exception {
+ try (RestClient rc = RestClient.create().mockHttpConnection(a).rootUrl("http://localhost/A").build()) {
+ A03c t = rc.getRemoteResource(A03c.class);
+ assertEquals("foo", t.a03());
+ assertEquals("foo", t.a03a());
+ assertEquals("foo", t.a03b());
+ }
+ }
+
+ @RemoteResource(path="/A/")
+ public static interface A03d {
+ @RemoteMethod
+ public String a03();
+ @RemoteMethod(path="a03")
+ public String a03a();
+ @RemoteMethod(path="/a03/")
+ public String a03b();
+ }
+
+ @Test
+ public void a03d_partialPathExtraSlashes() throws Exception {
+ try (RestClient rc = RestClient.create().mockHttpConnection(a).rootUrl("http://localhost/A/").build()) {
+ A03d t = rc.getRemoteResource(A03d.class);
+ assertEquals("foo", t.a03());
+ assertEquals("foo", t.a03a());
+ assertEquals("foo", t.a03b());
+ }
+ }
+
+ //=================================================================================================================
+ // @RemoteResource(path), absolute paths
+ //=================================================================================================================
+
+ @RestResource
+ public static class B {
+
+ @RestMethod(path="B/b01")
+ public String b01() {
+ return "foo";
+ }
+
+ @RestMethod(path="/B/b02")
+ public String b02() {
+ return "foo";
+ }
+
+ @RestMethod(path="/B/b03")
+ public String b03() {
+ return "foo";
+ }
+ }
+ private static MockRest b = MockRest.create(B.class);
+ private static RestClient rb = RestClient.create().mockHttpConnection(b).rootUrl("http://localhost/B").build();
+
+ @RemoteResource
+ public static interface B01 {
+ @RemoteMethod
+ public String b01();
+ @RemoteMethod(path="b01")
+ public String b01a();
+ @RemoteMethod(path="/b01/")
+ public String b01b();
+ }
+
+ @Test
+ public void b01_noPath() throws Exception {
+ B01 t = rb.getRemoteResource(B01.class);
+ assertEquals("foo", t.b01());
+ assertEquals("foo", t.b01a());
+ assertEquals("foo", t.b01b());
+ }
+
+ @RemoteResource(path="http://localhost/B")
+ public static interface B02 {
+ @RemoteMethod
+ public String b01();
+ @RemoteMethod(path="b01")
+ public String b01a();
+ @RemoteMethod(path="/b01/")
+ public String b01b();
+ }
+
+ @Test
+ public void b02_absolutePathOnClass() throws Exception {
+ B02 t = rb.getRemoteResource(B02.class);
+ assertEquals("foo", t.b01());
+ assertEquals("foo", t.b01a());
+ assertEquals("foo", t.b01b());
+ }
+
+ @RemoteResource
+ public static interface B03 {
+ @RemoteMethod
+ public String b01();
+ @RemoteMethod(path="http://localhost/B/b01")
+ public String b01a();
+ @RemoteMethod(path="http://localhost/B/b01/")
+ public String b01b();
+ }
+
+ @Test
+ public void b03_absolutePathsOnMethods() throws Exception {
+ B03 t = rb.getRemoteResource(B03.class);
+ assertEquals("foo", t.b01());
+ assertEquals("foo", t.b01a());
+ assertEquals("foo", t.b01b());
+ }
+}