Repository: incubator-juneau-website
Updated Branches:
  refs/heads/asf-site 765b322f2 -> 2b547a5cf


More

Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/commit/2b547a5c
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/tree/2b547a5c
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/diff/2b547a5c

Branch: refs/heads/asf-site
Commit: 2b547a5cfcb9652e0a9973bda2dcd22c5d517747
Parents: 765b322
Author: JamesBognar <[email protected]>
Authored: Wed Nov 16 11:22:29 2016 -0500
Committer: JamesBognar <[email protected]>
Committed: Wed Nov 16 11:22:29 2016 -0500

----------------------------------------------------------------------
 content/about.html | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-juneau-website/blob/2b547a5c/content/about.html
----------------------------------------------------------------------
diff --git a/content/about.html b/content/about.html
index b28e811..4ff6d63 100644
--- a/content/about.html
+++ b/content/about.html
@@ -172,6 +172,50 @@
                to provide annotated REST servlets that automatically negotiate 
the HTTP media types and allow the developer
                to work with requests, responses, headers, path variables, 
query parameters, and form data as POJOs.
        </p>
+       <p>
+               A simple example...
+       </p>
+       <p class='bcode'>
+       <ja>@RestResource</ja>(
+               path=<js>"/systemProperties"</js>,
+               title=<js>"System properties resource"</js>
+       )
+       <jk>public class</jk> SystemPropertiesResource <jk>extends</jk> 
RestServletDefault {
+       
+               <ja>@RestMethod</ja>(name=<js>"GET"</js>, 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>return new</jk> 
TreeMap(System.<jsm>getProperties</jsm>());
+                       <jk>return</jk> System.<jsm>getProperties</jsm>();
+               }
+       
+               <ja>@RestMethod</ja>(name=<js>"GET"</js>, 
path=<js>"/{propertyName}"</js>)
+               <jk>public</jk> String getSystemProperty(<ja>@Path</ja> String 
propertyName) <jk>throws</jk> Throwable {
+                       <jk>return</jk> 
System.<jsm>getProperty</jsm>(propertyName);
+               }
+       
+               <ja>@RestMethod</ja>(name=<js>"PUT"</js>, 
path=<js>"/{propertyName}"</js>)
+               <jk>public</jk> String setSystemProperty(<ja>@Path</ja> String 
propertyName, <ja>@Body</ja> String value) {
+                       System.<jsm>setProperty</jsm>(propertyName, value);
+                       <jk>return</jk> <js>"OK"</js>;
+               }
+       
+               <ja>@RestMethod</ja>(name=<js>"POST"</js>, path=<js>"/"</js>)
+               <jk>public</jk> String setSystemProperties(<ja>@Body</ja> 
java.util.Properties newProperties) {
+                       System.<jsm>setProperties</jsm>(newProperties);
+                       <jk>return</jk> <js>"OK"</js>;
+               }
+       
+               <ja>@RestMethod</ja>(name=<js>"DELETE"</js>, 
path=<js>"/{propertyName}"</js>)
+               <jk>public</jk> string deleteSystemProperty(<ja>@Path</ja> 
String propertyName) {
+                       System.<jsm>clearProperty</jsm>(propertyName);
+                       <jk>return</jk> <js>"OK"</js>;
+               }
+       }
+       </p>
+       <p>
+               A more sophisticated example of the same resource...
+       </p>
        <p class='bcode'>
        <ja>@RestResource</ja>(
                path=<js>"/systemProperties"</js>,

Reply via email to