You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2020/10/02 17:46:10 UTC
[juneau-website] branch asf-site updated: Website updates.
This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/juneau-website.git
The following commit(s) were added to refs/heads/asf-site by this push:
new 975d582 Website updates.
975d582 is described below
commit 975d582dfe9388c12f9702e878d5c003e7bb61c1
Author: JamesBognar <ja...@salesforce.com>
AuthorDate: Fri Oct 2 13:46:05 2020 -0400
Website updates.
---
content/config.html | 27 ++---
content/dto.html | 15 ++-
content/examples.html | 12 +-
content/marshall.html | 269 +++++++++++++++++++++--------------------
content/petstore.html | 44 +++----
content/rest-client.html | 214 +++++++-------------------------
content/rest-server.html | 45 ++++---
content/styles/juneau-code.css | 20 +--
content/styles/juneau-doc.css | 39 +++++-
templates/config.html | 27 ++---
templates/dto.html | 15 ++-
templates/examples.html | 12 +-
templates/marshall.html | 269 +++++++++++++++++++++--------------------
templates/petstore.html | 44 +++----
templates/rest-client.html | 214 +++++++-------------------------
templates/rest-server.html | 45 ++++---
16 files changed, 539 insertions(+), 772 deletions(-)
diff --git a/content/config.html b/content/config.html
index 1887c85..41d6efc 100644
--- a/content/config.html
+++ b/content/config.html
@@ -100,19 +100,19 @@
</p>
<p class='bcode w800'>
<jc>// Load our config file</jc>
- Config c = Config.<jsm>create</jsm>().name(<js>"MyIniFile.cfg"</js>).build();
+ Config <jv>config</jv> = Config.<jsm>create</jsm>().name(<js>"MyIniFile.cfg"</js>).build();
- <jk>int</jk> anInt = c.getInt(<js>"MySection/anInt"</js>);
- <jk>boolean</jk> aBoolean = c.getBoolean(<js>"MySection/aBoolean"</js>);
- <jk>int</jk>[] anIntArray = c.getObject(<js>"MySection/anIntArray"</js>, <jk>int</jk>[].<jk>class</jk>);
- URL aURL = c.getObject(<js>"MySection/aURL"</js>, URL.<jk>class</jk>);
- MyBean aBean = c.getObject(<js>"MySection/aBean"</js>, MyBean.<jk>class</jk>);
- Locale locale = c.getObject(<js>"MySection/locale"</js>, Locale.<jk>class</jk>);
- String path = c.getString(<js>"MySection/path"</js>);
- String mainClass = c.getString(<js>"MySection/mainClass"</js>);
- <jk>int</jk> sameAsAnInt = c.getInt(<js>"MySection/sameAsAnInt"</js>);
- String myArg = c.getString(<js>"MySection/myArg"</js>);
- String firstArg = c.getString(<js>"MySection/firstArg"</js>);
+ <jk>int</jk> <jv>anInt</jv> = <jv>config</jv>.getInt(<js>"MySection/anInt"</js>);
+ <jk>boolean</jk> <jv>aBoolean</jv> = <jv>config</jv>.getBoolean(<js>"MySection/aBoolean"</js>);
+ <jk>int</jk>[] <jv>anIntArray</jv> = <jv>config</jv>.getObject(<js>"MySection/anIntArray"</js>, <jk>int</jk>[].<jk>class</jk>);
+ URL <jv>aURL</jv> = <jv>config</jv>.getObject(<js>"MySection/aURL"</js>, URL.<jk>class</jk>);
+ MyBean <jv>aBean</jv> = <jv>config</jv>.getObject(<js>"MySection/aBean"</js>, MyBean.<jk>class</jk>);
+ Locale <jv>locale</jv> = <jv>config</jv>.getObject(<js>"MySection/locale"</js>, Locale.<jk>class</jk>);
+ String <jv>path</jv> = <jv>config</jv>.getString(<js>"MySection/path"</js>);
+ String <jv>mainClass</jv> = <jv>config</jv>.getString(<js>"MySection/mainClass"</js>);
+ <jk>int</jk> <jv>sameAsAnInt</jv> = <jv>config</jv>.getInt(<js>"MySection/sameAsAnInt"</js>);
+ String <jv>myArg</jv> = <jv>config</jv>.getString(<js>"MySection/myArg"</js>);
+ String <jv>firstArg</jv> = <jv>config</jv>.getString(<js>"MySection/firstArg"</js>);
</p>
<p>
One of the more powerful aspects of the REST servlets is that you can pull values directly from
@@ -161,8 +161,7 @@
An extensible storage API allows you to write your own config storage location for files such as databases or the cloud.
</ul>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-config'>juneau-config</a>
</ul>
</div>
diff --git a/content/dto.html b/content/dto.html
index 735b9b8..15c7fc7 100644
--- a/content/dto.html
+++ b/content/dto.html
@@ -62,7 +62,7 @@
<p class='bcode w800'>
<jk>import static</jk> org.apache.juneau.dto.html5.HtmlBuilder.*;
- Object myform =
+ Object <jv>myform</jv> =
<jsm>form</jsm>().action(<js>"/submit"</js>).method(<js>"POST"</js>)
.children(
<js>"Position (1-10000): "</js>, <jsm>input</jsm>(<js>"number"</js>).name(<js>"pos"</js>).value(1), <jsm>br</jsm>(),
@@ -71,7 +71,7 @@
<jsm>button</jsm>(<js>"reset"</js>, <js>"Reset"</js>)
);
- String html = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(myform);
+ String <jv>html</jv> = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>myform</jv>);
</p>
<p class='bcode w800'><xt>
<form <xa>action</xa>=<xs>'/submit'</xs> <xa>method</xa>=<xs>'POST'</xs>>
@@ -108,7 +108,7 @@
<p class='bcode w800'>
<jk>import static</jk> org.apache.juneau.dto.atom.AtomBuilder.*;
- Feed feed =
+ Feed <jv>feed</jv> =
<jsm>feed</jsm>(<js>"tag:juneau.apache.org"</js>, <js>"Juneau ATOM specification"</js>, <js>"2016-01-02T03:04:05Z"</js>)
.subtitle(<jsm>text</jsm>(<js>"html"</js>).text(<js>"Describes <em>stuff</em> about Juneau"</js>))
.links(
@@ -128,7 +128,7 @@
);
<jc>// Serialize to ATOM/XML</jc>
- String atomXml = XmlSerializer.<jsf>DEFAULT</jsf>.serialize(feed);
+ String <jv>atomXml</jv> = XmlSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>feed</jv>);
</p>
<p class='bcode w800'>
<xt><feed></xt>
@@ -168,7 +168,7 @@
<p class='bcode w800'>
<jk>import static</jk> org.apache.juneau.dto.swagger.SwaggerBuilder.*;
- Swagger swagger = <jsm>swagger</jsm>()
+ Swagger <jv>swagger</jv> = <jsm>swagger</jsm>()
.swagger(<js>"2.0"</js>)
.info(
<jsm>info</jsm>(<js>"Swagger Petstore"</js>, <js>"1.0.0"</js>)
@@ -198,7 +198,7 @@
);
<jc>// Serialize to Swagger/JSON</jc>
- String swaggerJson = JsonSerializer.<jsf>DEFAULT_READABLE</jsf>.serialize(swagger);
+ String <jv>swaggerJson</jv> = JsonSerializer.<jsf>DEFAULT_READABLE</jsf>.serialize(<jv>swagger</jv>);
</p>
<p class='bcode w800'>
{
@@ -260,8 +260,7 @@
be serialized directly to a string in the typical language (e.g. HTML5 beans to HTML, Swagger to JSON, etc...).
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-dto'>juneau-dto</a>
</ul>
</div>
diff --git a/content/examples.html b/content/examples.html
index 996db56..7b9dfe4 100644
--- a/content/examples.html
+++ b/content/examples.html
@@ -37,8 +37,7 @@
<img class='bordered' src='images/juneau-examples-core.Installing.3.png' style='width:400px'>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-examples-core'>juneau-examples-core</a>
</ul>
</div>
@@ -67,8 +66,7 @@
</p>
<img class='bordered w800' src='images/juneau-examples-rest.RootResources.1.png'>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-examples-rest'>juneau-examples-rest</a>
</ul>
</div>
@@ -91,8 +89,7 @@
<img class='bordered' src='images/juneau-examples-rest-jetty.Installing.3.png' style='width:400px'>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-examples-rest-jetty'>juneau-examples-rest-jetty</a>
</ul>
</div>
@@ -125,8 +122,7 @@
<img class='bordered' src='images/juneau-examples-rest-springboot.Installing.3.png' style='width:400px'>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-examples-rest-springboot'>juneau-examples-rest-springboot</a>
</ul>
</div>
diff --git a/content/marshall.html b/content/marshall.html
index 38a6032..0609bcc 100644
--- a/content/marshall.html
+++ b/content/marshall.html
@@ -52,7 +52,9 @@
<p>
<a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#Glossaries.LanguageSupport'>Glossary > Language Support</a>
</p>
- <h5 class='section'>Features:</h5>
+ <p>
+ Features include:
+ </p>
<ul class='spaced-list'>
<li>Serializers can send output directly to Writers, OutputStreams, Files, Strings, or byte arrays.
<li>Parsers can receive input directly from Readers, InputStreams, Files, Strings, or byte arrays.
@@ -77,48 +79,47 @@
<jk>public int</jk> age = 21;
}
- Person p = <jk>new</jk> Person(); <jc>// An arbitrary POJO</jc>
+ Person <jv>person</jv> = <jk>new</jk> Person(); <jc>// An arbitrary POJO</jc>
<jc>// Produces:
// "{name:'John Smith',age:21}"</jc>
- String laxJson = SimpleJsonSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>laxJson</jv> = SimpleJsonSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// "{"name":"John Smith","age":21}"</jc>
- String strictJson = JsonSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>strictJson</jv> = JsonSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// <object>
// <name>John Smith</name>
// <age>21</age>
// </object></jc>
- String xml = XmlSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>xml</jv> = XmlSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// <table>
// <tr><td>name</td><td>John Smith</td></tr>
// <tr><td>age</td><td>21</td></tr>
// </table></jc>
- String html = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>html</jv> = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Same as Html, but wraps it in HTML and BODY elements with page title/description/links:</jc>
- String htmlDoc = HtmlDocSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>htmlDoc</jv> = HtmlDocSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// name='John+Smith'&age=21</jc>
- String urlEncoding = UrlEncodingSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>urlEncoding</jv> = UrlEncodingSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// (name='John Smith',age=21)</jc>
- String uon = UonSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>uon</jv> = UonSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// 82 A4 name AA 4A John Smith 68 A3 age 15</jc>
- <jk>byte</jk>[] messagePack = MsgPackSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ <jk>byte</jk>[] <jv>messagePack</jv> = MsgPackSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-marshall.Serializers'>juneau-marshall > Serializers</a>
</ul>
@@ -133,53 +134,68 @@
</p>
<p class='bcode w800'>
<jc>// Use one of the predefined parsers.</jc>
- ReaderParser parser = JsonParser.<jsf>DEFAULT</jsf>;
+ ReaderParser <jv>parser</jv> = JsonParser.<jsf>DEFAULT</jsf>;
<jc>// Parse a JSON object (creates a generic ObjectMap).</jc>
- String json = <js>"{name:'John Smith',age:21}"</js>;
- Map m1 = parser.parse(json, Map.<jk>class</jk>);
+ String <jv>json</jv> = <js>"{name:'John Smith',age:21}"</js>;
+ Map <jv>map</jv> = <jv>parser</jv>.parse(<jv>json</jv>, Map.<jk>class</jk>);
<jc>// Parse a JSON string.</jc>
- json = <js>"'foobar'"</js>;
- String s2 = parser.parse(json, String.<jk>class</jk>);
+ <jv>json</jv> = <js>"'foobar'"</js>;
+ String <jv>string</jv> = <jv>parser</jv>.parse(<jv>json</jv>, String.<jk>class</jk>);
<jc>// Parse a JSON number as a Long or Float.</jc>
- json = <js>"123"</js>;
- Long l3 = parser.parse(json, Long.<jk>class</jk>);
- Float f3 = parser.parse(json, Float.<jk>class</jk>);
+ <jv>json</jv> = <js>"123"</js>;
+ Long <jv>long</jv> = <jv>parser</jv>.parse(<jv>json</jv>, Long.<jk>class</jk>);
+ Float <jv>float</jv> = <jv>parser</jv>.parse(<jv>json</jv>, Float.<jk>class</jk>);
<jc>// Parse a JSON object as a bean.</jc>
- json = <js>"{name:'John Smith',age:21}"</js>;
- Person p4 = parser.parse(json, Person.<jk>class</jk>);
+ <jv>json</jv> = <js>"{name:'John Smith',age:21}"</js>;
+ Person <jv>person</jv> = <jv>parser</jv>.parse(<jv>json</jv>, Person.<jk>class</jk>);
<jc>// Parse a JSON object as a HashMap<String,Person>.</jc>
- json = <js>"{a:{name:'John Smith',age:21},b:{name:'Joe Smith',age:42}}"</js>;
- Map<String,Person> m5 = parser.parse(json, HashMap.<jk>class</jk>, String.<jk>class</jk>, Person.<jk>class</jk>);
+ <jv>json</jv> = <js>"{a:{name:'John Smith',age:21},b:{name:'Joe Smith',age:42}}"</js>;
+ Map<String,Person> <jv>personMap</jv> = <jv>parser</jv>.parse(
+ <jv>json</jv>,
+ HashMap.<jk>class</jk>,
+ String.<jk>class</jk>,
+ Person.<jk>class</jk>
+ );
<jc>// Parse a JSON object as a HashMap<String,LinkedList<Person>>.</jc>
- json = <js>"{a:[{name:'John Smith',age:21},{name:'Joe Smith',age:42}]}"</js>;
- Map<String,List<Person>> m6 = parser.parse(json, HashMap.<jk>class</jk>, String.<jk>class</jk>, LinkedList.<jk>class</jk>, Person.<jk>class</jk>);
+ <jv>json</jv> = <js>"{a:[{name:'John Smith',age:21},{name:'Joe Smith',age:42}]}"</js>;
+ Map<String,List<Person>> personListMap = <jv>parser</jv>.parse(
+ <jv>json</jv>,
+ HashMap.<jk>class</jk>,
+ String.<jk>class</jk>,
+ LinkedList.<jk>class</jk>,
+ Person.<jk>class</jk>
+ );
<jc>// Parse a JSON array of integers as a Collection of Integers or int[] array.</jc>
- json = <js>"[1,2,3]"</js>;
- List<Integer> l7 = parser.parse(json, LinkedList.<jk>class</jk>, Integer.<jk>class</jk>);
- <jk>int</jk>[] i7 = parser.parse(json, <jk>int</jk>[].<jk>class</jk>);
+ <jv>json</jv> = <js>"[1,2,3]"</js>;
+ List<Integer> <jv>integerList</jv> = <jv>parser</jv>.parse(
+ <jv>json</jv>,
+ LinkedList.<jk>class</jk>,
+ Integer.<jk>class</jk>
+ );
+ <jk>int</jk>[] <jv>intList</jv> = <jv>parser</jv>.parse(
+ <jv>json</jv>,
+ <jk>int</jk>[].<jk>class</jk>
+ );
<jc>// Parse arbitrary input into ObjectMap or ObjectList objects
// (similar to JSONObject/JSONArray but generalized for all languages).</jc>
- json = <js>"{name:'John Smith',age:21}"</js>;
- ObjectMap m8a = parser.parse(json, ObjectMap.<jk>class</jk>);
- <jk>int</jk> age = m8a.getInt(<js>"age"</js>);
- ObjectMap m8b = (ObjectMap)parser.parse(json, Object.<jk>class</jk>); <jc>// Equivalent.</jc>
+ <jv>json</jv> = <js>"{name:'John Smith',age:21}"</js>;
+ OMap <jv>oMap</jv> = <jv>parser</jv>.parse(<jv>json</jv>, OMap.<jk>class</jk>);
+ <jk>int</jk> age = <jv>oMap</jv>.getInt(<js>"age"</js>);
- json = <js>"[1,true,null]"</js>;
- ObjectList l9a = parser.parse(json, ObjectList.<jk>class</jk>);
- <jk>boolean</jk> b = l9a.getBoolean(1);
- ObjectList l9b = (ObjectList)parser.parse(json, Object.<jk>class</jk>); <jc>// Equivalent.</jc>
+ <jv>json</jv> = <js>"[1,true,null]"</js>;
+ OList <jv>oList</jv> = <jv>parser</jv>.parse(<jv>json</jv>, ObjectList.<jk>class</jk>);
+ <jk>boolean</jk> <jv>boolean</jv> = <jv>oList</jv>.getBoolean(1);
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-marshall.Parsers'>juneau-marshall > Parsers</a>
</ul>
<hr>
@@ -187,40 +203,39 @@
Marshalls are pairings of serializers and parsers in a single class for even simpler code:
</p>
<p class='bcode w800'>
- Person p = <jk>new</jk> Person(); <jc>// An arbitrary POJO</jc>
+ Person <jv>person</jv> = <jk>new</jk> Person(); <jc>// An arbitrary POJO</jc>
<jc>// Serialize</jc>
- String json = Json.<jsf>DEFAULT</jsf>.write(p);
- String simpleJson = SimpleJson.<jsf>DEFAULT</jsf>.write(p);
- String xml = Xml.<jsf>DEFAULT</jsf>.write(p);
- String html = Html.<jsf>DEFAULT</jsf>.write(p);
- String uon = Uon.<jsf>DEFAULT</jsf>.write(p);
- String urlEncoding = UrlEncoding.<jsf>DEFAULT</jsf>.write(p);
- String openapi = OpenApi.<jsf>DEFAULT</jsf>.write(p);
- <jk>byte</jk>[] msgPack = MsgPack.<jsf>DEFAULT</jsf>.write(p);
- String rdfXml = RdfXml.<jsf>DEFAULT</jsf>.write(p);
- String rdfXmlAbbrev = RdfXmlAbbrev.<jsf>DEFAULT</jsf>.write(p);
- String n3 = N3.<jsf>DEFAULT</jsf>.write(p);
- String nTuple = NTuple.<jsf>DEFAULT</jsf>.write(p);
- String turtle = Turtle.<jsf>DEFAULT</jsf>.write(p);
+ String <jv>json</jv> = Json.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>simpleJson</jv> = SimpleJson.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>xml</jv> = Xml.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>html</jv> = Html.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>uon</jv> = Uon.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>urlEncoding</jv> = UrlEncoding.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>openapi</jv> = OpenApi.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ <jk>byte</jk>[] <jv>msgPack</jv> = MsgPack.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>rdfXml</jv> = RdfXml.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>rdfXmlAbbrev</jv> = RdfXmlAbbrev.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>n3</jv> = N3.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>nTuple</jv> = NTuple.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>turtle</jv> = Turtle.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
<jc>// Parse</jc>
- p = Json.<jsf>DEFAULT</jsf>.read(json, Person.<jk>class</jk>);
- p = Xml.<jsf>DEFAULT</jsf>.read(xml, Person.<jk>class</jk>);
- p = Html.<jsf>DEFAULT</jsf>.read(html, Person.<jk>class</jk>);
- p = Uon.<jsf>DEFAULT</jsf>.read(uon, Person.<jk>class</jk>);
- p = UrlEncoding.<jsf>DEFAULT</jsf>.read(urlEncoding, Person.<jk>class</jk>);
- p = OpenApi.<jsf>DEFAULT</jsf>.read(openapi, Person.<jk>class</jk>);
- p = MsgPack.<jsf>DEFAULT</jsf>.read(msgPack, Person.<jk>class</jk>);
- p = RdfXml.<jsf>DEFAULT</jsf>.read(rdfXml, Person.<jk>class</jk>);
- p = RdfXmlAbbrev.<jsf>DEFAULT</jsf>.read(rdfXmlAbbrev, Person.<jk>class</jk>);
- p = N3.<jsf>DEFAULT</jsf>.read(n3, Person.<jk>class</jk>);
- p = NTuple.<jsf>DEFAULT</jsf>.read(nTuple, Person.<jk>class</jk>);
- p = Turtle.<jsf>DEFAULT</jsf>.read(turtle, Person.<jk>class</jk>);
+ <jv>person</jv> = Json.<jsf>DEFAULT</jsf>.read(<jv>json</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = Xml.<jsf>DEFAULT</jsf>.read(<jv>xml</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = Html.<jsf>DEFAULT</jsf>.read(<jv>html</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = Uon.<jsf>DEFAULT</jsf>.read(<jv>uon</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = UrlEncoding.<jsf>DEFAULT</jsf>.read(<jv>urlEncoding</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = OpenApi.<jsf>DEFAULT</jsf>.read(<jv>openapi</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = MsgPack.<jsf>DEFAULT</jsf>.read(<jv>msgPack</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = RdfXml.<jsf>DEFAULT</jsf>.read(<jv>rdfXml</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = RdfXmlAbbrev.<jsf>DEFAULT</jsf>.read(<jv>rdfXmlAbbrev</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = N3.<jsf>DEFAULT</jsf>.read(<jv>n3</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = NTuple.<jsf>DEFAULT</jsf>.read(<jv>nTuple</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = Turtle.<jsf>DEFAULT</jsf>.read(<jv>turtle</jv>, Person.<jk>class</jk>);
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-marshall.Marshalls'>juneau-marshall > Marshalls</a>
</ul>
@@ -231,23 +246,22 @@
</p>
<p class='bcode w800'>
<jc>// Create a serializer from scratch programmatically using a builder.</jc>
- JsonSerializer serializer = JsonSerializer.<jsm>create</jsm>()
+ JsonSerializer <jv>serializer</jv> = JsonSerializer.<jsm>create</jsm>()
.simple() <jc>// Simple mode</jc>
.sq() <jc>// Use single quotes</jc>
- .pojoSwaps( <jc>// Swap unserializable classes with surrogate POJOs</jc>
+ .swaps( <jc>// Swap unserializable classes with surrogate POJOs</jc>
IteratorSwap.<jk>class</jk>, <jc>// Iterators swapped with lists</jc>
ByteArrayBase64Swap.<jk>class</jk>, <jc>// byte[] swapped with base-64 encoded strings</jc>
CalendarSwap.ISO8601DT.<jk>class</jk> <jc>// Calendars swapped with ISO8601-compliant strings</jc>
- )
- .beanFilters(MyBeanFilter.<jk>class</jk>) <jc>// Control how bean properties are handled</jc>
- .timeZone(TimeZone.<jsf>GMT</jsf>) <jc>// For serializing Calendars</jc>
- .locale(Locale.<jsf>JAPAN</jsf>) <jc>// For timezone-specific serialization</jc>
- .sortCollections() <jc>// For locale-specific serialization</jc>
- .sortProperties() <jc>// Various behavior settings</jc>
- .trimNullProperties()
+ )
+ .timeZone(TimeZone.<jsf>GMT</jsf>) <jc>// For timezone-specific serialization</jc>
+ .locale(Locale.<jsf>JAPAN</jsf>) <jc>// For locale-specific serialization</jc>
+ .sortCollections()
+ .sortProperties()
+ .keepNullProperties()
.trimStrings()
- .methodVisibility(<jsf>PROTECTED</jsf>) <jc>// Control which fields/methods are serialized</jc>
- .beanDictionary( <jc>// Adds type variables for resolution during parsing</jc>
+ .beanMethodVisibility(<jsf>PROTECTED</jsf>) <jc>// Control which fields/methods are serialized</jc>
+ .dictionary( <jc>// Adds type variables for resolution during parsing</jc>
MyBeanA.<jk>class</jk>,
MyBeanB.<jk>class</jk>
)
@@ -256,33 +270,31 @@
<jc>// Same as above, but using declarative named properties.</jc>
<jc>// This is how serializers and parsers are typically configured on REST servlets and clients.</jc>
- JsonSerializer serializer = JsonSerializer.<jsm>create</jsm>()
+ JsonSerializer <jv>serializer</jv> = JsonSerializer.<jsm>create</jsm>()
.set(<jsf>JSON_simpleMode</jsf>, <jk>true</jk>)
.set(<jsf>SERIALIZER_quoteChar</jsf>, <js>'\''</js>)
- .set(<jsf>BEAN_pojoSwaps_add</jsf>, IteratorSwap.<jk>class</jk>)
- .set(<jsf>BEAN_pojoSwaps_add</jsf>, ByteArrayBase64Swap.<jk>class</jk>)
- .set(<jsf>BEAN_pojoSwaps_add</jsf>, CalendarSwap.ISO8601DT.<jk>class</jk>)
- .set(<jsf>BEAN_beanFilters_add</jsf>, MyBeanFilter.<jk>class</jk>)
+ .appendTo(<jsf>BEAN_swaps</jsf>, IteratorSwap.<jk>class</jk>)
+ .appendTo(<jsf>BEAN_swaps</jsf>, ByteArrayBase64Swap.<jk>class</jk>)
+ .appendTo(<jsf>BEAN_swaps</jsf>, CalendarSwap.ISO8601DT.<jk>class</jk>)
.set(<jsf>BEAN_timeZone</jsf>, TimeZone.<jsf>GMT</jsf>)
.set(<jsf>BEAN_locale</jsf>, Locale.<jsf>JAPAN</jsf>)
.set(<jsf>SERIALIZER_sortCollections</jsf>, <jk>true</jk>)
.set(<jsf>BEAN_sortProperties</jsf>, <jk>true</jk>)
- .set(<jsf>SERIALIZER_trimNullProperties</jsf>, <jk>true</jk>)
+ .set(<jsf>SERIALIZER_keepNullProperties</jsf>, <jk>true</jk>)
.set(<jsf>SERIALIZER_trimStrings</jsf>, <jk>true</jk>)
- .set(<jsf>BEAN_methodVisibility</jsf>, <jsf>PROTECTED</jsf>)
- .set(<jsf>BEAN_beanDictionary_add</jsf>, MyBeanA.<jk>class</jk>)
- .set(<jsf>BEAN_beanDictionary_add</jsf>, MyBeanB.<jk>class</jk>)
+ .set(<jsf>BEAN_beanMethodVisibility</jsf>, <jsf>PROTECTED</jsf>)
+ .appendTo(<jsf>BEAN_dictionary</jsf>, MyBeanA.<jk>class</jk>)
+ .appendTo(<jsf>BEAN_dictionary</jsf>, MyBeanB.<jk>class</jk>)
.set(<jsf>BEAN_debug</jsf>, <jk>true</jk>)
.build();
<jc>// Clone an existing serializer and modify it to use single-quotes.</jc>
- JsonSerializer serializer = JsonSerializer.<jsf>DEFAULT</jsf>.builder()
+ JsonSerializer <jv>serializer</jv> = JsonSerializer.<jsf>DEFAULT</jsf>.builder()
.sq()
.build();
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-marshall.ConfigurableProperties'>juneau-marshall > Configurable Properties</a>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#Glossaries.ConfigurableProperties'>Glossary > Configurable Properties</a>
</ul>
@@ -314,8 +326,7 @@
<code>fromString(String)</code>, <code>T(String)</code>, <code>Object swap(BeanSession)</code>, <code>T unswap(BeanSession, T.class)</code>
</ul>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-marshall.PojoCategories'>juneau-marshall > POJO Categories</a>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#Glossaries.Annotations'>Glossary > Annotations</a>
</ul>
@@ -348,8 +359,7 @@
)
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-marshall.UonDetails'>juneau-marshall > UON Details</a>
</ul>
@@ -359,37 +369,32 @@
</p>
<p class='bcode w800'>
<jc>// Create JSON strings from scratch using fluent-style code.</jc>
- String jsonObject = <jk>new</jk> ObjectMap().append(<js>"foo"</js>,<js>"bar"</js>).toString();
- String jsonArray = <jk>new</jk> ObjectList().append(<js>"foo"</js>).append(123).append(<jk>null</jk>).toString();
+ String <jv>jsonObject</jv> = <jk>new</jk> OMap().append(<js>"foo"</js>,<js>"bar"</js>).toString();
+ String <jv>jsonArray</jv> = <jk>new</jk> OList().append(<js>"foo"</js>).append(123).append(<jk>null</jk>).toString();
<jc>// Create maps and beans directly from JSON.</jc>
- Map<String,Object> myMap = <jk>new</jk> ObjectMap(<js>"{foo:'bar'}"</js>);
- List<Object> myList = <jk>new</jk> ObjectList(<js>"['foo',123,null]"</js>);
+ Map<String,Object> <jv>myMap</jv> = <jk>new</jk> OMap(<js>"{foo:'bar'}"</js>);
+ List<Object> <jv>myList</jv> = <jk>new</jk> OList(<js>"['foo',123,null]"</js>);
<jc>// Load a POJO from a JSON file.</jc>
- MyPojo myPojo = JsonParser.<jsf>DEFAULT</jsf>.parse(<jk>new</jk> File(<js>"myPojo.json"</js>));
+ MyPojo <jv>myPojo</jv> = JsonParser.<jsf>DEFAULT</jsf>.parse(<jk>new</jk> File(<js>"myPojo.json"</js>));
<jc>// Serialize POJOs and ignore exceptions (great for logging)</jc>
- String json = SimpleJson.<jsf>DEFAULT</jsf>.toString(myPojo);
+ String <jv>json</jv> = SimpleJson.<jsf>DEFAULT</jsf>.toString(<jv>myPojo</jv>);
<jc>// Dump a POJO to the console.</jc>
- SimpleJson.<jsf>DEFAULT</jsf>.println(myPojo);
+ SimpleJson.<jsf>DEFAULT</jsf>.println(<jv>myPojo</jv>);
- <jc>// Delayed serialization.</jc>
- <jc>// (e.g. don't serialize an object if it's not going to be logged).</jc>
- logger.log(<jsf>FINE</jsf>, <js>"My POJO was: {0}"</js>, <jk>new</jk> StringObject(myPojo));
- logger.log(<jsf>FINE</jsf>, <js>"My POJO in XML was: {0}"</js>, <jk>new</jk> StringObject(XmlSerializer.<jsf>DEFAULT</jsf>, myPojo));
-
- String message = <jk>new</jk> StringMessage(<js>"My POJO in {0}: {1}"</js>, <js>"JSON"</js>, <jk>new</jk> StringObject(myPojo)).toString();
+ String <jv>message</jv> = <jk>new</jk> StringMessage(<js>"My POJO in {0}: {1}"</js>, <js>"JSON"</js>, <jk>new</jk> StringObject(<jv>myPojo</jv>)).toString();
<jc>// Create a 'REST-like' wrapper around a POJO.</jc>
<jc>// Allows you to manipulate POJO trees using URIs and GET/PUT/POST/DELETE commands.</jc>
- PojoRest pojoRest = <jk>new</jk> PojoRest(myPojo);
- pojoRest.get(String.<jk>class</jk>, <js>"addressBook/0/name"</js>);
- pojoRest.put(<js>"addressBook/0/name"</js>, <js>"John Smith"</js>);
+ PojoRest <jv>pojoRest</jv> = <jk>new</jk> PojoRest(<jv>myPojo</jv>);
+ <jv>pojoRest</jv>.get(String.<jk>class</jk>, <js>"addressBook/0/name"</js>);
+ <jv>pojoRest</jv>.put(<js>"addressBook/0/name"</js>, <js>"John Smith"</js>);
</p>
- <h5 class='section'>More Information:</h5>
+ <ul class='seealso'>
<ul class='doctree'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-marshall.ObjectMap'>juneau-marshall > ObjectMap and ObjectList</a>
</ul>
@@ -401,28 +406,27 @@
</p>
<p class='bcode w800'>
<jc>// Construct a new serializer group with configuration parameters that get applied to all serializers.</jc>
- SerializerGroup sg = SerializerGroup.<jsm>create</jsm>()
+ SerializerGroup <jv>serializerGroup</jv> = SerializerGroup.<jsm>create</jsm>()
.append(JsonSerializer.<jk>class</jk>, UrlEncodingSerializer.<jk>class</jk>);
.ws() <jc>// or .setUseWhitespace(true) or .set(SERIALIZER_useWhitespace, true)</jc>
- .pojoSwaps(CalendarSwap.ISO8601DT.<jk>class</jk>) <jc>// or .set(BEAN_pojoSwaps_add, CalendarSwap.ISO8601DT.class)</jc>
+ .swaps(CalendarSwap.ISO8601DT.<jk>class</jk>) <jc>// or .appendTo(BEAN_pojoSwaps, CalendarSwap.ISO8601DT.class)</jc>
.build();
<jc>// Find the appropriate serializer by Accept type and serialize our POJO to the specified writer.</jc>
<jc>// Fully RFC2616 compliant.</jc>
- sg.getSerializer(<js>"text/invalid, text/json;q=0.8, text/*;q:0.6, *\/*;q=0.0"</js>)
- .serialize(myPersonObject, myWriter);
+ <jv>serializerGroup</jv>.getSerializer(<js>"text/invalid, text/json;q=0.8, text/*;q:0.6, *\/*;q=0.0"</js>)
+ .serialize(<jv>person</jv>, <jv>myWriter</jv>);
<jc>// Construct a new parser group with configuration parameters that get applied to all parsers.</jc>
- ParserGroup pg = ParserGroup.<jsm>create</jsm>()
+ ParserGroup <jv>parserGroup</jv> = ParserGroup.<jsm>create</jsm>()
.append(JsonParser.<jk>class</jk>, UrlEncodingParser.<jk>class</jk>);
- .pojoSwaps(CalendarSwap.ISO8601DT.<jk>class</jk>) <jc>// or .set(BEAN_pojoSwaps_add, CalendarSwap.ISO8601DT.class)</jc>
+ .swaps(CalendarSwap.ISO8601DT.<jk>class</jk>) <jc>// or .appendTo(BEAN_pojoSwaps, CalendarSwap.ISO8601DT.class)</jc>
.build();
- Person p = pg.getParser(<js>"text/json"</js>).parse(myReader, Person.<jk>class</jk>);
+ Person <jv>person</jv> = <jv>parserGroup</jv>.getParser(<js>"text/json"</js>).parse(<jv>myReader</jv>, Person.<jk>class</jk>);
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-marshall.Groups'>juneau-marshall > SerializerGroups and ParserGroups</a>
</ul>
<p>
@@ -436,7 +440,7 @@
</p>
<p class='bcode w800'>
<jc>// Use the default variable resolver to resolve a string that contains $S (system property) variables</jc>
- String myProperty = VarResolver.<jsf>DEFAULT</jsf>.resolve(<js>"The Java home directory is $S{java.home}"</js>);
+ String <jv>myProperty</jv> = VarResolver.<jsf>DEFAULT</jsf>.resolve(<js>"The Java home directory is $S{java.home}"</js>);
</p>
<p>
The following shows how variables can be arbitrarily nested:
@@ -446,7 +450,7 @@
// 1) MYPROPERTY environment variable.
// 2) 'my.property' system property if environment variable not found.
// 3) 'not found' string if system property not found.</jc>
- String myproperty = VarResolver.<jsf>DEFAULT</jsf>.resolve(<js>"$E{MYPROPERTY,$S{my.property,not found}}"</js>);
+ String <jv>myproperty</jv> = VarResolver.<jsf>DEFAULT</jsf>.resolve(<js>"$E{MYPROPERTY,$S{my.property,not found}}"</js>);
</p>
<p>
SVL is a large topic on it's own.
@@ -456,8 +460,7 @@
Plugging in your own variables is also easy.
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-svl'>juneau-svl</a>
</ul>
@@ -507,12 +510,12 @@
<p class='bcode w800'>
<jc>// A simple bean</jc>
<jk>public class</jk> Person {
- <jk>public</jk> String name = <js>"This is RDF format."</js>;
- <jk>public</jk> String id = "rdf";
+ <jk>public</jk> String <jf>name</jf> = <js>"This is RDF format."</js>;
+ <jk>public</jk> String <jf>id</jf> = "rdf";
}
<jc>// Serialize a bean to various RDF languages</jc>
- Person p = <jk>new</jk> Person();
+ Person <jv>person</jv> = <jk>new</jk> Person();
<jc>// Produces:
// <rdf:RDF
@@ -524,31 +527,29 @@
// <jp:id>rdf</jp:id>
// </rdf:Description>
// </rdf:RDF></jc>
- String rdfXml = RdfXmlAbbrevSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>rdfXml</jv> = RdfXmlAbbrevSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// @prefix jp: <http://www.apache.org/juneaubp/> .
// @prefix j: <http://www.apache.org/juneau/> .
// [] jp:id "rdf" ;
// jp:name "This is RDF format." .</jc>
- String rdfN3 = N3Serializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>rdfN3</jv> = N3Serializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// _:A3bf53c85X3aX157cf407e2dX3aXX2dX7ffd <http://www.apache.org/juneaubp/name> "This is RDF format." .
// _:A3bf53c85X3aX157cf407e2dX3aXX2dX7ffd <http://www.apache.org/juneaubp/age> "rdf" .</jc>
- String rdfNTriple = NTripleSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>rdfNTriple</jv> = NTripleSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// @prefix jp: <http://www.apache.org/juneaubp/> .
// @prefix j: <http://www.apache.org/juneau/> .
// [] jp:id "rdf" ;
// jp:name "This is RDF format." .</jc>
- String rdfTurtle = TurtleSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>rdfTurtle</jv> = TurtleSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
-
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-marshall-rdf'>juneau-marshall-rdf</a>
</ul>
</div>
diff --git a/content/petstore.html b/content/petstore.html
index f82811f..dae0a2b 100644
--- a/content/petstore.html
+++ b/content/petstore.html
@@ -98,14 +98,14 @@
description=<js>"ID of pet to return"</js>,
example=<js>"123"</js>
)
- <jk>long</jk> petId
+ <jk>long</jk> <jv>petId</jv>
) <jk>throws</jk> IdNotFound, NotAcceptable;
<ja>@RemoteMethod</ja>(method=<jsf>POST</jsf>, path=<js>"/pet"</js>)
<jk>public long</jk> createPet(
<ja>@Body</ja>(
description=<js>"Pet object to add to the store"</js>
- ) CreatePet pet
+ ) CreatePet <jv>pet</jv>
) <jk>throws</jk> IdConflict, NotAcceptable, UnsupportedMediaType;
...
@@ -178,23 +178,19 @@
<p class='bcode w800'>
<jk>public class</jk> Main {
- <jk>public static void</jk> main(String[] args) {
+ <jk>public static void</jk> main(String[] <jv>args</jv>) {
<jc>// Create a RestClient with JSON serialization support.</jc>
- <jk>try</jk> (RestClient rc = RestClient.create(SimpleJsonSerializer.<jk>class</jk> JsonParser.<jk>class</jk>).build()) {
+ RestClient <jv>restClient</jv> = RestClient.<jsm>create</jsm>().simpleJson().build();
- <jc>// Instantiate our proxy.</jc>
- PetStore petStore = rc.getRemote(PetStore.<jk>class</jk>, <js>"http://localhost:5000"</js>);
-
- <jc>// Print out the pets in the store.</jc>
- Collection<Pet> pets = petStore.getPets();
-
- <jc>// Pretty-print them to STDOUT.</jc>
- SimpleJson.<jsf>DEFAULT_READABLE</jsf>.println(pets);
-
- } <jk>catch</jk> (Exception e) {
- e.printStackTrace();
- }
+ <jc>// Instantiate our proxy.</jc>
+ PetStore <jv>petStore</jv> = <jv>restClient</jv>.getRemote(PetStore.<jk>class</jk>, <js>"http://localhost:5000"</js>);
+
+ <jc>// Print out the pets in the store.</jc>
+ Collection<Pet> <jv>pets</jv> = <jv>petStore</jv>.getPets();
+
+ <jc>// Pretty-print them to STDOUT.</jc>
+ SimpleJson.<jsf>DEFAULT_READABLE</jsf>.println(<jv>pets</jv>);
}
}
</p>
@@ -215,14 +211,14 @@
<ja>@SpringBootApplication</ja>
<jk>public class</jk> App {
- <jk>public static void</jk> main(String[] args) {
- <jk>new</jk> App().start(args);
+ <jk>public static void</jk> main(String[] <jv>args</jv>) {
+ <jk>new</jk> App().start(<jv>args</jv>);
}
- <jk>protected void</jk> start(String[] args) {
+ <jk>protected void</jk> start(String[] <jv>args</jv>) {
<jk>new</jk> SpringApplicationBuilder(App.<jk>class</jk>)
.initializers(<jk>new</jk> JuneauRestInitializer(App.<jk>class</jk>))
- .run(args);
+ .run(<jv>args</jv>);
}
}
</p>
@@ -474,8 +470,8 @@
tags=<js>"pet"</js>
)
)
- <jk>public</jk> Pet getPet(long petId) <jk>throws</jk> IdNotFound, NotAcceptable {
- <jk>return</jk> <jf>store</jf>.getPet(petId);
+ <jk>public</jk> Pet getPet(<jk>long</jk> <jv>petId</jv>) <jk>throws</jk> IdNotFound, NotAcceptable {
+ <jk>return</jk> <jf>store</jf>.getPet(<jv>petId</jv>);
}
<ja>@Override</ja> <jc>/* PetStore */</jc>
@@ -488,8 +484,8 @@
),
roleGuard=<js>"ROLE_ADMIN || (ROLE_USER && ROLE_WRITABLE)"</js> <jc>// Restrict access to this method.</jc>
)
- <jk>public long</jk> createPet(CreatePet pet) <jk>throws</jk> IdConflict, NotAcceptable, UnsupportedMediaType {
- <jk>return</jk> <jf>store</jf>.create(pet).getId();
+ <jk>public long</jk> createPet(CreatePet <jv>pet</jv>) <jk>throws</jk> IdConflict, NotAcceptable, UnsupportedMediaType {
+ <jk>return</jk> <jf>store</jf>.create(<jv>pet</jv>).getId();
}
...
diff --git a/content/rest-client.html b/content/rest-client.html
index e37758d..b871057 100644
--- a/content/rest-client.html
+++ b/content/rest-client.html
@@ -46,193 +46,69 @@
</p>
<p>
- The REST client API allows you to access REST interfaces using POJOs:
+ Built upon the feature-rich Apache HttpClient library, the Juneau RestClient API adds support for fluent-style
+ REST calls and the ability to perform marshalling of POJOs to and from HTTP parts.
</p>
+
+ <h5 class='figure'>Example:</h5>
<p class='bcode w800'>
- <jc>// Create a reusable JSON client.</jc>
- RestClient client = RestClient.<jsm>create</jsm>().build();
-
- <jc>// The address of the root resource.</jc>
- String url = <js>"http://localhost:10000/systemProperties"</js>;
-
- <jc>// Do a REST GET against a remote REST interface and convert
- // the response to an unstructured ObjectMap object.</jc>
- Map m1 = client.doGet(url).getResponse(TreeMap.<jk>class</jk>);
-
- <jc>// Add some new system properties.
- // Use XML as the transport medium.</jc>
- client = RestClient.<jsm>create</jsm>().serializer(XmlSerializer.<jk>class</jk>).parser(XmlParser.<jk>class</jk>).build();
- Properties p = <jk>new</jk> Properties();
- p.load(reader);
- <jk>int</jk> returnCode = client.doPost(url + <js>"/systemProperties"</js>, p).execute();
- </p>
- <p>
- The client API uses the same serializers and parsers (and subsequently their flexibility and configurability) as the server side to marshall POJOs back and forth.
+ <jc>// Create a basic REST client with JSON support and download a bean.</jc>
+ MyBean <jv>bean</jv> = RestClient.<jsm>create</jsm>()
+ .simpleJson()
+ .build()
+ .get(<jsf>URI</jsf>)
+ .run()
+ .assertStatus().code().is(200)
+ .assertHeader(<js>"Content-Type"</js>).matchesSimple(<js>"application/json*"</js>)
+ .getBody().as(MyBean.<jk>class</jk>);
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
- <li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-rest-client.juneau-rest-client'>juneau-rest-client</a>
- </ul>
- <hr>
+
<p>
- <b>restRPC</b> (RPC over REST) allows the creation of client-side remote proxy interfaces for calling methods on server-side POJOs using entirely REST.
+ Breaking apart the fluent call, we can see the classes being used:
</p>
+
<p class='bcode w800'>
- <jc>// Get an interface proxy.</jc>
- IAddressBook ab = restClient.getRemote(IAddressBook.<jk>class</jk>);
-
- <jc>// Invoke a method on the server side and get the returned result.</jc>
- Person p = ab.createPerson(
- <jk>new</jk> Person(
- <js>"John Smith"</js>,
- <js>"Aug 1, 1999"</js>,
- <jk>new</jk> Address(<js>"My street"</js>, <js>"My city"</js>, <js>"My state"</js>, 12345, <jk>true</jk>)
- )
- );
- </p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
- <li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-rest-server.restRPC'>juneau-rest-server > restRPC</a>
- </ul>
- <hr>
- <p>
- The <code>juneau-rest-client</code> library can also be used to define interface proxies against 3rd-party REST interfaces.
- This is an extremely powerful feature that allows you to quickly define easy-to-use interfaces against virtually any REST interface.
+ RestClientBuilder <jv>builder</jv> = RestClient.<jsm>create</jsm>().simpleJson();
+ RestClient <jv>client</jv> = <jv>builder</jv>.build();
+ RestRequest <jv>req</jv> = <jv>client</jv>.get(<jsf>URI</jsf>);
+ RestResponse <jv>res</jv> = <jv>req</jv>.run();
+ RestResponseStatusLineAssertion <jv>statusLineAssertion</jv> = <jv>res</jv>.assertStatus();
+ FluentIntegerAssertion<RestResponse> <jv>codeAssertion</jv> = <jv>statusLineAssertion</jv>.code();
+ <jv>res</jv> = <jv>codeAssertion</jv>.is(200);
+ FluentStringAssertion<RestResponse> <jv>headerAssertion</jv> = <jv>res</jv>.assertHeader(<js>"Content-Type"</js>);
+ <jv>res</jv> = <jv>headerAssertion</jv>.matchesSimple(<js>"application/json*"</js>);
+ RestResponseBody <jv>body</jv> = <jv>res</jv>.getBody();
+ MyBean <jv>bean</jv> = <jv>body</jv>.as(MyBean.<jk>class</jk>);
</p>
+
<p>
- Similar in concept to restRPC services defined above, but in this case we simply define our interface with
- special annotations that tell us how to convert input and output to HTTP headers, query parameters, form post parameters, or request/response bodies.
+ It additionally provides support for creating remote proxy interfaces using REST as the transport medium.
</p>
+
<h5 class='figure'>Example:</h5>
- <p class='bcode w800'>
+ <p class='bcode w800'>
+ <jc>// Define a Remote proxy for interacting with a REST interface.</jc>
<ja>@Remote</ja>(path=<js>"/petstore"</js>)
<jk>public interface</jk> PetStore {
-
- <ja>@RemoteMethod</ja>(httpMethod=<jsf>POST</jsf>, path=<js>"/pets"</js>)
- String addPet(
- <ja>@Body</ja> CreatePet pet,
- <ja>@Header</ja>(<js>"E-Tag"</js>) UUID etag,
- <ja>@Query</ja>(<js>"debug"</js>) <jk>boolean</jk> debug
+
+ <ja>@RemoteMethod</ja>(method=<jsf>POST</jsf>, path=<js>"/pets"</js>)
+ Pet addPet(
+ <ja>@Body</ja> CreatePet <jv>pet</jv>,
+ <ja>@Header</ja>(<js>"E-Tag"</js>) UUID <jv>etag</jv>,
+ <ja>@Query</ja>(<js>"debug"</js>) <jk>boolean</jk> <jv>debug</jv>
);
}
- </p>
- <p class='bcode w800'>
+
<jc>// Use a RestClient with default Simple JSON support.</jc>
- <jk>try</jk> (RestClient client = RestClient.<jsm>create</jsm>().simpleJson().build()) {
- PetStore store = client.getRemoteResource(PetStore.<jk>class</jk>, <js>"http://localhost:10000"</js>);
- CreatePet pet = <jk>new</jk> CreatePet(<js>"Fluffy"</js>, 9.99);
- String response = store.createPet(pet, UUID.<jsm>randomUUID</jsm>(), <jk>true</jk>);
- }
- </p>
- <p>
- The call above translates to the following REST call:
- </p>
- <p class='bcode w800'>
- POST http://localhost:10000/petstore/pets?debug=true HTTP/1.1
- Accept: application/json
- Content-Type: application/json
- E-Tag: 475588d4-0b27-4f56-9296-cc683251d314
+ RestClient <jv>client</jv> = RestClient.<jsm>create</jsm>().simpleJson().build();
- {
- name: 'Fluffy',
- price: 9.99
- }
+ PetStore <jv>store</jv> = <jv>client</jv>.getRemote(PetStore.<jk>class</jk>, <js>"http://localhost:10000"</js>);
+ CreatePet <jv>createPet</jv> = <jk>new</jk> CreatePet(<js>"Fluffy"</js>, 9.99);
+ Pet <jv>pet</jv> = <jv>store</jv>.addPet(<jv>createPet</jv>, UUID.<jsm>randomUUID</jsm>(), <jk>true</jk>);
</p>
- <br><hr>
- <p>
- A common coding practice is to use the same Java interface to define both your server and client side REST interfaces.
- The advantage to this approach is that changes that you make to your REST interface can be reflected in both places
- at the same time, reducing the chances for compatibility mistakes.
- </p>
- <p>
- What makes this possible is that method-level annotations such as <ja>@RestMethod</ja> and parameter-level annotations
- such as <ja>@Query</ja> are inherited from parent classes.
- This normally isn't possible, but the framework will spider up the parent hierarchy of classes to find method and parameter level
- annotations defined on overridden methods.
- </p>
- <p>
- The general approach is to define your <ja>@Remote</ja>-annotated interface first.
- The following example is pulled from the PetStore app:
- </p>
- <p class='bcode w800'>
- <ja>@Remote</ja>(path=<js>"/petstore"</js>)
- <jk>public interface</jk> PetStore {
-
- <ja>@RemoteMethod</ja>(method=<jsf>GET</jsf>, path=<js>"/pet"</js>)
- <jk>public</jk> Collection<Pet> getPets() <jk>throws</jk> NotAcceptable;
-
- <ja>@RemoteMethod</ja>(method=<jsf>DELETE</jsf>, path=<js>"/pet/{petId}"</js>)
- <jk>public</jk> Ok deletePet(
- <ja>@Header</ja>(
- name=<js>"api_key"</js>,
- description=<js>"Security API key"</js>,
- required=<jk>true</jk>,
- example=<js>"foobar"</js>
- )
- String apiKey,
- <ja>@Path</ja>(
- name=<js>"petId"</js>,
- description=<js>"Pet id to delete"</js>,
- example=<js>"123"</js>
- )
- <jk>long</jk> petId
- ) <jk>throws</jk> IdNotFound, NotAcceptable;
-
- ...
- </p>
- <p>
- Next you define the implementation of your interface as a normal Juneau REST resource:
- </p>
- <p class='bcode w800'>
- <ja>@Rest</ja>(
- path=<js>"/petstore"</js>,
- title=<js>"Petstore application"</js>,
- ...
- )
- <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> PetStore {
-
- ...
-
- <ja>@Override</ja> <jc>/* PetStore */</jc>
- <ja>@RestMethod</ja>(
- name=<jsm>GET</jsm>,
- path=<js>"/pet"</js>,
- summary=<js>"All pets in the store"</js>,
- ...
- )
- <jk>public</jk> Collection<Pet> getPets() <jk>throws</jk> NotAcceptable {
- <jk>return</jk> <jsf>store</jsf>.getPets();
- }
-
- <ja>@Override</ja> <jc>/* PetStore */</jc>
- <ja>@RestMethod</ja>(
- name=<jsf>DELETE</jsf>,
- path=<js>"/pet/{petId}"</js>,
- summary=<js>"Deletes a pet"</js>,
- ...
- )
- <jk>public</jk> Ok deletePet(String apiKey, long petId) <jk>throws</jk> IdNotFound, NotAcceptable {
- <jsf>store</jsf>.removePet(petId);
- <jk>return</jk> <jsf>OK</jsf>;
- }
- </p>
- <p>
- Then use the interface as a remote resource like so:
- </p>
- <p class='bcode w800'>
- <jk>try</jk> (RestClient rc = RestClient.<jsm>create</jsm>().json().rootUrl(<js>"http://localhost:10000"</js>).build()) {
- PetStore ps = rc.getRemoteResource(PetStore.<jk>class</jk>);
-
- <jk>for</jk> (Pet x : ps.getPets()) {
- ps.deletePet(<js>"my-special-key"</js>, x.getId());
- System.<jsf>out</jsf>.println(<js>"Deleted pet: id="</js> + x.getId());
- }
- }
- </p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
- <li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-rest-client.RestProxies.DualPurposeInterfaces'>juneau-rest-client > Dual-Purpose Interfaces</a>
+ <ul class='seealso'>
+ <li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-rest-client'>juneau-rest-client</a>
</ul>
</div>
</body>
diff --git a/content/rest-server.html b/content/rest-server.html
index 6c8c127..dbd8527 100644
--- a/content/rest-server.html
+++ b/content/rest-server.html
@@ -74,32 +74,32 @@
<jk>public class</jk> SystemPropertiesResource <jk>extends</jk> BasicRestServlet {
<ja>@RestMethod</ja>(name=<jsf>GET</jsf>, path=<js>"/"</js>)
- <jk>public</jk> Map getSystemProperties(<ja>@Query</ja>(<js>"sort"</js>) <jk>boolean</jk> sort) <jk>throws</jk> Throwable {
- <jk>if</jk> (sort)
+ <jk>public</jk> Map getSystemProperties(<ja>@Query</ja>(<js>"sort"</js>) <jk>boolean</jk> <jv>sort</jv>) <jk>throws</jk> Throwable {
+ <jk>if</jk> (<jv>sort</jv>)
<jk>return new</jk> TreeMap(System.<jsm>getProperties</jsm>());
<jk>return</jk> System.<jsm>getProperties</jsm>();
}
<ja>@RestMethod</ja>(name=<jsf>GET</jsf>, path=<js>"/{propertyName}"</js>)
- <jk>public</jk> String getSystemProperty(<ja>@Path</ja>(<js>"propertyName"</js>) String propertyName) <jk>throws</jk> Throwable {
- <jk>return</jk> System.<jsm>getProperty</jsm>(propertyName);
+ <jk>public</jk> String getSystemProperty(<ja>@Path</ja>(<js>"propertyName"</js>) String <jv>propertyName</jv>) <jk>throws</jk> Throwable {
+ <jk>return</jk> System.<jsm>getProperty</jsm>(<jv>propertyName</jv>);
}
<ja>@RestMethod</ja>(name=<jsf>PUT</jsf>, path=<js>"/{propertyName}"</js>, guards=AdminGuard.<jk>class</jk>)
- <jk>public</jk> String setSystemProperty(<ja>@Path</ja>(<js>"propertyName"</js>) String propertyName, <ja>@Body</ja> String value) {
- System.<jsm>setProperty</jsm>(propertyName, value);
+ <jk>public</jk> String setSystemProperty(<ja>@Path</ja>(<js>"propertyName"</js>) String <jv>propertyName</jv>, <ja>@Body</ja> String <jv>value</jv>) {
+ System.<jsm>setProperty</jsm>(<jv>propertyName</jv>, <jv>value</jv>);
<jk>return</jk> <js>"OK"</js>;
}
<ja>@RestMethod</ja>(name=<jsf>POST</jsf>, path=<js>"/"</js>, guards=AdminGuard.<jk>class</jk>)
- <jk>public</jk> String setSystemProperties(<ja>@Body</ja> java.util.Properties newProperties) {
- System.<jsm>setProperties</jsm>(newProperties);
+ <jk>public</jk> String setSystemProperties(<ja>@Body</ja> java.util.Properties <jv>newProperties</jv>) {
+ System.<jsm>setProperties</jsm>(<jv>newProperties</jv>);
<jk>return</jk> <js>"OK"</js>;
}
<ja>@RestMethod</ja>(name=<jsf>DELETE</jsf>, path=<js>"/{propertyName}"</js>, guards=AdminGuard.<jk>class</jk>)
- <jk>public</jk> String deleteSystemProperty(<ja>@Path</ja>(<js>"propertyName"</js>) String propertyName) {
- System.<jsm>clearProperty</jsm>(propertyName);
+ <jk>public</jk> String deleteSystemProperty(<ja>@Path</ja>(<js>"propertyName"</js>) String <jv>propertyName</jv>) {
+ System.<jsm>clearProperty</jsm>(<jv>propertyName</jv>);
<jk>return</jk> <js>"OK"</js>;
}
}
@@ -249,9 +249,9 @@
<jk>public</jk> Date <jf>birthDate</jf>;
<jk>public int</jk> getAge() {
- Calendar c = <jk>new</jk> GregorianCalendar();
- c.setTime(<jf>birthDate</jf>);
- <jk>return new</jk> GregorianCalendar().get(Calendar.<jsf>YEAR</jsf>) - c.get(Calendar.<jsf>YEAR</jsf>);
+ Calendar <jv>calendar</jv> = <jk>new</jk> GregorianCalendar();
+ <jv>calendar</jv>.setTime(<jf>birthDate</jf>);
+ <jk>return new</jk> GregorianCalendar().get(Calendar.<jsf>YEAR</jsf>) - <jv>calendar</jv>.get(Calendar.<jsf>YEAR</jsf>);
}
}
@@ -262,11 +262,11 @@
<jk>public static class</jk> KindRender <jk>extends</jk> HtmlRender<Kind> {
<ja>@Override</ja>
- <jk>public</jk> Object getContent(SerializerSession session, Kind value) {
- <jk>return new</jk> Img().src(<js>"servlet:/htdocs/"</js>+value.toString().toLowerCase()+<js>".png"</js>);
+ <jk>public</jk> Object getContent(SerializerSession <jv>session</jv>, Kind <jv>value</jv>) {
+ <jk>return new</jk> Img().src(<js>"servlet:/htdocs/"</js>+<jv>value</jv>.toString().toLowerCase()+<js>".png"</js>);
}
<ja>@Override</ja>
- <jk>public</jk> String getStyle(SerializerSession session, Kind value) {
+ <jk>public</jk> String getStyle(SerializerSession <jv>session</jv>, Kind <jv>value</jv>) {
<jk>return</jk> <js>"background-color:#FDF2E9"</js>;
}
}
@@ -347,8 +347,7 @@
<br>
<img class='bordered w900' src='images/juneau-examples-rest.PetStoreResource.9e.png'>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-rest-server'>juneau-rest-server</a>
</ul>
@@ -390,10 +389,10 @@
<ja>@Controller</ja>
<jk>public class</jk> App {
- <jk>public static void</jk> main(String[] args) {
+ <jk>public static void</jk> main(String[] <jv>args</jv>) {
<jk>new</jk> SpringApplicationBuilder(App.<jk>class</jk>)
.initializers(<jk>new</jk> JuneauRestInitializer(App.<jk>class</jk>))
- .run(args);
+ .run(<jv>args</jv>);
}
<jd>/** Our root resource */</jd>
@@ -408,8 +407,7 @@
as a top-level servlet to be deployed in the Spring Boot web container.
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-rest-server-springboot'>juneau-rest-server-springboot</a>
</ul>
</div>
@@ -444,8 +442,7 @@
<code>MessageBodyWriter</code> implementations for using Juneau serializers and parsers in JAX-RS environments.
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-8.1.3/overview-summary.html#juneau-rest-server-jaxrs'>juneau-rest-server-jaxrs</a>
</ul>
</div>
diff --git a/content/styles/juneau-code.css b/content/styles/juneau-code.css
index f7cf4dd..8a0f058 100644
--- a/content/styles/juneau-code.css
+++ b/content/styles/juneau-code.css
@@ -39,6 +39,8 @@
* <jsf> - Java static field
* <jsm> - Java static method
* <ja> - Java annotation
+ * <jp> - Java parameter
+ * <jv> - Java local variable
* <xt> - XML tag
* <xa> - XML attribute
* <xc> - XML comment
@@ -59,7 +61,7 @@
.code,
.bcode,
.bpcode,
-jc,jd,jt,jk,js,jf,jsf,jsm,ja,
+jc,jd,jt,jk,js,jf,jsf,jsm,ja,jp,jv
xt,xa,xc,xs,
mc,mk,mv,
cc,cs,ck,ce,
@@ -84,7 +86,9 @@ bc {
/*--- Bordered code ---*/
p.bcode,
-p.bpcode {
+p.bpcode,
+div.bcode,
+div.bpcode {
border: 1px solid black;
margin: 0px 20px;
border-radius: 10px;
@@ -94,23 +98,24 @@ p.bpcode {
box-shadow: 1px 1px 1px 0px rgba(0, 0, 0, 0.5);
}
-p.bpcode {
+p.bpcode,
+div.bpcode {
padding-bottom: 15px;
}
/*--- Bordered code in a section of a method doc ---*/
-dd p.bcode {
+dd p.bcode, dd div.bcode {
margin-left:0px;
margin-right:20px;
}
/* Override padding bottom in javadoc comments. */
-.blockList p.bcode {
+.blockList p.bcode, .blocklist div.bcode {
padding-bottom: 0px !important;
}
/*--- Unbordered code ---*/
-p.code {
+p.code, div.code {
padding-bottom: 15px;
margin: -15px;
}
@@ -119,9 +124,10 @@ p.code {
jc { color: green; }
jd { color: #3f5fbf; }
jt { color: #7f9fbf; font-weight: bold; }
-jk { color: #7f0055; font-weight: bold; }
+jk { color: #7f0055; font-weight: 500; }
js { color: #00B; }
jf { color: DarkBlue; }
+jp,jv { color: #654040; }
jsf { color: DarkBlue; font-style: italic; }
jsm { font-style: italic; }
ja { color: grey; }
diff --git a/content/styles/juneau-doc.css b/content/styles/juneau-doc.css
index 8d2cfb2..ba65a40 100755
--- a/content/styles/juneau-doc.css
+++ b/content/styles/juneau-doc.css
@@ -41,6 +41,7 @@
*
* Available tags:
* <l> - A literal.
+ * <review> - Identifies code that needs review.
***************************************************************************************************************************/
.fixedWidth {
@@ -376,14 +377,29 @@ ul.seealso:before {
ul.notes:before {
content: 'Notes:';
}
-ul.seealso:before, ul.notes:before {
+div.description ul.seealso:before,
+div.description ul.notes:before,
+div.topic ul.seealso:before,
+div.topic ul.notes:before {
white-space: pre;
font-size: 1.1em;
font-weight: bold;
color: #4e4e4e;
margin-left: -40px;
padding-bottom: 20px;
- line-height: 30px;
+ line-height: 30px;
+}
+div.details ul.seealso:before,
+div.details ul.notes:before,
+div.topic ul.seealso:before,
+div.topic ul.notes:before {
+ white-space: pre;
+ font-size: 1.1em;
+ font-weight: bold;
+ color: #4e4e4e;
+ margin-left: -40px;
+ padding-bottom: 20px;
+ line-height: 30px;
}
ul.seealso, ul.notes {
margin-top:20px;
@@ -429,6 +445,14 @@ ul.notes>li {
margin-left: -40px;
}
+ul.notes ul li {
+ padding: 10px;
+}
+
+ul.notes ul.compact li {
+ padding: 0px;
+}
+
.topic a {
border-bottom: 1px dotted #4c6b87;
}
@@ -474,7 +498,7 @@ hr {
}
div.info, div.warn, div.severe {
- background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgo8c3ZnIAoJaWQ9InN2ZzI4MTAiIAoJeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAKCXhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiAKCWhlaWdodD0iMjQiIAoJd2lkdGg9IjQyIiAKCXZlcnNpb249IjEuMCIgCgl2aWV3Qm94PSIwIDAgNDgwIDQ4MCI+Cgk8ZGVmcyBpZD0iZGVmczI4MzYiPgoJCTxsaW5lYXJHcmFkaWVudCBpZD0ibGl [...]
+ background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhLS0gQ3JlYXRlZCB3aXRoIElua3NjYXBlIChodHRwOi8vd3d3Lmlua3NjYXBlLm9yZy8pIC0tPgo8c3ZnIAoJaWQ9InN2ZzI4MTAiIAoJeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAKCXhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiAKCWhlaWdodD0iMjQiIAoJd2lkdGg9IjQyIiAKCXZlcnNpb249IjEuMCIgCgl2aWV3Qm94PSIwIDAgNDgwIDQ4MCI+Cgk8ZGVmcyBpZD0iZGVmczI4MzYiPgoJCTxsaW5lYXJHcmFkaWVudCBpZD0ibGluZW [...]
background-repeat: no-repeat;
background-position: left center;
padding: 15px 50px;
@@ -508,3 +532,12 @@ div.severe {
.todo {
background-color:#FD8;
}
+
+review {
+ background-color: #ffdf00;
+ padding: 10px;
+ border-radius: 5px;
+ width: 800px;
+ text-align: center;
+ box-shadow: 1px 1px 1px 0px rgba(0, 0, 0, 0.5);
+}
diff --git a/templates/config.html b/templates/config.html
index a01e99d..5a6bf72 100644
--- a/templates/config.html
+++ b/templates/config.html
@@ -100,19 +100,19 @@
</p>
<p class='bcode w800'>
<jc>// Load our config file</jc>
- Config c = Config.<jsm>create</jsm>().name(<js>"MyIniFile.cfg"</js>).build();
+ Config <jv>config</jv> = Config.<jsm>create</jsm>().name(<js>"MyIniFile.cfg"</js>).build();
- <jk>int</jk> anInt = c.getInt(<js>"MySection/anInt"</js>);
- <jk>boolean</jk> aBoolean = c.getBoolean(<js>"MySection/aBoolean"</js>);
- <jk>int</jk>[] anIntArray = c.getObject(<js>"MySection/anIntArray"</js>, <jk>int</jk>[].<jk>class</jk>);
- URL aURL = c.getObject(<js>"MySection/aURL"</js>, URL.<jk>class</jk>);
- MyBean aBean = c.getObject(<js>"MySection/aBean"</js>, MyBean.<jk>class</jk>);
- Locale locale = c.getObject(<js>"MySection/locale"</js>, Locale.<jk>class</jk>);
- String path = c.getString(<js>"MySection/path"</js>);
- String mainClass = c.getString(<js>"MySection/mainClass"</js>);
- <jk>int</jk> sameAsAnInt = c.getInt(<js>"MySection/sameAsAnInt"</js>);
- String myArg = c.getString(<js>"MySection/myArg"</js>);
- String firstArg = c.getString(<js>"MySection/firstArg"</js>);
+ <jk>int</jk> <jv>anInt</jv> = <jv>config</jv>.getInt(<js>"MySection/anInt"</js>);
+ <jk>boolean</jk> <jv>aBoolean</jv> = <jv>config</jv>.getBoolean(<js>"MySection/aBoolean"</js>);
+ <jk>int</jk>[] <jv>anIntArray</jv> = <jv>config</jv>.getObject(<js>"MySection/anIntArray"</js>, <jk>int</jk>[].<jk>class</jk>);
+ URL <jv>aURL</jv> = <jv>config</jv>.getObject(<js>"MySection/aURL"</js>, URL.<jk>class</jk>);
+ MyBean <jv>aBean</jv> = <jv>config</jv>.getObject(<js>"MySection/aBean"</js>, MyBean.<jk>class</jk>);
+ Locale <jv>locale</jv> = <jv>config</jv>.getObject(<js>"MySection/locale"</js>, Locale.<jk>class</jk>);
+ String <jv>path</jv> = <jv>config</jv>.getString(<js>"MySection/path"</js>);
+ String <jv>mainClass</jv> = <jv>config</jv>.getString(<js>"MySection/mainClass"</js>);
+ <jk>int</jk> <jv>sameAsAnInt</jv> = <jv>config</jv>.getInt(<js>"MySection/sameAsAnInt"</js>);
+ String <jv>myArg</jv> = <jv>config</jv>.getString(<js>"MySection/myArg"</js>);
+ String <jv>firstArg</jv> = <jv>config</jv>.getString(<js>"MySection/firstArg"</js>);
</p>
<p>
One of the more powerful aspects of the REST servlets is that you can pull values directly from
@@ -161,8 +161,7 @@
An extensible storage API allows you to write your own config storage location for files such as databases or the cloud.
</ul>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-config'>juneau-config</a>
</ul>
</div>
diff --git a/templates/dto.html b/templates/dto.html
index a5e3c61..d5cf8da 100644
--- a/templates/dto.html
+++ b/templates/dto.html
@@ -62,7 +62,7 @@
<p class='bcode w800'>
<jk>import static</jk> org.apache.juneau.dto.html5.HtmlBuilder.*;
- Object myform =
+ Object <jv>myform</jv> =
<jsm>form</jsm>().action(<js>"/submit"</js>).method(<js>"POST"</js>)
.children(
<js>"Position (1-10000): "</js>, <jsm>input</jsm>(<js>"number"</js>).name(<js>"pos"</js>).value(1), <jsm>br</jsm>(),
@@ -71,7 +71,7 @@
<jsm>button</jsm>(<js>"reset"</js>, <js>"Reset"</js>)
);
- String html = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(myform);
+ String <jv>html</jv> = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>myform</jv>);
</p>
<p class='bcode w800'><xt>
<form <xa>action</xa>=<xs>'/submit'</xs> <xa>method</xa>=<xs>'POST'</xs>>
@@ -108,7 +108,7 @@
<p class='bcode w800'>
<jk>import static</jk> org.apache.juneau.dto.atom.AtomBuilder.*;
- Feed feed =
+ Feed <jv>feed</jv> =
<jsm>feed</jsm>(<js>"tag:juneau.apache.org"</js>, <js>"Juneau ATOM specification"</js>, <js>"2016-01-02T03:04:05Z"</js>)
.subtitle(<jsm>text</jsm>(<js>"html"</js>).text(<js>"Describes <em>stuff</em> about Juneau"</js>))
.links(
@@ -128,7 +128,7 @@
);
<jc>// Serialize to ATOM/XML</jc>
- String atomXml = XmlSerializer.<jsf>DEFAULT</jsf>.serialize(feed);
+ String <jv>atomXml</jv> = XmlSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>feed</jv>);
</p>
<p class='bcode w800'>
<xt><feed></xt>
@@ -168,7 +168,7 @@
<p class='bcode w800'>
<jk>import static</jk> org.apache.juneau.dto.swagger.SwaggerBuilder.*;
- Swagger swagger = <jsm>swagger</jsm>()
+ Swagger <jv>swagger</jv> = <jsm>swagger</jsm>()
.swagger(<js>"2.0"</js>)
.info(
<jsm>info</jsm>(<js>"Swagger Petstore"</js>, <js>"1.0.0"</js>)
@@ -198,7 +198,7 @@
);
<jc>// Serialize to Swagger/JSON</jc>
- String swaggerJson = JsonSerializer.<jsf>DEFAULT_READABLE</jsf>.serialize(swagger);
+ String <jv>swaggerJson</jv> = JsonSerializer.<jsf>DEFAULT_READABLE</jsf>.serialize(<jv>swagger</jv>);
</p>
<p class='bcode w800'>
{
@@ -260,8 +260,7 @@
be serialized directly to a string in the typical language (e.g. HTML5 beans to HTML, Swagger to JSON, etc...).
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-dto'>juneau-dto</a>
</ul>
</div>
diff --git a/templates/examples.html b/templates/examples.html
index 0286ead..fda57b5 100644
--- a/templates/examples.html
+++ b/templates/examples.html
@@ -37,8 +37,7 @@
<img class='bordered' src='images/juneau-examples-core.Installing.3.png' style='width:400px'>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-examples-core'>juneau-examples-core</a>
</ul>
</div>
@@ -67,8 +66,7 @@
</p>
<img class='bordered w800' src='images/juneau-examples-rest.RootResources.1.png'>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-examples-rest'>juneau-examples-rest</a>
</ul>
</div>
@@ -91,8 +89,7 @@
<img class='bordered' src='images/juneau-examples-rest-jetty.Installing.3.png' style='width:400px'>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-examples-rest-jetty'>juneau-examples-rest-jetty</a>
</ul>
</div>
@@ -125,8 +122,7 @@
<img class='bordered' src='images/juneau-examples-rest-springboot.Installing.3.png' style='width:400px'>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-examples-rest-springboot'>juneau-examples-rest-springboot</a>
</ul>
</div>
diff --git a/templates/marshall.html b/templates/marshall.html
index a8e981a..2021eae 100644
--- a/templates/marshall.html
+++ b/templates/marshall.html
@@ -52,7 +52,9 @@
<p>
<a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#Glossaries.LanguageSupport'>Glossary > Language Support</a>
</p>
- <h5 class='section'>Features:</h5>
+ <p>
+ Features include:
+ </p>
<ul class='spaced-list'>
<li>Serializers can send output directly to Writers, OutputStreams, Files, Strings, or byte arrays.
<li>Parsers can receive input directly from Readers, InputStreams, Files, Strings, or byte arrays.
@@ -77,48 +79,47 @@
<jk>public int</jk> age = 21;
}
- Person p = <jk>new</jk> Person(); <jc>// An arbitrary POJO</jc>
+ Person <jv>person</jv> = <jk>new</jk> Person(); <jc>// An arbitrary POJO</jc>
<jc>// Produces:
// "{name:'John Smith',age:21}"</jc>
- String laxJson = SimpleJsonSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>laxJson</jv> = SimpleJsonSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// "{"name":"John Smith","age":21}"</jc>
- String strictJson = JsonSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>strictJson</jv> = JsonSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// <object>
// <name>John Smith</name>
// <age>21</age>
// </object></jc>
- String xml = XmlSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>xml</jv> = XmlSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// <table>
// <tr><td>name</td><td>John Smith</td></tr>
// <tr><td>age</td><td>21</td></tr>
// </table></jc>
- String html = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>html</jv> = HtmlSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Same as Html, but wraps it in HTML and BODY elements with page title/description/links:</jc>
- String htmlDoc = HtmlDocSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>htmlDoc</jv> = HtmlDocSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// name='John+Smith'&age=21</jc>
- String urlEncoding = UrlEncodingSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>urlEncoding</jv> = UrlEncodingSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// (name='John Smith',age=21)</jc>
- String uon = UonSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>uon</jv> = UonSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// 82 A4 name AA 4A John Smith 68 A3 age 15</jc>
- <jk>byte</jk>[] messagePack = MsgPackSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ <jk>byte</jk>[] <jv>messagePack</jv> = MsgPackSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-marshall.Serializers'>juneau-marshall > Serializers</a>
</ul>
@@ -133,53 +134,68 @@
</p>
<p class='bcode w800'>
<jc>// Use one of the predefined parsers.</jc>
- ReaderParser parser = JsonParser.<jsf>DEFAULT</jsf>;
+ ReaderParser <jv>parser</jv> = JsonParser.<jsf>DEFAULT</jsf>;
<jc>// Parse a JSON object (creates a generic ObjectMap).</jc>
- String json = <js>"{name:'John Smith',age:21}"</js>;
- Map m1 = parser.parse(json, Map.<jk>class</jk>);
+ String <jv>json</jv> = <js>"{name:'John Smith',age:21}"</js>;
+ Map <jv>map</jv> = <jv>parser</jv>.parse(<jv>json</jv>, Map.<jk>class</jk>);
<jc>// Parse a JSON string.</jc>
- json = <js>"'foobar'"</js>;
- String s2 = parser.parse(json, String.<jk>class</jk>);
+ <jv>json</jv> = <js>"'foobar'"</js>;
+ String <jv>string</jv> = <jv>parser</jv>.parse(<jv>json</jv>, String.<jk>class</jk>);
<jc>// Parse a JSON number as a Long or Float.</jc>
- json = <js>"123"</js>;
- Long l3 = parser.parse(json, Long.<jk>class</jk>);
- Float f3 = parser.parse(json, Float.<jk>class</jk>);
+ <jv>json</jv> = <js>"123"</js>;
+ Long <jv>long</jv> = <jv>parser</jv>.parse(<jv>json</jv>, Long.<jk>class</jk>);
+ Float <jv>float</jv> = <jv>parser</jv>.parse(<jv>json</jv>, Float.<jk>class</jk>);
<jc>// Parse a JSON object as a bean.</jc>
- json = <js>"{name:'John Smith',age:21}"</js>;
- Person p4 = parser.parse(json, Person.<jk>class</jk>);
+ <jv>json</jv> = <js>"{name:'John Smith',age:21}"</js>;
+ Person <jv>person</jv> = <jv>parser</jv>.parse(<jv>json</jv>, Person.<jk>class</jk>);
<jc>// Parse a JSON object as a HashMap<String,Person>.</jc>
- json = <js>"{a:{name:'John Smith',age:21},b:{name:'Joe Smith',age:42}}"</js>;
- Map<String,Person> m5 = parser.parse(json, HashMap.<jk>class</jk>, String.<jk>class</jk>, Person.<jk>class</jk>);
+ <jv>json</jv> = <js>"{a:{name:'John Smith',age:21},b:{name:'Joe Smith',age:42}}"</js>;
+ Map<String,Person> <jv>personMap</jv> = <jv>parser</jv>.parse(
+ <jv>json</jv>,
+ HashMap.<jk>class</jk>,
+ String.<jk>class</jk>,
+ Person.<jk>class</jk>
+ );
<jc>// Parse a JSON object as a HashMap<String,LinkedList<Person>>.</jc>
- json = <js>"{a:[{name:'John Smith',age:21},{name:'Joe Smith',age:42}]}"</js>;
- Map<String,List<Person>> m6 = parser.parse(json, HashMap.<jk>class</jk>, String.<jk>class</jk>, LinkedList.<jk>class</jk>, Person.<jk>class</jk>);
+ <jv>json</jv> = <js>"{a:[{name:'John Smith',age:21},{name:'Joe Smith',age:42}]}"</js>;
+ Map<String,List<Person>> personListMap = <jv>parser</jv>.parse(
+ <jv>json</jv>,
+ HashMap.<jk>class</jk>,
+ String.<jk>class</jk>,
+ LinkedList.<jk>class</jk>,
+ Person.<jk>class</jk>
+ );
<jc>// Parse a JSON array of integers as a Collection of Integers or int[] array.</jc>
- json = <js>"[1,2,3]"</js>;
- List<Integer> l7 = parser.parse(json, LinkedList.<jk>class</jk>, Integer.<jk>class</jk>);
- <jk>int</jk>[] i7 = parser.parse(json, <jk>int</jk>[].<jk>class</jk>);
+ <jv>json</jv> = <js>"[1,2,3]"</js>;
+ List<Integer> <jv>integerList</jv> = <jv>parser</jv>.parse(
+ <jv>json</jv>,
+ LinkedList.<jk>class</jk>,
+ Integer.<jk>class</jk>
+ );
+ <jk>int</jk>[] <jv>intList</jv> = <jv>parser</jv>.parse(
+ <jv>json</jv>,
+ <jk>int</jk>[].<jk>class</jk>
+ );
<jc>// Parse arbitrary input into ObjectMap or ObjectList objects
// (similar to JSONObject/JSONArray but generalized for all languages).</jc>
- json = <js>"{name:'John Smith',age:21}"</js>;
- ObjectMap m8a = parser.parse(json, ObjectMap.<jk>class</jk>);
- <jk>int</jk> age = m8a.getInt(<js>"age"</js>);
- ObjectMap m8b = (ObjectMap)parser.parse(json, Object.<jk>class</jk>); <jc>// Equivalent.</jc>
+ <jv>json</jv> = <js>"{name:'John Smith',age:21}"</js>;
+ OMap <jv>oMap</jv> = <jv>parser</jv>.parse(<jv>json</jv>, OMap.<jk>class</jk>);
+ <jk>int</jk> age = <jv>oMap</jv>.getInt(<js>"age"</js>);
- json = <js>"[1,true,null]"</js>;
- ObjectList l9a = parser.parse(json, ObjectList.<jk>class</jk>);
- <jk>boolean</jk> b = l9a.getBoolean(1);
- ObjectList l9b = (ObjectList)parser.parse(json, Object.<jk>class</jk>); <jc>// Equivalent.</jc>
+ <jv>json</jv> = <js>"[1,true,null]"</js>;
+ OList <jv>oList</jv> = <jv>parser</jv>.parse(<jv>json</jv>, ObjectList.<jk>class</jk>);
+ <jk>boolean</jk> <jv>boolean</jv> = <jv>oList</jv>.getBoolean(1);
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-marshall.Parsers'>juneau-marshall > Parsers</a>
</ul>
<hr>
@@ -187,40 +203,39 @@
Marshalls are pairings of serializers and parsers in a single class for even simpler code:
</p>
<p class='bcode w800'>
- Person p = <jk>new</jk> Person(); <jc>// An arbitrary POJO</jc>
+ Person <jv>person</jv> = <jk>new</jk> Person(); <jc>// An arbitrary POJO</jc>
<jc>// Serialize</jc>
- String json = Json.<jsf>DEFAULT</jsf>.write(p);
- String simpleJson = SimpleJson.<jsf>DEFAULT</jsf>.write(p);
- String xml = Xml.<jsf>DEFAULT</jsf>.write(p);
- String html = Html.<jsf>DEFAULT</jsf>.write(p);
- String uon = Uon.<jsf>DEFAULT</jsf>.write(p);
- String urlEncoding = UrlEncoding.<jsf>DEFAULT</jsf>.write(p);
- String openapi = OpenApi.<jsf>DEFAULT</jsf>.write(p);
- <jk>byte</jk>[] msgPack = MsgPack.<jsf>DEFAULT</jsf>.write(p);
- String rdfXml = RdfXml.<jsf>DEFAULT</jsf>.write(p);
- String rdfXmlAbbrev = RdfXmlAbbrev.<jsf>DEFAULT</jsf>.write(p);
- String n3 = N3.<jsf>DEFAULT</jsf>.write(p);
- String nTuple = NTuple.<jsf>DEFAULT</jsf>.write(p);
- String turtle = Turtle.<jsf>DEFAULT</jsf>.write(p);
+ String <jv>json</jv> = Json.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>simpleJson</jv> = SimpleJson.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>xml</jv> = Xml.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>html</jv> = Html.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>uon</jv> = Uon.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>urlEncoding</jv> = UrlEncoding.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>openapi</jv> = OpenApi.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ <jk>byte</jk>[] <jv>msgPack</jv> = MsgPack.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>rdfXml</jv> = RdfXml.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>rdfXmlAbbrev</jv> = RdfXmlAbbrev.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>n3</jv> = N3.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>nTuple</jv> = NTuple.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
+ String <jv>turtle</jv> = Turtle.<jsf>DEFAULT</jsf>.write(<jv>person</jv>);
<jc>// Parse</jc>
- p = Json.<jsf>DEFAULT</jsf>.read(json, Person.<jk>class</jk>);
- p = Xml.<jsf>DEFAULT</jsf>.read(xml, Person.<jk>class</jk>);
- p = Html.<jsf>DEFAULT</jsf>.read(html, Person.<jk>class</jk>);
- p = Uon.<jsf>DEFAULT</jsf>.read(uon, Person.<jk>class</jk>);
- p = UrlEncoding.<jsf>DEFAULT</jsf>.read(urlEncoding, Person.<jk>class</jk>);
- p = OpenApi.<jsf>DEFAULT</jsf>.read(openapi, Person.<jk>class</jk>);
- p = MsgPack.<jsf>DEFAULT</jsf>.read(msgPack, Person.<jk>class</jk>);
- p = RdfXml.<jsf>DEFAULT</jsf>.read(rdfXml, Person.<jk>class</jk>);
- p = RdfXmlAbbrev.<jsf>DEFAULT</jsf>.read(rdfXmlAbbrev, Person.<jk>class</jk>);
- p = N3.<jsf>DEFAULT</jsf>.read(n3, Person.<jk>class</jk>);
- p = NTuple.<jsf>DEFAULT</jsf>.read(nTuple, Person.<jk>class</jk>);
- p = Turtle.<jsf>DEFAULT</jsf>.read(turtle, Person.<jk>class</jk>);
+ <jv>person</jv> = Json.<jsf>DEFAULT</jsf>.read(<jv>json</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = Xml.<jsf>DEFAULT</jsf>.read(<jv>xml</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = Html.<jsf>DEFAULT</jsf>.read(<jv>html</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = Uon.<jsf>DEFAULT</jsf>.read(<jv>uon</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = UrlEncoding.<jsf>DEFAULT</jsf>.read(<jv>urlEncoding</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = OpenApi.<jsf>DEFAULT</jsf>.read(<jv>openapi</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = MsgPack.<jsf>DEFAULT</jsf>.read(<jv>msgPack</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = RdfXml.<jsf>DEFAULT</jsf>.read(<jv>rdfXml</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = RdfXmlAbbrev.<jsf>DEFAULT</jsf>.read(<jv>rdfXmlAbbrev</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = N3.<jsf>DEFAULT</jsf>.read(<jv>n3</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = NTuple.<jsf>DEFAULT</jsf>.read(<jv>nTuple</jv>, Person.<jk>class</jk>);
+ <jv>person</jv> = Turtle.<jsf>DEFAULT</jsf>.read(<jv>turtle</jv>, Person.<jk>class</jk>);
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-marshall.Marshalls'>juneau-marshall > Marshalls</a>
</ul>
@@ -231,23 +246,22 @@
</p>
<p class='bcode w800'>
<jc>// Create a serializer from scratch programmatically using a builder.</jc>
- JsonSerializer serializer = JsonSerializer.<jsm>create</jsm>()
+ JsonSerializer <jv>serializer</jv> = JsonSerializer.<jsm>create</jsm>()
.simple() <jc>// Simple mode</jc>
.sq() <jc>// Use single quotes</jc>
- .pojoSwaps( <jc>// Swap unserializable classes with surrogate POJOs</jc>
+ .swaps( <jc>// Swap unserializable classes with surrogate POJOs</jc>
IteratorSwap.<jk>class</jk>, <jc>// Iterators swapped with lists</jc>
ByteArrayBase64Swap.<jk>class</jk>, <jc>// byte[] swapped with base-64 encoded strings</jc>
CalendarSwap.ISO8601DT.<jk>class</jk> <jc>// Calendars swapped with ISO8601-compliant strings</jc>
- )
- .beanFilters(MyBeanFilter.<jk>class</jk>) <jc>// Control how bean properties are handled</jc>
- .timeZone(TimeZone.<jsf>GMT</jsf>) <jc>// For serializing Calendars</jc>
- .locale(Locale.<jsf>JAPAN</jsf>) <jc>// For timezone-specific serialization</jc>
- .sortCollections() <jc>// For locale-specific serialization</jc>
- .sortProperties() <jc>// Various behavior settings</jc>
- .trimNullProperties()
+ )
+ .timeZone(TimeZone.<jsf>GMT</jsf>) <jc>// For timezone-specific serialization</jc>
+ .locale(Locale.<jsf>JAPAN</jsf>) <jc>// For locale-specific serialization</jc>
+ .sortCollections()
+ .sortProperties()
+ .keepNullProperties()
.trimStrings()
- .methodVisibility(<jsf>PROTECTED</jsf>) <jc>// Control which fields/methods are serialized</jc>
- .beanDictionary( <jc>// Adds type variables for resolution during parsing</jc>
+ .beanMethodVisibility(<jsf>PROTECTED</jsf>) <jc>// Control which fields/methods are serialized</jc>
+ .dictionary( <jc>// Adds type variables for resolution during parsing</jc>
MyBeanA.<jk>class</jk>,
MyBeanB.<jk>class</jk>
)
@@ -256,33 +270,31 @@
<jc>// Same as above, but using declarative named properties.</jc>
<jc>// This is how serializers and parsers are typically configured on REST servlets and clients.</jc>
- JsonSerializer serializer = JsonSerializer.<jsm>create</jsm>()
+ JsonSerializer <jv>serializer</jv> = JsonSerializer.<jsm>create</jsm>()
.set(<jsf>JSON_simpleMode</jsf>, <jk>true</jk>)
.set(<jsf>SERIALIZER_quoteChar</jsf>, <js>'\''</js>)
- .set(<jsf>BEAN_pojoSwaps_add</jsf>, IteratorSwap.<jk>class</jk>)
- .set(<jsf>BEAN_pojoSwaps_add</jsf>, ByteArrayBase64Swap.<jk>class</jk>)
- .set(<jsf>BEAN_pojoSwaps_add</jsf>, CalendarSwap.ISO8601DT.<jk>class</jk>)
- .set(<jsf>BEAN_beanFilters_add</jsf>, MyBeanFilter.<jk>class</jk>)
+ .appendTo(<jsf>BEAN_swaps</jsf>, IteratorSwap.<jk>class</jk>)
+ .appendTo(<jsf>BEAN_swaps</jsf>, ByteArrayBase64Swap.<jk>class</jk>)
+ .appendTo(<jsf>BEAN_swaps</jsf>, CalendarSwap.ISO8601DT.<jk>class</jk>)
.set(<jsf>BEAN_timeZone</jsf>, TimeZone.<jsf>GMT</jsf>)
.set(<jsf>BEAN_locale</jsf>, Locale.<jsf>JAPAN</jsf>)
.set(<jsf>SERIALIZER_sortCollections</jsf>, <jk>true</jk>)
.set(<jsf>BEAN_sortProperties</jsf>, <jk>true</jk>)
- .set(<jsf>SERIALIZER_trimNullProperties</jsf>, <jk>true</jk>)
+ .set(<jsf>SERIALIZER_keepNullProperties</jsf>, <jk>true</jk>)
.set(<jsf>SERIALIZER_trimStrings</jsf>, <jk>true</jk>)
- .set(<jsf>BEAN_methodVisibility</jsf>, <jsf>PROTECTED</jsf>)
- .set(<jsf>BEAN_beanDictionary_add</jsf>, MyBeanA.<jk>class</jk>)
- .set(<jsf>BEAN_beanDictionary_add</jsf>, MyBeanB.<jk>class</jk>)
+ .set(<jsf>BEAN_beanMethodVisibility</jsf>, <jsf>PROTECTED</jsf>)
+ .appendTo(<jsf>BEAN_dictionary</jsf>, MyBeanA.<jk>class</jk>)
+ .appendTo(<jsf>BEAN_dictionary</jsf>, MyBeanB.<jk>class</jk>)
.set(<jsf>BEAN_debug</jsf>, <jk>true</jk>)
.build();
<jc>// Clone an existing serializer and modify it to use single-quotes.</jc>
- JsonSerializer serializer = JsonSerializer.<jsf>DEFAULT</jsf>.builder()
+ JsonSerializer <jv>serializer</jv> = JsonSerializer.<jsf>DEFAULT</jsf>.builder()
.sq()
.build();
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-marshall.ConfigurableProperties'>juneau-marshall > Configurable Properties</a>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#Glossaries.ConfigurableProperties'>Glossary > Configurable Properties</a>
</ul>
@@ -314,8 +326,7 @@
<code>fromString(String)</code>, <code>T(String)</code>, <code>Object swap(BeanSession)</code>, <code>T unswap(BeanSession, T.class)</code>
</ul>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-marshall.PojoCategories'>juneau-marshall > POJO Categories</a>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#Glossaries.Annotations'>Glossary > Annotations</a>
</ul>
@@ -348,8 +359,7 @@
)
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-marshall.UonDetails'>juneau-marshall > UON Details</a>
</ul>
@@ -359,37 +369,32 @@
</p>
<p class='bcode w800'>
<jc>// Create JSON strings from scratch using fluent-style code.</jc>
- String jsonObject = <jk>new</jk> ObjectMap().append(<js>"foo"</js>,<js>"bar"</js>).toString();
- String jsonArray = <jk>new</jk> ObjectList().append(<js>"foo"</js>).append(123).append(<jk>null</jk>).toString();
+ String <jv>jsonObject</jv> = <jk>new</jk> OMap().append(<js>"foo"</js>,<js>"bar"</js>).toString();
+ String <jv>jsonArray</jv> = <jk>new</jk> OList().append(<js>"foo"</js>).append(123).append(<jk>null</jk>).toString();
<jc>// Create maps and beans directly from JSON.</jc>
- Map<String,Object> myMap = <jk>new</jk> ObjectMap(<js>"{foo:'bar'}"</js>);
- List<Object> myList = <jk>new</jk> ObjectList(<js>"['foo',123,null]"</js>);
+ Map<String,Object> <jv>myMap</jv> = <jk>new</jk> OMap(<js>"{foo:'bar'}"</js>);
+ List<Object> <jv>myList</jv> = <jk>new</jk> OList(<js>"['foo',123,null]"</js>);
<jc>// Load a POJO from a JSON file.</jc>
- MyPojo myPojo = JsonParser.<jsf>DEFAULT</jsf>.parse(<jk>new</jk> File(<js>"myPojo.json"</js>));
+ MyPojo <jv>myPojo</jv> = JsonParser.<jsf>DEFAULT</jsf>.parse(<jk>new</jk> File(<js>"myPojo.json"</js>));
<jc>// Serialize POJOs and ignore exceptions (great for logging)</jc>
- String json = SimpleJson.<jsf>DEFAULT</jsf>.toString(myPojo);
+ String <jv>json</jv> = SimpleJson.<jsf>DEFAULT</jsf>.toString(<jv>myPojo</jv>);
<jc>// Dump a POJO to the console.</jc>
- SimpleJson.<jsf>DEFAULT</jsf>.println(myPojo);
+ SimpleJson.<jsf>DEFAULT</jsf>.println(<jv>myPojo</jv>);
- <jc>// Delayed serialization.</jc>
- <jc>// (e.g. don't serialize an object if it's not going to be logged).</jc>
- logger.log(<jsf>FINE</jsf>, <js>"My POJO was: {0}"</js>, <jk>new</jk> StringObject(myPojo));
- logger.log(<jsf>FINE</jsf>, <js>"My POJO in XML was: {0}"</js>, <jk>new</jk> StringObject(XmlSerializer.<jsf>DEFAULT</jsf>, myPojo));
-
- String message = <jk>new</jk> StringMessage(<js>"My POJO in {0}: {1}"</js>, <js>"JSON"</js>, <jk>new</jk> StringObject(myPojo)).toString();
+ String <jv>message</jv> = <jk>new</jk> StringMessage(<js>"My POJO in {0}: {1}"</js>, <js>"JSON"</js>, <jk>new</jk> StringObject(<jv>myPojo</jv>)).toString();
<jc>// Create a 'REST-like' wrapper around a POJO.</jc>
<jc>// Allows you to manipulate POJO trees using URIs and GET/PUT/POST/DELETE commands.</jc>
- PojoRest pojoRest = <jk>new</jk> PojoRest(myPojo);
- pojoRest.get(String.<jk>class</jk>, <js>"addressBook/0/name"</js>);
- pojoRest.put(<js>"addressBook/0/name"</js>, <js>"John Smith"</js>);
+ PojoRest <jv>pojoRest</jv> = <jk>new</jk> PojoRest(<jv>myPojo</jv>);
+ <jv>pojoRest</jv>.get(String.<jk>class</jk>, <js>"addressBook/0/name"</js>);
+ <jv>pojoRest</jv>.put(<js>"addressBook/0/name"</js>, <js>"John Smith"</js>);
</p>
- <h5 class='section'>More Information:</h5>
+ <ul class='seealso'>
<ul class='doctree'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-marshall.ObjectMap'>juneau-marshall > ObjectMap and ObjectList</a>
</ul>
@@ -401,28 +406,27 @@
</p>
<p class='bcode w800'>
<jc>// Construct a new serializer group with configuration parameters that get applied to all serializers.</jc>
- SerializerGroup sg = SerializerGroup.<jsm>create</jsm>()
+ SerializerGroup <jv>serializerGroup</jv> = SerializerGroup.<jsm>create</jsm>()
.append(JsonSerializer.<jk>class</jk>, UrlEncodingSerializer.<jk>class</jk>);
.ws() <jc>// or .setUseWhitespace(true) or .set(SERIALIZER_useWhitespace, true)</jc>
- .pojoSwaps(CalendarSwap.ISO8601DT.<jk>class</jk>) <jc>// or .set(BEAN_pojoSwaps_add, CalendarSwap.ISO8601DT.class)</jc>
+ .swaps(CalendarSwap.ISO8601DT.<jk>class</jk>) <jc>// or .appendTo(BEAN_pojoSwaps, CalendarSwap.ISO8601DT.class)</jc>
.build();
<jc>// Find the appropriate serializer by Accept type and serialize our POJO to the specified writer.</jc>
<jc>// Fully RFC2616 compliant.</jc>
- sg.getSerializer(<js>"text/invalid, text/json;q=0.8, text/*;q:0.6, *\/*;q=0.0"</js>)
- .serialize(myPersonObject, myWriter);
+ <jv>serializerGroup</jv>.getSerializer(<js>"text/invalid, text/json;q=0.8, text/*;q:0.6, *\/*;q=0.0"</js>)
+ .serialize(<jv>person</jv>, <jv>myWriter</jv>);
<jc>// Construct a new parser group with configuration parameters that get applied to all parsers.</jc>
- ParserGroup pg = ParserGroup.<jsm>create</jsm>()
+ ParserGroup <jv>parserGroup</jv> = ParserGroup.<jsm>create</jsm>()
.append(JsonParser.<jk>class</jk>, UrlEncodingParser.<jk>class</jk>);
- .pojoSwaps(CalendarSwap.ISO8601DT.<jk>class</jk>) <jc>// or .set(BEAN_pojoSwaps_add, CalendarSwap.ISO8601DT.class)</jc>
+ .swaps(CalendarSwap.ISO8601DT.<jk>class</jk>) <jc>// or .appendTo(BEAN_pojoSwaps, CalendarSwap.ISO8601DT.class)</jc>
.build();
- Person p = pg.getParser(<js>"text/json"</js>).parse(myReader, Person.<jk>class</jk>);
+ Person <jv>person</jv> = <jv>parserGroup</jv>.getParser(<js>"text/json"</js>).parse(<jv>myReader</jv>, Person.<jk>class</jk>);
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-marshall.Groups'>juneau-marshall > SerializerGroups and ParserGroups</a>
</ul>
<p>
@@ -436,7 +440,7 @@
</p>
<p class='bcode w800'>
<jc>// Use the default variable resolver to resolve a string that contains $S (system property) variables</jc>
- String myProperty = VarResolver.<jsf>DEFAULT</jsf>.resolve(<js>"The Java home directory is $S{java.home}"</js>);
+ String <jv>myProperty</jv> = VarResolver.<jsf>DEFAULT</jsf>.resolve(<js>"The Java home directory is $S{java.home}"</js>);
</p>
<p>
The following shows how variables can be arbitrarily nested:
@@ -446,7 +450,7 @@
// 1) MYPROPERTY environment variable.
// 2) 'my.property' system property if environment variable not found.
// 3) 'not found' string if system property not found.</jc>
- String myproperty = VarResolver.<jsf>DEFAULT</jsf>.resolve(<js>"$E{MYPROPERTY,$S{my.property,not found}}"</js>);
+ String <jv>myproperty</jv> = VarResolver.<jsf>DEFAULT</jsf>.resolve(<js>"$E{MYPROPERTY,$S{my.property,not found}}"</js>);
</p>
<p>
SVL is a large topic on it's own.
@@ -456,8 +460,7 @@
Plugging in your own variables is also easy.
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-svl'>juneau-svl</a>
</ul>
@@ -507,12 +510,12 @@
<p class='bcode w800'>
<jc>// A simple bean</jc>
<jk>public class</jk> Person {
- <jk>public</jk> String name = <js>"This is RDF format."</js>;
- <jk>public</jk> String id = "rdf";
+ <jk>public</jk> String <jf>name</jf> = <js>"This is RDF format."</js>;
+ <jk>public</jk> String <jf>id</jf> = "rdf";
}
<jc>// Serialize a bean to various RDF languages</jc>
- Person p = <jk>new</jk> Person();
+ Person <jv>person</jv> = <jk>new</jk> Person();
<jc>// Produces:
// <rdf:RDF
@@ -524,31 +527,29 @@
// <jp:id>rdf</jp:id>
// </rdf:Description>
// </rdf:RDF></jc>
- String rdfXml = RdfXmlAbbrevSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>rdfXml</jv> = RdfXmlAbbrevSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// @prefix jp: <http://www.apache.org/juneaubp/> .
// @prefix j: <http://www.apache.org/juneau/> .
// [] jp:id "rdf" ;
// jp:name "This is RDF format." .</jc>
- String rdfN3 = N3Serializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>rdfN3</jv> = N3Serializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// _:A3bf53c85X3aX157cf407e2dX3aXX2dX7ffd <http://www.apache.org/juneaubp/name> "This is RDF format." .
// _:A3bf53c85X3aX157cf407e2dX3aXX2dX7ffd <http://www.apache.org/juneaubp/age> "rdf" .</jc>
- String rdfNTriple = NTripleSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>rdfNTriple</jv> = NTripleSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
<jc>// Produces:
// @prefix jp: <http://www.apache.org/juneaubp/> .
// @prefix j: <http://www.apache.org/juneau/> .
// [] jp:id "rdf" ;
// jp:name "This is RDF format." .</jc>
- String rdfTurtle = TurtleSerializer.<jsf>DEFAULT</jsf>.serialize(p);
+ String <jv>rdfTurtle</jv> = TurtleSerializer.<jsf>DEFAULT</jsf>.serialize(<jv>person</jv>);
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
-
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-marshall-rdf'>juneau-marshall-rdf</a>
</ul>
</div>
diff --git a/templates/petstore.html b/templates/petstore.html
index f82811f..dae0a2b 100644
--- a/templates/petstore.html
+++ b/templates/petstore.html
@@ -98,14 +98,14 @@
description=<js>"ID of pet to return"</js>,
example=<js>"123"</js>
)
- <jk>long</jk> petId
+ <jk>long</jk> <jv>petId</jv>
) <jk>throws</jk> IdNotFound, NotAcceptable;
<ja>@RemoteMethod</ja>(method=<jsf>POST</jsf>, path=<js>"/pet"</js>)
<jk>public long</jk> createPet(
<ja>@Body</ja>(
description=<js>"Pet object to add to the store"</js>
- ) CreatePet pet
+ ) CreatePet <jv>pet</jv>
) <jk>throws</jk> IdConflict, NotAcceptable, UnsupportedMediaType;
...
@@ -178,23 +178,19 @@
<p class='bcode w800'>
<jk>public class</jk> Main {
- <jk>public static void</jk> main(String[] args) {
+ <jk>public static void</jk> main(String[] <jv>args</jv>) {
<jc>// Create a RestClient with JSON serialization support.</jc>
- <jk>try</jk> (RestClient rc = RestClient.create(SimpleJsonSerializer.<jk>class</jk> JsonParser.<jk>class</jk>).build()) {
+ RestClient <jv>restClient</jv> = RestClient.<jsm>create</jsm>().simpleJson().build();
- <jc>// Instantiate our proxy.</jc>
- PetStore petStore = rc.getRemote(PetStore.<jk>class</jk>, <js>"http://localhost:5000"</js>);
-
- <jc>// Print out the pets in the store.</jc>
- Collection<Pet> pets = petStore.getPets();
-
- <jc>// Pretty-print them to STDOUT.</jc>
- SimpleJson.<jsf>DEFAULT_READABLE</jsf>.println(pets);
-
- } <jk>catch</jk> (Exception e) {
- e.printStackTrace();
- }
+ <jc>// Instantiate our proxy.</jc>
+ PetStore <jv>petStore</jv> = <jv>restClient</jv>.getRemote(PetStore.<jk>class</jk>, <js>"http://localhost:5000"</js>);
+
+ <jc>// Print out the pets in the store.</jc>
+ Collection<Pet> <jv>pets</jv> = <jv>petStore</jv>.getPets();
+
+ <jc>// Pretty-print them to STDOUT.</jc>
+ SimpleJson.<jsf>DEFAULT_READABLE</jsf>.println(<jv>pets</jv>);
}
}
</p>
@@ -215,14 +211,14 @@
<ja>@SpringBootApplication</ja>
<jk>public class</jk> App {
- <jk>public static void</jk> main(String[] args) {
- <jk>new</jk> App().start(args);
+ <jk>public static void</jk> main(String[] <jv>args</jv>) {
+ <jk>new</jk> App().start(<jv>args</jv>);
}
- <jk>protected void</jk> start(String[] args) {
+ <jk>protected void</jk> start(String[] <jv>args</jv>) {
<jk>new</jk> SpringApplicationBuilder(App.<jk>class</jk>)
.initializers(<jk>new</jk> JuneauRestInitializer(App.<jk>class</jk>))
- .run(args);
+ .run(<jv>args</jv>);
}
}
</p>
@@ -474,8 +470,8 @@
tags=<js>"pet"</js>
)
)
- <jk>public</jk> Pet getPet(long petId) <jk>throws</jk> IdNotFound, NotAcceptable {
- <jk>return</jk> <jf>store</jf>.getPet(petId);
+ <jk>public</jk> Pet getPet(<jk>long</jk> <jv>petId</jv>) <jk>throws</jk> IdNotFound, NotAcceptable {
+ <jk>return</jk> <jf>store</jf>.getPet(<jv>petId</jv>);
}
<ja>@Override</ja> <jc>/* PetStore */</jc>
@@ -488,8 +484,8 @@
),
roleGuard=<js>"ROLE_ADMIN || (ROLE_USER && ROLE_WRITABLE)"</js> <jc>// Restrict access to this method.</jc>
)
- <jk>public long</jk> createPet(CreatePet pet) <jk>throws</jk> IdConflict, NotAcceptable, UnsupportedMediaType {
- <jk>return</jk> <jf>store</jf>.create(pet).getId();
+ <jk>public long</jk> createPet(CreatePet <jv>pet</jv>) <jk>throws</jk> IdConflict, NotAcceptable, UnsupportedMediaType {
+ <jk>return</jk> <jf>store</jf>.create(<jv>pet</jv>).getId();
}
...
diff --git a/templates/rest-client.html b/templates/rest-client.html
index 53a5401..33a2d96 100644
--- a/templates/rest-client.html
+++ b/templates/rest-client.html
@@ -46,193 +46,69 @@
</p>
<p>
- The REST client API allows you to access REST interfaces using POJOs:
+ Built upon the feature-rich Apache HttpClient library, the Juneau RestClient API adds support for fluent-style
+ REST calls and the ability to perform marshalling of POJOs to and from HTTP parts.
</p>
+
+ <h5 class='figure'>Example:</h5>
<p class='bcode w800'>
- <jc>// Create a reusable JSON client.</jc>
- RestClient client = RestClient.<jsm>create</jsm>().build();
-
- <jc>// The address of the root resource.</jc>
- String url = <js>"http://localhost:10000/systemProperties"</js>;
-
- <jc>// Do a REST GET against a remote REST interface and convert
- // the response to an unstructured ObjectMap object.</jc>
- Map m1 = client.doGet(url).getResponse(TreeMap.<jk>class</jk>);
-
- <jc>// Add some new system properties.
- // Use XML as the transport medium.</jc>
- client = RestClient.<jsm>create</jsm>().serializer(XmlSerializer.<jk>class</jk>).parser(XmlParser.<jk>class</jk>).build();
- Properties p = <jk>new</jk> Properties();
- p.load(reader);
- <jk>int</jk> returnCode = client.doPost(url + <js>"/systemProperties"</js>, p).execute();
- </p>
- <p>
- The client API uses the same serializers and parsers (and subsequently their flexibility and configurability) as the server side to marshall POJOs back and forth.
+ <jc>// Create a basic REST client with JSON support and download a bean.</jc>
+ MyBean <jv>bean</jv> = RestClient.<jsm>create</jsm>()
+ .simpleJson()
+ .build()
+ .get(<jsf>URI</jsf>)
+ .run()
+ .assertStatus().code().is(200)
+ .assertHeader(<js>"Content-Type"</js>).matchesSimple(<js>"application/json*"</js>)
+ .getBody().as(MyBean.<jk>class</jk>);
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
- <li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-rest-client.juneau-rest-client'>juneau-rest-client</a>
- </ul>
- <hr>
+
<p>
- <b>restRPC</b> (RPC over REST) allows the creation of client-side remote proxy interfaces for calling methods on server-side POJOs using entirely REST.
+ Breaking apart the fluent call, we can see the classes being used:
</p>
+
<p class='bcode w800'>
- <jc>// Get an interface proxy.</jc>
- IAddressBook ab = restClient.getRemote(IAddressBook.<jk>class</jk>);
-
- <jc>// Invoke a method on the server side and get the returned result.</jc>
- Person p = ab.createPerson(
- <jk>new</jk> Person(
- <js>"John Smith"</js>,
- <js>"Aug 1, 1999"</js>,
- <jk>new</jk> Address(<js>"My street"</js>, <js>"My city"</js>, <js>"My state"</js>, 12345, <jk>true</jk>)
- )
- );
- </p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
- <li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-rest-server.restRPC'>juneau-rest-server > restRPC</a>
- </ul>
- <hr>
- <p>
- The <code>juneau-rest-client</code> library can also be used to define interface proxies against 3rd-party REST interfaces.
- This is an extremely powerful feature that allows you to quickly define easy-to-use interfaces against virtually any REST interface.
+ RestClientBuilder <jv>builder</jv> = RestClient.<jsm>create</jsm>().simpleJson();
+ RestClient <jv>client</jv> = <jv>builder</jv>.build();
+ RestRequest <jv>req</jv> = <jv>client</jv>.get(<jsf>URI</jsf>);
+ RestResponse <jv>res</jv> = <jv>req</jv>.run();
+ RestResponseStatusLineAssertion <jv>statusLineAssertion</jv> = <jv>res</jv>.assertStatus();
+ FluentIntegerAssertion<RestResponse> <jv>codeAssertion</jv> = <jv>statusLineAssertion</jv>.code();
+ <jv>res</jv> = <jv>codeAssertion</jv>.is(200);
+ FluentStringAssertion<RestResponse> <jv>headerAssertion</jv> = <jv>res</jv>.assertHeader(<js>"Content-Type"</js>);
+ <jv>res</jv> = <jv>headerAssertion</jv>.matchesSimple(<js>"application/json*"</js>);
+ RestResponseBody <jv>body</jv> = <jv>res</jv>.getBody();
+ MyBean <jv>bean</jv> = <jv>body</jv>.as(MyBean.<jk>class</jk>);
</p>
+
<p>
- Similar in concept to restRPC services defined above, but in this case we simply define our interface with
- special annotations that tell us how to convert input and output to HTTP headers, query parameters, form post parameters, or request/response bodies.
+ It additionally provides support for creating remote proxy interfaces using REST as the transport medium.
</p>
+
<h5 class='figure'>Example:</h5>
- <p class='bcode w800'>
+ <p class='bcode w800'>
+ <jc>// Define a Remote proxy for interacting with a REST interface.</jc>
<ja>@Remote</ja>(path=<js>"/petstore"</js>)
<jk>public interface</jk> PetStore {
-
- <ja>@RemoteMethod</ja>(httpMethod=<jsf>POST</jsf>, path=<js>"/pets"</js>)
- String addPet(
- <ja>@Body</ja> CreatePet pet,
- <ja>@Header</ja>(<js>"E-Tag"</js>) UUID etag,
- <ja>@Query</ja>(<js>"debug"</js>) <jk>boolean</jk> debug
+
+ <ja>@RemoteMethod</ja>(method=<jsf>POST</jsf>, path=<js>"/pets"</js>)
+ Pet addPet(
+ <ja>@Body</ja> CreatePet <jv>pet</jv>,
+ <ja>@Header</ja>(<js>"E-Tag"</js>) UUID <jv>etag</jv>,
+ <ja>@Query</ja>(<js>"debug"</js>) <jk>boolean</jk> <jv>debug</jv>
);
}
- </p>
- <p class='bcode w800'>
+
<jc>// Use a RestClient with default Simple JSON support.</jc>
- <jk>try</jk> (RestClient client = RestClient.<jsm>create</jsm>().simpleJson().build()) {
- PetStore store = client.getRemoteResource(PetStore.<jk>class</jk>, <js>"http://localhost:10000"</js>);
- CreatePet pet = <jk>new</jk> CreatePet(<js>"Fluffy"</js>, 9.99);
- String response = store.createPet(pet, UUID.<jsm>randomUUID</jsm>(), <jk>true</jk>);
- }
- </p>
- <p>
- The call above translates to the following REST call:
- </p>
- <p class='bcode w800'>
- POST http://localhost:10000/petstore/pets?debug=true HTTP/1.1
- Accept: application/json
- Content-Type: application/json
- E-Tag: 475588d4-0b27-4f56-9296-cc683251d314
+ RestClient <jv>client</jv> = RestClient.<jsm>create</jsm>().simpleJson().build();
- {
- name: 'Fluffy',
- price: 9.99
- }
+ PetStore <jv>store</jv> = <jv>client</jv>.getRemote(PetStore.<jk>class</jk>, <js>"http://localhost:10000"</js>);
+ CreatePet <jv>createPet</jv> = <jk>new</jk> CreatePet(<js>"Fluffy"</js>, 9.99);
+ Pet <jv>pet</jv> = <jv>store</jv>.addPet(<jv>createPet</jv>, UUID.<jsm>randomUUID</jsm>(), <jk>true</jk>);
</p>
- <br><hr>
- <p>
- A common coding practice is to use the same Java interface to define both your server and client side REST interfaces.
- The advantage to this approach is that changes that you make to your REST interface can be reflected in both places
- at the same time, reducing the chances for compatibility mistakes.
- </p>
- <p>
- What makes this possible is that method-level annotations such as <ja>@RestMethod</ja> and parameter-level annotations
- such as <ja>@Query</ja> are inherited from parent classes.
- This normally isn't possible, but the framework will spider up the parent hierarchy of classes to find method and parameter level
- annotations defined on overridden methods.
- </p>
- <p>
- The general approach is to define your <ja>@Remote</ja>-annotated interface first.
- The following example is pulled from the PetStore app:
- </p>
- <p class='bcode w800'>
- <ja>@Remote</ja>(path=<js>"/petstore"</js>)
- <jk>public interface</jk> PetStore {
-
- <ja>@RemoteMethod</ja>(method=<jsf>GET</jsf>, path=<js>"/pet"</js>)
- <jk>public</jk> Collection<Pet> getPets() <jk>throws</jk> NotAcceptable;
-
- <ja>@RemoteMethod</ja>(method=<jsf>DELETE</jsf>, path=<js>"/pet/{petId}"</js>)
- <jk>public</jk> Ok deletePet(
- <ja>@Header</ja>(
- name=<js>"api_key"</js>,
- description=<js>"Security API key"</js>,
- required=<jk>true</jk>,
- example=<js>"foobar"</js>
- )
- String apiKey,
- <ja>@Path</ja>(
- name=<js>"petId"</js>,
- description=<js>"Pet id to delete"</js>,
- example=<js>"123"</js>
- )
- <jk>long</jk> petId
- ) <jk>throws</jk> IdNotFound, NotAcceptable;
-
- ...
- </p>
- <p>
- Next you define the implementation of your interface as a normal Juneau REST resource:
- </p>
- <p class='bcode w800'>
- <ja>@Rest</ja>(
- path=<js>"/petstore"</js>,
- title=<js>"Petstore application"</js>,
- ...
- )
- <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> PetStore {
-
- ...
-
- <ja>@Override</ja> <jc>/* PetStore */</jc>
- <ja>@RestMethod</ja>(
- name=<jsm>GET</jsm>,
- path=<js>"/pet"</js>,
- summary=<js>"All pets in the store"</js>,
- ...
- )
- <jk>public</jk> Collection<Pet> getPets() <jk>throws</jk> NotAcceptable {
- <jk>return</jk> <jsf>store</jsf>.getPets();
- }
-
- <ja>@Override</ja> <jc>/* PetStore */</jc>
- <ja>@RestMethod</ja>(
- name=<jsf>DELETE</jsf>,
- path=<js>"/pet/{petId}"</js>,
- summary=<js>"Deletes a pet"</js>,
- ...
- )
- <jk>public</jk> Ok deletePet(String apiKey, long petId) <jk>throws</jk> IdNotFound, NotAcceptable {
- <jsf>store</jsf>.removePet(petId);
- <jk>return</jk> <jsf>OK</jsf>;
- }
- </p>
- <p>
- Then use the interface as a remote resource like so:
- </p>
- <p class='bcode w800'>
- <jk>try</jk> (RestClient rc = RestClient.<jsm>create</jsm>().json().rootUrl(<js>"http://localhost:10000"</js>).build()) {
- PetStore ps = rc.getRemoteResource(PetStore.<jk>class</jk>);
-
- <jk>for</jk> (Pet x : ps.getPets()) {
- ps.deletePet(<js>"my-special-key"</js>, x.getId());
- System.<jsf>out</jsf>.println(<js>"Deleted pet: id="</js> + x.getId());
- }
- }
- </p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
- <li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-rest-client.RestProxies.DualPurposeInterfaces'>juneau-rest-client > Dual-Purpose Interfaces</a>
+ <ul class='seealso'>
+ <li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-rest-client'>juneau-rest-client</a>
</ul>
</div>
</body>
diff --git a/templates/rest-server.html b/templates/rest-server.html
index 562a891..4e13fd8 100644
--- a/templates/rest-server.html
+++ b/templates/rest-server.html
@@ -74,32 +74,32 @@
<jk>public class</jk> SystemPropertiesResource <jk>extends</jk> BasicRestServlet {
<ja>@RestMethod</ja>(name=<jsf>GET</jsf>, path=<js>"/"</js>)
- <jk>public</jk> Map getSystemProperties(<ja>@Query</ja>(<js>"sort"</js>) <jk>boolean</jk> sort) <jk>throws</jk> Throwable {
- <jk>if</jk> (sort)
+ <jk>public</jk> Map getSystemProperties(<ja>@Query</ja>(<js>"sort"</js>) <jk>boolean</jk> <jv>sort</jv>) <jk>throws</jk> Throwable {
+ <jk>if</jk> (<jv>sort</jv>)
<jk>return new</jk> TreeMap(System.<jsm>getProperties</jsm>());
<jk>return</jk> System.<jsm>getProperties</jsm>();
}
<ja>@RestMethod</ja>(name=<jsf>GET</jsf>, path=<js>"/{propertyName}"</js>)
- <jk>public</jk> String getSystemProperty(<ja>@Path</ja>(<js>"propertyName"</js>) String propertyName) <jk>throws</jk> Throwable {
- <jk>return</jk> System.<jsm>getProperty</jsm>(propertyName);
+ <jk>public</jk> String getSystemProperty(<ja>@Path</ja>(<js>"propertyName"</js>) String <jv>propertyName</jv>) <jk>throws</jk> Throwable {
+ <jk>return</jk> System.<jsm>getProperty</jsm>(<jv>propertyName</jv>);
}
<ja>@RestMethod</ja>(name=<jsf>PUT</jsf>, path=<js>"/{propertyName}"</js>, guards=AdminGuard.<jk>class</jk>)
- <jk>public</jk> String setSystemProperty(<ja>@Path</ja>(<js>"propertyName"</js>) String propertyName, <ja>@Body</ja> String value) {
- System.<jsm>setProperty</jsm>(propertyName, value);
+ <jk>public</jk> String setSystemProperty(<ja>@Path</ja>(<js>"propertyName"</js>) String <jv>propertyName</jv>, <ja>@Body</ja> String <jv>value</jv>) {
+ System.<jsm>setProperty</jsm>(<jv>propertyName</jv>, <jv>value</jv>);
<jk>return</jk> <js>"OK"</js>;
}
<ja>@RestMethod</ja>(name=<jsf>POST</jsf>, path=<js>"/"</js>, guards=AdminGuard.<jk>class</jk>)
- <jk>public</jk> String setSystemProperties(<ja>@Body</ja> java.util.Properties newProperties) {
- System.<jsm>setProperties</jsm>(newProperties);
+ <jk>public</jk> String setSystemProperties(<ja>@Body</ja> java.util.Properties <jv>newProperties</jv>) {
+ System.<jsm>setProperties</jsm>(<jv>newProperties</jv>);
<jk>return</jk> <js>"OK"</js>;
}
<ja>@RestMethod</ja>(name=<jsf>DELETE</jsf>, path=<js>"/{propertyName}"</js>, guards=AdminGuard.<jk>class</jk>)
- <jk>public</jk> String deleteSystemProperty(<ja>@Path</ja>(<js>"propertyName"</js>) String propertyName) {
- System.<jsm>clearProperty</jsm>(propertyName);
+ <jk>public</jk> String deleteSystemProperty(<ja>@Path</ja>(<js>"propertyName"</js>) String <jv>propertyName</jv>) {
+ System.<jsm>clearProperty</jsm>(<jv>propertyName</jv>);
<jk>return</jk> <js>"OK"</js>;
}
}
@@ -249,9 +249,9 @@
<jk>public</jk> Date <jf>birthDate</jf>;
<jk>public int</jk> getAge() {
- Calendar c = <jk>new</jk> GregorianCalendar();
- c.setTime(<jf>birthDate</jf>);
- <jk>return new</jk> GregorianCalendar().get(Calendar.<jsf>YEAR</jsf>) - c.get(Calendar.<jsf>YEAR</jsf>);
+ Calendar <jv>calendar</jv> = <jk>new</jk> GregorianCalendar();
+ <jv>calendar</jv>.setTime(<jf>birthDate</jf>);
+ <jk>return new</jk> GregorianCalendar().get(Calendar.<jsf>YEAR</jsf>) - <jv>calendar</jv>.get(Calendar.<jsf>YEAR</jsf>);
}
}
@@ -262,11 +262,11 @@
<jk>public static class</jk> KindRender <jk>extends</jk> HtmlRender<Kind> {
<ja>@Override</ja>
- <jk>public</jk> Object getContent(SerializerSession session, Kind value) {
- <jk>return new</jk> Img().src(<js>"servlet:/htdocs/"</js>+value.toString().toLowerCase()+<js>".png"</js>);
+ <jk>public</jk> Object getContent(SerializerSession <jv>session</jv>, Kind <jv>value</jv>) {
+ <jk>return new</jk> Img().src(<js>"servlet:/htdocs/"</js>+<jv>value</jv>.toString().toLowerCase()+<js>".png"</js>);
}
<ja>@Override</ja>
- <jk>public</jk> String getStyle(SerializerSession session, Kind value) {
+ <jk>public</jk> String getStyle(SerializerSession <jv>session</jv>, Kind <jv>value</jv>) {
<jk>return</jk> <js>"background-color:#FDF2E9"</js>;
}
}
@@ -347,8 +347,7 @@
<br>
<img class='bordered w900' src='images/juneau-examples-rest.PetStoreResource.9e.png'>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-rest-server'>juneau-rest-server</a>
</ul>
@@ -390,10 +389,10 @@
<ja>@Controller</ja>
<jk>public class</jk> App {
- <jk>public static void</jk> main(String[] args) {
+ <jk>public static void</jk> main(String[] <jv>args</jv>) {
<jk>new</jk> SpringApplicationBuilder(App.<jk>class</jk>)
.initializers(<jk>new</jk> JuneauRestInitializer(App.<jk>class</jk>))
- .run(args);
+ .run(<jv>args</jv>);
}
<jd>/** Our root resource */</jd>
@@ -408,8 +407,7 @@
as a top-level servlet to be deployed in the Spring Boot web container.
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-rest-server-springboot'>juneau-rest-server-springboot</a>
</ul>
</div>
@@ -444,8 +442,7 @@
<code>MessageBodyWriter</code> implementations for using Juneau serializers and parsers in JAX-RS environments.
</p>
- <h5 class='section'>More Information:</h5>
- <ul class='doctree'>
+ <ul class='seealso'>
<li><a class='doclink' href='http://juneau.apache.org/site/apidocs-{@property juneauVersion}/overview-summary.html#juneau-rest-server-jaxrs'>juneau-rest-server-jaxrs</a>
</ul>
</div>