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 c836d34 Swagger UI enhancements.
c836d34 is described below
commit c836d34caef1eeb2112be2d2a291e82668a3f6fe
Author: JamesBognar <[email protected]>
AuthorDate: Sat Apr 14 14:21:34 2018 -0400
Swagger UI enhancements.
---
.../apache/juneau/html/HtmlDocTemplateBasic.java | 43 ++++---
juneau-doc/src/main/javadoc/overview.html | 12 ++
.../examples/rest/SampleRemoteableServlet.java | 68 -----------
.../microservice/resources/DirectoryResource.java | 29 +++--
.../apache/juneau/rest/test/HtmlDocResource.java | 1 +
.../java/org/apache/juneau/rest/RequestBody.java | 14 +++
.../org/apache/juneau/rest/RestParamDefaults.java | 26 ++++
.../org/apache/juneau/rest/annotation/HtmlDoc.java | 4 +-
.../juneau/rest/remoteable/RemoteableServlet.java | 136 +++++++++++++--------
9 files changed, 178 insertions(+), 155 deletions(-)
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java
index dfc74b1..731d394 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocTemplateBasic.java
@@ -109,32 +109,31 @@ public class HtmlDocTemplateBasic implements
HtmlDocTemplate {
@Override /* HtmlDocTemplate */
public void nav(HtmlDocSerializerSession session, HtmlWriter w, Object
o) throws Exception {
+ String[] links = session.getNavLinks();
+ if (links.length > 0 && ! ArrayUtils.contains("NONE", links)) {
+ w.sTag(3, "ol").nl(3);
+ for (String l : links) {
+ w.sTag(4, "li");
+ if (l.matches("(?s)\\S+\\:.*")) {
+ int i = l.indexOf(':');
+ String key = l.substring(0, i);
+ String val = l.substring(i+1).trim();
+ if (val.startsWith("<"))
+ w.nl(4).appendln(5, val);
+ else
+ w.oTag("a").attr("href",
session.resolveUri(val), true).cTag().text(key, true).eTag("a");
+ w.eTag("li").nl(4);
+ } else {
+ w.nl(4).appendln(5, l);
+ w.eTag(4, "li").nl(4);
+ }
+ }
+ w.eTag(3, "ol").nl(3);
+ }
String[] nav = session.getNav();
if (nav.length > 0) {
for (int i = 0; i < nav.length; i++)
w.sIf(i > 0).appendln(3, nav[i]);
- } else {
- String[] links = session.getNavLinks();
- if (links.length > 0) {
- w.sTag(3, "ol").nl(3);
- for (String l : links) {
- w.sTag(4, "li");
- if (l.matches("(?s)\\S+\\:.*")) {
- int i = l.indexOf(':');
- String key = l.substring(0, i);
- String val =
l.substring(i+1).trim();
- if (val.startsWith("<"))
- w.nl(4).appendln(5,
val);
- else
-
w.oTag("a").attr("href", session.resolveUri(val), true).cTag().text(key,
true).eTag("a");
- w.eTag("li").nl(4);
- } else {
- w.nl(4).appendln(5, l);
- w.eTag(4, "li").nl(4);
- }
- }
- w.eTag(3, "ol").nl(3);
- }
}
}
diff --git a/juneau-doc/src/main/javadoc/overview.html
b/juneau-doc/src/main/javadoc/overview.html
index 7f3922d..7313a9e 100644
--- a/juneau-doc/src/main/javadoc/overview.html
+++ b/juneau-doc/src/main/javadoc/overview.html
@@ -11537,6 +11537,8 @@
<li
class='jc'>{@link org.apache.juneau.rest.RestLogger} - Logger with additional
features.
<li
class='jc'>{@link org.apache.juneau.rest.RestContext} - The resource read-only
context.
<li
class='jc'>{@link org.apache.juneau.parser.Parser} - The parser matching the
request content type.
+ <li
class='jc'>{@link org.apache.juneau.parser.ReaderParser} - The reader parser
matching the request content type.
+ <li
class='jc'>{@link org.apache.juneau.parser.InputStreamParser} - The input
stream parser matching the request content type.
<li
class='jc'>{@link org.apache.juneau.dto.swagger.Swagger} - The auto-generated
Swagger doc.
<li
class='jc'>{@link org.apache.juneau.config.Config} - The external config for
the resource.
<li
class='jc'>{@link org.apache.juneau.rest.RequestProperties} - API for modifying
request-time configuration properties.
@@ -21448,6 +21450,16 @@
<li class='jc'>{@link
org.apache.juneau.rest.exception.VariantAlsoNegotiates}
</ul>
</ul>
+ <li>
+ The {@link
org.apache.juneau.rest.annotation.HtmlDoc#nav() @HtmlDoc.nav()} and {@link
org.apache.juneau.rest.annotation.HtmlDoc#navlinks() @HtmlDoc.navlinks()}
+ can now both be used on the same annotation.
+ <br>The contents of <code>nav()</code> are
free-form HTML that gets rendered immediately after the navigation links.
+ <li>
+ The following new parameter types can be used
on REST methods:
+ <ul>
+ <li class='jc'>{@link
org.apache.juneau.parser.ReaderParser} - The reader parser matching the request
content type.
+ <li class='jc'>{@link
org.apache.juneau.parser.InputStreamParser} - The input stream parser matching
the request content type.
+ </ul>
</ul>
<h5 class='topic w800'>juneau-rest-client</h5>
diff --git
a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SampleRemoteableServlet.java
b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SampleRemoteableServlet.java
index c62fd99..c32de94 100644
---
a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SampleRemoteableServlet.java
+++
b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/SampleRemoteableServlet.java
@@ -12,15 +12,10 @@
//
***************************************************************************************************************************
package org.apache.juneau.examples.rest;
-import static org.apache.juneau.http.HttpMethodName.*;
-
import java.util.*;
import java.util.Map;
-import org.apache.juneau.dto.*;
-import org.apache.juneau.dto.html5.*;
import org.apache.juneau.examples.addressbook.*;
-import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.remoteable.*;
@@ -73,67 +68,4 @@ public class SampleRemoteableServlet extends
RemoteableServlet {
m.put(AddressBook.class, addressBook);
return m;
}
-
-
//-----------------------------------------------------------------------------------------------------------------
- // Overridden methods to provide aside messages
-
//-----------------------------------------------------------------------------------------------------------------
-
- @Override /* RemoteableServlet */
- @RestMethod(
- name=GET,
- path="/",
- summary="List of available remoteable interfaces",
- description="Shows a list of the interfaces registered with
this remoteable servlet.",
- htmldoc=@HtmlDoc(
- aside={
- "<div style='max-width:400px;min-width:200px'
class='text'>",
- " <p>Shows how to use the
<code>RemoteableServlet</code> class to define RPC-style remoteable interfaces
using REST as a protocol.</p>",
- " <p>Remoteable proxies are retrieved on
the client side using <code>RestClient.getInterfaceProxy(Class)</code>.</p>",
- " <p>Methods are invoked using POSTs of
serialized arrays of objects and the returned value is marshalled back as a
response.</p>",
- " <p>This page shows the list of keys
returned by the getServiceMap() method which returns a Map<Class,Object>
which maps interfaces to objects.</p>",
- " <p>This example shows the differences
between using interfaces (preferred) and classes as keys.</p>",
- "</div>"
- }
- )
- )
- public List<LinkString> getInterfaces(RestRequest req) throws Exception
{
- return super.getInterfaces(req);
- }
-
- @Override /* RemoteableServlet */
- @RestMethod(
- name=GET,
- path="/{javaInterface}",
- summary="List of available methods on
$CO{{$RP{javaInterface},an interface}",
- htmldoc=@HtmlDoc(
- aside={
- "<div style='max-width:400px;min-width:200px'
class='text'>",
- " <p>Shows the list of methods defined on
this interface.</p>",
- " <p>Links take you to a form-entry page
for testing.</p>",
- "</div>"
- }
- )
- )
- public Collection<LinkString> listMethods(RestRequest req,
@Path("javaInterface") String javaInterface) throws Exception {
- return super.listMethods(req, javaInterface);
- }
-
- @Override /* RemoteableServlet */
- @RestMethod(
- name=GET,
- path="/{javaInterface}/{javaMethod}",
- summary="Form entry for $CO{$RP{javaMethod},method} on
$CO{$RP{javaInterface},interface}",
- htmldoc=@HtmlDoc(
- aside={
- "<div style='max-width:400px;min-width:200px'
class='text'>",
- " <p>A rudimentary form-entry page.</p>",
- " <p>When using this form, arguments are
passed as a URL-encoded FORM post.</p>",
- " <p>However, other formats such as JSON
and XML can also be posted.</p>",
- "</div>"
- }
- )
- )
- public Div showEntryForm(RestRequest req, @Path("javaInterface") String
javaInterface, @Path("javaMethod") String javaMethod) throws Exception {
- return super.showEntryForm(req, javaInterface, javaMethod);
- }
}
diff --git
a/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
b/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
index e5be768..9d50ec6 100755
---
a/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
+++
b/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
@@ -55,9 +55,6 @@ import org.apache.juneau.utils.*;
* <li>
* <l>DirectoryResource.allowDeletes</l> - If <jk>true</jk>,
allows files to be deleted.
* </ul>
- *
- * <p>
- * Access can also be controlled by overriding the {@link
#checkAccess(RestRequest)} method.
*/
@RestResource(
title="File System Explorer",
@@ -117,11 +114,18 @@ public class DirectoryResource extends BasicRestServlet {
path="/*",
summary="View files on directory",
description="Returns a listing of all files in the specified
directory.",
- converters={Queryable.class}
+ converters={Queryable.class},
+ htmldoc=@HtmlDoc(
+ nav={"<h5>Folder: $RA{fullPath}</h5>"}
+ )
)
- public FileListing listFiles(@PathRemainder String path) throws
NotFound, Exception {
+ public FileListing listFiles(RestRequest req, @PathRemainder String
path) throws NotFound, Exception {
+
+ File dir = getDir(path);
+ req.setAttribute("fullPath", dir.getAbsolutePath());
+
FileListing l = new FileListing();
- for (File fc : getDir(path).listFiles())
+ for (File fc : dir.listFiles())
l.add(new FileResource(fc, (path != null ? (path + '/')
: "") + urlEncode(fc.getName())));
return l;
}
@@ -130,10 +134,17 @@ public class DirectoryResource extends BasicRestServlet {
name=GET,
path="/file/*",
summary="View information about file",
- description="Returns detailed information about the specified
file."
+ description="Returns detailed information about the specified
file.",
+ htmldoc=@HtmlDoc(
+ nav={"<h5>File: $RA{fullPath}</h5>"}
+ )
)
- public FileResource getFileInfo(@PathRemainder String path) throws
NotFound, Exception {
- return new FileResource(getFile(path), path);
+ public FileResource getFileInfo(RestRequest req, @PathRemainder String
path) throws NotFound, Exception {
+
+ File f = getFile(path);
+ req.setAttribute("fullPath", f.getAbsolutePath());
+
+ return new FileResource(f, path);
}
@RestMethod(
diff --git
a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocResource.java
b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocResource.java
index 4881d3c..e836a57 100644
---
a/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocResource.java
+++
b/juneau-microservice/juneau-microservice-test/src/main/java/org/apache/juneau/rest/test/HtmlDocResource.java
@@ -24,6 +24,7 @@ import org.apache.juneau.rest.annotation.*;
aside={"aside1a","aside1b","INHERIT"},
footer={"footer1a","footer1b"},
header={"header1a","header1b"},
+ navlinks={"NONE"},
nav={"nav1a","nav1b"},
script={"script1a","script1b"},
style={"style1a","style1b"},
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestBody.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestBody.java
index dfddced..22e91fe 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestBody.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RequestBody.java
@@ -372,6 +372,20 @@ public class RequestBody {
return null;
}
+ /**
+ * Returns the input stream parser matching the request
<code>Content-Type</code> header.
+ *
+ * @return
+ * The input stream parser matching the request
<code>Content-Type</code> header, or <jk>null</jk> if no matching
+ * reader parser was found, or the matching parser was a reader
parser.
+ */
+ public InputStreamParser getInputStreamParser() {
+ Parser p = getParser();
+ if (p != null && ! p.isReaderParser())
+ return (InputStreamParser)p;
+ return null;
+ }
+
/* Workhorse method */
private <T> T parse(ClassMeta<T> cm) throws BadRequest,
UnsupportedMediaType, InternalServerError {
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
index dafc52a..3e7f48a 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
@@ -111,6 +111,8 @@ class RestParamDefaults {
RestLoggerObject.class,
RestContextObject.class,
ParserObject.class,
+ ReaderParserObject.class,
+ InputStreamParserObject.class,
LocaleObject.class,
SwaggerObject.class,
RequestPathMatchObject.class,
@@ -1012,6 +1014,30 @@ class RestParamDefaults {
}
}
+ static final class ReaderParserObject extends RestMethodParam {
+
+ protected ReaderParserObject() {
+ super(OTHER, null, ReaderParser.class);
+ }
+
+ @Override /* RestMethodParam */
+ public Object resolve(RestRequest req, RestResponse res) throws
Exception {
+ return req.getBody().getReaderParser();
+ }
+ }
+
+ static final class InputStreamParserObject extends RestMethodParam {
+
+ protected InputStreamParserObject() {
+ super(OTHER, null, InputStreamParser.class);
+ }
+
+ @Override /* RestMethodParam */
+ public Object resolve(RestRequest req, RestResponse res) throws
Exception {
+ return req.getBody().getInputStreamParser();
+ }
+ }
+
static final class LocaleObject extends RestMethodParam {
protected LocaleObject() {
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/HtmlDoc.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/HtmlDoc.java
index fee217f..1fe9bb7 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/HtmlDoc.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/HtmlDoc.java
@@ -276,7 +276,7 @@ public @interface HtmlDoc {
* <ja>@RestResource</ja>(
* htmldoc=<ja>@HtmlDoc</ja>(
* nav={
- * <js>"<p>Custom nav
content</p>"</js>
+ * <js>"<h5>Custom nav
content</h5>"</js>
* }
* )
* )
@@ -287,7 +287,7 @@ public @interface HtmlDoc {
* <li>
* The format of this value is HTML.
* <li>
- * When a value is specified, the {@link #navlinks()}
value will be ignored.
+ * When {@link #navlinks()} is also specified, this
content is placed AFTER the navigation links.
* <li>
* Supports <a class="doclink"
href="../../../../../overview-summary.html#DefaultRestSvlVariables">initialization-time
and request-time variables</a>
* (e.g. <js>"$L{my.localized.variable}"</js>).
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/remoteable/RemoteableServlet.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/remoteable/RemoteableServlet.java
index 04209d4..df36c7e 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/remoteable/RemoteableServlet.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/remoteable/RemoteableServlet.java
@@ -16,6 +16,7 @@ import static org.apache.juneau.dto.html5.HtmlBuilder.*;
import static org.apache.juneau.http.HttpMethodName.*;
import static org.apache.juneau.internal.StringUtils.*;
+import java.io.*;
import java.lang.reflect.*;
import java.util.*;
import java.util.Map;
@@ -24,10 +25,12 @@ import java.util.concurrent.*;
import org.apache.juneau.*;
import org.apache.juneau.dto.*;
import org.apache.juneau.dto.html5.*;
+import org.apache.juneau.http.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.annotation.Header;
import org.apache.juneau.rest.exception.*;
/**
@@ -45,7 +48,7 @@ import org.apache.juneau.rest.exception.*;
* <li class='link'><a class="doclink"
href="../../../../../overview-summary.html#juneau-rest-server.RemoteableProxies">Overview
> juneau-rest-server > Remoteable Proxies</a>
* </ul>
*/
-@SuppressWarnings("serial")
+@SuppressWarnings({"serial","javadoc"})
public abstract class RemoteableServlet extends BasicRestServlet {
private final Map<String,Class<?>> classNameMap = new
ConcurrentHashMap<>();
@@ -69,53 +72,56 @@ public abstract class RemoteableServlet extends
BasicRestServlet {
// REST methods
//--------------------------------------------------------------------------------
- /**
- * [GET /] - Get the list of all remote interfaces.
- *
- * @param req The HTTP servlet request.
- * @return The list of links to the remote interfaces.
- * @throws Exception
- */
- @RestMethod(name=GET, path="/")
- public List<LinkString> getInterfaces(RestRequest req) throws Exception
{
+ @RestMethod(
+ name=GET,
+ path="/",
+ summary="List of available remoteable interfaces",
+ description="Shows a list of the interfaces registered with
this remoteable servlet."
+ )
+ public List<LinkString> getInterfaces() throws Exception {
List<LinkString> l = new LinkedList<>();
boolean useAll = ! useOnlyAnnotated();
- for (Class<?> c : getServiceMap().keySet()) {
+ for (Class<?> c : getServiceMap().keySet())
if (useAll ||
getContext().getBeanContext().getClassMeta(c).isRemoteable())
- l.add(new LinkString(c.getName(), "{0}/{1}",
req.getRequestURI(), urlEncode(c.getName())));
- }
+ l.add(new LinkString(c.getName(),
"servlet:/{0}", urlEncode(c.getName())));
return l;
}
- /**
- * [GET /{javaInterface] - Get the list of all remoteable methods on
the specified interface name.
- *
- * @param req The HTTP servlet request.
- * @param javaInterface The Java interface name.
- * @return The methods defined on the interface.
- * @throws Exception
- */
- @RestMethod(name=GET, path="/{javaInterface}", summary="List of
available methods on $RP{javaInterface}.")
- public Collection<LinkString> listMethods(RestRequest req,
@Path("javaInterface") String javaInterface) throws Exception {
+ @RestMethod(
+ name=GET,
+ path="/{javaInterface}",
+ summary="List of available methods on interface",
+ description="Shows a list of all the exposed methods on an
interface.",
+ htmldoc=@HtmlDoc(
+ nav="<h5>Interface: $RP{javaInterface}</h5>"
+ )
+ )
+ public Collection<LinkString> listMethods(
+ @Path(value="javaInterface", description="Java
interface name", example="com.foo.MyInterface") String javaInterface
+ ) throws Exception {
+
List<LinkString> l = new ArrayList<>();
- for (String s : getMethods(javaInterface).keySet()) {
- l.add(new LinkString(s, "{0}/{1}", req.getRequestURI(),
urlEncode(s)));
- }
+ for (String s : getMethods(javaInterface).keySet())
+ l.add(new LinkString(s, "servlet:/{0}/{1}",
urlEncode(javaInterface), urlEncode(s)));
return l;
}
- /**
- * [GET /{javaInterface] - Get the list of all remoteable methods on
the specified interface name.
- *
- * @param req The HTTP servlet request.
- * @param javaInterface The Java interface name.
- * @param javaMethod The Java method name or signature.
- * @return A simple form entry page for invoking a remoteable method.
- * @throws NotFound
- * @throws Exception
- */
- @RestMethod(name=GET, path="/{javaInterface}/{javaMethod}",
summary="Form entry for method $RP{javaMethod} on interface $RP{javaInterface}")
- public Div showEntryForm(RestRequest req, @Path("javaInterface") String
javaInterface, @Path("javaMethod") String javaMethod) throws NotFound,
Exception {
+ @RestMethod(
+ name=GET,
+ path="/{javaInterface}/{javaMethod}",
+ summary="Form entry for interface method call",
+ description="Shows a form entry page for executing a remoteable
interface method.",
+ htmldoc=@HtmlDoc(
+ nav={
+ "<h5>Interface: $RP{javaInterface}</h5>",
+ "<h5>Method: $RP{javaMethod}</h5>"
+ }
+ )
+ )
+ public Div showEntryForm(
+ @Path(value="javaInterface", description="Java
interface name", example="com.foo.MyInterface") String javaInterface,
+ @Path(value="javaMethod", description="Java method
name", example="myMethod") String javaMethod
+ ) throws NotFound, Exception {
// Find the method.
java.lang.reflect.Method m =
getMethods(javaInterface).get(javaMethod);
@@ -148,24 +154,46 @@ public abstract class RemoteableServlet extends
BasicRestServlet {
return
div(form().id("form").action("request:/").method(POST).children(t));
}
- /**
- * [POST /{javaInterface}/{javaMethod}] - Invoke the specified service
method.
- *
- * @param req The HTTP request.
- * @param javaInterface The Java interface name.
- * @param javaMethod The Java method name or signature.
- * @return The results from invoking the specified Java method.
- * @throws UnsupportedMediaType
- * @throws NotFound
- * @throws Exception
- */
- @RestMethod(name=POST, path="/{javaInterface}/{javaMethod}")
- public Object invoke(RestRequest req, @Path String javaInterface, @Path
String javaMethod) throws UnsupportedMediaType, NotFound, Exception {
+ @RestMethod(
+ name=POST,
+ path="/{javaInterface}/{javaMethod}",
+ summary="Invoke an interface method",
+ description="Invoke a Java method by passing in the arguments
as an array of serialized objects.\nThe returned object is then serialized to
the response.",
+ htmldoc=@HtmlDoc(
+ nav= {
+ "<h5>Interface: $RP{javaInterface}</h5>",
+ "<h5>Method: $RP{javaMethod}</h5>"
+ }
+ ),
+ swagger= {
+ "parameters: [",
+ "{",
+ "in: 'body',",
+ "description: 'Serialized array of Java
objects',",
+ "schema: {",
+ "type': 'array'",
+ "},",
+ "x-examples: {",
+ "'application/json+lax':
'[\\'foo\\', 123, true]'",
+ "}",
+ "}",
+ "],",
+ "responses:{",
+ "200:{ description:'The return object
serialized', schema:{type:'any'},'x-example':{foo:123} }",
+ "}"
+ }
+ )
+ public Object invoke(
+ Reader r,
+ ReaderParser p,
+ @Header("Content-Type") ContentType contentType,
+ @Path(value="javaInterface", description="Java
interface name", example="com.foo.MyInterface") String javaInterface,
+ @Path(value="javaMethod", description="Java method
name", example="myMethod") String javaMethod
+ ) throws UnsupportedMediaType, NotFound, Exception {
// Find the parser.
- ReaderParser p = req.getBody().getReaderParser();
if (p == null)
- throw new UnsupportedMediaType("Could not find parser
for media type ''{0}''", req.getHeaders().getContentType());
+ throw new UnsupportedMediaType("Could not find parser
for media type ''{0}''", contentType);
Class<?> c = getInterfaceClass(javaInterface);
// Find the service.
@@ -179,7 +207,7 @@ public abstract class RemoteableServlet extends
BasicRestServlet {
throw new NotFound("Method not found");
// Parse the args and invoke the method.
- Object[] params = p.parseArgs(req.getReader(),
m.getGenericParameterTypes());
+ Object[] params = p.parseArgs(r, m.getGenericParameterTypes());
return m.invoke(service, params);
}
--
To stop receiving notification emails like this one, please contact
[email protected].