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 890ef7f73 Improvements to REST config interfaces.
890ef7f73 is described below
commit 890ef7f73ef56110aae6975ea4b080253c9886da
Author: JamesBognar <[email protected]>
AuthorDate: Sun Jul 3 14:38:56 2022 -0400
Improvements to REST config interfaces.
---
.../org/apache/juneau/dto/swagger/Swagger.java | 8 +
.../org/apache/juneau/collections/JsonList.java | 9 +
.../org/apache/juneau/collections/JsonMap.java | 9 +
.../org/apache/juneau/httppart/HttpPartType.java | 3 +
.../apache/juneau/marshaller/CharMarshaller.java | 4 +
.../java/org/apache/juneau/marshaller/Csv.java | 8 +
.../java/org/apache/juneau/marshaller/Html.java | 8 +
.../java/org/apache/juneau/marshaller/Json.java | 8 +
.../org/apache/juneau/marshaller/Marshaller.java | 4 +
.../java/org/apache/juneau/marshaller/MsgPack.java | 8 +
.../java/org/apache/juneau/marshaller/OpenApi.java | 23 +-
.../org/apache/juneau/marshaller/PlainText.java | 8 +
.../org/apache/juneau/marshaller/SimpleJson.java | 8 +
.../apache/juneau/marshaller/StreamMarshaller.java | 4 +
.../java/org/apache/juneau/marshaller/Uon.java | 8 +
.../org/apache/juneau/marshaller/UrlEncoding.java | 8 +
.../java/org/apache/juneau/marshaller/Xml.java | 8 +
.../docs/Topics/01.Overview/01.o.Marshalling.html | 11 +-
.../docs/Topics/01.Overview/02.o.EndToEndRest.html | 2 +-
.../docs/Topics/01.Overview/03.o.RestServer.html | 209 ++++++++++++++++-
.../docs/Topics/01.Overview/04.o.RestClient.html | 5 +-
juneau-doc/docs/Topics/01.Overview/05.o.Dtos.html | 8 +-
.../Topics/01.Overview/07.o.FluentAssertions.html | 14 +-
juneau-doc/src/main/javadoc/overview.html | 247 +++++++++++++++++++--
.../java/org/apache/juneau/rest/RestContext.java | 4 +-
.../java/org/apache/juneau/rest/RestRequest.java | 6 +-
.../java/org/apache/juneau/rest/RestResponse.java | 6 +-
.../org/apache/juneau/rest/annotation/Rest.java | 2 +-
.../apache/juneau/rest/config/BasicJsonConfig.java | 16 +-
.../juneau/rest/config/BasicJsonHtmlConfig.java | 46 +---
.../juneau/rest/config/BasicOpenApiConfig.java | 16 +-
.../juneau/rest/config/BasicSimpleJsonConfig.java | 15 +-
.../juneau/rest/config/BasicUniversalConfig.java | 49 +---
.../apache/juneau/rest/config/DefaultConfig.java | 129 +++++++++++
.../juneau/rest/config/DefaultHtmlConfig.java | 71 +++---
.../rest/annotation/RestAnnotation_Test.java | 10 +-
36 files changed, 775 insertions(+), 227 deletions(-)
diff --git
a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Swagger.java
b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Swagger.java
index 196e43276..b25446fc5 100644
---
a/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Swagger.java
+++
b/juneau-core/juneau-dto/src/main/java/org/apache/juneau/dto/swagger/Swagger.java
@@ -978,6 +978,14 @@ public class Swagger extends SwaggerElement {
return new MultiSet<>(s, super.keySet());
}
+ /**
+ * A synonym of {@link #toString()}.
+ * @return This object serialized as JSON.
+ */
+ public String asJson() {
+ return toString();
+ }
+
@Override /* Object */
public String toString() {
return JsonSerializer.DEFAULT.toString(this);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonList.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonList.java
index aaeaa3418..73be978ea 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonList.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonList.java
@@ -1058,6 +1058,15 @@ public class JsonList extends LinkedList<Object> {
// Overridden methods.
//------------------------------------------------------------------------------------------------------------------
+ /**
+ * A synonym for {@link #toString()}
+ *
+ * @return This object as a JSON string.
+ */
+ public String asJson() {
+ return toString();
+ }
+
@Override /* Object */
public String toString() {
return SimpleJson.of(this);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
index 7deae2100..915f977b7 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/collections/JsonMap.java
@@ -1892,6 +1892,15 @@ public class JsonMap extends
LinkedHashMap<String,Object> {
};
}
+ /**
+ * A synonym for {@link #toString()}
+ *
+ * @return This object as a JSON string.
+ */
+ public String asJson() {
+ return toString();
+ }
+
@Override /* Object */
public String toString() {
return SimpleJson.of(this);
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartType.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartType.java
index a2bead58c..d11f00e27 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartType.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartType.java
@@ -46,6 +46,9 @@ public enum HttpPartType {
/** An HTTP response status code */
RESPONSE_STATUS,
+ /** Generic part */
+ ANY,
+
/** A non-standard field */
OTHER,
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/CharMarshaller.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/CharMarshaller.java
index df789fb58..8ecf72f16 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/CharMarshaller.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/CharMarshaller.java
@@ -28,6 +28,10 @@ import org.apache.juneau.serializer.*;
*/
public class CharMarshaller extends Marshaller {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
private final ReaderParser p;
private final WriterSerializer s;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Csv.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Csv.java
index 77fce1f1b..264ac99b7 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Csv.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Csv.java
@@ -31,11 +31,19 @@ import org.apache.juneau.serializer.*;
*/
public class Csv extends CharMarshaller {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Static
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Default reusable instance.
*/
public static final Csv DEFAULT = new Csv();
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Html.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Html.java
index 92e7fb9fd..614843856 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Html.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Html.java
@@ -47,11 +47,19 @@ import org.apache.juneau.serializer.*;
*/
public class Html extends CharMarshaller {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Static
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Default reusable instance.
*/
public static final Html DEFAULT = new Html();
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Json.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Json.java
index 443e68e8c..871cf050c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Json.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Json.java
@@ -47,11 +47,19 @@ import org.apache.juneau.serializer.*;
*/
public class Json extends CharMarshaller {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Static
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Default reusable instance.
*/
public static final Json DEFAULT = new Json();
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Marshaller.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Marshaller.java
index 3a833fae0..00ea2f341 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Marshaller.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Marshaller.java
@@ -47,6 +47,10 @@ import org.apache.juneau.serializer.*;
*/
public abstract class Marshaller {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
private final Serializer s;
private final Parser p;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/MsgPack.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/MsgPack.java
index 768c9cd80..446093962 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/MsgPack.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/MsgPack.java
@@ -46,11 +46,19 @@ import org.apache.juneau.serializer.*;
*/
public class MsgPack extends StreamMarshaller {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Static
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Default reusable instance.
*/
public static final MsgPack DEFAULT = new MsgPack();
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/OpenApi.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/OpenApi.java
index 6a87b5c23..60a6cffda 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/OpenApi.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/OpenApi.java
@@ -48,11 +48,22 @@ import org.apache.juneau.serializer.*;
*/
public class OpenApi extends CharMarshaller {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Static
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Default reusable instance.
*/
public static final OpenApi DEFAULT = new OpenApi();
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
+ private final OpenApiSerializer s;
+ private final OpenApiParser p;
+
/**
* Constructor.
*
@@ -65,6 +76,8 @@ public class OpenApi extends CharMarshaller {
*/
public OpenApi(OpenApiSerializer s, OpenApiParser p) {
super(s, p);
+ this.s = s;
+ this.p = p;
}
/**
@@ -130,7 +143,6 @@ public class OpenApi extends CharMarshaller {
* A shortcut for calling <c><jsf>DEFAULT</jsf>.read(<jv>input</jv>,
<jv>type</jv>)</c>.
*
* @param <T> The class type of the object being created.
- * @param partType The part type being created.
* @param schema The part type schema. Can be <jk>null</jk>.
* @param input
* The input.
@@ -139,8 +151,8 @@ public class OpenApi extends CharMarshaller {
* @throws ParseException Malformed input encountered.
* @throws IOException Thrown by underlying stream.
*/
- public static <T> T to(HttpPartType partType, HttpPartSchema schema,
String input, Class<T> type) throws ParseException, IOException {
- return ((OpenApiParser)DEFAULT.getParser()).parse(partType,
schema, input, type);
+ public static <T> T to(HttpPartSchema schema, String input, Class<T>
type) throws ParseException, IOException {
+ return DEFAULT.p.parse(HttpPartType.ANY, schema, input, type);
}
/**
@@ -248,13 +260,12 @@ public class OpenApi extends CharMarshaller {
*
* <p>
* A shortcut for calling
<c><jsf>DEFAULT</jsf>.write(<jv>output</jv>)</c>.
- * @param partType The part type being parsed.
* @param schema The part schema. Can be <jk>null</jk>.
* @param object The object to serialize.
* @return The output object.
* @throws SerializeException If a problem occurred trying to convert
the output.
*/
- public static String of(HttpPartType partType, HttpPartSchema schema,
Object object) throws SerializeException {
- return
((OpenApiSerializer)DEFAULT.getSerializer()).serialize(partType, schema,
object);
+ public static String of(HttpPartSchema schema, Object object) throws
SerializeException {
+ return DEFAULT.s.serialize(HttpPartType.ANY, schema, object);
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/PlainText.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/PlainText.java
index 6d9956526..ce6f2936e 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/PlainText.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/PlainText.java
@@ -47,11 +47,19 @@ import org.apache.juneau.serializer.*;
*/
public class PlainText extends CharMarshaller {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Static
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Default reusable instance.
*/
public static final PlainText DEFAULT = new PlainText();
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/SimpleJson.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/SimpleJson.java
index 813925a05..23a6ed9a3 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/SimpleJson.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/SimpleJson.java
@@ -47,6 +47,10 @@ import org.apache.juneau.serializer.*;
*/
public class SimpleJson extends CharMarshaller {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Static
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Default reusable instance.
*/
@@ -57,6 +61,10 @@ public class SimpleJson extends CharMarshaller {
*/
public static final SimpleJson DEFAULT_READABLE = new
SimpleJson(SimpleJsonSerializer.DEFAULT_READABLE, SimpleJsonParser.DEFAULT);
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/StreamMarshaller.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/StreamMarshaller.java
index d132436aa..82edeace2 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/StreamMarshaller.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/StreamMarshaller.java
@@ -29,6 +29,10 @@ import org.apache.juneau.serializer.*;
*/
public class StreamMarshaller extends Marshaller {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
private final OutputStreamSerializer s;
private final InputStreamParser p;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Uon.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Uon.java
index 1906706ad..133acea90 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Uon.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Uon.java
@@ -47,11 +47,19 @@ import org.apache.juneau.uon.*;
*/
public class Uon extends CharMarshaller {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Static
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Default reusable instance.
*/
public static final Uon DEFAULT = new Uon();
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/UrlEncoding.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/UrlEncoding.java
index 9fffbc242..c039d48a3 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/UrlEncoding.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/UrlEncoding.java
@@ -47,11 +47,19 @@ import org.apache.juneau.urlencoding.*;
*/
public class UrlEncoding extends CharMarshaller {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Static
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Default reusable instance.
*/
public static final UrlEncoding DEFAULT = new UrlEncoding();
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Xml.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Xml.java
index f0e88e76a..f646f342e 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Xml.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/marshaller/Xml.java
@@ -47,11 +47,19 @@ import org.apache.juneau.xml.*;
*/
public class Xml extends CharMarshaller {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Static
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Default reusable instance.
*/
public static final Xml DEFAULT = new Xml();
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
diff --git a/juneau-doc/docs/Topics/01.Overview/01.o.Marshalling.html
b/juneau-doc/docs/Topics/01.Overview/01.o.Marshalling.html
index c473302d2..8be06b28a 100644
--- a/juneau-doc/docs/Topics/01.Overview/01.o.Marshalling.html
+++ b/juneau-doc/docs/Topics/01.Overview/01.o.Marshalling.html
@@ -322,7 +322,7 @@
| Object <jv>value</jv> = <jk>new
long</jk>[][]{{1,2,3},{4,5,6},{7,8,9}};
|
| <jc>// Produces "1,2,3|4,5,6|7,8,9"</jc>
- | String <jv>output</jv> =
OpenApi.<jsm>of</jsm>(HttpPartType.<jsf>HEADER</jsf>, <jv>schema</jv>,
<jv>value</jv>);
+ | String <jv>output</jv> =
OpenApi.<jsm>of</jsm>(<jv>schema</jv>, <jv>value</jv>);
</p>
<p>
Schema-based serialization and parsing is used heavily in both
the server and client REST APIs with built-in schema
@@ -351,8 +351,8 @@
</p>
<p class='bjava'>
| <jc>// Create JSON strings from scratch using
fluent-style code.</jc>
- | String <jv>myMap</jv> =
JsonMap.<jsm>create</jsm>().append(<js>"foo"</js>,<js>"bar"</js>).toString();
- | String <jv>myList</jv> =
JsonList.<jsm>of</jsm>(<js>"foo"</js>, 123, <jk>null</jk>,
<jv>jsonObject</jv>).toString();
+ | String <jv>myMap</jv> =
JsonMap.<jsm>create</jsm>().append(<js>"foo"</js>,<js>"bar"</js>).asJson();
+ | String <jv>myList</jv> =
JsonList.<jsm>of</jsm>(<js>"foo"</js>, 123, <jk>null</jk>,
<jv>jsonObject</jv>).asJson();
|
| <jc>// Parse directly from JSON into generic DOMs.</jc>
| Map<String,Object> <jv>myMap</jv> =
JsonMap.<jsm>ofJson</jsm>(<js>"{foo:'bar'}"</js>);
@@ -373,11 +373,12 @@
<h5 class='topic'>Serializer and Parser Sets</h5>
<div class='topic'>
<p>
- <code>SerializerSet</code> and <code>ParserSet</code> classes
allow serializers and parsers
+ {@link oaj.serializer.SerializerSet} and {@link
oaj.parser.ParserSet} classes allow serializers and parsers
to be retrieved by W3C-compliant HTTP <code>Accept</code> and
<code>Content-Type</code> values:
</p>
<p class='bjava'>
- | <jc>// Construct a new serializer group with
configuration parameters that get applied to all serializers.</jc>
+ | <jc>// Construct a new serializer group with
configuration parameters that get applied
+ | // to all serializers.</jc>
| SerializerSet <jv>serializerSet</jv> = SerializerSet
| .<jsm>create</jsm>()
| .add(JsonSerializer.<jk>class</jk>,
UrlEncodingSerializer.<jk>class</jk>);
diff --git a/juneau-doc/docs/Topics/01.Overview/02.o.EndToEndRest.html
b/juneau-doc/docs/Topics/01.Overview/02.o.EndToEndRest.html
index a913bba62..5646fd2c8 100644
--- a/juneau-doc/docs/Topics/01.Overview/02.o.EndToEndRest.html
+++ b/juneau-doc/docs/Topics/01.Overview/02.o.EndToEndRest.html
@@ -35,7 +35,7 @@
| <ja>@Header</ja>(<js>"E-Tag"</js>) UUID
<jv>etag</jv>,
| <ja>@Query</ja>(<js>"debug"</js>)
<jk>boolean</jk> <jv>debug</jv>
| ) <jk>throws</jk> BadRequest, Unauthorized,
InternalServerError {
- | <jc>// Process request.</jc>
+ | <jc>// Process request here.</jc>
| <jk>return</jk> Ok.<jsf>OK</jsf>;
<jc>// Standard 400-OK response.</jc>
| }
| }
diff --git a/juneau-doc/docs/Topics/01.Overview/03.o.RestServer.html
b/juneau-doc/docs/Topics/01.Overview/03.o.RestServer.html
index 0aa8890bb..d9e93dd94 100644
--- a/juneau-doc/docs/Topics/01.Overview/03.o.RestServer.html
+++ b/juneau-doc/docs/Topics/01.Overview/03.o.RestServer.html
@@ -57,7 +57,7 @@
| http://localhost:10000/helloWorld
</p>
<img class='bordered w800' src='doc-files/jrs.HelloWorldExample.1.png'>
- <ul>
+ <ul class='spaced-list'>
<li>Parsers for request bodies are selected based on the
request <c>Content-Type</c> header.
<li>Serializers for response bodies are selected based on the
request <c>Accept</c> header.
<ul>
@@ -91,20 +91,217 @@
| <ja>@Rest</ja>(
| path=<js>"/child"</js> <jc>// Path relative to
parent resource.</jc>
| )
- | <jk>public</jk> MyChildResource {...} <jc>// Note that
we don't need to extend from RestServlet.</jc>
+ | <jc>// Note that we don't need to extend from
RestServlet.</jc>
+ | <jk>public</jk> MyChildResource <jk>implements</jk>
BasicUniversalConfig {
+ | ...
+ | }
</p>
<p>
The path of the child resource gets appended to the path of the
parent resource.
So in the example above, the child resource is accessed through
the URL <l>/parent/child</l>.
</p>
<p>
- A HUGE advantage of using child resources is that they do not
need to be declared in the JEE <l>web.xml</l>
+ The advantage of using child resources is that they do not need
to be declared in the JEE <l>web.xml</l>
file.
Initialization of and access to the child resources occurs
through the parent resource.
Children can be nested arbitrary deep to create complex REST
interfaces with a single top-level REST servlet.
</p>
</div>
+<h5 class='topic'>Predefined Configuration Interfaces</h5>
+<div class='topic'>
+ <p>
+ The servlets in the previous section implemented the {@link
oajr.config.BasicUniversalConfig} which simply defines
+ a preconfigured set of annotations that get inherited by the
child classes:
+ </p>
+ <p class='bjava'>
+ | <jd>/**
+ | * Predefined configuration for a REST resource that
supports all languages
+ | * and provides common default configuration
values.</jd>
+ | */</jd>
+ | <ja>@Rest</ja>(
+ |
+ | <jc>// Default serializers for all Java methods
in the class.</jc>
+ | serializers={
+ | HtmlDocSerializer.<jk>class</jk>,
+ |
HtmlStrippedDocSerializer.<jk>class</jk>,
+ | HtmlSchemaDocSerializer.<jk>class</jk>,
+ | JsonSerializer.<jk>class</jk>,
+ | SimpleJsonSerializer.<jk>class</jk>,
+ | JsonSchemaSerializer.<jk>class</jk>,
+ | XmlDocSerializer.<jk>class</jk>,
+ | UonSerializer.<jk>class</jk>,
+ | UrlEncodingSerializer.<jk>class</jk>,
+ | OpenApiSerializer.<jk>class</jk>,
+ | MsgPackSerializer.<jk>class</jk>,
+ | SoapXmlSerializer.<jk>class</jk>,
+ | PlainTextSerializer.<jk>class</jk>,
+ | CsvSerializer.<jk>class</jk>
+ | },
+ |
+ | <jc>// Default parsers for all Java methods in
the class.</jc>
+ | parsers={
+ | JsonParser.<jk>class</jk>,
+ | SimpleJsonParser.<jk>class</jk>,
+ | XmlParser.<jk>class</jk>,
+ | HtmlParser.<jk>class</jk>,
+ | UonParser.<jk>class</jk>,
+ | UrlEncodingParser.<jk>class</jk>,
+ | OpenApiParser.<jk>class</jk>,
+ | MsgPackParser.<jk>class</jk>,
+ | PlainTextParser.<jk>class</jk>,
+ | CsvParser.<jk>class</jk>
+ | }
+ | )
+ | <jk>public interface</jk> BasicUniversalConfig
<jk>extends</jk> DefaultConfig, DefaultHtmlConfig {}
+ </p>
+ <p class='bjava'>
+ | <jd>/**
+ | * Predefined REST configuration that defines common
default values for all configurations.
+ | */</jd>
+ | <ja>@Rest</ja>(
+ |
allowedHeaderParams=<js>"$S{j.allowedHeaderParams,$E{J_ALLOWED_HEADER_PARAMS,Accept,Content-Type}}"</js>,
+ |
allowedMethodHeaders=<js>"$S{j.allowedMethodHeaders,$E{J_ALLOWED_METHOD_HEADERS,}}"</js>,
+ |
allowedMethodParams=<js>"$S{j.allowedMethodParams,$E{J_ALLOWED_METHOD_PARAMS,HEAD,OPTIONS}}"</js>,
+ | beanStore=BeanStore.<jk>class</jk>,
+ | callLogger=BasicRestLogger.<jk>class</jk>,
+ |
clientVersionHeader=<js>"$S{j.clientVersionHeader,$E{J_CLIENT_VERSION_HEADER,Client-Version}}"</js>,
+ |
config=<js>"$S{j.configFile,$E{J_CONFIG_FILE,SYSTEM_DEFAULT}}"</js>,
+ | consumes={},
+ | contextClass=RestContext.<jk>class</jk>,
+ | converters={},
+ | debug=<js>"$S{j.debug,$E{J_DEBUG,}}"</js>,
+ |
debugEnablement=BasicDebugEnablement.<jk>class</jk>,
+ |
debugOn=<js>"$S{j.debugOn,$E{J_DEBUG_ON,}}"</js>,
+ |
defaultAccept=<js>"$S{j.defaultAccept,$E{J_DEFAULT_ACCEPT,}}"</js>,
+ |
defaultCharset=<js>"$S{j.defaultCharset,$E{J_DEFAULT_CHARSET,UTF-8}}"</js>,
+ |
defaultContentType=<js>"$S{j.defaultContentType,$E{J_DEFAULT_CONTENT_TYPE,}}"</js>,
+ |
defaultRequestAttributes=<js>"$S{j.defaultRequestAttributes,$E{J_DEFAULT_REQUEST_ATTRIBUTES,}}"</js>,
+ |
defaultRequestHeaders=<js>"$S{j.defaultRequestHeaders,$E{J_DEFAULT_REQUEST_HEADERS,}}"</js>,
+ |
defaultResponseHeaders=<js>"$S{j.defaultResponseHeaders,$E{J_DEFAULT_RESPONSE_HEADERS,}}"</js>,
+ | description=<js>""</js>,
+ |
disableContentParam=<js>"$S{j.disableContentParam,$E{J_DISABLE_CONTENT_PARAM,false}}"</js>,
+ | encoders={IdentityEncoder.<jk>class</jk>},
+ | fileFinder=BasicFileFinder.<jk>class</jk>,
+ | guards={},
+ |
maxInput=<js>"$S{j.maxInput,$E{J_MAX_INPUT,1000000}}"</js>,
+ |
messages=<js>"$S{j.messages,$E{J_MESSAGES,}}"</js>,
+ | parsers={},
+ | partParser=OpenApiParser.<jk>class</jk>,
+ | partSerializer=OpenApiSerializer.<jk>class</jk>,
+ | path=<js>""</js>,
+ | produces={},
+ |
renderResponseStackTraces=<js>"$S{j.renderResponseStackTraces,$E{J_RENDER_RESPONSE_STACK_TRACES,false}}"</js>,
+ | responseProcessors={
+ | ReaderProcessor.<jk>class</jk>,
+ | InputStreamProcessor.<jk>class</jk>,
+ | ThrowableProcessor.<jk>class</jk>,
+ | HttpResponseProcessor.<jk>class</jk>,
+ | HttpResourceProcessor.<jk>class</jk>,
+ | HttpEntityProcessor.<jk>class</jk>,
+ | ResponseBeanProcessor.<jk>class</jk>,
+ | PlainTextPojoProcessor.<jk>class</jk>,
+ | SerializedPojoProcessor.<jk>class</jk>
+ | },
+ | restChildrenClass=RestChildren.<jk>class</jk>,
+ | restOpArgs={
+ | AttributeArg.<jk>class</jk>,
+ | ContentArg.<jk>class</jk>,
+ | FormDataArg.<jk>class</jk>,
+ | HasFormDataArg.<jk>class</jk>,
+ | HasQueryArg.<jk>class</jk>,
+ | HeaderArg.<jk>class</jk>,
+ | HttpServletRequestArgs.<jk>class</jk>,
+ | HttpServletResponseArgs.<jk>class</jk>,
+ | HttpSessionArgs.<jk>class</jk>,
+ | InputStreamParserArg.<jk>class</jk>,
+ | MethodArg.<jk>class</jk>,
+ | ParserArg.<jk>class</jk>,
+ | PathArg.<jk>class</jk>,
+ | QueryArg.<jk>class</jk>,
+ | ReaderParserArg.<jk>class</jk>,
+ | RequestBeanArg.<jk>class</jk>,
+ | ResponseBeanArg.<jk>class</jk>,
+ | ResponseHeaderArg.<jk>class</jk>,
+ | ResponseCodeArg.<jk>class</jk>,
+ | RestContextArgs.<jk>class</jk>,
+ | RestSessionArgs.<jk>class</jk>,
+ | RestOpContextArgs.<jk>class</jk>,
+ | RestOpSessionArgs.<jk>class</jk>,
+ | RestRequestArgs.<jk>class</jk>,
+ | RestResponseArgs.<jk>class</jk>,
+ | DefaultArg.<jk>class</jk>
+ | },
+ | restOpContextClass=RestOpContext.<jk>class</jk>,
+ |
restOperationsClass=RestOperations.<jk>class</jk>,
+ | roleGuard=<js>""</js>,
+ | rolesDeclared=<js>""</js>,
+ | serializers={},
+ |
siteName=<js>"$S{j.siteName,$E{J_SITE_NAME,}}"</js>,
+ | staticFiles=BasicStaticFiles.<jk>class</jk>,
+ | swagger=<ja>@Swagger</ja>,
+ |
swaggerProvider=BasicSwaggerProvider.<jk>class</jk>,
+ | title=<js>"$S{j.title,$E{J_TITLE,}}"</js>,
+ |
uriAuthority=<js>"$S{j.uriAuthority,$E{J_URI_AUTHORITY,}}"</js>,
+ |
uriContext=<js>"$S{j.uriContext,$E{J_URI_CONTEXT,}}"</js>,
+ |
uriRelativity=<js>"$S{j.uriRelativity,$E{J_URI_RELATIVITY,}}"</js>,
+ |
uriResolution=<js>"$S{j.uriResolution,$E{J_URI_RESOLUTION,}}"</js>
+ | )
+ | <ja>@BeanConfig</ja>(
+ | <jc>// When parsing generated beans, ignore
unknown properties
+ | // that may only exist as getters and not
setters.</jc>
+ | ignoreUnknownBeanProperties=<js>"true"</js>,
+ | ignoreUnknownEnumValues=<js>"true"</js>
+ | )
+ | <ja>@SerializerConfig</ja>(
+ | <jc>// Enable automatic resolution of URI
objects to root-relative values.</jc>
+ | uriResolution=<js>"ROOT_RELATIVE"</js>
+ | )
+ | <jk>public interface</jk> DefaultConfig {}
+ </p>
+ <p class='bjava'>
+ | <jd>/**
+ | * Predefined REST configuration that defines common
default values the HTML Doc serializer.
+ | */</jd>
+ | <ja>@HtmlDocConfig</ja>(
+ |
+ | <jc>// Default page header contents.</jc>
+ | header={
+ |
<js>"<h1>$RS{title}</h1>"</js>, <jc>// Use @Rest(title)</jc>
+ |
<js>"<h2>$RS{operationSummary,description}</h2>"</js>, <jc>// Use
either @RestOp(summary) or @Rest(description)</jc>
+ | <js>"$C{REST/header}"</js> <jc>//
Extra header HTML defined in external config file.</jc>
+ | },
+ |
+ | <jc>// Basic page navigation links.</jc>
+ | navlinks={
+ | <js>"up: request:/.."</js>
+ | },
+ |
+ | <jc>// Default stylesheet to use for the page.
+ | // Can be overridden from external config file.
+ | // Default is DevOps look-and-feel (aka
Depression look-and-feel).</jc>
+ |
stylesheet=<js>"$C{REST/theme,servlet:/htdocs/themes/devops.css}"</js>,
+ |
+ | <jc>// Default contents to add to the
<head> section of the HTML page.
+ | // Use it to add a favicon link to the
page.</jc>
+ | head=<js>"$C{REST/head}"</js>,
+ |
+ | <jc>// No default page footer contents.
+ | // Can be overridden from external config
file.</jc>
+ | footer=<js>"$C{REST/footer}"</js>,
+ |
+ | <jc>// By default, table cell contents should
not wrap.</jc>
+ | nowrap=<js>"true"</js>
+ | )
+ | <jk>public interface</jk> DefaultHtmlConfig {}
+ </p>
+ <p>
+ The {@link oajr.config} package contains other basic
configurations for use.
+ Annotations are aggregated from child-to-parent order allowing
for these basic configurations
+ to be extended and modified, or you can create your own
annotations from scratch.
+ </p>
+</div>
+
<h5 class='topic'>REST Group Pages</h5>
<div class='topic'>
<p>
@@ -240,10 +437,8 @@
<div class='topic'>
<p>
The {@link oajr.springboot.BasicSpringRestServlet} class is
typically entry point for your REST resources
- when working within a Spring Boot environment.
- </p>
- <p>
- The <c>SpringRestServlet</c> class provides additional
capabilities including:
+ when working within a Spring Boot environment. It extends from
+ {@link oajr.springboot.SpringRestServlet} which provides
additional capabilities including:
</p>
<ul>
<li>Your REST resources can be defined as injectable Spring
beans.
diff --git a/juneau-doc/docs/Topics/01.Overview/04.o.RestClient.html
b/juneau-doc/docs/Topics/01.Overview/04.o.RestClient.html
index e133eaf99..0cab8e24c 100644
--- a/juneau-doc/docs/Topics/01.Overview/04.o.RestClient.html
+++ b/juneau-doc/docs/Topics/01.Overview/04.o.RestClient.html
@@ -39,7 +39,8 @@
<div class='topic'>
<p>
The {@link oajr.mock.MockRestClient} class is used for
performing serverless unit testing of {@link oajr.annotation.Rest
@Rest}-annotated
- and {@link oaj.http.remote.Remote @Remote}-annotated classes.
+ and {@link oaj.http.remote.Remote @Remote}-annotated classes.
It perform full serialization and parsing of the HTTP request and responses,
+ but bypasses the network layer to significantly improve speed
while still performing real testing.
</p>
<h5 class='figure'>Example:</h5>
<p class='bjava'>
@@ -53,7 +54,7 @@
| <jc>// Our REST resource to test.</jc>
| <jc>// Simply echos the response.</jc>
| <ja>@Rest</ja>
- | <jk>public static class</jk> EchoRest
<jk>implements</jk> BasicRestServlet {
+ | <jk>public static class</jk> EchoRest
<jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicJsonConfig {
|
| <ja>@RestPut</ja>
| <jk>public</jk> MyBean
echo(<ja>@Content</ja> MyBean <jv>bean</jv>) {
diff --git a/juneau-doc/docs/Topics/01.Overview/05.o.Dtos.html
b/juneau-doc/docs/Topics/01.Overview/05.o.Dtos.html
index 0937c9406..b1a8335b2 100644
--- a/juneau-doc/docs/Topics/01.Overview/05.o.Dtos.html
+++ b/juneau-doc/docs/Topics/01.Overview/05.o.Dtos.html
@@ -50,7 +50,7 @@
| )
| );
|
- | String <jv>html</jv> =
HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>mytable</jv>);
+ | String <jv>html</jv> =
Html.<jsm>of</jsm>(<jv>mytable</jv>);
</p>
<p class='bxml'><xt>
| <table>
@@ -174,10 +174,10 @@
| );
|
| <jc>// Serialize using JSON serializer.</jc>
- | String <jv>swaggerJson</jv> =
JsonSerializer.<jsf>DEFAULT_READABLE</jsf>.serialize(<jv>swagger</jv>);
+ | String <jv>swaggerJson</jv> =
Json.<jsm>of</jsm>(<jv>swagger</jv>);
|
- | <jc>// Or just use toString().</jc>
- | String <jv>swaggerJson</jv> =
<jv>swagger</jv>.toString();
+ | <jc>// Or just use toString() or asJson().</jc>
+ | String <jv>swaggerJson</jv> = <jv>swagger</jv>.asJson();
</p>
<ul class='seealso'>
<li class='link'>{@doc jd.Swagger Swagger} for more information.
diff --git a/juneau-doc/docs/Topics/01.Overview/07.o.FluentAssertions.html
b/juneau-doc/docs/Topics/01.Overview/07.o.FluentAssertions.html
index cb564c787..85b8237d1 100644
--- a/juneau-doc/docs/Topics/01.Overview/07.o.FluentAssertions.html
+++ b/juneau-doc/docs/Topics/01.Overview/07.o.FluentAssertions.html
@@ -17,7 +17,17 @@
<div class='topic'>
<p>
- The {@doc juneau-assertions} module in Juneau is a powerful API
for performing fluent style assertions.
+ The {@doc juneau-assertions juneau-assertions} module in Juneau
is a powerful API for performing fluent style assertions.
+ </p>
+ <p>
+ Fluent assertions have two types of methods:
+ </p>
+ <ul>
+ <li><c>"asX"</c> methods which perform transformations.
+ <li><c>"isX"</c> methods which perform assertions.
+ </ul>
+ <p>
+ Multiple transformations and assertions can be performed per
statement.
</p>
<h5 class='figure'>Examples:</h5>
<p class='bjava'>
@@ -33,7 +43,7 @@
| <jc>// Extract a subset of properties from a list of
beans and compare using Simplified JSON.</jc>
| List<MyBean> <jv>myListOfBeans</jv> = ...;
| <jsm>assertBeanList</jsm>(<jv>myListOfBeans</jv>)
- | .asPropertyMap(<js>"a,b"</js>)
+ | .asPropertyMaps(<js>"a,b"</js>)
| .asJson().is(<js>"[{a:1,b:'foo'}]"</js>);
|
| <jc>// Perform an arbitrary Predicate check against a
bean.</jc>
diff --git a/juneau-doc/src/main/javadoc/overview.html
b/juneau-doc/src/main/javadoc/overview.html
index f9f0fe30f..1cc6c4771 100644
--- a/juneau-doc/src/main/javadoc/overview.html
+++ b/juneau-doc/src/main/javadoc/overview.html
@@ -1026,7 +1026,7 @@
Object <jv>value</jv> = <jk>new long</jk>[][]{{1,2,3},{4,5,6},{7,8,9}};
<jc>// Produces "1,2,3|4,5,6|7,8,9"</jc>
- String <jv>output</jv> =
OpenApi.<jsm>of</jsm>(HttpPartType.<jsf>HEADER</jsf>, <jv>schema</jv>,
<jv>value</jv>);
+ String <jv>output</jv> = OpenApi.<jsm>of</jsm>(<jv>schema</jv>,
<jv>value</jv>);
</p>
<p>
Schema-based serialization and parsing is used heavily in both
the server and client REST APIs with built-in schema
@@ -1055,8 +1055,8 @@
</p>
<p class='bjava'>
<jc>// Create JSON strings from scratch using fluent-style code.</jc>
- String <jv>myMap</jv> =
JsonMap.<jsm>create</jsm>().append(<js>"foo"</js>,<js>"bar"</js>).toString();
- String <jv>myList</jv> = JsonList.<jsm>of</jsm>(<js>"foo"</js>, 123,
<jk>null</jk>, <jv>jsonObject</jv>).toString();
+ String <jv>myMap</jv> =
JsonMap.<jsm>create</jsm>().append(<js>"foo"</js>,<js>"bar"</js>).asJson();
+ String <jv>myList</jv> = JsonList.<jsm>of</jsm>(<js>"foo"</js>, 123,
<jk>null</jk>, <jv>jsonObject</jv>).asJson();
<jc>// Parse directly from JSON into generic DOMs.</jc>
Map<String,Object> <jv>myMap</jv> =
JsonMap.<jsm>ofJson</jsm>(<js>"{foo:'bar'}"</js>);
@@ -1077,11 +1077,12 @@
<h5 class='topic'>Serializer and Parser Sets</h5>
<div class='topic'>
<p>
- <code>SerializerSet</code> and <code>ParserSet</code> classes
allow serializers and parsers
+ {@link org.apache.juneau.serializer.SerializerSet} and {@link
org.apache.juneau.parser.ParserSet} classes allow serializers and parsers
to be retrieved by W3C-compliant HTTP <code>Accept</code> and
<code>Content-Type</code> values:
</p>
<p class='bjava'>
- <jc>// Construct a new serializer group with configuration parameters
that get applied to all serializers.</jc>
+ <jc>// Construct a new serializer group with configuration parameters
that get applied
+ // to all serializers.</jc>
SerializerSet <jv>serializerSet</jv> = SerializerSet
.<jsm>create</jsm>()
.add(JsonSerializer.<jk>class</jk>,
UrlEncodingSerializer.<jk>class</jk>);
@@ -1162,7 +1163,7 @@
<ja>@Header</ja>(<js>"E-Tag"</js>) UUID <jv>etag</jv>,
<ja>@Query</ja>(<js>"debug"</js>) <jk>boolean</jk>
<jv>debug</jv>
) <jk>throws</jk> BadRequest, Unauthorized, InternalServerError
{
- <jc>// Process request.</jc>
+ <jc>// Process request here.</jc>
<jk>return</jk> Ok.<jsf>OK</jsf>; <jc>// Standard
400-OK response.</jc>
}
}
@@ -1268,7 +1269,7 @@
http://localhost:10000/helloWorld
</p>
<img class='bordered w800' src='doc-files/jrs.HelloWorldExample.1.png'>
- <ul>
+ <ul class='spaced-list'>
<li>Parsers for request bodies are selected based on the
request <c>Content-Type</c> header.
<li>Serializers for response bodies are selected based on the
request <c>Accept</c> header.
<ul>
@@ -1302,20 +1303,217 @@
<ja>@Rest</ja>(
path=<js>"/child"</js> <jc>// Path relative to parent
resource.</jc>
)
- <jk>public</jk> MyChildResource {...} <jc>// Note that we don't need to
extend from RestServlet.</jc>
+ <jc>// Note that we don't need to extend from RestServlet.</jc>
+ <jk>public</jk> MyChildResource <jk>implements</jk>
BasicUniversalConfig {
+ ...
+ }
</p>
<p>
The path of the child resource gets appended to the path of the
parent resource.
So in the example above, the child resource is accessed through
the URL <l>/parent/child</l>.
</p>
<p>
- A HUGE advantage of using child resources is that they do not
need to be declared in the JEE <l>web.xml</l>
+ The advantage of using child resources is that they do not need
to be declared in the JEE <l>web.xml</l>
file.
Initialization of and access to the child resources occurs
through the parent resource.
Children can be nested arbitrary deep to create complex REST
interfaces with a single top-level REST servlet.
</p>
</div>
+<h5 class='topic'>Predefined Configuration Interfaces</h5>
+<div class='topic'>
+ <p>
+ The servlets in the previous section implemented the {@link
org.apache.juneau.rest.config.BasicUniversalConfig} which simply defines
+ a preconfigured set of annotations that get inherited by the
child classes:
+ </p>
+ <p class='bjava'>
+ <jd>/**
+ * Predefined configuration for a REST resource that supports all
languages
+ * and provides common default configuration values.</jd>
+ */</jd>
+ <ja>@Rest</ja>(
+
+ <jc>// Default serializers for all Java methods in the
class.</jc>
+ serializers={
+ HtmlDocSerializer.<jk>class</jk>,
+ HtmlStrippedDocSerializer.<jk>class</jk>,
+ HtmlSchemaDocSerializer.<jk>class</jk>,
+ JsonSerializer.<jk>class</jk>,
+ SimpleJsonSerializer.<jk>class</jk>,
+ JsonSchemaSerializer.<jk>class</jk>,
+ XmlDocSerializer.<jk>class</jk>,
+ UonSerializer.<jk>class</jk>,
+ UrlEncodingSerializer.<jk>class</jk>,
+ OpenApiSerializer.<jk>class</jk>,
+ MsgPackSerializer.<jk>class</jk>,
+ SoapXmlSerializer.<jk>class</jk>,
+ PlainTextSerializer.<jk>class</jk>,
+ CsvSerializer.<jk>class</jk>
+ },
+
+ <jc>// Default parsers for all Java methods in the class.</jc>
+ parsers={
+ JsonParser.<jk>class</jk>,
+ SimpleJsonParser.<jk>class</jk>,
+ XmlParser.<jk>class</jk>,
+ HtmlParser.<jk>class</jk>,
+ UonParser.<jk>class</jk>,
+ UrlEncodingParser.<jk>class</jk>,
+ OpenApiParser.<jk>class</jk>,
+ MsgPackParser.<jk>class</jk>,
+ PlainTextParser.<jk>class</jk>,
+ CsvParser.<jk>class</jk>
+ }
+ )
+ <jk>public interface</jk> BasicUniversalConfig <jk>extends</jk>
DefaultConfig, DefaultHtmlConfig {}
+ </p>
+ <p class='bjava'>
+ <jd>/**
+ * Predefined REST configuration that defines common default values for
all configurations.
+ */</jd>
+ <ja>@Rest</ja>(
+
allowedHeaderParams=<js>"$S{j.allowedHeaderParams,$E{J_ALLOWED_HEADER_PARAMS,Accept,Content-Type}}"</js>,
+
allowedMethodHeaders=<js>"$S{j.allowedMethodHeaders,$E{J_ALLOWED_METHOD_HEADERS,}}"</js>,
+
allowedMethodParams=<js>"$S{j.allowedMethodParams,$E{J_ALLOWED_METHOD_PARAMS,HEAD,OPTIONS}}"</js>,
+ beanStore=BeanStore.<jk>class</jk>,
+ callLogger=BasicRestLogger.<jk>class</jk>,
+
clientVersionHeader=<js>"$S{j.clientVersionHeader,$E{J_CLIENT_VERSION_HEADER,Client-Version}}"</js>,
+
config=<js>"$S{j.configFile,$E{J_CONFIG_FILE,SYSTEM_DEFAULT}}"</js>,
+ consumes={},
+ contextClass=RestContext.<jk>class</jk>,
+ converters={},
+ debug=<js>"$S{j.debug,$E{J_DEBUG,}}"</js>,
+ debugEnablement=BasicDebugEnablement.<jk>class</jk>,
+ debugOn=<js>"$S{j.debugOn,$E{J_DEBUG_ON,}}"</js>,
+
defaultAccept=<js>"$S{j.defaultAccept,$E{J_DEFAULT_ACCEPT,}}"</js>,
+
defaultCharset=<js>"$S{j.defaultCharset,$E{J_DEFAULT_CHARSET,UTF-8}}"</js>,
+
defaultContentType=<js>"$S{j.defaultContentType,$E{J_DEFAULT_CONTENT_TYPE,}}"</js>,
+
defaultRequestAttributes=<js>"$S{j.defaultRequestAttributes,$E{J_DEFAULT_REQUEST_ATTRIBUTES,}}"</js>,
+
defaultRequestHeaders=<js>"$S{j.defaultRequestHeaders,$E{J_DEFAULT_REQUEST_HEADERS,}}"</js>,
+
defaultResponseHeaders=<js>"$S{j.defaultResponseHeaders,$E{J_DEFAULT_RESPONSE_HEADERS,}}"</js>,
+ description=<js>""</js>,
+
disableContentParam=<js>"$S{j.disableContentParam,$E{J_DISABLE_CONTENT_PARAM,false}}"</js>,
+ encoders={IdentityEncoder.<jk>class</jk>},
+ fileFinder=BasicFileFinder.<jk>class</jk>,
+ guards={},
+ maxInput=<js>"$S{j.maxInput,$E{J_MAX_INPUT,1000000}}"</js>,
+ messages=<js>"$S{j.messages,$E{J_MESSAGES,}}"</js>,
+ parsers={},
+ partParser=OpenApiParser.<jk>class</jk>,
+ partSerializer=OpenApiSerializer.<jk>class</jk>,
+ path=<js>""</js>,
+ produces={},
+
renderResponseStackTraces=<js>"$S{j.renderResponseStackTraces,$E{J_RENDER_RESPONSE_STACK_TRACES,false}}"</js>,
+ responseProcessors={
+ ReaderProcessor.<jk>class</jk>,
+ InputStreamProcessor.<jk>class</jk>,
+ ThrowableProcessor.<jk>class</jk>,
+ HttpResponseProcessor.<jk>class</jk>,
+ HttpResourceProcessor.<jk>class</jk>,
+ HttpEntityProcessor.<jk>class</jk>,
+ ResponseBeanProcessor.<jk>class</jk>,
+ PlainTextPojoProcessor.<jk>class</jk>,
+ SerializedPojoProcessor.<jk>class</jk>
+ },
+ restChildrenClass=RestChildren.<jk>class</jk>,
+ restOpArgs={
+ AttributeArg.<jk>class</jk>,
+ ContentArg.<jk>class</jk>,
+ FormDataArg.<jk>class</jk>,
+ HasFormDataArg.<jk>class</jk>,
+ HasQueryArg.<jk>class</jk>,
+ HeaderArg.<jk>class</jk>,
+ HttpServletRequestArgs.<jk>class</jk>,
+ HttpServletResponseArgs.<jk>class</jk>,
+ HttpSessionArgs.<jk>class</jk>,
+ InputStreamParserArg.<jk>class</jk>,
+ MethodArg.<jk>class</jk>,
+ ParserArg.<jk>class</jk>,
+ PathArg.<jk>class</jk>,
+ QueryArg.<jk>class</jk>,
+ ReaderParserArg.<jk>class</jk>,
+ RequestBeanArg.<jk>class</jk>,
+ ResponseBeanArg.<jk>class</jk>,
+ ResponseHeaderArg.<jk>class</jk>,
+ ResponseCodeArg.<jk>class</jk>,
+ RestContextArgs.<jk>class</jk>,
+ RestSessionArgs.<jk>class</jk>,
+ RestOpContextArgs.<jk>class</jk>,
+ RestOpSessionArgs.<jk>class</jk>,
+ RestRequestArgs.<jk>class</jk>,
+ RestResponseArgs.<jk>class</jk>,
+ DefaultArg.<jk>class</jk>
+ },
+ restOpContextClass=RestOpContext.<jk>class</jk>,
+ restOperationsClass=RestOperations.<jk>class</jk>,
+ roleGuard=<js>""</js>,
+ rolesDeclared=<js>""</js>,
+ serializers={},
+ siteName=<js>"$S{j.siteName,$E{J_SITE_NAME,}}"</js>,
+ staticFiles=BasicStaticFiles.<jk>class</jk>,
+ swagger=<ja>@Swagger</ja>,
+ swaggerProvider=BasicSwaggerProvider.<jk>class</jk>,
+ title=<js>"$S{j.title,$E{J_TITLE,}}"</js>,
+ uriAuthority=<js>"$S{j.uriAuthority,$E{J_URI_AUTHORITY,}}"</js>,
+ uriContext=<js>"$S{j.uriContext,$E{J_URI_CONTEXT,}}"</js>,
+
uriRelativity=<js>"$S{j.uriRelativity,$E{J_URI_RELATIVITY,}}"</js>,
+
uriResolution=<js>"$S{j.uriResolution,$E{J_URI_RESOLUTION,}}"</js>
+ )
+ <ja>@BeanConfig</ja>(
+ <jc>// When parsing generated beans, ignore unknown properties
+ // that may only exist as getters and not setters.</jc>
+ ignoreUnknownBeanProperties=<js>"true"</js>,
+ ignoreUnknownEnumValues=<js>"true"</js>
+ )
+ <ja>@SerializerConfig</ja>(
+ <jc>// Enable automatic resolution of URI objects to
root-relative values.</jc>
+ uriResolution=<js>"ROOT_RELATIVE"</js>
+ )
+ <jk>public interface</jk> DefaultConfig {}
+ </p>
+ <p class='bjava'>
+ <jd>/**
+ * Predefined REST configuration that defines common default values the
HTML Doc serializer.
+ */</jd>
+ <ja>@HtmlDocConfig</ja>(
+
+ <jc>// Default page header contents.</jc>
+ header={
+ <js>"<h1>$RS{title}</h1>"</js>, <jc>// Use
@Rest(title)</jc>
+
<js>"<h2>$RS{operationSummary,description}</h2>"</js>, <jc>// Use
either @RestOp(summary) or @Rest(description)</jc>
+ <js>"$C{REST/header}"</js> <jc>// Extra header HTML
defined in external config file.</jc>
+ },
+
+ <jc>// Basic page navigation links.</jc>
+ navlinks={
+ <js>"up: request:/.."</js>
+ },
+
+ <jc>// Default stylesheet to use for the page.
+ // Can be overridden from external config file.
+ // Default is DevOps look-and-feel (aka Depression
look-and-feel).</jc>
+
stylesheet=<js>"$C{REST/theme,servlet:/htdocs/themes/devops.css}"</js>,
+
+ <jc>// Default contents to add to the <head> section of
the HTML page.
+ // Use it to add a favicon link to the page.</jc>
+ head=<js>"$C{REST/head}"</js>,
+
+ <jc>// No default page footer contents.
+ // Can be overridden from external config file.</jc>
+ footer=<js>"$C{REST/footer}"</js>,
+
+ <jc>// By default, table cell contents should not wrap.</jc>
+ nowrap=<js>"true"</js>
+ )
+ <jk>public interface</jk> DefaultHtmlConfig {}
+ </p>
+ <p>
+ The {@link org.apache.juneau.rest.config} package contains
other basic configurations for use.
+ Annotations are aggregated from child-to-parent order allowing
for these basic configurations
+ to be extended and modified, or you can create your own
annotations from scratch.
+ </p>
+</div>
+
<h5 class='topic'>REST Group Pages</h5>
<div class='topic'>
<p>
@@ -1451,10 +1649,8 @@
<div class='topic'>
<p>
The {@link
org.apache.juneau.rest.springboot.BasicSpringRestServlet} class is typically
entry point for your REST resources
- when working within a Spring Boot environment.
- </p>
- <p>
- The <c>SpringRestServlet</c> class provides additional
capabilities including:
+ when working within a Spring Boot environment. It extends from
+ {@link org.apache.juneau.rest.springboot.SpringRestServlet}
which provides additional capabilities including:
</p>
<ul>
<li>Your REST resources can be defined as injectable Spring
beans.
@@ -1547,7 +1743,8 @@
<div class='topic'>
<p>
The {@link org.apache.juneau.rest.mock.MockRestClient} class is
used for performing serverless unit testing of {@link
org.apache.juneau.rest.annotation.Rest @Rest}-annotated
- and {@link org.apache.juneau.http.remote.Remote
@Remote}-annotated classes.
+ and {@link org.apache.juneau.http.remote.Remote
@Remote}-annotated classes. It perform full serialization and parsing of the
HTTP request and responses,
+ but bypasses the network layer to significantly improve speed
while still performing real testing.
</p>
<h5 class='figure'>Example:</h5>
<p class='bjava'>
@@ -1561,7 +1758,7 @@
<jc>// Our REST resource to test.</jc>
<jc>// Simply echos the response.</jc>
<ja>@Rest</ja>
- <jk>public static class</jk> EchoRest <jk>implements</jk>
BasicRestServlet {
+ <jk>public static class</jk> EchoRest <jk>extends</jk>
BasicRestServlet <jk>implements</jk> BasicJsonConfig {
<ja>@RestPut</ja>
<jk>public</jk> MyBean echo(<ja>@Content</ja> MyBean
<jv>bean</jv>) {
@@ -1640,7 +1837,7 @@
)
);
- String <jv>html</jv> =
HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>mytable</jv>);
+ String <jv>html</jv> = Html.<jsm>of</jsm>(<jv>mytable</jv>);
</p>
<p class='bxml'><xt>
<table>
@@ -1764,10 +1961,10 @@
);
<jc>// Serialize using JSON serializer.</jc>
- String <jv>swaggerJson</jv> =
JsonSerializer.<jsf>DEFAULT_READABLE</jsf>.serialize(<jv>swagger</jv>);
+ String <jv>swaggerJson</jv> = Json.<jsm>of</jsm>(<jv>swagger</jv>);
- <jc>// Or just use toString().</jc>
- String <jv>swaggerJson</jv> = <jv>swagger</jv>.toString();
+ <jc>// Or just use toString() or asJson().</jc>
+ String <jv>swaggerJson</jv> = <jv>swagger</jv>.asJson();
</p>
<ul class='seealso'>
<li class='link'>{@doc jd.Swagger Swagger} for more information.
@@ -1850,7 +2047,17 @@
<div class='topic'><!-- START: 1.7 - Overview.o.FluentAssertions -->
<div class='topic'>
<p>
- The {@doc juneau-assertions} module in Juneau is a powerful API
for performing fluent style assertions.
+ The {@doc juneau-assertions juneau-assertions} module in Juneau
is a powerful API for performing fluent style assertions.
+ </p>
+ <p>
+ Fluent assertions have two types of methods:
+ </p>
+ <ul>
+ <li><c>"asX"</c> methods which perform transformations.
+ <li><c>"isX"</c> methods which perform assertions.
+ </ul>
+ <p>
+ Multiple transformations and assertions can be performed per
statement.
</p>
<h5 class='figure'>Examples:</h5>
<p class='bjava'>
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
index 649bb8a67..f91bf2328 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
@@ -1789,7 +1789,7 @@ public class RestContext extends Context {
* <h5 class='section'>Example:</h5>
* <p class='bjava'>
* <jc>// Our customized logger.</jc>
- * <jk>public class</jk> MyLogger <jk>extends</jk>
BasicRestLogger {
+ * <jk>public class</jk> MyLogger <jk>extends</jk>
RestLogger {
*
* <ja>@Override</ja>
* <jk>protected void</jk> log(Level
<jv>level</jv>, String <jv>msg</jv>, Throwable <jv>e</jv>) {
@@ -1818,7 +1818,7 @@ public class RestContext extends Context {
*
* <ul class='notes'>
* <li class='note'>
- * The default call logger if not specified is
{@link BasicRestLogger}.
+ * The default call logger if not specified is
{@link RestLogger}.
* <li class='note'>
* The resource class itself will be used if it
implements the {@link RestLogger} interface and not
* explicitly overridden via this annotation.
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestRequest.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestRequest.java
index 418990b27..868db1595 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestRequest.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestRequest.java
@@ -1376,7 +1376,7 @@ public final class RestRequest {
* Sets the <js>"Exception"</js> attribute to the specified throwable.
*
* <p>
- * This exception is used by {@link BasicRestLogger} for logging
purposes.
+ * This exception is used by {@link RestLogger} for logging purposes.
*
* @param t The attribute value.
* @return This object.
@@ -1390,7 +1390,7 @@ public final class RestRequest {
* Sets the <js>"NoTrace"</js> attribute to the specified boolean.
*
* <p>
- * This flag is used by {@link BasicRestLogger} and tells it not to log
the current request.
+ * This flag is used by {@link RestLogger} and tells it not to log the
current request.
*
* @param b The attribute value.
* @return This object.
@@ -1413,7 +1413,7 @@ public final class RestRequest {
* Sets the <js>"Debug"</js> attribute to the specified boolean.
*
* <p>
- * This flag is used by {@link BasicRestLogger} to help determine how a
request should be logged.
+ * This flag is used by {@link RestLogger} to help determine how a
request should be logged.
*
* @param b The attribute value.
* @return This object.
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
index ec679d85f..91f621419 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestResponse.java
@@ -634,7 +634,7 @@ public final class RestResponse {
* Sets the <js>"Exception"</js> attribute to the specified throwable.
*
* <p>
- * This exception is used by {@link BasicRestLogger} for logging
purposes.
+ * This exception is used by {@link RestLogger} for logging purposes.
*
* @param t The attribute value.
* @return This object.
@@ -648,7 +648,7 @@ public final class RestResponse {
* Sets the <js>"NoTrace"</js> attribute to the specified boolean.
*
* <p>
- * This flag is used by {@link BasicRestLogger} and tells it not to log
the current request.
+ * This flag is used by {@link RestLogger} and tells it not to log the
current request.
*
* @param b The attribute value.
* @return This object.
@@ -671,7 +671,7 @@ public final class RestResponse {
* Sets the <js>"Debug"</js> attribute to the specified boolean.
*
* <p>
- * This flag is used by {@link BasicRestLogger} to help determine how a
request should be logged.
+ * This flag is used by {@link RestLogger} to help determine how a
request should be logged.
*
* @param b The attribute value.
* @return This object.
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Rest.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Rest.java
index 735eb0592..d2613cdce 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Rest.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Rest.java
@@ -199,7 +199,7 @@ public @interface Rest {
*
* <ul class='notes'>
* <li class='note'>
- * The default call logger if not specified is {@link
BasicRestLogger}.
+ * The default call logger if not specified is {@link
RestLogger}.
* <li class='note'>
* The resource class itself will be used if it implements
the {@link RestLogger} interface and not
* explicitly overridden via this annotation.
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicJsonConfig.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicJsonConfig.java
index 5af0db062..a418e0330 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicJsonConfig.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicJsonConfig.java
@@ -93,18 +93,6 @@ import org.apache.juneau.serializer.annotation.*;
SimpleJsonParser.class
},
- defaultAccept="text/json",
-
- // Optional external configuration file.
- config="$S{juneau.configFile,SYSTEM_DEFAULT}"
-)
-@BeanConfig(
- // When parsing generated beans, ignore unknown properties that may
only exist as getters and not setters.
- ignoreUnknownBeanProperties="true",
- ignoreUnknownEnumValues="true"
-)
-@SerializerConfig(
- // Enable automatic resolution of URI objects to root-relative values.
- uriResolution="ROOT_RELATIVE"
+ defaultAccept="text/json"
)
-public interface BasicJsonConfig {}
+public interface BasicJsonConfig extends DefaultConfig {}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicJsonHtmlConfig.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicJsonHtmlConfig.java
index 275307517..e1961ff09 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicJsonHtmlConfig.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicJsonHtmlConfig.java
@@ -109,48 +109,6 @@ import org.apache.juneau.serializer.annotation.*;
SimpleJsonParser.class
},
- defaultAccept="text/json",
-
- // Optional external configuration file.
- config="$S{juneau.configFile,SYSTEM_DEFAULT}"
-)
-@BeanConfig(
- // When parsing generated beans, ignore unknown properties that may
only exist as getters and not setters.
- ignoreUnknownBeanProperties="true",
- ignoreUnknownEnumValues="true"
-)
-@SerializerConfig(
- // Enable automatic resolution of URI objects to root-relative values.
- uriResolution="ROOT_RELATIVE"
-)
-@HtmlDocConfig(
-
- // Default page header contents.
- header={
- "<h1>$RS{title}</h1>", // Use @Rest(title)
- "<h2>$RS{operationSummary,description}</h2>", // Use either
@RestOp(summary) or @Rest(description)
- "$C{REST/header}" // Extra header HTML defined in external
config file.
- },
-
- // Basic page navigation links.
- navlinks={
- "up: request:/.."
- },
-
- // Default stylesheet to use for the page.
- // Can be overridden from external config file.
- // Default is DevOps look-and-feel (aka Depression look-and-feel).
- stylesheet="$C{REST/theme,servlet:/htdocs/themes/devops.css}",
-
- // Default contents to add to the <head> section of the HTML page.
- // Use it to add a favicon link to the page.
- head="$C{REST/head}",
-
- // No default page footer contents.
- // Can be overridden from external config file.
- footer="$C{REST/footer}",
-
- // By default, table cell contents should not wrap.
- nowrap="true"
+ defaultAccept="text/json"
)
-public interface BasicJsonHtmlConfig {}
+public interface BasicJsonHtmlConfig extends DefaultConfig, DefaultHtmlConfig
{}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicOpenApiConfig.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicOpenApiConfig.java
index c7b958481..7a0c4acb8 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicOpenApiConfig.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicOpenApiConfig.java
@@ -89,18 +89,6 @@ import org.apache.juneau.serializer.annotation.*;
OpenApiParser.class,
},
- defaultAccept="text/openapi",
-
- // Optional external configuration file.
- config="$S{juneau.configFile,SYSTEM_DEFAULT}"
-)
-@BeanConfig(
- // When parsing generated beans, ignore unknown properties that may
only exist as getters and not setters.
- ignoreUnknownBeanProperties="true",
- ignoreUnknownEnumValues="true"
-)
-@SerializerConfig(
- // Enable automatic resolution of URI objects to root-relative values.
- uriResolution="ROOT_RELATIVE"
+ defaultAccept="text/openapi"
)
-public interface BasicOpenApiConfig {}
+public interface BasicOpenApiConfig extends DefaultConfig {}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicSimpleJsonConfig.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicSimpleJsonConfig.java
index dfcc7f81b..69a472e57 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicSimpleJsonConfig.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicSimpleJsonConfig.java
@@ -90,17 +90,6 @@ import org.apache.juneau.serializer.annotation.*;
},
// Optional external configuration file.
- config="$S{juneau.configFile,SYSTEM_DEFAULT}",
-
- defaultAccept="text/json+simple"
-)
-@SerializerConfig(
- // Enable automatic resolution of URI objects to root-relative values.
- uriResolution="ROOT_RELATIVE"
-)
-@BeanConfig(
- // When parsing generated beans, ignore unknown properties that may
only exist as getters and not setters.
- ignoreUnknownBeanProperties="true",
- ignoreUnknownEnumValues="true"
+ config="$S{juneau.configFile,SYSTEM_DEFAULT}"
)
-public interface BasicSimpleJsonConfig {}
+public interface BasicSimpleJsonConfig extends DefaultConfig {}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicUniversalConfig.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicUniversalConfig.java
index 519ba9025..74591abf0 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicUniversalConfig.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/BasicUniversalConfig.java
@@ -29,7 +29,8 @@ import org.apache.juneau.urlencoding.*;
import org.apache.juneau.xml.*;
/**
- * Basic configuration for a REST resource that supports all languages and
provides common default configuration values.
+ * Predefined configuration for a REST resource that supports all languages
+ * and provides common default configuration values.
*
* <p>
* Default settings defined:
@@ -155,48 +156,6 @@ import org.apache.juneau.xml.*;
MsgPackParser.class,
PlainTextParser.class,
CsvParser.class
- },
-
- // Optional external configuration file.
- config="$S{juneau.configFile,SYSTEM_DEFAULT}"
-)
-@BeanConfig(
- // When parsing generated beans, ignore unknown properties that may
only exist as getters and not setters.
- ignoreUnknownBeanProperties="true",
- ignoreUnknownEnumValues="true"
-)
-@SerializerConfig(
- // Enable automatic resolution of URI objects to root-relative values.
- uriResolution="ROOT_RELATIVE"
-)
-@HtmlDocConfig(
-
- // Default page header contents.
- header={
- "<h1>$RS{title}</h1>", // Use @Rest(title)
- "<h2>$RS{operationSummary,description}</h2>", // Use either
@RestOp(summary) or @Rest(description)
- "$C{REST/header}" // Extra header HTML defined in external
config file.
- },
-
- // Basic page navigation links.
- navlinks={
- "up: request:/.."
- },
-
- // Default stylesheet to use for the page.
- // Can be overridden from external config file.
- // Default is DevOps look-and-feel (aka Depression look-and-feel).
- stylesheet="$C{REST/theme,servlet:/htdocs/themes/devops.css}",
-
- // Default contents to add to the <head> section of the HTML page.
- // Use it to add a favicon link to the page.
- head="$C{REST/head}",
-
- // No default page footer contents.
- // Can be overridden from external config file.
- footer="$C{REST/footer}",
-
- // By default, table cell contents should not wrap.
- nowrap="true"
+ }
)
-public interface BasicUniversalConfig {}
+public interface BasicUniversalConfig extends DefaultConfig, DefaultHtmlConfig
{}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/DefaultConfig.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/DefaultConfig.java
new file mode 100644
index 000000000..2604531d8
--- /dev/null
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/DefaultConfig.java
@@ -0,0 +1,129 @@
+//
***************************************************************************************************************************
+// * 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.config;
+
+import org.apache.juneau.annotation.*;
+import org.apache.juneau.cp.*;
+import org.apache.juneau.encoders.*;
+import org.apache.juneau.rest.*;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.arg.*;
+import org.apache.juneau.rest.debug.*;
+import org.apache.juneau.rest.logging.*;
+import org.apache.juneau.rest.processor.*;
+import org.apache.juneau.rest.staticfile.*;
+import org.apache.juneau.rest.swagger.*;
+import org.apache.juneau.serializer.annotation.*;
+import org.apache.juneau.oapi.*;
+
+/**
+ * Predefined REST configuration that defines common default values for all
configurations.
+ */
+@Rest(
+
allowedHeaderParams="$S{j.allowedHeaderParams,$E{J_ALLOWED_HEADER_PARAMS,Accept,Content-Type}}",
+
allowedMethodHeaders="$S{j.allowedMethodHeaders,$E{J_ALLOWED_METHOD_HEADERS,}}",
+
allowedMethodParams="$S{j.allowedMethodParams,$E{J_ALLOWED_METHOD_PARAMS,HEAD,OPTIONS}}",
+ beanStore=BeanStore.class,
+ callLogger=BasicRestLogger.class,
+
clientVersionHeader="$S{j.clientVersionHeader,$E{J_CLIENT_VERSION_HEADER,Client-Version}}",
+ config="$S{j.configFile,$E{J_CONFIG_FILE,SYSTEM_DEFAULT}}",
+ consumes={},
+ contextClass=RestContext.class,
+ converters={},
+ debug="$S{j.debug,$E{J_DEBUG,}}",
+ debugEnablement=BasicDebugEnablement.class,
+ debugOn="$S{j.debugOn,$E{J_DEBUG_ON,}}",
+ defaultAccept="$S{j.defaultAccept,$E{J_DEFAULT_ACCEPT,}}",
+ defaultCharset="$S{j.defaultCharset,$E{J_DEFAULT_CHARSET,UTF-8}}",
+
defaultContentType="$S{j.defaultContentType,$E{J_DEFAULT_CONTENT_TYPE,}}",
+
defaultRequestAttributes="$S{j.defaultRequestAttributes,$E{J_DEFAULT_REQUEST_ATTRIBUTES,}}",
+
defaultRequestHeaders="$S{j.defaultRequestHeaders,$E{J_DEFAULT_REQUEST_HEADERS,}}",
+
defaultResponseHeaders="$S{j.defaultResponseHeaders,$E{J_DEFAULT_RESPONSE_HEADERS,}}",
+ description="",
+
disableContentParam="$S{j.disableContentParam,$E{J_DISABLE_CONTENT_PARAM,false}}",
+ encoders={IdentityEncoder.class},
+ fileFinder=BasicFileFinder.class,
+ guards={},
+ maxInput="$S{j.maxInput,$E{J_MAX_INPUT,1000000}}",
+ messages="$S{j.messages,$E{J_MESSAGES,}}",
+ parsers={},
+ partParser=OpenApiParser.class,
+ partSerializer=OpenApiSerializer.class,
+ path="",
+ produces={},
+
renderResponseStackTraces="$S{j.renderResponseStackTraces,$E{J_RENDER_RESPONSE_STACK_TRACES,false}}",
+ responseProcessors={
+ ReaderProcessor.class,
+ InputStreamProcessor.class,
+ ThrowableProcessor.class,
+ HttpResponseProcessor.class,
+ HttpResourceProcessor.class,
+ HttpEntityProcessor.class,
+ ResponseBeanProcessor.class,
+ PlainTextPojoProcessor.class,
+ SerializedPojoProcessor.class
+ },
+ restChildrenClass=RestChildren.class,
+ restOpArgs={
+ AttributeArg.class,
+ ContentArg.class,
+ FormDataArg.class,
+ HasFormDataArg.class,
+ HasQueryArg.class,
+ HeaderArg.class,
+ HttpServletRequestArgs.class,
+ HttpServletResponseArgs.class,
+ HttpSessionArgs.class,
+ InputStreamParserArg.class,
+ MethodArg.class,
+ ParserArg.class,
+ PathArg.class,
+ QueryArg.class,
+ ReaderParserArg.class,
+ RequestBeanArg.class,
+ ResponseBeanArg.class,
+ ResponseHeaderArg.class,
+ ResponseCodeArg.class,
+ RestContextArgs.class,
+ RestSessionArgs.class,
+ RestOpContextArgs.class,
+ RestOpSessionArgs.class,
+ RestRequestArgs.class,
+ RestResponseArgs.class,
+ DefaultArg.class
+ },
+ restOpContextClass=RestOpContext.class,
+ restOperationsClass=RestOperations.class,
+ roleGuard="",
+ rolesDeclared="",
+ serializers={},
+ siteName="$S{j.siteName,$E{J_SITE_NAME,}}",
+ staticFiles=BasicStaticFiles.class,
+ swagger=@Swagger,
+ swaggerProvider=BasicSwaggerProvider.class,
+ title="$S{j.title,$E{J_TITLE,}}",
+ uriAuthority="$S{j.uriAuthority,$E{J_URI_AUTHORITY,}}",
+ uriContext="$S{j.uriContext,$E{J_URI_CONTEXT,}}",
+ uriRelativity="$S{j.uriRelativity,$E{J_URI_RELATIVITY,}}",
+ uriResolution="$S{j.uriResolution,$E{J_URI_RESOLUTION,}}"
+)
+@BeanConfig(
+ // When parsing generated beans, ignore unknown properties that may
only exist as getters and not setters.
+ ignoreUnknownBeanProperties="true",
+ ignoreUnknownEnumValues="true"
+)
+@SerializerConfig(
+ // Enable automatic resolution of URI objects to root-relative values.
+ uriResolution="ROOT_RELATIVE"
+)
+public interface DefaultConfig {}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartType.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/DefaultHtmlConfig.java
similarity index 58%
copy from
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartType.java
copy to
juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/DefaultHtmlConfig.java
index a2bead58c..e43ae29e1 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartType.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/config/DefaultHtmlConfig.java
@@ -10,42 +10,41 @@
// * "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.httppart;
+package org.apache.juneau.rest.config;
+
+import org.apache.juneau.html.annotation.*;
/**
- * Represents possible enum values that can be passed to the {@link
HttpPartSerializerSession#serialize(HttpPartType, HttpPartSchema, Object)}.
- *
- * <ul class='seealso'>
- * <li class='link'>{@doc jm.HttpPartSerializersParsers}
- * <li class='extlink'>{@source}
- * </ul>
+ * Predefined REST configuration that defines common default values for HTML
Doc serializers.
*/
-public enum HttpPartType {
-
- /** An HTTP request body */
- BODY,
-
- /** A URI path variable */
- PATH,
-
- /** A URI query parameter */
- QUERY,
-
- /** A form-data parameter */
- FORMDATA,
-
- /** An HTTP request header */
- HEADER,
-
- /** An HTTP response header */
- RESPONSE_HEADER,
-
- /** An HTTP response body */
- RESPONSE_BODY,
-
- /** An HTTP response status code */
- RESPONSE_STATUS,
-
- /** A non-standard field */
- OTHER,
-}
+@HtmlDocConfig(
+
+ // Default page header contents.
+ header={
+ "<h1>$RS{title}</h1>", // Use @Rest(title)
+ "<h2>$RS{operationSummary,description}</h2>", // Use either
@RestOp(summary) or @Rest(description)
+ "$C{REST/header}" // Extra header HTML defined in external
config file.
+ },
+
+ // Basic page navigation links.
+ navlinks={
+ "up: request:/.."
+ },
+
+ // Default stylesheet to use for the page.
+ // Can be overridden from external config file.
+ // Default is DevOps look-and-feel (aka Depression look-and-feel).
+ stylesheet="$C{REST/theme,servlet:/htdocs/themes/devops.css}",
+
+ // Default contents to add to the <head> section of the HTML page.
+ // Use it to add a favicon link to the page.
+ head="$C{REST/head}",
+
+ // No default page footer contents.
+ // Can be overridden from external config file.
+ footer="$C{REST/footer}",
+
+ // By default, table cell contents should not wrap.
+ nowrap="true"
+)
+public interface DefaultHtmlConfig {}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/RestAnnotation_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/RestAnnotation_Test.java
index e90e8153e..42682405b 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/RestAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/rest/annotation/RestAnnotation_Test.java
@@ -49,7 +49,7 @@ public class RestAnnotation_Test {
.allowedMethodHeaders("allowedMethodHeaders")
.allowedMethodParams("allowedMethodParams")
.beanStore(BeanStore.class)
- .callLogger(BasicRestLogger.class)
+ .callLogger(RestLogger.class)
.children(RestAnnotation_Test.class)
.clientVersionHeader("clientVersionHeader")
.config("config")
@@ -104,7 +104,7 @@ public class RestAnnotation_Test {
.allowedMethodHeaders("allowedMethodHeaders")
.allowedMethodParams("allowedMethodParams")
.beanStore(BeanStore.class)
- .callLogger(BasicRestLogger.class)
+ .callLogger(RestLogger.class)
.children(RestAnnotation_Test.class)
.clientVersionHeader("clientVersionHeader")
.config("config")
@@ -162,7 +162,7 @@ public class RestAnnotation_Test {
+ "allowedMethodParams:'allowedMethodParams',"
+ "beanStore:'org.apache.juneau.cp.BeanStore',"
+
"builder:'org.apache.juneau.rest.RestContext$Builder$Void',"
- +
"callLogger:'org.apache.juneau.rest.logging.BasicRestLogger',"
+ +
"callLogger:'org.apache.juneau.rest.logging.RestLogger',"
+ "children:['"+CNAME+"'],"
+ "clientVersionHeader:'clientVersionHeader',"
+ "config:'config',"
@@ -263,7 +263,7 @@ public class RestAnnotation_Test {
allowedMethodHeaders="allowedMethodHeaders",
allowedMethodParams="allowedMethodParams",
beanStore=BeanStore.class,
- callLogger=BasicRestLogger.class,
+ callLogger=RestLogger.class,
children=RestAnnotation_Test.class,
clientVersionHeader="clientVersionHeader",
config="config",
@@ -320,7 +320,7 @@ public class RestAnnotation_Test {
allowedMethodHeaders="allowedMethodHeaders",
allowedMethodParams="allowedMethodParams",
beanStore=BeanStore.class,
- callLogger=BasicRestLogger.class,
+ callLogger=RestLogger.class,
children=RestAnnotation_Test.class,
clientVersionHeader="clientVersionHeader",
config="config",