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 2022/09/11 16:00:20 UTC
[juneau] branch master updated: Simplify RestServlet/RestObject classes.
This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new f47567458 Simplify RestServlet/RestObject classes.
f47567458 is described below
commit f475674586769ea449e3509b3437c295fbe3c89b
Author: JamesBognar <ja...@salesforce.com>
AuthorDate: Sun Sep 11 12:00:01 2022 -0400
Simplify RestServlet/RestObject classes.
---
juneau-doc/src/main/javadoc/overview.html | 112 ++++----
.../examples/rest/dto/JsonSchemaResource.java | 1 -
.../rest/springboot/BasicSpringRestServlet.java | 2 +-
.../springboot/BasicSpringRestServletGroup.java | 2 +-
.../apache/juneau/rest/annotation/RestDestroy.java | 10 -
.../apache/juneau/rest/annotation/RestEndCall.java | 11 -
.../apache/juneau/rest/annotation/RestInit.java | 10 -
.../juneau/rest/annotation/RestPostCall.java | 10 -
.../juneau/rest/annotation/RestPostInit.java | 11 -
.../apache/juneau/rest/annotation/RestPreCall.java | 10 -
.../juneau/rest/annotation/RestStartCall.java | 10 -
.../juneau/rest/servlet/BasicRestObject.java | 2 +-
.../juneau/rest/servlet/BasicRestObjectGroup.java | 2 +-
.../juneau/rest/servlet/BasicRestServlet.java | 2 +-
.../juneau/rest/servlet/BasicRestServletGroup.java | 2 +-
.../org/apache/juneau/rest/servlet/RestObject.java | 310 +-------------------
.../apache/juneau/rest/servlet/RestServlet.java | 320 +--------------------
17 files changed, 70 insertions(+), 757 deletions(-)
diff --git a/juneau-doc/src/main/javadoc/overview.html b/juneau-doc/src/main/javadoc/overview.html
index d7c5ccb36..05555a327 100644
--- a/juneau-doc/src/main/javadoc/overview.html
+++ b/juneau-doc/src/main/javadoc/overview.html
@@ -1254,7 +1254,7 @@
}
)
<ja>@BeanConfig</ja>(sortProperties=<js>"true"</js>)
- <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniveralConfig {
+ <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestServlet {
<ja>@RestGet</ja>(path=<js>"/*"</js>, summary=<js>"Responds with \"Hello world!\""</js>)
<jk>public</jk> String sayHello() {
@@ -1296,7 +1296,7 @@
MyChildResource.<jk>class</jk>
}
)
- <jk>public</jk> MyParentResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {...}
+ <jk>public</jk> MyParentResource <jk>extends</jk> BasicRestServlet {...}
</p>
<p class='bjava'>
<jd>/** Child Resource */</jd>
@@ -1304,7 +1304,7 @@
path=<js>"/child"</js> <jc>// Path relative to parent resource.</jc>
)
<jc>// Note that we don't need to extend from RestServlet.</jc>
- <jk>public</jk> MyChildResource <jk>implements</jk> BasicUniversalConfig {
+ <jk>public</jk> MyChildResource <jk>implements</jk> BasicRestObject {
...
}
</p>
@@ -1553,7 +1553,7 @@
ShutdownResource.<jk>class</jk>
}
)
- <jk>public class</jk> RootResources <jk>extends</jk> BasicRestServletGroup <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> RootResources <jk>extends</jk> BasicRestServletGroup {
<jc>// NO CODE!!!</jc>
}
</p>
@@ -1714,7 +1714,7 @@
HelloWorldResource.<jk>class</jk>
}
)
- <jk>public class</jk> RootResources <jk>extends</jk> BasicSpringRestServletGroup <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> RootResources <jk>extends</jk> BasicSpringRestServletGroup {
<jc>// No code!</jc>
}
</p>
@@ -1771,7 +1771,7 @@
<jc>// Our REST resource to test.</jc>
<jc>// Simply echos the response.</jc>
<ja>@Rest</ja>
- <jk>public static class</jk> EchoRest <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicJsonConfig {
+ <jk>public static class</jk> EchoRest <jk>extends</jk> BasicRestServlet {
<ja>@RestPut</ja>
<jk>public</jk> MyBean echo(<ja>@Content</ja> MyBean <jv>bean</jv>) {
@@ -3498,7 +3498,7 @@
<ja>@RdfConfig</ja>(rdfxml_tab=<js>"5"</js>, addRootProperty=<js>"true"</js>)
<ja>@BeanConfig</ja>(sortProperties=<js>"true"</js>, examples=<js>"Feed: $F{AddressBook_example.json}"</js>)
<ja>@Bean</ja>(onClass=Address.<jk>class</jk>, properties=<js>"street,city,state"</js>)
- <jk>public class</jk> AddressBookResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> AddressBookResource <jk>extends</jk> BasicRestServlet {
...
}
</p>
@@ -9990,7 +9990,7 @@
<js>"</div>"</js>
}
)
- <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {...}
+ <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestServlet {...}
</p>
<p>
The {@link org.apache.juneau.html.HtmlDocSerializer.Builder#template(Class)} setting defines
@@ -16252,10 +16252,7 @@
// You can apply any of the Serializer/Parser/BeanContext settings this way.</jc>
quoteChar=<js>"'"</js>
)
- <jk>public class</jk> RootResources <jk>extends</jk> BasicRestServletGroup <jk>implements</jk> BasicUniversalJenaConfig {
- <jc>// IMPORTANT! If you don't need RDF support, change the parent interface to BasicUniversalConfig.
- // It allows you to remove the Jena prerequisite.</jc>
-
+ <jk>public class</jk> RootResources <jk>extends</jk> BasicRestServletGroup {
<jk>private static final long</jk> <jsf>serialVersionUID</jsf> = 1L;
}
</p>
@@ -16287,7 +16284,7 @@
<js>"</div>"</js>
}
)
- <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestObject <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestObject {
<ja>@RestGet</ja>(path=<js>"/*"</js>, summary=<js>"Responds with \"Hello world!\""</js>)
<jk>public</jk> String sayHello() {
@@ -16424,14 +16421,14 @@
<ul>
<li class='jac'>{@link org.apache.juneau.rest.servlet.RestServlet}
<ul>
- <li class='jac'>{@link org.apache.juneau.rest.servlet.BasicRestServlet} <jk>implements</jk> {@link org.apache.juneau.rest.servlet.BasicRestOperations}, {@link org.apache.juneau.rest.config.BasicJsonConfig}
+ <li class='jac'>{@link org.apache.juneau.rest.servlet.BasicRestServlet} <jk>implements</jk> {@link org.apache.juneau.rest.servlet.BasicRestOperations}, {@link org.apache.juneau.rest.config.BasicUniversalConfig}
<ul>
<li class='jac'>{@link org.apache.juneau.rest.servlet.BasicRestServletGroup} <jk>implements</jk> {@link org.apache.juneau.rest.servlet.BasicGroupOperations}
</ul>
</li>
<li class='jac'>{@link org.apache.juneau.rest.springboot.SpringRestServlet}
<ul>
- <li class='jac'>{@link org.apache.juneau.rest.springboot.BasicSpringRestServlet} <jk>implements</jk> {@link org.apache.juneau.rest.servlet.BasicRestOperations}, {@link org.apache.juneau.rest.config.BasicJsonConfig}
+ <li class='jac'>{@link org.apache.juneau.rest.springboot.BasicSpringRestServlet} <jk>implements</jk> {@link org.apache.juneau.rest.servlet.BasicRestOperations}, {@link org.apache.juneau.rest.config.BasicUniversalConfig}
<ul>
<li class='jac'>{@link org.apache.juneau.rest.springboot.BasicSpringRestServletGroup} <jk>implements</jk> {@link org.apache.juneau.rest.servlet.BasicGroupOperations}
</ul>
@@ -16535,7 +16532,7 @@
</p>
<p class='bjava'>
<ja>@Rest</ja>(...)
- <jk>public class</jk> MyResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> MyResource <jk>extends</jk> RestServlet <jk>implements</jk> BasicUniversalConfig {
...
}
</p>
@@ -16605,7 +16602,7 @@
path=<js>"/parent"</js>,
children={MyChildResource.<jk>class</jk>}
)
- <jk>public</jk> MyRootResources <jk>extends</jk> BasicRestServletGroup <jk>implements</jk> BasicUniversalConfig {...}
+ <jk>public</jk> MyRootResources <jk>extends</jk> BasicRestServletGroup {...}
</p>
<p class='bjava'>
<jd>/** Child Resource */</jd>
@@ -16613,7 +16610,7 @@
path=<js>"/child"</js> <jc>// Path relative to parent resource.</jc>
)
<jc>// Note that we don't need to extend from RestServlet.</jc>
- <jk>public</jk> MyChildResource <jk>extends</jk> BasicRestObject <jk>implements</jk> BasicUniversalConfig {...}
+ <jk>public</jk> MyChildResource <jk>extends</jk> BasicRestObject {...}
</p>
<p>
The path of the child resource gets appended to the path of the parent resource.
@@ -16648,7 +16645,7 @@
<ja>@Rest</ja>(
path=<js>"/myResource/{foo}/{bar}"</js>
)
- <jk>public class</jk> MyResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> MyResource <jk>extends</jk> BasicRestServlet {
<ja>@RestPost</ja>(<js>"/{baz}"</js>)
<jk>public void</jk> String doX(<ja>@Path</ja> String <jv>foo</jv>, <ja>@Path</ja> <jk>int</jk> <jv>bar</jv>) {
@@ -16741,7 +16738,7 @@
</p>
<p class='bjava'>
<ja>@Rest</ja>(...)
- <jk>public class</jk> MyResource <jk>extends</jk> BasicRestObject <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> MyResource <jk>extends</jk> BasicRestObject {
<jc>// Our database.</jc>
<jk>private</jk> Map<Integer,Object> <jf>myDatabase</jf>;
@@ -16757,7 +16754,7 @@
</p>
<p class='bjava'>
<ja>@Rest</ja>(...)
- <jk>public class</jk> MyResource <jk>extends</jk> BasicRestObject <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> MyResource <jk>extends</jk> BasicRestObject {
<jc>// Add a request attribute to all incoming requests.</jc>
<ja>@RestPreCall</ja>
@@ -17105,7 +17102,7 @@
<ja>@Rest</ja>(
restOpArgs={ MyOpArg.<jk>class</jk> } <jc>// Option #1 - Via annotation</jc>
)
- <jk>public class</jk> MyResource <jk>extends</jk> BasicRestObject <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> MyResource <jk>extends</jk> BasicRestObject {
// Option #2 - Programmatically
<ja>@RestInit</ja>
@@ -17262,7 +17259,7 @@
<ja>@Rest</ja>(
responseProcessors={ MyResponseProcessor.<jk>class</jk> } <jc>// Option #1 - Via annotation</jc>
)
- <jk>public class</jk> MyResource <jk>extends</jk> BasicRestObject <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> MyResource <jk>extends</jk> BasicRestObject {
// Option #2 - Programmatically
<ja>@RestInit</ja>
@@ -18240,7 +18237,7 @@
<jc>// Add a version header attribute to all responses</jc>
defaultResponseHeaders={<js>"X-Version: 1.0"</js>}
)
- <jk>public</jk> MyRestServlet <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
+ <jk>public</jk> MyRestServlet <jk>extends</jk> BasicRestServlet {
...
}
</p>
@@ -18627,7 +18624,7 @@
<ja>@BeanConfig</ja>(sortProperties=<js>"true"</js>)
<ja>@SerializerConfig</ja>(trimNulls=<js>"true"</js>)
<ja>@JsonConfig</ja>(escapeSolidus=<js>"true"</js>)
- <jk>public class</jk> MyResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> MyResource <jk>extends</jk> BasicRestServlet {
<ja>@RestPost</ja>
<ja>@BeanConfig</ja>(sortProperties=<js>"false"</js>)
@@ -18660,7 +18657,7 @@
MyInterface.<jk>class</jk>
}
)
- <jk>public</jk> MyResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {...}
+ <jk>public</jk> MyResource <jk>extends</jk> BasicRestServlet {...}
</p>
<p>
Config annotations are defined for all serializers and parsers:
@@ -18718,7 +18715,7 @@
</p>
<p class='bjava'>
<ja>@Rest</ja>(...)
- <jk>public class</jk> MyRestResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> MyRestResource <jk>extends</jk> BasicRestServlet {
<jc>// Our form input endpoint.</jc>
<ja>@RestPost</ja>(<js>"/"</js>)
@@ -18881,7 +18878,7 @@
<jc>// Servlet with class-level guard applied</jc>
<ja>@Rest</ja>(guards=BillyGuard.<jk>class</jk>)
- <jk>public</jk> MyRestServlet <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
+ <jk>public</jk> MyRestServlet <jk>extends</jk> BasicRestServlet {
<jc>// Delete method that only Billy is allowed to call.</jc>
<ja>@RestDelete</ja>
@@ -18944,7 +18941,7 @@
path=<js>"/foo"</js>,
roleGuard=<js>"ROLE_ADMIN || (ROLE_READ_WRITE && ROLE_SPECIAL)"</js>
)
- <jk>public class</jk> MyResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> MyResource <jk>extends</jk> BasicRestServlet {
...
}
</p>
@@ -19123,7 +19120,7 @@
<p class='bjava'>
<jc>// Servlet with automated support for GZIP compression</jc>
<ja>@Rest</ja>(encoders={GzipEncoder.<jk>class</jk>})
- <jk>public</jk> MyRestServlet <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
+ <jk>public</jk> MyRestServlet <jk>extends</jk> BasicRestServlet {
...
}
</p>
@@ -19274,7 +19271,7 @@
config=<js>"config_dir/myconfig.cfg"</js>,
...
)
- <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestServlet {
<jd>/**
* GET request handler.
@@ -19311,7 +19308,7 @@
config=<js>"config_dir/myconfig.cfg"</js>,
...
)
- <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestServlet {
<jd>/**
* GET request handler.
@@ -19594,7 +19591,7 @@
<jc>// Register it with our resource.</jc>
<ja>@Rest</ja>(...)
- <jk>public class</jk> MyResource <jk>extends</jk> BasicRestObject <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> MyResource <jk>extends</jk> BasicRestObject {
<ja>@RestInit</ja>
<jk>public void</jk> init(RestContext.Builder <jv>builder</jv>) {
@@ -19832,7 +19829,7 @@
swagger=<ja>@Swagger</ja>(<js>"$F{PetStoreResource.json}"</js>),
...
)
- <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {...}
+ <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestServlet {...}
</p>
<p>
In this particular case, the Swagger is pulled in from a localized Swagger JSON file located in the
@@ -19888,7 +19885,7 @@
),
...
)
- <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {...}
+ <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestServlet {...}
</p>
<p>
However, a more typical (and less error-prone) scenario is to define all of your Swagger as annotations:
@@ -19918,7 +19915,7 @@
),
...
)
- <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {...}
+ <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestServlet {...}
</p>
<p>
All annotations support {@doc jrs.SvlVariables SVL variables}, so you could for example
@@ -19950,7 +19947,7 @@
),
...
)
- <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {...}
+ <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestServlet {...}
</p>
<p>
A third option is to define your Swagger information in your {@link org.apache.juneau.rest.annotation.Rest#messages @Rest(messages)} resource
@@ -20576,7 +20573,7 @@
<js>"</div>"</js>
}
)
- <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {...}
+ <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestServlet {...}
</p>
<p>
SVL variables can be used in any of these annotations:
@@ -20602,7 +20599,7 @@
<js>"</div>"</js>
}
)
- <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {...}
+ <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestServlet {...}
</p>
</div>
@@ -21069,7 +21066,7 @@
},
asideFloat=<js>"RIGHT"</js>
)
- <jk>public class</jk> RootResources <jk>extends</jk> BasicRestServletGroup <jk>implements</jk> BasicUniversalJenaConfig {...}
+ <jk>public class</jk> RootResources <jk>extends</jk> BasicRestServletGroup {...}
</p>
<p>
@@ -21165,7 +21162,7 @@
<ja>@HtmlDocConfig</ja>(
stylesheet=<js>"servlet:/htdocs/themes/my-style.css"</js>
)
- <jk>public class</jk> MyResourceBaseClass <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {...}
+ <jk>public class</jk> MyResourceBaseClass <jk>extends</jk> BasicRestServlet {...}
</p>
<p>
You can try out different stylesheets by passing in a <c>stylesheet</c> attribute in the request
@@ -21190,7 +21187,7 @@
<js>"source: $C{Source/gitHub}/org/apache/juneau/examples/rest/$R{servletClassSimple}.java"</js>
}
)
- <jk>public class</jk> RootResources <jk>extends</jk> BasicRestServletGroup <jk>implements</jk> BasicUniversalConfig {...}
+ <jk>public class</jk> RootResources <jk>extends</jk> BasicRestServletGroup {...}
</p>
<p>
The <c>StyleMenuItem</c> is a widget that extends from {@link org.apache.juneau.rest.widget.MenuItemWidget}, a
@@ -21922,7 +21919,7 @@
path=<js>"/example"</js>,
responseProcessors=FooProcessor.<jk>class</jk>
)
- <jk>public class</jk> Example <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> Example <jk>extends</jk> BasicRestServlet {
<ja>@RestGet</ja>(<js>"/"</js>)
<jk>public</jk> Foo test1() {
@@ -22891,7 +22888,7 @@
<ja>@SerializerConfig</ja>(
quoteChar=<js>"'"</js>
)
- <jk>public class</jk> RootResources <jk>extends</jk> BasicSpringRestServletGroup <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> RootResources <jk>extends</jk> BasicSpringRestServletGroup {
<jk>private static final long</jk> <jsf>serialVersionUID</jsf> = 1L;
}
</p>
@@ -22920,7 +22917,7 @@
<js>"</div>"</js>
}
)
- <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestObject <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestObject {
<ja>@Autowired</ja>
<jk>private</jk> HelloWorldMessageProvider <jf>messageProvider</jf>;
@@ -24941,7 +24938,7 @@
title=<js>"Petstore application"</js>,
...
)
- <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalJenaConfig, PetStore {
+ <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> PetStore {
...
@@ -26586,7 +26583,7 @@
LogsResource.<jk>class</jk>
}
)
- <jk>public class</jk> RootResources <jk>extends</jk> BasicRestServletGroup <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> RootResources <jk>extends</jk> BasicRestServletGroup {
<jc>// No code! </jc>
}
</p>
@@ -26627,7 +26624,7 @@
title=<js>"Hello World example"</js>,
description=<js>"Simplest possible REST resource"</js>
)
- <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> HelloWorldResource <jk>extends</jk> BasicRestServlet {
<ja>@RestGet</ja>(<js>"/*"</js>)
<jk>public</jk> String sayHello() {
@@ -26835,7 +26832,7 @@
<cc># Contents of MyHelloResource.java </cc>
<cc>#---------------------------------</cc>
<ja>@Rest</ja>(...)
- <jk>public class</jk> MyHelloResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> MyHelloResource <jk>extends</jk> BasicRestServlet {
<jk>private</jk> String <jf>greeting</jf>;
<jc>// Or access config file in servlet init method.</jc>
@@ -26875,7 +26872,7 @@
messages=<js>"nls/Messages"</js>,
...
)
- <jk>public class</jk> MyHelloResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> MyHelloResource <jk>extends</jk> BasicRestServlet {
<jd>/** Standard hello message. */</jd>
<ja>@RestGet</ja>(<js>"/{person}"</js>)
@@ -27313,7 +27310,7 @@
<js>"options: servlet:/?method=OPTIONS"</js>
}
)
- <jk>public class</jk> RootResources <jk>extends</jk> BasicRestServletGroup <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> RootResources <jk>extends</jk> BasicRestServletGroup {
<jc>// No code</jc>
}
</p>
@@ -27689,7 +27686,7 @@
LogsResource.<jk>class</jk>
}
)
- <jk>public class</jk> RootResources <jk>extends</jk> BasicRestServletGroup <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> RootResources <jk>extends</jk> BasicRestServletGroup {
<jc>// No code</jc>
}
</p>
@@ -28233,7 +28230,7 @@
<js>"</div>"</js>
}
)
- <jk>public class</jk> RootResources <jk>extends</jk> BasicSpringRestServletGroup <jk>implements</jk> BasicUniversalConfig {
+ <jk>public class</jk> RootResources <jk>extends</jk> BasicSpringRestServletGroup {
<jk>private static final long</jk> <jsf>serialVersionUID</jsf> = 1L;
}
</p>
@@ -28333,7 +28330,7 @@
},
stylesheet=<js>"servlet:/htdocs/themes/dark.css"</js> <jc>// Use dark theme by default.</jc>
)
- <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestObject <jk>implements</jk> BasicUniversalConfig, PetStore {
+ <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestObject <jk>implements</jk> PetStore {
<ja>@Autowired</ja>
<jk>private</jk> PetStoreService <jf>store</jf>;
@@ -36633,14 +36630,13 @@
processors, serializers/parsers, JSON schema generators, statistics gathering stores, and default request attributes/headers and response
headers.
<li>
- Defining REST resources with predefined marshalling support is now much simpler. You now extend from a basic REST servlet/object
- class and then include an interface with predefined common annotations.
+ Defining REST resources with predefined marshalling support is now much simpler. You now extend from a basic REST servlet/object.
<p class='bcode'>
<jc>// A root resource that supports JSON/HTML marshalling.</jc>
- <jk>public class</jk> MyRootResources <jk>extends</jk> BasicRestServletGroup <jk>implements</jk> BasicJsonHtmlConfig { ... }
+ <jk>public class</jk> MyRootResources <jk>extends</jk> BasicRestServletGroup { ... }
<jc>// A child resource that supports all available marshalling.</jc>
- <jk>public class</jk> MyChildResource <jk>extends</jk> BasicRestObject <jk>implements</jk> BasicUniversalConfig { ... }
+ <jk>public class</jk> MyChildResource <jk>extends</jk> BasicRestObject { ... }
</p>
REST servlets/objects are in the {@link org.apache.juneau.rest.servlet} package and REST configs are in the {@link org.apache.juneau.rest.config} package.
<li>
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/dto/JsonSchemaResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/dto/JsonSchemaResource.java
index a1c0f8dd4..cee6183a2 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/dto/JsonSchemaResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/dto/JsonSchemaResource.java
@@ -52,7 +52,6 @@ import org.apache.juneau.rest.widget.*;
"api: servlet:/api",
"stats: servlet:/stats",
"$W{ContentTypeMenuItem}",
- "$W{ThemeMenuItem}",
"source: $C{Source/gitHub}/org/apache/juneau/examples/rest/dto/JsonSchemaResource.java"
},
aside={
diff --git a/juneau-rest/juneau-rest-server-springboot/src/main/java/org/apache/juneau/rest/springboot/BasicSpringRestServlet.java b/juneau-rest/juneau-rest-server-springboot/src/main/java/org/apache/juneau/rest/springboot/BasicSpringRestServlet.java
index 4cc4824d7..b46c83f42 100644
--- a/juneau-rest/juneau-rest-server-springboot/src/main/java/org/apache/juneau/rest/springboot/BasicSpringRestServlet.java
+++ b/juneau-rest/juneau-rest-server-springboot/src/main/java/org/apache/juneau/rest/springboot/BasicSpringRestServlet.java
@@ -31,7 +31,7 @@ import org.apache.juneau.rest.stats.*;
* Meant as base class for top-level REST resources in Spring Boot environments.
*
* <p>
- * Provides support for JSON, XML, HTML, URL-Encoding, UON, XML, and MessagePack. See {@link BasicUniversalConfig}
+ * Provides support for JSON, XML, HTML, URL-Encoding, UON, XML, OpenAPI, and MessagePack. See {@link BasicUniversalConfig}
* for details.
*
* <p>
diff --git a/juneau-rest/juneau-rest-server-springboot/src/main/java/org/apache/juneau/rest/springboot/BasicSpringRestServletGroup.java b/juneau-rest/juneau-rest-server-springboot/src/main/java/org/apache/juneau/rest/springboot/BasicSpringRestServletGroup.java
index d2736229e..577b8feb8 100644
--- a/juneau-rest/juneau-rest-server-springboot/src/main/java/org/apache/juneau/rest/springboot/BasicSpringRestServletGroup.java
+++ b/juneau-rest/juneau-rest-server-springboot/src/main/java/org/apache/juneau/rest/springboot/BasicSpringRestServletGroup.java
@@ -25,7 +25,7 @@ import org.apache.juneau.rest.servlet.*;
* Meant as a base class for top-level REST resources in Spring Boot environments.
*
* <p>
- * Provides support for JSON, XML, HTML, URL-Encoding, UON, XML, and MessagePack. See {@link BasicUniversalConfig}
+ * Provides support for JSON, XML, HTML, URL-Encoding, UON, XML, OpenAPI, and MessagePack. See {@link BasicUniversalConfig}
* for details.
*
* <p>
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDestroy.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDestroy.java
index 4f1c9cc3f..e5ecc4a4b 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDestroy.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDestroy.java
@@ -20,7 +20,6 @@ import java.lang.annotation.*;
import javax.servlet.*;
import org.apache.juneau.rest.*;
-import org.apache.juneau.rest.servlet.*;
/**
* Identifies a method that gets called during servlet destroy.
@@ -65,15 +64,6 @@ import org.apache.juneau.rest.servlet.*;
* Note that if you override a parent method, you probably need to call <code><jk>super</jk>.parentMethod(...)</code>.
* <br>The method is still considered part of the parent class for ordering purposes even though it's
* overridden by the child class.
- * <li class='note'>
- * The {@link RestServlet} class itself implements a method annotated with this annotation
- * that can be overridden directly:
- * <ul class='javatree'>
- * <li class='jac'>{@link RestServlet}
- * <ul>
- * <li class='jm'>{@link RestServlet#onDestroy(RestContext) onDestroy(RestContext)}
- * </ul>
- * </ul>
* </ul>
*
* <ul class='seealso'>
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestEndCall.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestEndCall.java
index bcb9f8ff5..5d5bfc77b 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestEndCall.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestEndCall.java
@@ -19,8 +19,6 @@ import java.lang.annotation.*;
import javax.servlet.http.*;
-import org.apache.juneau.rest.servlet.*;
-
/**
* Identifies a method that gets called right before we exit the servlet service method.
*
@@ -79,15 +77,6 @@ import org.apache.juneau.rest.servlet.*;
* Note that if you override a parent method, you probably need to call <code><jk>super</jk>.parentMethod(...)</code>.
* <br>The method is still considered part of the parent class for ordering purposes even though it's
* overridden by the child class.
- * <li class='note'>
- * The {@link RestServlet} class itself implements a convenience method annotated with this annotation
- * that can be overridden directly:
- * <ul class='javatree'>
- * <li class='jac'>{@link RestServlet}
- * <ul>
- * <li class='jm'>{@link RestServlet#onEndCall(HttpServletRequest,HttpServletResponse) onEndCall(HttpServletRequest,HttpServletResponse)}
- * </ul>
- * </ul>
* </ul>
*
* <ul class='seealso'>
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestInit.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestInit.java
index e6f92a5f2..89b3800c6 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestInit.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestInit.java
@@ -20,7 +20,6 @@ import java.lang.annotation.*;
import javax.servlet.*;
import org.apache.juneau.rest.*;
-import org.apache.juneau.rest.servlet.*;
/**
* Identifies a method that gets called during servlet initialization.
@@ -70,15 +69,6 @@ import org.apache.juneau.rest.servlet.*;
* Note that if you override a parent method, you probably need to call <code><jk>super</jk>.parentMethod(...)</code>.
* <br>The method is still considered part of the parent class for ordering purposes even though it's
* overridden by the child class.
- * <li class='note'>
- * The {@link RestServlet} class itself implements the following convenience method annotated with this annotation
- * that can be overridden directly:
- * <ul class='javatree'>
- * <li class='jac'>{@link RestServlet}
- * <ul>
- * <li class='jm'>{@link RestServlet#onInit(RestContext.Builder) onInit(RestContext.Builder)}
- * </ul>
- * </ul>
* </ul>
*
* <ul class='seealso'>
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPostCall.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPostCall.java
index 5621a7e90..480991dce 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPostCall.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPostCall.java
@@ -30,7 +30,6 @@ import org.apache.juneau.http.header.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.converter.*;
import org.apache.juneau.rest.httppart.*;
-import org.apache.juneau.rest.servlet.*;
/**
* Identifies a method that gets called immediately after the <ja>@RestOp</ja> annotated method gets called.
@@ -140,15 +139,6 @@ import org.apache.juneau.rest.servlet.*;
* Note that if you override a parent method, you probably need to call <code><jk>super</jk>.parentMethod(...)</code>.
* <br>The method is still considered part of the parent class for ordering purposes even though it's
* overridden by the child class.
- * <li class='note'>
- * The {@link RestServlet} class itself implements a convenience method annotated with this annotation
- * that can be overridden directly:
- * <ul class='javatree'>
- * <li class='jac'>{@link RestServlet}
- * <ul>
- * <li class='jm'>{@link RestServlet#onPostCall(RestRequest,RestResponse) onPostCall(RestRequest,RestResponse)}
- * </ul>
- * </ul>
* </ul>
*
* <ul class='seealso'>
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPostInit.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPostInit.java
index 7b13935e0..8de2ce955 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPostInit.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPostInit.java
@@ -20,7 +20,6 @@ import java.lang.annotation.*;
import javax.servlet.*;
import org.apache.juneau.rest.*;
-import org.apache.juneau.rest.servlet.*;
/**
* Identifies a method that gets called immediately after servlet initialization.
@@ -50,16 +49,6 @@ import org.apache.juneau.rest.servlet.*;
* Note that if you override a parent method, you probably need to call <code><jk>super</jk>.parentMethod(...)</code>.
* <br>The method is still considered part of the parent class for ordering purposes even though it's
* overridden by the child class.
- * <li class='note'>
- * The {@link RestServlet} class itself implements the following convenience methods annotated with this annotation
- * that can be overridden directly:
- * <ul class='javatree'>
- * <li class='jac'>{@link RestServlet}
- * <ul>
- * <li class='jm'>{@link RestServlet#onPostInit(RestContext) onPostInit(RestContext)}
- * <li class='jm'>{@link RestServlet#onPostInitChildFirst(RestContext) onPostInitChildFirst(RestContext)}
- * </ul>
- * </ul>
* </ul>
*/
@Target({METHOD,TYPE})
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPreCall.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPreCall.java
index 52c4a9b60..fafcd2187 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPreCall.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPreCall.java
@@ -32,7 +32,6 @@ import org.apache.juneau.rest.*;
import org.apache.juneau.rest.guard.*;
import org.apache.juneau.rest.httppart.*;
import org.apache.juneau.rest.matcher.*;
-import org.apache.juneau.rest.servlet.*;
/**
* Identifies a method that gets called immediately before the <ja>@RestOp</ja> annotated method gets called.
@@ -147,15 +146,6 @@ import org.apache.juneau.rest.servlet.*;
* <li class='note'>
* It's advisable not to mess around with the HTTP content itself since you may end up consuming the content
* before the actual REST method has a chance to use it.
- * <li class='note'>
- * The {@link RestServlet} class itself implements a convenience method annotated with this annotation
- * that can be overridden directly:
- * <ul class='javatree'>
- * <li class='jac'>{@link RestServlet}
- * <ul>
- * <li class='jm'>{@link RestServlet#onPreCall(RestRequest,RestResponse) onPreCall(RestRequest,RestResponse)}
- * </ul>
- * </ul>
* </ul>
*
* <ul class='seealso'>
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestStartCall.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestStartCall.java
index d9b08984c..223f39e0e 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestStartCall.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestStartCall.java
@@ -20,7 +20,6 @@ import java.lang.annotation.*;
import javax.servlet.http.*;
import org.apache.juneau.http.response.*;
-import org.apache.juneau.rest.servlet.*;
/**
* Identifies a method that is called immediately after the <c>HttpServlet.service(HttpServletRequest, HttpServletResponse)</c>
@@ -71,15 +70,6 @@ import org.apache.juneau.rest.servlet.*;
* Note that if you override a parent method, you probably need to call <code><jk>super</jk>.parentMethod(...)</code>.
* <br>The method is still considered part of the parent class for ordering purposes even though it's
* overridden by the child class.
- * <li class='note'>
- * The {@link RestServlet} class itself implements a convenience method annotated with this annotation
- * that can be overridden directly:
- * <ul class='javatree'>
- * <li class='jac'>{@link RestServlet}
- * <ul>
- * <li class='jm'>{@link RestServlet#onStartCall(HttpServletRequest,HttpServletResponse) onStartCall(HttpServletRequest,HttpServletResponse)}
- * </ul>
- * </ul>
* </ul>
*
* <ul class='seealso'>
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/BasicRestObject.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/BasicRestObject.java
index 3f88502b9..cbcaf542c 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/BasicRestObject.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/BasicRestObject.java
@@ -32,7 +32,7 @@ import org.apache.juneau.http.response.*;
* Meant as a base class for child REST resources in servlet containers and Spring Boot environments.
*
* <p>
- * Provides support for JSON, XML, HTML, URL-Encoding, UON, XML, and MessagePack. See {@link BasicUniversalConfig}
+ * Provides support for JSON, XML, HTML, URL-Encoding, UON, XML, OpenAPI, and MessagePack. See {@link BasicUniversalConfig}
* for details.
*
* <p>
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/BasicRestObjectGroup.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/BasicRestObjectGroup.java
index 03b6e0b0b..08ed3183a 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/BasicRestObjectGroup.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/BasicRestObjectGroup.java
@@ -26,7 +26,7 @@ import org.apache.juneau.rest.config.*;
* Meant as a base class for child REST resources in servlet containers or Spring Boot environments.
*
* <p>
- * Provides support for JSON, XML, HTML, URL-Encoding, UON, XML, and MessagePack. See {@link BasicUniversalConfig}
+ * Provides support for JSON, XML, HTML, URL-Encoding, UON, XML, OpenAPI, and MessagePack. See {@link BasicUniversalConfig}
* for details.
*
* <p>
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/BasicRestServlet.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/BasicRestServlet.java
index 74b39cd2f..57630a948 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/BasicRestServlet.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/BasicRestServlet.java
@@ -30,7 +30,7 @@ import org.apache.juneau.rest.stats.*;
* Meant as a base class for top-level REST resources in servlet containers.
*
* <p>
- * Provides support for JSON, XML, HTML, URL-Encoding, UON, XML, and MessagePack. See {@link BasicUniversalConfig}
+ * Provides support for JSON, XML, HTML, URL-Encoding, UON, XML, OpenAPI, and MessagePack. See {@link BasicUniversalConfig}
* for details.
*
* <p>
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/BasicRestServletGroup.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/BasicRestServletGroup.java
index 046471922..3ea2a808a 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/BasicRestServletGroup.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/BasicRestServletGroup.java
@@ -24,7 +24,7 @@ import org.apache.juneau.rest.config.*;
* Meant as a base class for top-level REST resources in servlet containers.
*
* <p>
- * Provides support for JSON, XML, HTML, URL-Encoding, UON, XML, and MessagePack. See {@link BasicUniversalConfig}
+ * Provides support for JSON, XML, HTML, URL-Encoding, UON, XML, OpenAPI, and MessagePack. See {@link BasicUniversalConfig}
* for details.
*
* <p>
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/RestObject.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/RestObject.java
index d258fef20..fd998812f 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/RestObject.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/RestObject.java
@@ -25,10 +25,6 @@ import javax.servlet.http.*;
import org.apache.juneau.http.response.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.rest.*;
-import org.apache.juneau.rest.annotation.*;
-import org.apache.juneau.rest.converter.*;
-import org.apache.juneau.rest.guard.*;
-import org.apache.juneau.rest.matcher.*;
/**
* Identical to {@link RestServlet} but doesn't extend from {@link HttpServlet}.
@@ -75,31 +71,6 @@ public abstract class RestObject {
// Convenience logger methods
//-----------------------------------------------------------------------------------------------------------------
- /**
- * Log a message at {@link Level#INFO} level.
- *
- * <p>
- * Subclasses can intercept the handling of these messages by overriding {@link #doLog(Level, Throwable, Supplier)}.
- *
- * @param msg The message to log.
- */
- public void log(String msg) {
- doLog(Level.INFO, null, () -> msg);
- }
-
- /**
- * Log a message.
- *
- * <p>
- * Subclasses can intercept the handling of these messages by overriding {@link #doLog(Level, Throwable, Supplier)}.
- *
- * @param msg The message to log.
- * @param cause The cause.
- */
- public void log(String msg, Throwable cause) {
- doLog(Level.INFO, null, () -> msg);
- }
-
/**
* Log a message.
*
@@ -150,296 +121,23 @@ public abstract class RestObject {
logger.log(level, cause, msg);
}
- //-----------------------------------------------------------------------------------------------------------------
- // Hook events
- //-----------------------------------------------------------------------------------------------------------------
-
- /**
- * Method that gets called during servlet initialization.
- *
- * <p>
- * This method is called from within the {@link Servlet#init(ServletConfig)} method after the {@link org.apache.juneau.rest.RestContext.Builder}
- * object has been created and initialized with the annotations defined on the class, but before the
- * {@link RestContext} object has been created.
- *
- * <p>
- * An example of this is the <c>PetStoreResource</c> class that uses an init method to perform initialization
- * of an internal data structure.
- *
- * <h5 class='figure'>Example:</h5>
- * <p class='bjava'>
- * <ja>@Rest</ja>(...)
- * <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalJenaConfig {
- *
- * <jc>// Our database.</jc>
- * <jk>private</jk> Map<Integer,Pet> <jf>petDB</jf>;
- *
- * <ja>@Override</ja>
- * <jk>public void</jk> onInit(RestContext.Builder <jv>builder</jv>) <jk>throws</jk> Exception {
- * <jc>// Load our database from a local JSON file.</jc>
- * <jf>petDB</jf> = JsonParser.<jsf>DEFAULT</jsf>.parse(getClass().getResourceAsStream(<js>"PetStore.json"</js>), LinkedHashMap.<jk>class</jk>, Integer.<jk>class</jk>, Pet.<jk>class</jk>);
- * }
- * }
- * </p>
- *
- * <ul class='notes'>
- * <li class='note'>
- * The default implementation of this method is a no-op.
- * <li class='note'>
- * Multiple init methods can be defined on a class.
- * <br>Init methods on parent classes are invoked before init methods on child classes.
- * <br>The order of init method invocations within a class is alphabetical, then by parameter count, then by parameter types.
- * <li class='note'>
- * The method can throw any exception causing initialization of the servlet to fail.
- * </ul>
- *
- * @param builder Context builder which can be used to configure the servlet.
- * @throws Exception Any exception thrown will cause servlet to fail startup.
- */
- @RestInit
- public void onInit(RestContext.Builder builder) throws Exception {}
-
- /**
- * Method that gets called immediately after servlet initialization.
- *
- * <p>
- * This method is called from within the {@link Servlet#init(ServletConfig)} method after the {@link RestContext}
- * object has been created.
- *
- * <ul class='notes'>
- * <li class='note'>
- * The default implementation of this method is a no-op.
- * <li class='note'>
- * Multiple post-init methods can be defined on a class.
- * <br>Post-init methods on parent classes are invoked before post-init methods on child classes.
- * <br>The order of post-init method invocations within a class is alphabetical, then by parameter count, then by parameter types.
- * <li class='note'>
- * The method can throw any exception causing initialization of the servlet to fail.
- * </ul>
- *
- * @param context The initialized context object.
- * @throws Exception Any exception thrown will cause servlet to fail startup.
- */
- @RestPostInit
- public void onPostInit(RestContext context) throws Exception {}
-
- /**
- * Identical to {@link #onPostInit(RestContext)} except the order of execution is child-resources first.
- *
- * <p>
- * Use this method if you need to perform any kind of initialization on child resources before the parent resource.
- *
- * <p>
- * This method is called from within the {@link Servlet#init(ServletConfig)} method after the {@link RestContext}
- * object has been created and after the child-last {@link RestPostInit} methods have been called.
- *
- * <p>
- * The only valid parameter type for this method is {@link RestContext} which can be used to retrieve information
- * about the servlet.
- *
- * <ul class='notes'>
- * <li class='note'>
- * The default implementation of this method is a no-op.
- * <li class='note'>
- * Multiple post-init methods can be defined on a class.
- * <br>Post-init methods on parent classes are invoked before post-init methods on child classes.
- * <br>The order of post-init method invocations within a class is alphabetical, then by parameter count, then by parameter types.
- * <li class='note'>
- * The method can throw any exception causing initialization of the servlet to fail.
- * </ul>
- *
- * @param context The initialized context object.
- * @throws Exception Any exception thrown will cause servlet to fail startup.
- */
- @RestPostInit(childFirst=true)
- public void onPostInitChildFirst(RestContext context) throws Exception {}
-
- /**
- * Method that gets called during servlet destroy.
- *
- * <p>
- * This method is called from within the {@link Servlet#destroy()}.
- *
- * <h5 class='figure'>Example:</h5>
- * <p class='bjava'>
- * <ja>@Rest</ja>(...)
- * <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalJenaConfig {
- *
- * <jc>// Our database.</jc>
- * <jk>private</jk> Map<Integer,Pet> <jf>petDB</jf>;
- *
- * <ja>@Override</ja>
- * <jk>public void</jk> onDestroy(RestContext <jv>context</jv>) {
- * <jf>petDB</jf> = <jk>null</jk>;
- * }
- * }
- * </p>
- *
- * <ul class='notes'>
- * <li class='note'>
- * The default implementation of this method is a no-op.
- * <li class='note'>
- * Multiple destroy methods can be defined on a class.
- * <br>Destroy methods on child classes are invoked before destroy methods on parent classes.
- * <br>The order of destroy method invocations within a class is alphabetical, then by parameter count, then by parameter types.
- * <li class='note'>
- * In general, destroy methods should not throw any exceptions, although if any are thrown, the stack trace will be
- * printed to <c>System.err</c>.
- * </ul>
- *
- * @param context The initialized context object.
- * @throws Exception Any exception thrown will cause stack trace to be printed to <c>System.err</c>.
- */
- @RestDestroy
- public void onDestroy(RestContext context) throws Exception {}
-
- /**
- * A method that is called immediately after the <c>HttpServlet.service(HttpServletRequest, HttpServletResponse)</c>
- * method is called.
- *
- * <p>
- * Note that you only have access to the raw request and response objects at this point.
- *
- * <h5 class='figure'>Example:</h5>
- * <p class='bjava'>
- * <ja>@Rest</ja>(...)
- * <jk>public class</jk> MyResource <jk>extends</jk> BasicRestServlet <jk>implements</jk> BasicUniversalConfig {
- *
- * <jc>// Add a request attribute to all incoming requests.</jc>
- * <ja>@Override</ja>
- * <jk>public void</jk> onStartCall(HttpServletRequest <jv>req</jv>, HttpServletResponse <jv>res</jv>) {
- * <jv>req</jv>.setAttribute(<js>"foobar"</js>, <jk>new</jk> FooBar());
- * }
- * }
- * </p>
- *
- * <ul class='notes'>
- * <li class='note'>
- * The default implementation of this method is a no-op.
- * <li class='note'>
- * Multiple start-call methods can be defined on a class.
- * <br>start-call methods on parent classes are invoked before start-call methods on child classes.
- * <br>The order of start-call method invocations within a class is alphabetical, then by parameter count, then by parameter types.
- * <li class='note'>
- * The method can throw any exception.
- * <br>{@link BasicHttpException HttpExceptions} can be thrown to cause a particular HTTP error status code.
- * <br>All other exceptions cause an HTTP 500 error status code.
- * </ul>
- *
- * @param req The HTTP servlet request object.
- * @param res The HTTP servlet response object.
- * @throws Exception Any exception.
- */
- @RestStartCall
- public void onStartCall(HttpServletRequest req, HttpServletResponse res) throws Exception {}
-
- /**
- * Method that gets called immediately before the <ja>@RestOp</ja> annotated method gets called.
- *
- * <p>
- * At this point, the {@link RestRequest} object has been fully initialized, and all {@link RestGuard} and
- * {@link RestMatcher} objects have been called.
- *
- * <ul class='notes'>
- * <li class='note'>
- * The default implementation of this method is a no-op.
- * <li class='note'>
- * Multiple pre-call methods can be defined on a class.
- * <br>Pre-call methods on parent classes are invoked before pre-call methods on child classes.
- * <br>The order of pre-call method invocations within a class is alphabetical, then by parameter count, then by parameter types.
- * <li class='note'>
- * The method can throw any exception.
- * <br>{@link BasicHttpException HttpExceptions} can be thrown to cause a particular HTTP error status code.
- * <br>All other exceptions cause an HTTP 500 error status code.
- * <li class='note'>
- * It's advisable not to mess around with the HTTP content itself since you may end up consuming the content
- * before the actual REST method has a chance to use it.
- * </ul>
- *
- * @param req The request object.
- * @param res The response object.
- * @throws Exception Any exception.
- */
- @RestPreCall
- public void onPreCall(RestRequest req, RestResponse res) throws Exception {}
-
- /**
- * Method that gets called immediately after the <ja>@RestOp</ja> annotated method gets called.
- *
- * <p>
- * At this point, the output object returned by the method call has been set on the response, but
- * {@link RestConverter RestConverters} have not yet been executed and the response has not yet been written.
- *
- * <ul class='notes'>
- * <li class='note'>
- * The default implementation of this method is a no-op.
- * <li class='note'>
- * Multiple post-call methods can be defined on a class.
- * <br>post-call methods on parent classes are invoked before post-call methods on child classes.
- * <br>The order of post-call method invocations within a class is alphabetical, then by parameter count, then by parameter types.
- * <li class='note'>
- * The method can throw any exception, although at this point it is too late to set an HTTP error status code.
- * </ul>
- *
- * @param req The request object.
- * @param res The response object.
- * @throws Exception Any exception.
- */
- @RestPostCall
- public void onPostCall(RestRequest req, RestResponse res) throws Exception {}
-
- /**
- * Method that gets called right before we exit the servlet service method.
- *
- * <p>
- * At this point, the output has been written and flushed.
- *
- * <p>
- * The following attributes are set on the {@link HttpServletRequest} object that can be useful for logging purposes:
- * <ul>
- * <li><js>"Exception"</js> - Any exceptions thrown during the request.
- * <li><js>"ExecTime"</js> - Execution time of the request.
- * </ul>
- *
- * <ul class='notes'>
- * <li class='note'>
- * The default implementation of this method is a no-op.
- * <li class='note'>
- * Multiple end-call methods can be defined on a class.
- * <br>end-call methods on parent classes are invoked before end-call methods on child classes.
- * <br>The order of end-call method invocations within a class is alphabetical, then by parameter count, then by parameter types.
- * <li class='note'>
- * The method can throw any exception, although at this point it is too late to set an HTTP error status code.
- * <li class='note'>
- * Note that if you override a parent method, you probably need to call <code><jk>super</jk>.parentMethod(...)</code>.
- * <br>The method is still considered part of the parent class for ordering purposes even though it's
- * overridden by the child class.
- * </ul>
- *
- * @param req The HTTP servlet request object.
- * @param res The HTTP servlet response object.
- * @throws Exception Any exception.
- */
- @RestEndCall
- public void onEndCall(HttpServletRequest req, HttpServletResponse res) throws Exception {}
-
//-----------------------------------------------------------------------------------------------------------------
// Other methods
//-----------------------------------------------------------------------------------------------------------------
/**
- * Returns the current HTTP request.
+ * Returns the current thread-local HTTP request.
*
- * @return The current HTTP request, or <jk>null</jk> if it wasn't created.
+ * @return The current thread-local HTTP request, or <jk>null</jk> if it wasn't created.
*/
public synchronized RestRequest getRequest() {
return getContext().getLocalSession().getOpSession().getRequest();
}
/**
- * Returns the current HTTP response.
+ * Returns the current thread-local HTTP response.
*
- * @return The current HTTP response, or <jk>null</jk> if it wasn't created.
+ * @return The current thread-local HTTP response, or <jk>null</jk> if it wasn't created.
*/
public synchronized RestResponse getResponse() {
return getContext().getLocalSession().getOpSession().getResponse();
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/RestServlet.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/RestServlet.java
index c69079834..760f37a97 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/RestServlet.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/RestServlet.java
@@ -29,9 +29,6 @@ import org.apache.juneau.internal.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
-import org.apache.juneau.rest.converter.*;
-import org.apache.juneau.rest.guard.*;
-import org.apache.juneau.rest.matcher.*;
import org.apache.juneau.*;
import org.apache.juneau.http.response.*;
@@ -108,7 +105,8 @@ public abstract class RestServlet extends HttpServlet {
}
/**
- * Returns the path defined on this servlet if it's defined via {@link Rest#path()}.
+ * Returns the path for this resource as defined by the @Rest(path) annotation or RestContext.Builder.path(String) method
+ * concatenated with those on all parent classes.
*
* @return The path defined on this servlet, or an empty string if not specified.
*/
@@ -184,33 +182,6 @@ public abstract class RestServlet extends HttpServlet {
// Convenience logger methods
//-----------------------------------------------------------------------------------------------------------------
- /**
- * Log a message at {@link Level#INFO} level.
- *
- * <p>
- * Subclasses can intercept the handling of these messages by overriding {@link #doLog(Level, Throwable, Supplier)}.
- *
- * @param msg The message to log.
- */
- @Override /* GenericServlet */
- public void log(String msg) {
- doLog(Level.INFO, null, () -> msg);
- }
-
- /**
- * Log a message.
- *
- * <p>
- * Subclasses can intercept the handling of these messages by overriding {@link #doLog(Level, Throwable, Supplier)}.
- *
- * @param msg The message to log.
- * @param cause The cause.
- */
- @Override /* GenericServlet */
- public void log(String msg, Throwable cause) {
- doLog(Level.INFO, null, () -> msg);
- }
-
/**
* Log a message.
*
@@ -261,302 +232,23 @@ public abstract class RestServlet extends HttpServlet {
logger.log(level, cause, msg);
}
- //-----------------------------------------------------------------------------------------------------------------
- // Hook events
- //-----------------------------------------------------------------------------------------------------------------
-
- /**
- * Method that gets called during servlet initialization.
- *
- * <p>
- * This method is called from within the {@link Servlet#init(ServletConfig)} method after the {@link org.apache.juneau.rest.RestContext.Builder}
- * object has been created and initialized with the annotations defined on the class, but before the
- * {@link RestContext} object has been created.
- *
- * <p>
- * An example of this is the <c>PetStoreResource</c> class that uses an init method to perform initialization
- * of an internal data structure.
- *
- * <h5 class='figure'>Example:</h5>
- * <p class='bjava'>
- * <ja>@Rest</ja>(...)
- * <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestServlet {
- *
- * <jc>// Our database.</jc>
- * <jk>private</jk> Map<Integer,Pet> <jf>petDB</jf>;
- *
- * <ja>@Override</ja>
- * <jk>public void</jk> onInit(RestContext.Builder <jv>builder</jv>) <jk>throws</jk> Exception {
- * <jc>// Load our database from a local JSON file.</jc>
- * <jf>petDB</jf> = JsonParser.<jsf>DEFAULT</jsf>
- * .parse(
- * getClass().getResourceAsStream(<js>"PetStore.json"</js>),
- * LinkedHashMap.<jk>class</jk>,
- * Integer.<jk>class</jk>,
- * Pet.<jk>class</jk>
- * );
- * }
- * }
- * </p>
- *
- * <ul class='notes'>
- * <li class='note'>
- * The default implementation of this method is a no-op.
- * <li>
- * Multiple init methods can be defined on a class.
- * <br>Init methods on parent classes are invoked before init methods on child classes.
- * <br>The order of init method invocations within a class is alphabetical, then by parameter count, then by parameter types.
- * <li>
- * The method can throw any exception causing initialization of the servlet to fail.
- * </ul>
- *
- * @param builder Context builder which can be used to configure the servlet.
- * @throws Exception Any exception thrown will cause servlet to fail startup.
- */
- @RestInit
- public void onInit(RestContext.Builder builder) throws Exception {}
-
- /**
- * Method that gets called immediately after servlet initialization.
- *
- * <p>
- * This method is called from within the {@link Servlet#init(ServletConfig)} method after the {@link RestContext}
- * object has been created.
- *
- * <ul class='notes'>
- * <li class='note'>
- * The default implementation of this method is a no-op.
- * <li class='note'>
- * Multiple post-init methods can be defined on a class.
- * <br>post-init methods on parent classes are invoked before post-init methods on child classes.
- * <br>The order of post-init method invocations within a class is alphabetical, then by parameter count, then by parameter types.
- * <li class='note'>
- * The method can throw any exception causing initialization of the servlet to fail.
- * </ul>
- *
- * @param context The initialized context object.
- * @throws Exception Any exception thrown will cause servlet to fail startup.
- */
- @RestPostInit
- public void onPostInit(RestContext context) throws Exception {}
-
- /**
- * Identical to {@link #onPostInit(RestContext)} except the order of execution is child-resources first.
- *
- * <p>
- * Use this method if you need to perform any kind of initialization on child resources before the parent resource.
- *
- * <p>
- * This method is called from within the {@link Servlet#init(ServletConfig)} method after the {@link RestContext}
- * object has been created and after the child-last {@link RestPostInit} methods have been called.
- *
- * <p>
- * The only valid parameter type for this method is {@link RestContext} which can be used to retrieve information
- * about the servlet.
- *
- * <ul class='notes'>
- * <li class='note'>
- * The default implementation of this method is a no-op.
- * <li class='note'>
- * Multiple POST_INIT_CHILD_FIRST methods can be defined on a class.
- * <br>POST_INIT_CHILD_FIRST methods on parent classes are invoked before POST_INIT_CHILD_FIRST methods on child classes.
- * <br>The order of POST_INIT_CHILD_FIRST method invocations within a class is alphabetical, then by parameter count, then by parameter types.
- * <li class='note'>
- * The method can throw any exception causing initialization of the servlet to fail.
- * </ul>
- *
- * @param context The initialized context object.
- * @throws Exception Any exception thrown will cause servlet to fail startup.
- */
- @RestPostInit(childFirst=true)
- public void onPostInitChildFirst(RestContext context) throws Exception {}
-
- /**
- * Method that gets called during servlet destroy.
- *
- * <p>
- * This method is called from within the {@link Servlet#destroy()}.
- *
- * <h5 class='figure'>Example:</h5>
- * <p class='bjava'>
- * <ja>@Rest</ja>(...)
- * <jk>public class</jk> PetStoreResource <jk>extends</jk> BasicRestServlet {
- *
- * <jc>// Our database.</jc>
- * <jk>private</jk> Map<Integer,Pet> <jf>petDB</jf>;
- *
- * <ja>@Override</ja>
- * <jk>public void</jk> onDestroy(RestContext <jv>context</jv>) {
- * <jf>petDB</jf> = <jk>null</jk>;
- * }
- * }
- * </p>
- *
- * <ul class='notes'>
- * <li class='note'>
- * The default implementation of this method is a no-op.
- * <li class='note'>
- * Multiple destroy methods can be defined on a class.
- * <br>Destroy methods on child classes are invoked before destroy methods on parent classes.
- * <br>The order of destroy method invocations within a class is alphabetical, then by parameter count, then by parameter types.
- * <li class='note'>
- * In general, destroy methods should not throw any exceptions, although if any are thrown, the stack trace will be
- * printed to <c>System.err</c>.
- * </ul>
- *
- * @param context The initialized context object.
- * @throws Exception Any exception thrown will cause stack trace to be printed to <c>System.err</c>.
- */
- @RestDestroy
- public void onDestroy(RestContext context) throws Exception {}
-
- /**
- * A method that is called immediately after the <c>HttpServlet.service(HttpServletRequest, HttpServletResponse)</c>
- * method is called.
- *
- * <p>
- * Note that you only have access to the raw request and response objects at this point.
- *
- * <h5 class='figure'>Example:</h5>
- * <p class='bjava'>
- * <ja>@Rest</ja>(...)
- * <jk>public class</jk> MyResource <jk>extends</jk> BasicRestServlet {
- *
- * <jc>// Add a request attribute to all incoming requests.</jc>
- * <ja>@Override</ja>
- * <jk>public void</jk> onStartCall(HttpServletRequest <jv>req</jv>, HttpServletResponse <jv>res</jv>) {
- * <jv>req</jv>.setAttribute(<js>"foobar"</js>, <jk>new</jk> FooBar());
- * }
- * }
- * </p>
- *
- * <ul class='notes'>
- * <li class='note'>
- * The default implementation of this method is a no-op.
- * <li class='note'>
- * Multiple start-call methods can be defined on a class.
- * <br>Start-call methods on parent classes are invoked before start-call methods on child classes.
- * <br>The order of start-call method invocations within a class is alphabetical, then by parameter count, then by parameter types.
- * <li class='note'>
- * The method can throw any exception.
- * <br>{@link BasicHttpException HttpExceptions} can be thrown to cause a particular HTTP error status code.
- * <br>All other exceptions cause an HTTP 500 error status code.
- * </ul>
- *
- * @param req The HTTP servlet request object.
- * @param res The HTTP servlet response object.
- * @throws Exception Any exception.
- */
- @RestStartCall
- public void onStartCall(HttpServletRequest req, HttpServletResponse res) throws Exception {}
-
- /**
- * Method that gets called immediately before the <ja>@RestOp</ja> annotated method gets called.
- *
- * <p>
- * At this point, the {@link RestRequest} object has been fully initialized, and all {@link RestGuard} and
- * {@link RestMatcher} objects have been called.
- *
- * <ul class='notes'>
- * <li class='note'>
- * The default implementation of this method is a no-op.
- * <li class='note'>
- * Multiple pre-call methods can be defined on a class.
- * <br>Pre-call methods on parent classes are invoked before pre-call methods on child classes.
- * <br>The order of pre-call method invocations within a class is alphabetical, then by parameter count, then by parameter types.
- * <li class='note'>
- * The method can throw any exception.
- * <br>{@link BasicHttpException HttpExceptions} can be thrown to cause a particular HTTP error status code.
- * <br>All other exceptions cause an HTTP 500 error status code.
- * <li class='note'>
- * It's advisable not to mess around with the HTTP content itself since you may end up consuming the content
- * before the actual REST method has a chance to use it.
- * </ul>
- *
- * @param req The request object.
- * @param res The response object.
- * @throws Exception Any exception.
- */
- @RestPreCall
- public void onPreCall(RestRequest req, RestResponse res) throws Exception {}
-
- /**
- * Method that gets called immediately after the <ja>@RestOp</ja> annotated method gets called.
- *
- * <p>
- * At this point, the output object returned by the method call has been set on the response, but
- * {@link RestConverter RestConverters} have not yet been executed and the response has not yet been written.
- *
- * <ul class='notes'>
- * <li class='note'>
- * The default implementation of this method is a no-op.
- * <li class='note'>
- * Multiple post-call methods can be defined on a class.
- * <br>Post-call methods on parent classes are invoked before post-call methods on child classes.
- * <br>The order of post-call method invocations within a class is alphabetical, then by parameter count, then by parameter types.
- * <li class='note'>
- * The method can throw any exception, although at this point it is too late to set an HTTP error status code.
- * </ul>
- *
- * @param req The request object.
- * @param res The response object.
- * @throws Exception Any exception.
- */
- @RestPostCall
- public void onPostCall(RestRequest req, RestResponse res) throws Exception {}
-
- /**
- * Method that gets called right before we exit the servlet service method.
- *
- * <p>
- * At this point, the output has been written and flushed.
- *
- * <p>
- * The following attributes are set on the {@link HttpServletRequest} object that can be useful for logging purposes:
- * <ul>
- * <li><js>"Exception"</js> - Any exceptions thrown during the request.
- * <li><js>"ExecTime"</js> - Execution time of the request.
- * </ul>
- *
- * <ul class='notes'>
- * <li class='note'>
- * The default implementation of this method is a no-op.
- * <li class='note'>
- * Multiple end-call methods can be defined on a class.
- * <br>End-call methods on parent classes are invoked before end-call methods on child classes.
- * <br>The order of end-call method invocations within a class is alphabetical, then by parameter count, then by parameter types.
- * <li class='note'>
- * The method can throw any exception, although at this point it is too late to set an HTTP error status code.
- * <li class='note'>
- * Note that if you override a parent method, you probably need to call <code><jk>super</jk>.parentMethod(...)</code>.
- * <br>The method is still considered part of the parent class for ordering purposes even though it's
- * overridden by the child class.
- * </ul>
- *
- * @param req The HTTP servlet request object.
- * @param res The HTTP servlet response object.
- * @throws Exception Any exception.
- */
- @RestEndCall
- public void onEndCall(HttpServletRequest req, HttpServletResponse res) throws Exception {}
-
//-----------------------------------------------------------------------------------------------------------------
// Other methods
//-----------------------------------------------------------------------------------------------------------------
/**
- * Returns the current HTTP request.
+ * Returns the current thread-local HTTP request.
*
- * @return The current HTTP request, or <jk>null</jk> if it wasn't created.
+ * @return The current thread-local HTTP request, or <jk>null</jk> if it wasn't created.
*/
public synchronized RestRequest getRequest() {
return getContext().getLocalSession().getOpSession().getRequest();
}
/**
- * Returns the current HTTP response.
+ * Returns the current thread-local HTTP response.
*
- * @return The current HTTP response, or <jk>null</jk> if it wasn't created.
+ * @return The current thread-local HTTP response, or <jk>null</jk> if it wasn't created.
*/
public synchronized RestResponse getResponse() {
return getContext().getLocalSession().getOpSession().getResponse();