This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch jbFixRestNpe
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/jbFixRestNpe by this push:
new feca61948 Javadocs
feca61948 is described below
commit feca619481c3d9ad56cd5e84d7a03ad934e89c6a
Author: JamesBognar <[email protected]>
AuthorDate: Mon Aug 8 10:16:18 2022 -0400
Javadocs
---
.../juneau/rest/springboot/SpringRestServlet.java | 2 +-
.../java/org/apache/juneau/rest/RestContext.java | 411 ++++-----------------
.../java/org/apache/juneau/rest/RestOpContext.java | 128 +------
.../annotation/{RestBean.java => RestInject.java} | 26 +-
...anAnnotation.java => RestInjectAnnotation.java} | 36 +-
.../juneau/rest/RestContext_Builder_Test.java | 22 +-
6 files changed, 132 insertions(+), 493 deletions(-)
diff --git
a/juneau-rest/juneau-rest-server-springboot/src/main/java/org/apache/juneau/rest/springboot/SpringRestServlet.java
b/juneau-rest/juneau-rest-server-springboot/src/main/java/org/apache/juneau/rest/springboot/SpringRestServlet.java
index 057df3b74..50e79d16f 100644
---
a/juneau-rest/juneau-rest-server-springboot/src/main/java/org/apache/juneau/rest/springboot/SpringRestServlet.java
+++
b/juneau-rest/juneau-rest-server-springboot/src/main/java/org/apache/juneau/rest/springboot/SpringRestServlet.java
@@ -50,7 +50,7 @@ public abstract class SpringRestServlet extends RestServlet {
* @param parent Optional parent resource.
* @return A BeanStore that retrieves beans from the Spring Boot app
context.
*/
- @RestBean
+ @RestInject
public BeanStore createBeanStore(Optional<BeanStore> parent) {
return new SpringBeanStore(appContext, parent, this);
}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
index 94e899882..5c9fbd567 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
@@ -369,21 +369,21 @@ public class RestContext extends Context {
ClassInfo rci = ClassInfo.of(resourceClass);
- // Get @RestBean fields initialized with values.
+ // Get @RestInject fields initialized with values.
rci.forEachAllField(
- x -> x.hasAnnotation(RestBean.class),
+ x -> x.hasAnnotation(RestInject.class),
x -> x.getOptional(resource.get()).ifPresent(
y -> beanStore.add(
x.getType().inner(),
y,
-
RestBeanAnnotation.name(x.getAnnotation(RestBean.class))
+
RestInjectAnnotation.name(x.getAnnotation(RestInject.class))
)
)
);
- rci.forEachMethod(x -> x.hasAnnotation(RestBean.class),
x -> {
+ rci.forEachMethod(x ->
x.hasAnnotation(RestInject.class), x -> {
Class<Object> rt = x.getReturnType().inner();
- String name =
RestBeanAnnotation.name(x.getAnnotation(RestBean.class));
+ String name =
RestInjectAnnotation.name(x.getAnnotation(RestInject.class));
if (! (DELAYED_INJECTION.contains(rt) ||
DELAYED_INJECTION_NAMES.contains(name))) {
beanStore
.createMethodFinder(rt)
@@ -403,14 +403,14 @@ public class RestContext extends Context {
runInitHooks(bs, resource());
- // Set @RestBean fields not initialized with values.
+ // Set @RestInject fields not initialized with values.
rci.forEachAllField(
- x -> x.hasAnnotation(RestBean.class),
+ x -> x.hasAnnotation(RestInject.class),
x -> x.setIfNull(
resource.get(),
beanStore.getBean(
x.getType().inner(),
-
RestBeanAnnotation.name(x.getAnnotation(RestBean.class))
+
RestInjectAnnotation.name(x.getAnnotation(RestInject.class))
).orElse(null)
)
);
@@ -568,10 +568,9 @@ public class RestContext extends Context {
* The default bean store can be overridden via any of the
following:
* <ul class='spaced-list'>
* <li>Class annotation: {@link Rest#beanStore()
@Rest(beanStore)}
- * <li>{@link RestBean @RestBean}-annotated methods:
+ * <li>{@link RestInject @RestInject}-annotated methods:
* <p class='bjava'>
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
BeanStore.Builder myMethod(<i><args></i>) {...}
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
BeanStore myMethod(<i><args></i>) {...}
+ * <ja>@RestInject</ja> <jk>public</jk> [<jk>static</jk>]
BeanStore myMethod(<i><args></i>) {...}
* </p>
* Args can be any injected bean including {@link
org.apache.juneau.cp.BeanStore.Builder}, the default builder.
* </ul>
@@ -662,13 +661,7 @@ public class RestContext extends Context {
// Apply @Rest(beanStore).
ClassInfo.of(resourceClass).forEachAnnotation(Rest.class, x ->
isNotVoid(x.beanStore()), x -> v.get().type(x.beanStore()));
- // Replace with builder from: @RestBean public
[static] BeanStore.Builder xxx(<args>)
- v.get().build()
- .createMethodFinder(BeanStore.Builder.class)
- .find(Builder::isRestBeanMethod)
- .run(x -> v.set(x));
-
- // Replace with bean from: @RestBean public [static]
BeanStore xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
BeanStore xxx(<args>)
v.get().build()
.createMethodFinder(BeanStore.class)
.find(Builder::isRestBeanMethod)
@@ -731,10 +724,9 @@ public class RestContext extends Context {
* The default var resolver can be overridden via any of the
following:
* <ul class='spaced-list'>
* <li>Injected via bean store.
- * <li>{@link RestBean @RestBean}-annotated methods:
+ * <li>{@link RestInject @RestInject}-annotated methods:
* <p class='bjava'>
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
VarResolver.Builder myMethod(<i><args></i>) {...}
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
VarResolver myMethod(<i><args></i>) {...}
+ * <ja>@RestInject</ja> <jk>public</jk> [<jk>static</jk>]
VarResolver myMethod(<i><args></i>) {...}
* </p>
* Args can be any injected bean including {@link
org.apache.juneau.svl.VarResolver.Builder}, the default builder.
* </ul>
@@ -845,13 +837,7 @@ public class RestContext extends Context {
.getBean(VarResolver.class)
.ifPresent(x -> v.get().impl(x));
- // Replace with builder from: @RestBean public
[static] VarResolver.Builder xxx(<args>)
- beanStore
- .createMethodFinder(VarResolver.Builder.class)
- .find(Builder::isRestBeanMethod)
- .run(x -> v.set(x));
-
- // Replace with bean from: @RestBean public [static]
VarResolver xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
VarResolver xxx(<args>)
beanStore
.createMethodFinder(VarResolver.class)
.addBean(VarResolver.Builder.class, v.get())
@@ -877,9 +863,9 @@ public class RestContext extends Context {
* <ul class='spaced-list'>
* <li>Injected via bean store.
* <li>Class annotation: {@link Rest#config()
@Rest(config)}
- * <li>{@link RestBean @RestBean}-annotated method:
+ * <li>{@link RestInject @RestInject}-annotated method:
* <p class='bjava'>
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
Config myMethod(<i><args></i>) {...}
+ * <ja>@RestInject</ja> <jk>public</jk> [<jk>static</jk>]
Config myMethod(<i><args></i>) {...}
* </p>
* Args can be any injected bean.
* </ul>
@@ -966,7 +952,7 @@ public class RestContext extends Context {
.getBean(Config.class)
.ifPresent(x -> v.set(x));
- // Replace with bean from: @RestBean public [static]
Config xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
Config xxx(<args>)
beanStore
.createMethodFinder(Config.class)
.addBean(Config.class, v.get())
@@ -997,9 +983,9 @@ public class RestContext extends Context {
* The default config can be overridden via any of the
following:
* <ul class='spaced-list'>
* <li>Injected via bean store.
- * <li>{@link RestBean @RestBean}-annotated method:
+ * <li>{@link RestInject @RestInject}-annotated method:
* <p class='bjava'>
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
Logger myMethod(<i><args></i>) {...}
+ * <ja>@RestInject</ja> <jk>public</jk> [<jk>static</jk>]
Logger myMethod(<i><args></i>) {...}
* </p>
* Args can be any injected bean.
* </ul>
@@ -1060,7 +1046,7 @@ public class RestContext extends Context {
.getBean(Logger.class)
.ifPresent(x -> v.set(x));
- // Replace with bean from: @RestBean public [static]
Logger xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
Logger xxx(<args>)
beanStore
.createMethodFinder(Logger.class)
.addBean(Logger.class, v.get())
@@ -1087,9 +1073,9 @@ public class RestContext extends Context {
* The default thrown store is inherited from the parent
context and can be overridden via any of the following:
* <ul class='spaced-list'>
* <li>Injected via bean store.
- * <li>{@link RestBean @RestBean}-annotated method:
+ * <li>{@link RestInject @RestInject}-annotated method:
* <p class='bjava'>
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
(ThrownStore.Builder|ThrownStore) myMethod(<i><args></i>) {...}
+ * <ja>@RestInject</ja> <jk>public</jk> [<jk>static</jk>]
ThrownStore myMethod(<i><args></i>) {...}
* </p>
* Args can be any injected bean including
ThrownStore.Builder, the default builder.
* </ul>
@@ -1186,14 +1172,7 @@ public class RestContext extends Context {
.getBean(ThrownStore.class)
.ifPresent(x->v.get().impl(x));
- // Replace with builder from: @RestBean public
[static] ThrownStore.Builder xxx(<args>)
- beanStore
- .createMethodFinder(ThrownStore.Builder.class)
- .addBean(ThrownStore.Builder.class, v.get())
- .find(Builder::isRestBeanMethod)
- .run(x -> v.set(x));
-
- // Replace with bean from: @RestBean public [static]
ThrownStore xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
ThrownStore xxx(<args>)
beanStore
.createMethodFinder(ThrownStore.class)
.addBean(ThrownStore.Builder.class, v.get())
@@ -1220,9 +1199,9 @@ public class RestContext extends Context {
* <ul class='spaced-list'>
* <li>Injected via bean store.
* <li>Class annotation: {@link Rest#encoders()
@Rest(encoders)}
- * <li>{@link RestBean @RestBean}-annotated method:
+ * <li>{@link RestInject @RestInject}-annotated method:
* <p class='bjava'>
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
(EncoderSet.Builder|EncoderSet) myMethod(<i><args></i>) {...}
+ * <ja>@RestInject</ja> <jk>public</jk> [<jk>static</jk>]
EncoderSet myMethod(<i><args></i>) {...}
* </p>
* Args can be any injected bean including
EncoderSet.Builder, the default builder.
* </ul>
@@ -1318,14 +1297,7 @@ public class RestContext extends Context {
.getBean(EncoderSet.class)
.ifPresent(x->v.get().impl(x));
- // Replace with builder from: @RestBean public
[static] EncoderSet.Builder xxx(<args>)
- beanStore
- .createMethodFinder(EncoderSet.Builder.class)
- .addBean(EncoderSet.Builder.class, v.get())
- .find(Builder::isRestBeanMethod)
- .run(x -> v.set(x));
-
- // Replace with bean from: @RestBean public [static]
EncoderSet xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
EncoderSet xxx(<args>)
beanStore
.createMethodFinder(EncoderSet.class)
.addBean(EncoderSet.Builder.class, v.get())
@@ -1351,9 +1323,9 @@ public class RestContext extends Context {
* <ul class='spaced-list'>
* <li>Injected via bean store.
* <li>Class annotation: {@link Rest#serializers()
@Rest(serializers)}
- * <li>{@link RestBean @RestBean}-annotated method:
+ * <li>{@link RestInject @RestInject}-annotated method:
* <p class='bjava'>
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
(SerializerSet.Builder|SerializerSet) myMethod(<i><args></i>) {...}
+ * <ja>@RestInject</ja> <jk>public</jk> [<jk>static</jk>]
SerializerSet myMethod(<i><args></i>) {...}
* </p>
* Args can be any injected bean including
SerializerSet.Builder, the default builder.
* </ul>
@@ -1447,14 +1419,7 @@ public class RestContext extends Context {
.getBean(SerializerSet.class)
.ifPresent(x->v.get().impl(x));
- // Replace with builder from: @RestBean public
[static] SerializerSet.Builder xxx(<args>)
- beanStore
- .createMethodFinder(SerializerSet.Builder.class)
- .addBean(SerializerSet.Builder.class, v.get())
- .find(Builder::isRestBeanMethod)
- .run(x -> v.set(x));
-
- // Replace with bean from: @RestBean public [static]
SerializerSet xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
SerializerSet xxx(<args>)
beanStore
.createMethodFinder(SerializerSet.class)
.addBean(SerializerSet.Builder.class, v.get())
@@ -1480,9 +1445,9 @@ public class RestContext extends Context {
* <ul class='spaced-list'>
* <li>Injected via bean store.
* <li>Class annotation: {@link Rest#parsers()
@Rest(parsers)}
- * <li>{@link RestBean @RestBean}-annotated method:
+ * <li>{@link RestInject @RestInject}-annotated method:
* <p class='bjava'>
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
(ParserSet.Builder|ParserSet) myMethod(<i><args></i>) {...}
+ * <ja>@RestInject</ja> <jk>public</jk> [<jk>static</jk>]
ParserSet myMethod(<i><args></i>) {...}
* </p>
* Args can be any injected bean including
ParserSet.Builder, the default builder.
* </ul>
@@ -1576,14 +1541,7 @@ public class RestContext extends Context {
.getBean(ParserSet.class)
.ifPresent(x->v.get().impl(x));
- // Replace with builder from: @RestBean public
[static] ParserSet.Builder xxx(<args>)
- beanStore
- .createMethodFinder(ParserSet.Builder.class)
- .addBean(ParserSet.Builder.class, v.get())
- .find(Builder::isRestBeanMethod)
- .run(x -> v.set(x));
-
- // Replace with bean from: @RestBean public [static]
ParserSet xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
ParserSet xxx(<args>)
beanStore
.createMethodFinder(ParserSet.class)
.addBean(ParserSet.Builder.class, v.get())
@@ -1609,9 +1567,9 @@ public class RestContext extends Context {
* The default method exec store can overridden via any of the
following:
* <ul class='spaced-list'>
* <li>Injected via bean store.
- * <li>{@link RestBean @RestBean}-annotated method:
+ * <li>{@link RestInject @RestInject}-annotated method:
* <p class='bjava'>
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
(MethodExecStore.Builder|MethodExecStore) myMethod(<i><args></i>) {...}
+ * <ja>@RestInject</ja> <jk>public</jk> [<jk>static</jk>]
MethodExecStore myMethod(<i><args></i>) {...}
* </p>
* Args can be any injected bean including
MethodExecStore.Builder, the default builder.
* </ul>
@@ -1703,14 +1661,7 @@ public class RestContext extends Context {
.getBean(MethodExecStore.class)
.ifPresent(x->v.get().impl(x));
- // Replace with builder from: @RestBean public
[static] MethodExecStore.Builder xxx(<args>)
- beanStore
-
.createMethodFinder(MethodExecStore.Builder.class)
- .addBean(MethodExecStore.Builder.class, v.get())
- .find(Builder::isRestBeanMethod)
- .run(x -> v.set(x));
-
- // Replace with bean from: @RestBean public [static]
MethodExecStore xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
MethodExecStore xxx(<args>)
beanStore
.createMethodFinder(MethodExecStore.class)
.addBean(MethodExecStore.Builder.class, v.get())
@@ -1798,9 +1749,9 @@ public class RestContext extends Context {
* <ul class='spaced-list'>
* <li>Injected via bean store.
* <li>Class annotation: {@link Rest#messages()
@Rest(messages)}
- * <li>{@link RestBean @RestBean}-annotated method:
+ * <li>{@link RestInject @RestInject}-annotated method:
* <p class='bjava'>
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
(Messages.Builder|Messages) myMethod(<i><args></i>) {...}
+ * <ja>@RestInject</ja> <jk>public</jk> [<jk>static</jk>]
Messages myMethod(<i><args></i>) {...}
* </p>
* Args can be any injected bean including
Messages.Builder, the default builder.
* </ul>
@@ -1893,13 +1844,7 @@ public class RestContext extends Context {
.getBean(Messages.class)
.ifPresent(x->v.get().impl(x));
- // Replace with builder from: @RestBean public
[static] Messages.Builder xxx(<args>)
- beanStore
- .createMethodFinder(Messages.Builder.class)
- .find(Builder::isRestBeanMethod)
- .run(x -> v.set(x));
-
- // Replace with bean from: @RestBean public [static]
Messages xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
Messages xxx(<args>)
beanStore
.createMethodFinder(Messages.class)
.addBean(Messages.Builder.class, v.get())
@@ -1980,9 +1925,9 @@ public class RestContext extends Context {
* <ul class='spaced-list'>
* <li>Injected via bean store.
* <li>Class annotation: {@link Rest#responseProcessors()
@Rest(responseProcessors)}
- * <li>{@link RestBean @RestBean}-annotated method:
+ * <li>{@link RestInject @RestInject}-annotated method:
* <p class='bjava'>
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
(ResponseProcessorList.Builder|ResponseProcessorList)
myMethod(<i><args></i>) {...}
+ * <ja>@RestInject</ja> <jk>public</jk> [<jk>static</jk>]
ResponseProcessorList myMethod(<i><args></i>) {...}
* </p>
* Args can be any injected bean including
ResponseProcessorList.Builder, the default builder.
* </ul>
@@ -2096,14 +2041,7 @@ public class RestContext extends Context {
.getBean(ResponseProcessorList.class)
.ifPresent(x -> v.get().impl(x));
- // Replace with builder from: @RestBean public
[static] ResponseProcessorList.Builder xxx(<args>)
- beanStore
-
.createMethodFinder(ResponseProcessorList.Builder.class)
- .addBean(ResponseProcessorList.Builder.class,
v.get())
- .find(Builder::isRestBeanMethod)
- .run(x -> v.set(x));
-
- // Replace with bean from: @RestBean public [static]
ResponseProcessorList xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
ResponseProcessorList xxx(<args>)
beanStore
.createMethodFinder(ResponseProcessorList.class)
.addBean(ResponseProcessorList.Builder.class,
v.get())
@@ -2155,9 +2093,9 @@ public class RestContext extends Context {
* <ul class='spaced-list'>
* <li>Injected via bean store.
* <li>Class annotation: {@link Rest#callLogger()
@Rest(callLogger)}
- * <li>{@link RestBean @RestBean}-annotated method:
+ * <li>{@link RestInject @RestInject}-annotated method:
* <p class='bjava'>
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
CallLogger myMethod(<i><args></i>) {...}
+ * <ja>@RestInject</ja> <jk>public</jk> [<jk>static</jk>]
CallLogger myMethod(<i><args></i>) {...}
* </p>
* Args can be any injected bean.
* </ul>
@@ -2260,7 +2198,7 @@ public class RestContext extends Context {
.getBean(CallLogger.class)
.ifPresent(x -> creator.impl(x));
- // Replace with bean from: @RestBean public [static]
CallLogger xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
CallLogger xxx(<args>)
beanStore
.createMethodFinder(CallLogger.class)
.find(Builder::isRestBeanMethod)
@@ -2283,11 +2221,6 @@ public class RestContext extends Context {
* The default bean context can overridden via any of the
following:
* <ul class='spaced-list'>
* <li>Injected via bean store.
- * <li>{@link RestBean @RestBean}-annotated method:
- * <p class='bjava'>
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
BeanContext.Builder myMethod(<i><args></i>) {...}
- * </p>
- * Args can be any injected bean.
* </ul>
*
* @return The bean context sub-builder.
@@ -2325,13 +2258,6 @@ public class RestContext extends Context {
.getBean(BeanContext.class)
.ifPresent(x -> v.get().impl(x));
- // Replace with builder from: @RestBean public
[static] BeanContext.Builder xxx(<args>)
- beanStore
- .createMethodFinder(BeanContext.Builder.class)
- .addBean(BeanContext.Builder.class, v.get())
- .find(Builder::isRestBeanMethod)
- .run(x -> v.set(x));
-
return v.get();
}
@@ -2350,9 +2276,9 @@ public class RestContext extends Context {
* It can overridden via any of the following:
* <ul class='spaced-list'>
* <li>Injected via bean store.
- * <li>{@link RestBean @RestBean}-annotated method:
+ * <li>{@link RestInject @RestInject}-annotated method:
* <p class='bjava'>
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
(HttpPartSerializer.Builder|HttpPartSerializer) myMethod(<i><args></i>)
{...}
+ * <ja>@RestInject</ja> <jk>public</jk> [<jk>static</jk>]
HttpPartSerializer myMethod(<i><args></i>) {...}
* </p>
* Args can be any injected bean including
HttpPartSerializer.Builder, the default builder.
* </ul>
@@ -2455,14 +2381,7 @@ public class RestContext extends Context {
.get(HttpPartSerializer.class)
.ifPresent(x -> v.get().type(x));
- // Replace with builder from: @RestBean public
[static] HttpPartSerializer.Creator xxx(<args>)
- beanStore
-
.createMethodFinder(HttpPartSerializer.Creator.class)
- .addBean(HttpPartSerializer.Creator.class,
v.get())
- .find(Builder::isRestBeanMethod)
- .run(x -> v.set(x));
-
- // Replace with bean from: @RestBean public [static]
HttpPartSerializer xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
HttpPartSerializer xxx(<args>)
beanStore
.createMethodFinder(HttpPartSerializer.class)
.addBean(HttpPartSerializer.Creator.class,
v.get())
@@ -2487,9 +2406,9 @@ public class RestContext extends Context {
* It can overridden via any of the following:
* <ul class='spaced-list'>
* <li>Injected via bean store.
- * <li>{@link RestBean @RestBean}-annotated method:
+ * <li>{@link RestInject @RestInject}-annotated method:
* <p class='bjava'>
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
(HttpPartParser.Builder|HttpPartParser) myMethod(<i><args></i>) {...}
+ * <ja>@RestInject</ja> <jk>public</jk> [<jk>static</jk>]
HttpPartParser myMethod(<i><args></i>) {...}
* </p>
* Args can be any injected bean including
HttpPartParser.Builder, the default builder.
* </ul>
@@ -2592,14 +2511,7 @@ public class RestContext extends Context {
.get(HttpPartParser.class)
.ifPresent(x -> v.get().type(x));
- // Replace with builder from: @RestBean public
[static] HttpPartParser.Creator xxx(<args>)
- beanStore
-
.createMethodFinder(HttpPartParser.Creator.class)
- .addBean(HttpPartParser.Creator.class, v.get())
- .find(Builder::isRestBeanMethod)
- .run(x -> v.set(x));
-
- // Replace with bean from: @RestBean public [static]
HttpPartParser xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
HttpPartParser xxx(<args>)
beanStore
.createMethodFinder(HttpPartParser.class)
.addBean(HttpPartParser.Creator.class, v.get())
@@ -2624,9 +2536,9 @@ public class RestContext extends Context {
* It can overridden via any of the following:
* <ul class='spaced-list'>
* <li>Injected via bean store.
- * <li>{@link RestBean @RestBean}-annotated method:
+ * <li>{@link RestInject @RestInject}-annotated method:
* <p class='bjava'>
- * <ja>@RestBean</ja> <jk>public</jk> [<jk>static</jk>]
(JsonSchemaGenerator.Builder|JsonSchemaGenerator) myMethod(<i><args></i>)
{...}
+ * <ja>@RestInject</ja> <jk>public</jk> [<jk>static</jk>]
JsonSchemaGenerator myMethod(<i><args></i>) {...}
* </p>
* Args can be any injected bean including
JsonSchemaGenerator.Builder, the default builder.
* </ul>
@@ -2718,14 +2630,7 @@ public class RestContext extends Context {
.getBean(JsonSchemaGenerator.class)
.ifPresent(x -> v.get().impl(x));
- // Replace with builder from: @RestBean public
[static] JsonSchemaGeneratorBuilder xxx(<args>)
- beanStore
-
.createMethodFinder(JsonSchemaGenerator.Builder.class)
- .addBean(JsonSchemaGenerator.Builder.class,
v.get())
- .find(Builder::isRestBeanMethod)
- .run(x -> v.set(x));
-
- // Replace with bean from: @RestBean public [static]
JsonSchemaGenerator xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
JsonSchemaGenerator xxx(<args>)
beanStore
.createMethodFinder(JsonSchemaGenerator.class)
.addBean(JsonSchemaGenerator.Builder.class,
v.get())
@@ -2872,7 +2777,7 @@ public class RestContext extends Context {
.getBean(StaticFiles.class)
.ifPresent(x -> creator.impl(x));
- // Replace with bean from: @RestBean public [static]
StaticFiles xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
StaticFiles xxx(<args>)
beanStore
.createMethodFinder(StaticFiles.class)
.find(Builder::isRestBeanMethod)
@@ -3008,14 +2913,7 @@ public class RestContext extends Context {
.getBean(HeaderList.class,
"defaultRequestHeaders")
.ifPresent(x -> v.get().impl(x));
- // Replace with builder from:
@RestBean(name="defaultRequestHeaders") public [static] HeaderList.Builder
xxx(<args>)
- beanStore
- .createMethodFinder(HeaderList.Builder.class)
- .addBean(HeaderList.Builder.class, v.get())
- .find(x -> isRestBeanMethod(x,
"defaultRequestHeaders"))
- .run(x -> v.set(x));
-
- // Replace with bean from:
@RestBean(name="defaultRequestHeaders") public [static] HeaderList xxx(<args>)
+ // Replace with bean from:
@RestInject(name="defaultRequestHeaders") public [static] HeaderList xxx(<args>)
beanStore
.createMethodFinder(HeaderList.class)
.addBean(HeaderList.Builder.class, v.get())
@@ -3040,28 +2938,6 @@ public class RestContext extends Context {
return defaultResponseHeaders;
}
-// /**
-// * Applies an operation to the default response headers
sub-builder.
-// *
-// * <p>
-// * Typically used to allow you to execute operations without
breaking the fluent flow of the context builder.
-// *
-// * <h5 class='section'>Example:</h5>
-// * <p class='bjava'>
-// * RestContext <jv>context</jv> = RestContext
-// * .<jsm>create</jsm>(<jv>resourceClass</jv>,
<jv>parentContext</jv>, <jv>servletConfig</jv>)
-// * .defaultResponseHeaders(<jv>x</jv> ->
<jv>x</jv>.remove(<js>"Foo"</js>)))
-// * .build();
-// * </p>
-// *
-// * @param operation The operation to apply.
-// * @return This object.
-// */
-// public Builder
defaultResponseHeaders(Consumer<HeaderList.Builder> operation) {
-// operation.accept(defaultResponseHeaders());
-// return this;
-// }
-
/**
* Default response headers.
*
@@ -3140,14 +3016,7 @@ public class RestContext extends Context {
.getBean(HeaderList.class,
"defaultResponseHeaders")
.ifPresent(x -> v.get().impl(x));
- // Replace with builder from:
@RestBean(name="defaultResponseHeaders") public [static] HeaderList.Builder
xxx(<args>)
- beanStore
- .createMethodFinder(HeaderList.Builder.class)
- .addBean(HeaderList.Builder.class, v.get())
- .find(x -> isRestBeanMethod(x,
"defaultResponseHeaders"))
- .run(x -> v.set(x));
-
- // Replace with bean from:
@RestBean(name="defaultResponseHeaders") public [static] HeaderList xxx(<args>)
+ // Replace with bean from:
@RestInject(name="defaultResponseHeaders") public [static] HeaderList
xxx(<args>)
beanStore
.createMethodFinder(HeaderList.class)
.addBean(HeaderList.Builder.class, v.get())
@@ -3172,28 +3041,6 @@ public class RestContext extends Context {
return defaultRequestAttributes;
}
-// /**
-// * Applies an operation to the default request attributes
sub-builder.
-// *
-// * <p>
-// * Typically used to allow you to execute operations without
breaking the fluent flow of the context builder.
-// *
-// * <h5 class='section'>Example:</h5>
-// * <p class='bjava'>
-// * RestContext <jv>context</jv> = RestContext
-// * .<jsm>create</jsm>(<jv>resourceClass</jv>,
<jv>parentContext</jv>, <jv>servletConfig</jv>)
-// * .defaultRequestAttributes(<jv>x</jv> ->
<jv>x</jv>.add(BasicNamedAttribute.<jsm>of</jsm>(<js>"Foo"</js>,
()-><jsm>getFoo</jsm>()))
-// * .build();
-// * </p>
-// *
-// * @param operation The operation to apply.
-// * @return This object.
-// */
-// public Builder
defaultRequestAttributes(Consumer<NamedAttributeList.Builder> operation) {
-// operation.accept(defaultRequestAttributes());
-// return this;
-// }
-
/**
* Default request attributes.
*
@@ -3268,14 +3115,7 @@ public class RestContext extends Context {
.getBean(NamedAttributeList.class,
"defaultRequestAttributes")
.ifPresent(x -> v.get().impl(x));
- // Replace with bean from:
@RestBean(name="defaultRequestAttributes") public [static]
NamedAttributeList.Builder xxx(<args>)
- beanStore
-
.createMethodFinder(NamedAttributeList.Builder.class)
- .addBean(NamedAttributeList.Builder.class,
v.get())
- .find(x -> isRestBeanMethod(x,
"defaultRequestAttributes"))
- .run(x -> v.set(x));
-
- // Replace with bean from:
@RestBean(name="defaultRequestAttributes") public [static] NamedAttributeList
xxx(<args>)
+ // Replace with bean from:
@RestInject(name="defaultRequestAttributes") public [static] NamedAttributeList
xxx(<args>)
beanStore
.createMethodFinder(NamedAttributeList.class)
.addBean(NamedAttributeList.Builder.class,
v.get())
@@ -3382,14 +3222,7 @@ public class RestContext extends Context {
.getBean(RestOpArgList.class)
.ifPresent(x -> v.get().impl(x));
- // Replace with builder from: @RestBean public
[static] RestOpArgList.Builder xxx(<args>)
- beanStore
- .createMethodFinder(RestOpArgList.Builder.class)
- .addBean(RestOpArgList.Builder.class, v.get())
- .find(Builder::isRestBeanMethod)
- .run(x -> v.set(x));
-
- // Replace with bean from: @RestBean public [static]
RestOpArgList xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
RestOpArgList xxx(<args>)
beanStore
.createMethodFinder(RestOpArgList.class)
.addBean(RestOpArgList.Builder.class, v.get())
@@ -3482,7 +3315,7 @@ public class RestContext extends Context {
.getBean(DebugEnablement.class)
.ifPresent(x -> creator.impl(x));
- // Replace with bean from: @RestBean public [static]
DebugEnablement xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
DebugEnablement xxx(<args>)
beanStore
.createMethodFinder(DebugEnablement.class)
.find(Builder::isRestBeanMethod)
@@ -3506,28 +3339,6 @@ public class RestContext extends Context {
return startCallMethods;
}
-// /**
-// * Applies an operation to the start call method list.
-// *
-// * <p>
-// * Typically used to allow you to execute operations without
breaking the fluent flow of the context builder.
-// *
-// * <h5 class='section'>Example:</h5>
-// * <p class='bjava'>
-// * RestContext <jv>context</jv> = RestContext
-// * .<jsm>create</jsm>(<jv>resourceClass</jv>,
<jv>parentContext</jv>, <jv>servletConfig</jv>)
-// * .startCallMethods(<jv>x</jv> ->
<jv>x</jv>.add(<jv>extraMethod</jv>))
-// * .build();
-// * </p>
-// *
-// * @param operation The operation to apply.
-// * @return This object.
-// */
-// public Builder startCallMethods(Consumer<MethodList> operation)
{
-// operation.accept(startCallMethods());
-// return this;
-// }
-
/**
* Instantiates the start call method list.
*
@@ -3544,7 +3355,7 @@ public class RestContext extends Context {
getAnnotatedMethods(resource,
RestStartCall.class, x -> true)
);
- // Replace with bean from:
@RestBean(name="startCallMethods") public [static] MethodList xxx(<args>)
+ // Replace with bean from:
@RestInject(name="startCallMethods") public [static] MethodList xxx(<args>)
beanStore
.createMethodFinder(MethodList.class)
.addBean(MethodList.class, v.get())
@@ -3569,28 +3380,6 @@ public class RestContext extends Context {
return endCallMethods;
}
-// /**
-// * Applies an operation to the end call method list.
-// *
-// * <p>
-// * Typically used to allow you to execute operations without
breaking the fluent flow of the context builder.
-// *
-// * <h5 class='section'>Example:</h5>
-// * <p class='bjava'>
-// * RestContext <jv>context</jv> = RestContext
-// * .<jsm>create</jsm>(<jv>resourceClass</jv>,
<jv>parentContext</jv>, <jv>servletConfig</jv>)
-// * .endCallMethods(<jv>x</jv> ->
<jv>x</jv>.add(<jv>extraMethod</jv>))
-// * .build();
-// * </p>
-// *
-// * @param operation The operation to apply.
-// * @return This object.
-// */
-// public Builder endCallMethods(Consumer<MethodList> operation) {
-// operation.accept(endCallMethods());
-// return this;
-// }
-
/**
* Instantiates the end call method list.
*
@@ -3607,7 +3396,7 @@ public class RestContext extends Context {
getAnnotatedMethods(resource,
RestEndCall.class, x -> true)
);
- // Replace with bean from:
@RestBean(name="endCallMethods") public [static] MethodList xxx(<args>)
+ // Replace with bean from:
@RestInject(name="endCallMethods") public [static] MethodList xxx(<args>)
beanStore
.createMethodFinder(MethodList.class)
.addBean(MethodList.class, v.get())
@@ -3632,28 +3421,6 @@ public class RestContext extends Context {
return postInitMethods;
}
-// /**
-// * Applies an operation to the post-init method list.
-// *
-// * <p>
-// * Typically used to allow you to execute operations without
breaking the fluent flow of the context builder.
-// *
-// * <h5 class='section'>Example:</h5>
-// * <p class='bjava'>
-// * RestContext <jv>context</jv> = RestContext
-// * .<jsm>create</jsm>(<jv>resourceClass</jv>,
<jv>parentContext</jv>, <jv>servletConfig</jv>)
-// * .postInitMethods(<jv>x</jv> ->
<jv>x</jv>.add(<jv>extraMethod</jv>))
-// * .build();
-// * </p>
-// *
-// * @param operation The operation to apply.
-// * @return This object.
-// */
-// public Builder postInitMethods(Consumer<MethodList> operation) {
-// operation.accept(postInitMethods());
-// return this;
-// }
-
/**
* Instantiates the post-init method list.
*
@@ -3670,7 +3437,7 @@ public class RestContext extends Context {
getAnnotatedMethods(resource,
RestPostInit.class, x -> ! x.childFirst())
);
- // Replace with bean from:
@RestBean(name="postInitMethods") public [static] MethodList xxx(<args>)
+ // Replace with bean from:
@RestInject(name="postInitMethods") public [static] MethodList xxx(<args>)
beanStore
.createMethodFinder(MethodList.class)
.addBean(MethodList.class, v.get())
@@ -3695,28 +3462,6 @@ public class RestContext extends Context {
return postInitChildFirstMethods;
}
-// /**
-// * Applies an operation to the post-init-child-first method
list.
-// *
-// * <p>
-// * Typically used to allow you to execute operations without
breaking the fluent flow of the context builder.
-// *
-// * <h5 class='section'>Example:</h5>
-// * <p class='bjava'>
-// * RestContext <jv>context</jv> = RestContext
-// * .<jsm>create</jsm>(<jv>resourceClass</jv>,
<jv>parentContext</jv>, <jv>servletConfig</jv>)
-// * .postInitChildFirstMethods(<jv>x</jv> ->
<jv>x</jv>.add(<jv>extraMethod</jv>))
-// * .build();
-// * </p>
-// *
-// * @param operation The operation to apply.
-// * @return This object.
-// */
-// public Builder postInitChildFirstMethods(Consumer<MethodList>
operation) {
-// operation.accept(postInitChildFirstMethods());
-// return this;
-// }
-
/**
* Instantiates the post-init-child-first method list.
*
@@ -3733,7 +3478,7 @@ public class RestContext extends Context {
getAnnotatedMethods(resource,
RestPostInit.class, x -> x.childFirst())
);
- // Replace with bean from:
@RestBean(name="postInitChildFirstMethods") public [static] MethodList
xxx(<args>)
+ // Replace with bean from:
@RestInject(name="postInitChildFirstMethods") public [static] MethodList
xxx(<args>)
beanStore
.createMethodFinder(MethodList.class)
.addBean(MethodList.class, v.get())
@@ -3774,7 +3519,7 @@ public class RestContext extends Context {
getAnnotatedMethods(resource,
RestDestroy.class, x -> true)
);
- // Replace with bean from:
@RestBean(name="destroyMethods") public [static] MethodList xxx(<args>)
+ // Replace with bean from:
@RestInject(name="destroyMethods") public [static] MethodList xxx(<args>)
beanStore
.createMethodFinder(MethodList.class)
.addBean(MethodList.class, v.get())
@@ -3818,7 +3563,7 @@ public class RestContext extends Context {
getAnnotatedMethods(resource,
RestPreCall.class, x -> true)
);
- // Replace with bean from:
@RestBean(name="preCallMethods") public [static] MethodList xxx(<args>)
+ // Replace with bean from:
@RestInject(name="preCallMethods") public [static] MethodList xxx(<args>)
beanStore
.createMethodFinder(MethodList.class)
.addBean(MethodList.class, v.get())
@@ -3862,7 +3607,7 @@ public class RestContext extends Context {
getAnnotatedMethods(resource,
RestPostCall.class, x -> true)
);
- // Replace with bean from:
@RestBean(name="postCallMethods") public [static] MethodList xxx(<args>)
+ // Replace with bean from:
@RestInject(name="postCallMethods") public [static] MethodList xxx(<args>)
beanStore
.createMethodFinder(MethodList.class)
.addBean(MethodList.class, v.get())
@@ -3981,14 +3726,7 @@ public class RestContext extends Context {
}
}
- // Replace with builder from: @RestBean public
[static] RestOperations.Builder xxx(<args>)
- beanStore
-
.createMethodFinder(RestOperations.Builder.class)
- .addBean(RestOperations.Builder.class, v.get())
- .find(Builder::isRestBeanMethod)
- .run(x -> v.set(x));
-
- // Replace with bean from: @RestBean public [static]
RestOperations xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
RestOperations xxx(<args>)
beanStore
.createMethodFinder(RestOperations.class)
.addBean(RestOperations.Builder.class, v.get())
@@ -4081,14 +3819,7 @@ public class RestContext extends Context {
v.get().add(cc);
}
- // Replace with builder from: @RestBean public
[static] RestChildren.Builder xxx(<args>)
- beanStore
- .createMethodFinder(RestChildren.Builder.class)
- .addBean(RestChildren.Builder.class, v.get())
- .find(Builder::isRestBeanMethod)
- .run(x -> v.set(x));
-
- // Replace with bean from: @RestBean public [static]
RestChildren xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
RestChildren xxx(<args>)
beanStore
.createMethodFinder(RestChildren.class)
.addBean(RestChildren.Builder.class, v.get())
@@ -4194,7 +3925,7 @@ public class RestContext extends Context {
.getBean(SwaggerProvider.class)
.ifPresent(x -> creator.impl(x));
- // Replace with bean from: @RestBean public [static]
SwaggerProvider xxx(<args>)
+ // Replace with bean from: @RestInject public [static]
SwaggerProvider xxx(<args>)
beanStore
.createMethodFinder(SwaggerProvider.class)
.find(Builder::isRestBeanMethod)
@@ -5603,12 +5334,12 @@ public class RestContext extends Context {
}
private static boolean isRestBeanMethod(MethodInfo mi) {
- RestBean x = mi.getAnnotation(RestBean.class);
+ RestInject x = mi.getAnnotation(RestInject.class);
return x != null && x.methodScope().length == 0;
}
private static boolean isRestBeanMethod(MethodInfo mi, String
name) {
- RestBean x = mi.getAnnotation(RestBean.class);
+ RestInject x = mi.getAnnotation(RestInject.class);
return x != null && x.methodScope().length == 0 &&
x.name().equals(name);
}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
index 855ddfe7e..c7c8b09b9 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContext.java
@@ -327,13 +327,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
parent.beanContext().copy()
);
- BeanStore
- .of(beanStore, resource)
- .addBean(BeanContext.Builder.class, v.get())
- .createMethodFinder(BeanContext.Builder.class,
resource)
- .find(x -> matches(x))
- .run(x -> v.set(x));
-
+ // Replace with bean from:
@RestInject(methodScope="foo") public [static] BeanContext xxx(<args>)
BeanStore
.of(beanStore, resource)
.addBean(BeanContext.Builder.class, v.get())
@@ -416,13 +410,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
parent.encoders().copy()
);
- BeanStore
- .of(beanStore, resource)
- .addBean(EncoderSet.Builder.class, v.get())
- .createMethodFinder(EncoderSet.Builder.class,
resource)
- .find(x -> matches(x))
- .run(x -> v.set(x));
-
+ // Replace with bean from:
@RestInject(methodScope="foo") public [static] EncoderSet xxx(<args>)
BeanStore
.of(beanStore, resource)
.addBean(EncoderSet.Builder.class, v.get())
@@ -505,13 +493,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
parent.serializers().copy()
);
- BeanStore
- .of(beanStore, resource)
- .addBean(SerializerSet.Builder.class, v.get())
-
.createMethodFinder(SerializerSet.Builder.class, resource)
- .find(x -> matches(x))
- .run(x -> v.set(x));
-
+ // Replace with bean from:
@RestInject(methodScope="foo") public [static] SerializerSet xxx(<args>)
BeanStore
.of(beanStore, resource)
.addBean(SerializerSet.Builder.class, v.get())
@@ -594,13 +576,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
parent.parsers().copy()
);
- BeanStore
- .of(beanStore, resource)
- .addBean(ParserSet.Builder.class, v.get())
- .createMethodFinder(ParserSet.Builder.class,
resource)
- .find(x -> matches(x))
- .run(x -> v.set(x));
-
+ // Replace with bean from:
@RestInject(methodScope="foo") public [static] ParserSet xxx(<args>)
BeanStore
.of(beanStore, resource)
.addBean(ParserSet.Builder.class, v.get())
@@ -682,13 +658,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
parent.partSerializer().copy()
);
- BeanStore
- .of(beanStore, resource)
- .addBean(HttpPartSerializer.Creator.class,
v.get())
-
.createMethodFinder(HttpPartSerializer.Creator.class, resource)
- .find(x -> matches(x))
- .run(x -> v.set(x));
-
+ // Replace with bean from:
@RestInject(methodScope="foo") public [static] HttpPartSerializer xxx(<args>)
BeanStore
.of(beanStore, resource)
.addBean(HttpPartSerializer.Creator.class,
v.get())
@@ -770,13 +740,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
parent.partParser().copy()
);
- BeanStore
- .of(beanStore, resource)
- .addBean(HttpPartParser.Creator.class, v.get())
-
.createMethodFinder(HttpPartParser.Creator.class, resource)
- .find(x -> matches(x))
- .run(x -> v.set(x));
-
+ // Replace with bean from:
@RestInject(methodScope="foo") public [static] HttpPartParser xxx(<args>)
BeanStore
.of(beanStore, resource)
.addBean(HttpPartParser.Creator.class, v.get())
@@ -858,13 +822,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
parent.jsonSchemaGenerator().copy()
);
- BeanStore
- .of(beanStore, resource)
- .addBean(JsonSchemaGenerator.Builder.class,
v.get())
-
.createMethodFinder(JsonSchemaGenerator.Builder.class, resource)
- .find(x -> matches(x))
- .run(x -> v.set(x));
-
+ // Replace with bean from:
@RestInject(methodScope="foo") public [static] JsonSchemaGenerator xxx(<args>)
BeanStore
.of(beanStore, resource)
.addBean(JsonSchemaGenerator.Builder.class,
v.get())
@@ -1024,14 +982,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
.getBean(RestConverterList.class)
.ifPresent(x->v.get().impl(x));
- // Replace with builder from: public [static]
RestConverterList.Builder createConverters(<args>)
- beanStore
-
.createMethodFinder(RestConverterList.Builder.class)
- .addBean(RestConverterList.Builder.class,
v.get())
- .find(x -> matches(x))
- .run(x -> v.set(x));
-
- // Replace with bean from: public [static]
RestConverterList createConverters(<args>)
+ // Replace with bean from:
@RestInject(methodScope="foo") public [static] RestConverterList xxx(<args>)
beanStore
.createMethodFinder(RestConverterList.class)
.addBean(RestConverterList.Builder.class,
v.get())
@@ -1139,14 +1090,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
.getBean(RestGuardList.class)
.ifPresent(x->v.get().impl(x));
- // Replace with builder from: public [static]
RestGuardList.Builder createGuards(<args>)
- beanStore
- .createMethodFinder(RestGuardList.Builder.class)
- .addBean(RestGuardList.Builder.class, v.get())
- .find(x -> matches(x))
- .run(x -> v.set(x));
-
- // Replace with bean from: public [static]
RestGuardList createGuards(<args>)
+ // Replace with bean from:
@RestInject(methodScope="foo") public [static] RestGuardList xxx(<args>)
beanStore
.createMethodFinder(RestGuardList.class)
.addBean(RestGuardList.Builder.class, v.get())
@@ -1295,14 +1239,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
.getBean(RestMatcherList.class)
.ifPresent(x->v.get().impl(x));
- // Replace with builder from: public [static]
RestMatcherList.Builder createMatchers(<args>)
- beanStore
-
.createMethodFinder(RestMatcherList.Builder.class)
- .addBean(RestMatcherList.Builder.class, v.get())
- .find(x -> matches(x))
- .run(x -> v.set(x));
-
- // Replace with bean from: public [static]
RestMatcherList createMatchers(<args>)
+ // Replace with bean from:
@RestInject(methodScope="foo") public [static] RestMatcherList xxx(<args>)
beanStore
.createMethodFinder(RestMatcherList.class)
.addBean(RestMatcherList.Builder.class, v.get())
@@ -1369,6 +1306,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
v.get().add(UrlPathMatcher.of(p));
}
+ // Replace with bean from:
@RestInject(methodScope="foo") public [static] UrlPathMatcherList xxx(<args>)
beanStore
.createMethodFinder(UrlPathMatcherList.class,
resource().get())
.addBean(UrlPathMatcherList.class, v.get())
@@ -1437,13 +1375,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
parent.defaultRequestHeaders().copy()
);
- BeanStore
- .of(beanStore, resource)
- .addBean(HeaderList.Builder.class, v.get())
- .createMethodFinder(HeaderList.Builder.class,
resource)
- .find(x -> matches(x, "defaultRequestHeaders"))
- .run(x -> v.set(x));
-
+ // Replace with bean from:
@RestInject(name="defaultRequestHeaders",methodScope="foo") public [static]
HeaderList xxx(<args>)
BeanStore
.of(beanStore, resource)
.addBean(HeaderList.Builder.class, v.get())
@@ -1503,13 +1435,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
parent.defaultResponseHeaders().copy()
);
- BeanStore
- .of(beanStore, resource)
- .addBean(HeaderList.Builder.class, v.get())
- .createMethodFinder(HeaderList.Builder.class,
resource)
- .find(x -> matches(x, "defaultResponseHeaders"))
- .run(x -> v.set(x));
-
+ // Replace with bean from:
@RestInject(name="defaultResponseHeaders",methodScope="foo") public [static]
HeaderList xxx(<args>)
BeanStore
.of(beanStore, resource)
.addBean(HeaderList.Builder.class, v.get())
@@ -1569,13 +1495,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
parent.defaultRequestAttributes().copy()
);
- BeanStore
- .of(beanStore, resource)
- .addBean(NamedAttributeList.Builder.class,
v.get())
-
.createMethodFinder(NamedAttributeList.Builder.class, resource)
- .find(x -> matches(x,
"defaultRequestAttributes"))
- .run(x -> v.set(x));
-
+ // Replace with bean from:
@RestInject(name="defaultRequestAttributes",methodScope="foo") public [static]
NamedAttributeList xxx(<args>)
BeanStore
.of(beanStore, resource)
.addBean(NamedAttributeList.Builder.class,
v.get())
@@ -1635,13 +1555,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
PartList.create()
);
- BeanStore
- .of(beanStore, resource)
- .addBean(PartList.Builder.class, v.get())
- .createMethodFinder(PartList.Builder.class,
resource)
- .find(x -> matches(x,
"defaultRequestQueryData"))
- .run(x -> v.set(x));
-
+ // Replace with bean from:
@RestInject(name="defaultRequestQueryData",methodScope="foo") public [static]
PartList xxx(<args>)
BeanStore
.of(beanStore, resource)
.addBean(PartList.Builder.class, v.get())
@@ -1701,13 +1615,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
PartList.create()
);
- BeanStore
- .of(beanStore, resource)
- .addBean(PartList.Builder.class, v.get())
- .createMethodFinder(PartList.Builder.class,
resource)
- .find(x -> matches(x, "defaultRequestFormData"))
- .run(x -> v.set(x));
-
+ // Replace with bean from:
@RestInject(name="defaultRequestFormData",methodScope="foo") public [static]
PartList xxx(<args>)
BeanStore
.of(beanStore, resource)
.addBean(PartList.Builder.class, v.get())
@@ -2272,7 +2180,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
//-----------------------------------------------------------------------------------------------------------------
private boolean matches(MethodInfo annotated) {
- RestBean a = annotated.getAnnotation(RestBean.class);
+ RestInject a =
annotated.getAnnotation(RestInject.class);
if (a != null) {
for (String n : a.methodScope()) {
if ("*".equals(n))
@@ -2285,7 +2193,7 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
}
private boolean matches(MethodInfo annotated, String beanName) {
- RestBean a = annotated.getAnnotation(RestBean.class);
+ RestInject a =
annotated.getAnnotation(RestInject.class);
if (a != null) {
if (! a.name().equals(beanName))
return false;
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestBean.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestInject.java
similarity index 91%
rename from
juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestBean.java
rename to
juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestInject.java
index de6233a3f..d357958ff 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestBean.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestInject.java
@@ -57,11 +57,11 @@ import org.apache.juneau.svl.*;
* <jk>public class</jk> MyRest <jk>extends</jk> BasicRestServlet
<jk>implements</jk> BasicUniversalConfig {
*
* <jc>// Option #1: As a field.</jc>
- * <ja>@RestBean</ja>
+ * <ja>@RestInject</ja>
* CallLogger <jf>myCallLogger</jf> =
CallLogger.<jsm>create</jsm>().logger(<js>"mylogger"</js>).build();
*
* <jc>// Option #2: As a method.</jc>
- * <ja>@RestBean</ja>
+ * <ja>@RestInject</ja>
* <jk>public</jk> CallLogger myCallLogger() {
* <jk>return</jk>
CallLogger.<jsm>create</jsm>().logger(<js>"mylogger"</js>).build();
* }
@@ -69,27 +69,27 @@ import org.apache.juneau.svl.*;
* </p>
*
* <p>
- * The {@link RestBean#name()}/{@link RestBean#value()} attributes are
used to differentiate between named beans.
+ * The {@link RestInject#name()}/{@link RestInject#value()} attributes are
used to differentiate between named beans.
* </p>
* <h5 class='figure'>Example</h5>
* <p class='bcode'>
* <jc>// Customized default request headers.</jc>
- * <ja>@RestBean</ja>(<js>"defaultRequestHeaders"</js>)
+ * <ja>@RestInject</ja>(<js>"defaultRequestHeaders"</js>)
* HeaderList <jf>defaultRequestHeaders</jf> =
HeaderList.<jsm>create</jsm>().set(ContentType.<jsf>TEXT_PLAIN</jsf>).build();
*
* <jc>// Customized default response headers.</jc>
- * <ja>@RestBean</ja>(<js>"defaultResponseHeaders"</js>)
+ * <ja>@RestInject</ja>(<js>"defaultResponseHeaders"</js>)
* HeaderList <jf>defaultResponseHeaders</jf> =
HeaderList.<jsm>create</jsm>().set(ContentType.<jsf>TEXT_PLAIN</jsf>).build();
* </p>
*
* <p>
- * The {@link RestBean#methodScope()} attribute is used to define beans in
the scope of specific {@link RestOp}-annotated methods.
+ * The {@link RestInject#methodScope()} attribute is used to define beans
in the scope of specific {@link RestOp}-annotated methods.
* </p>
* <h5 class='figure'>Example</h5>
* <p class='bcode'>
* <jc>// Set a default header on a specific REST method.</jc>
* <jc>// Input parameter is the default header list builder with all
annotations applied.</jc>
- * <ja>@RestBean</ja>(name=<js>"defaultRequestHeaders"</js>,
methodScope=<js>"myRestMethod"</js>)
+ * <ja>@RestInject</ja>(name=<js>"defaultRequestHeaders"</js>,
methodScope=<js>"myRestMethod"</js>)
* <jk>public</jk> HeaderList.Builder myRequestHeaders(HeaderList.Builder
<jv>builder</jv>) {
* <jk>return</jk>
<jv>builder</jv>.set(ContentType.<jsf>TEXT_PLAIN</jsf>);
* }
@@ -106,8 +106,8 @@ import org.apache.juneau.svl.*;
* <h5 class='figure'>Example</h5>
* <p class='bcode'>
* <jc>// Custom beans injected into the bean store.</jc>
- * <ja>@RestBean</ja> MyBean <jv>myBean1</jv> = <jk>new</jk> MyBean();
- * <ja>@RestBean</ja>(<js>"myBean2"</js>) MyBean <jv>myBean2</jv> =
<jk>new</jk> MyBean();
+ * <ja>@RestInject</ja> MyBean <jv>myBean1</jv> = <jk>new</jk> MyBean();
+ * <ja>@RestInject</ja>(<js>"myBean2"</js>) MyBean <jv>myBean2</jv> =
<jk>new</jk> MyBean();
*
* <jc>// Method that uses injected beans.</jc>
* <ja>@RestGet</ja>
@@ -121,8 +121,8 @@ import org.apache.juneau.svl.*;
* <h5 class='figure'>Example</h5>
* <p class='bcode'>
* <jc>// Fields that get set during initialization based on beans found
in the bean store.</jc>
- * <ja>@RestBean</ja> CallLogger <jf>callLogger</jf>;
- * <ja>@RestBean</ja> BeanStore <jf>beanStore</jf>; <jc>// Note that
BeanStore itself can be accessed this way.</jc>
+ * <ja>@RestInject</ja> CallLogger <jf>callLogger</jf>;
+ * <ja>@RestInject</ja> BeanStore <jf>beanStore</jf>; <jc>// Note that
BeanStore itself can be accessed this way.</jc>
* </p>
*
* <ul class='notes'>
@@ -130,7 +130,7 @@ import org.apache.juneau.svl.*;
* <li class='note'>Any injectable beans (including spring beans) can be
passed as arguments into methods.
* <li class='note'>Bean names are required when multiple beans of the
same type exist in the bean store.
* <li class='note'>By default, the injected bean scope is class-level
(applies to the entire class). The
- * {@link RestBean#methodScope()} annotation can be used to apply
to method-level only (when applicable).
+ * {@link RestInject#methodScope()} annotation can be used to
apply to method-level only (when applicable).
* </ul>
*
* <p>
@@ -174,7 +174,7 @@ import org.apache.juneau.svl.*;
@Target({METHOD,FIELD})
@Retention(RUNTIME)
@Inherited
-public @interface RestBean {
+public @interface RestInject {
/**
* The bean name to use to distinguish beans of the same type for
different purposes.
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestBeanAnnotation.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestInjectAnnotation.java
similarity index 85%
rename from
juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestBeanAnnotation.java
rename to
juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestInjectAnnotation.java
index bf8bad8cb..a7c6f5efe 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestBeanAnnotation.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestInjectAnnotation.java
@@ -20,20 +20,20 @@ import java.lang.annotation.*;
import org.apache.juneau.annotation.*;
/**
- * Utility classes and methods for the {@link RestBean RestBean} annotation.
+ * Utility classes and methods for the {@link RestInject RestInject}
annotation.
*
* <ul class='seealso'>
* <li class='extlink'>{@source}
* </ul>
*/
-public class RestBeanAnnotation {
+public class RestInjectAnnotation {
//-----------------------------------------------------------------------------------------------------------------
// Static
//-----------------------------------------------------------------------------------------------------------------
/** Default value */
- public static final RestBean DEFAULT = create().build();
+ public static final RestInject DEFAULT = create().build();
/**
* Instantiates a new builder for this class.
@@ -45,12 +45,12 @@ public class RestBeanAnnotation {
}
/**
- * Pulls the name/value attribute from a {@link RestBean} annotation.
+ * Pulls the name/value attribute from a {@link RestInject} annotation.
*
* @param a The annotation to check. Can be <jk>null</jk>.
* @return The annotation value, or an empty string if the annotation
is <jk>null</jk>.
*/
- public static String name(RestBean a) {
+ public static String name(RestInject a) {
if (a == null)
return "";
if (! a.name().isEmpty())
@@ -78,20 +78,20 @@ public class RestBeanAnnotation {
* Constructor.
*/
protected Builder() {
- super(RestBean.class);
+ super(RestInject.class);
}
/**
- * Instantiates a new {@link RestBean @RestBean} object
initialized with this builder.
+ * Instantiates a new {@link RestInject @RestInject} object
initialized with this builder.
*
- * @return A new {@link RestBean @RestBean} object.
+ * @return A new {@link RestInject @RestInject} object.
*/
- public RestBean build() {
+ public RestInject build() {
return new Impl(this);
}
/**
- * Sets the {@link RestBean#name()} property on this annotation.
+ * Sets the {@link RestInject#name()} property on this
annotation.
*
* @param value The new value for this property.
* @return This object.
@@ -102,7 +102,7 @@ public class RestBeanAnnotation {
}
/**
- * Sets the {@link RestBean#value()} property on this
annotation.
+ * Sets the {@link RestInject#value()} property on this
annotation.
*
* @param value The new value for this property.
* @return This object.
@@ -113,7 +113,7 @@ public class RestBeanAnnotation {
}
/**
- * Sets the {@link RestBean#methodScope()} property on this
annotation.
+ * Sets the {@link RestInject#methodScope()} property on this
annotation.
*
* @param value The new value for this property.
* @return This object.
@@ -144,7 +144,7 @@ public class RestBeanAnnotation {
// Implementation
//-----------------------------------------------------------------------------------------------------------------
- private static class Impl extends TargetedAnnotationImpl implements
RestBean {
+ private static class Impl extends TargetedAnnotationImpl implements
RestInject {
private final String name, value;
private final String[] methodScope;
@@ -157,17 +157,17 @@ public class RestBeanAnnotation {
postConstruct();
}
- @Override /* RestBean */
+ @Override /* RestInject */
public String name() {
return name;
}
- @Override /* RestBean */
+ @Override /* RestInject */
public String value() {
return value;
}
- @Override /* RestBean */
+ @Override /* RestInject */
public String[] methodScope() {
return methodScope;
}
@@ -178,7 +178,7 @@ public class RestBeanAnnotation {
//-----------------------------------------------------------------------------------------------------------------
/**
- * A collection of {@link RestBean @RestBean annotations}.
+ * A collection of {@link RestInject @RestInject annotations}.
*/
@Documented
@Target({FIELD,METHOD,TYPE})
@@ -191,6 +191,6 @@ public class RestBeanAnnotation {
*
* @return The annotation value.
*/
- RestBean[] value();
+ RestInject[] value();
}
}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/rest/RestContext_Builder_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/rest/RestContext_Builder_Test.java
index 2b9274404..f918414ea 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/rest/RestContext_Builder_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/rest/RestContext_Builder_Test.java
@@ -34,7 +34,7 @@ public class RestContext_Builder_Test {
@Rest
public static class A1 {
- @RestBean static BeanStore beanStore;
+ @RestInject static BeanStore beanStore;
}
@Test
@@ -51,7 +51,7 @@ public class RestContext_Builder_Test {
@Rest(beanStore=MyBeanStore.class)
public static class A2 {
- @RestBean static BeanStore beanStore;
+ @RestInject static BeanStore beanStore;
}
@Test
@@ -62,9 +62,9 @@ public class RestContext_Builder_Test {
@Rest
public static class A3 {
- @RestBean static BeanStore beanStore;
+ @RestInject static BeanStore beanStore;
- @RestBean BeanStore.Builder beanStore(BeanStore.Builder b) {
+ @RestInject BeanStore.Builder beanStore(BeanStore.Builder b) {
return b.type(MyBeanStore.class);
}
}
@@ -77,9 +77,9 @@ public class RestContext_Builder_Test {
@Rest
public static class A4 {
- @RestBean static BeanStore beanStore;
+ @RestInject static BeanStore beanStore;
- @RestBean BeanStore beanStore() {
+ @RestInject BeanStore beanStore() {
return
BeanStore.create().type(MyBeanStore.class).build();
}
}
@@ -91,7 +91,7 @@ public class RestContext_Builder_Test {
}
//-----------------------------------------------------------------------------------------------------------------
- // @RestBean on fields.
+ // @RestInject on fields.
//-----------------------------------------------------------------------------------------------------------------
public static class B {
@@ -104,11 +104,11 @@ public class RestContext_Builder_Test {
@Rest
public static class B1a implements BasicJsonConfig {
- @RestBean static B b1 = new B(1);
- @RestBean(name="b2") B b2 = new B(2);
+ @RestInject static B b1 = new B(1);
+ @RestInject(name="b2") B b2 = new B(2);
- @RestBean static B b3;
- @RestBean(name="b2") B b4;
+ @RestInject static B b3;
+ @RestInject(name="b2") B b4;
@RestGet("/a1") public B a1(B b) { return b; }
@RestGet("/a2") public B a2(@Named("b2") B b) { return b; }