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 290ad26 Context API refactoring.
290ad26 is described below
commit 290ad26f424bf8a16e3a8faa3b430dc1c7bf1a90
Author: JamesBognar <[email protected]>
AuthorDate: Mon Sep 13 12:52:15 2021 -0400
Context API refactoring.
---
.../src/main/java/org/apache/juneau/Context.java | 4 +-
.../java/org/apache/juneau/ContextBuilder.java | 10 +
.../org/apache/juneau/cp/DefaultClassList.java | 14 +-
...faultClassList.java => DefaultSettingsMap.java} | 74 ++---
.../org/apache/juneau/utils/ReflectionMap.java | 138 ++++++++-
.../apache/juneau/utils/ReflectionMapBuilder.java | 91 ------
.../apache/juneau/rest/mock/MockRestClient.java | 2 +-
.../apache/juneau/rest/BasicDebugEnablement.java | 4 +-
.../org/apache/juneau/rest/DebugEnablement.java | 226 ++++++++++++++-
.../apache/juneau/rest/DebugEnablementBuilder.java | 176 ------------
.../org/apache/juneau/rest/DebugEnablementMap.java | 36 ++-
.../juneau/rest/DebugEnablementMapBuilder.java | 34 ---
.../java/org/apache/juneau/rest/RestContext.java | 119 +-------
.../org/apache/juneau/rest/RestContextBuilder.java | 311 ++++++++++++++-------
.../org/apache/juneau/rest/annotation/Rest.java | 5 +-
.../juneau/rest/annotation/RestAnnotation.java | 2 +-
.../apache/juneau/rest/annotation/RestDelete.java | 3 +-
.../org/apache/juneau/rest/annotation/RestGet.java | 3 +-
.../org/apache/juneau/rest/annotation/RestOp.java | 3 +-
.../apache/juneau/rest/annotation/RestPost.java | 3 +-
.../org/apache/juneau/rest/annotation/RestPut.java | 3 +-
.../juneau/rest/logging/BasicRestLogger.java | 4 +-
.../org/apache/juneau/rest/logging/RestLogger.java | 2 +-
.../org/apache/juneau/utils/ReflectionMapTest.java | 2 +-
24 files changed, 678 insertions(+), 591 deletions(-)
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
index b835518..223b1ae 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Context.java
@@ -162,7 +162,7 @@ public abstract class Context implements MetaProvider {
this.identityCode = allowReuse ? new
HashCode().add(className(this)).add(cp).get() : System.identityHashCode(this);
debug = cp.getBoolean(CONTEXT_debug).orElse(false);
- ReflectionMapBuilder<Annotation> rmb =
ReflectionMap.create(Annotation.class);
+ ReflectionMap.Builder<Annotation> rmb =
ReflectionMap.create(Annotation.class);
for (Annotation a : cp.getList(CONTEXT_annotations,
Annotation.class).orElse(emptyList())) {
try {
ClassInfo ci = ClassInfo.of(a.getClass());
@@ -201,7 +201,7 @@ public abstract class Context implements MetaProvider {
identityCode = System.identityHashCode(this);
properties = builder.getContextProperties();
- ReflectionMapBuilder<Annotation> rmb =
ReflectionMap.create(Annotation.class);
+ ReflectionMap.Builder<Annotation> rmb =
ReflectionMap.create(Annotation.class);
for (Annotation a :
builder.getContextProperties().getList(CONTEXT_annotations,
Annotation.class).orElse(emptyList())) {
try {
ClassInfo ci = ClassInfo.of(a.getClass());
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java
index 4987384..15f27aa 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java
@@ -660,10 +660,20 @@ public abstract class ContextBuilder {
*/
@FluentSetter
public ContextBuilder debug() {
+ debug = true;
return set(CONTEXT_debug);
}
/**
+ * Returns <jk>true</jk> if debug is enabled.
+ *
+ * @return <jk>true</jk> if debug is enabled.
+ */
+ public boolean isDebug() {
+ return debug;
+ }
+
+ /**
* Sets a free-form configuration property on this object.
*
* <p>
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/DefaultClassList.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/DefaultClassList.java
index 81c1d5e..7526e05 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/DefaultClassList.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/DefaultClassList.java
@@ -14,14 +14,22 @@ package org.apache.juneau.cp;
import static java.util.Arrays.*;
import static org.apache.juneau.assertions.Assertions.*;
+import static java.util.Optional.*;
import java.util.*;
+import org.apache.juneau.annotation.*;
+
/**
* A list of default implementation classes.
*/
+@NotThreadSafe
public class DefaultClassList {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Static
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Static creator.
*
@@ -41,6 +49,10 @@ public class DefaultClassList {
return new DefaultClassList().add(values);
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
private final List<Class<?>> entries;
/**
@@ -82,7 +94,7 @@ public class DefaultClassList {
for (Class<?> e : entries)
if (e != null && type.isAssignableFrom(e))
return Optional.of((Class<? extends T>)e);
- return Optional.empty();
+ return empty();
}
/**
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/DefaultClassList.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/DefaultSettingsMap.java
similarity index 53%
copy from
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/DefaultClassList.java
copy to
juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/DefaultSettingsMap.java
index 81c1d5e..7542f7b 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/DefaultClassList.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/cp/DefaultSettingsMap.java
@@ -12,42 +12,44 @@
//
***************************************************************************************************************************
package org.apache.juneau.cp;
-import static java.util.Arrays.*;
-import static org.apache.juneau.assertions.Assertions.*;
+import static java.util.Optional.*;
import java.util.*;
+import org.apache.juneau.annotation.*;
/**
- * A list of default implementation classes.
+ * A list of default settings.
+ *
+ * <p>
+ * Consists of a simple string-keyed map of arbitrary objects.
*/
-public class DefaultClassList {
+@NotThreadSafe
+public class DefaultSettingsMap {
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Static
+
//-----------------------------------------------------------------------------------------------------------------
/**
* Static creator.
*
* @return A new object.
*/
- public static DefaultClassList create() {
- return new DefaultClassList();
+ public static DefaultSettingsMap create() {
+ return new DefaultSettingsMap();
}
- /**
- * Static creator.
- *
- * @param values Initial entries in this list.
- * @return A new object initialized with the specified values.
- */
- public static DefaultClassList of(Class<?>...values) {
- return new DefaultClassList().add(values);
- }
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
- private final List<Class<?>> entries;
+ private final Map<String,Object> entries;
/**
* Constructor.
*/
- protected DefaultClassList() {
- entries = new ArrayList<>();
+ protected DefaultSettingsMap() {
+ entries = new LinkedHashMap<>();
}
/**
@@ -55,42 +57,40 @@ public class DefaultClassList {
*
* @param value The object to copy.
*/
- public DefaultClassList(DefaultClassList value) {
- entries = new ArrayList<>(value.entries);
+ public DefaultSettingsMap(DefaultSettingsMap value) {
+ entries = new LinkedHashMap<>(value.entries);
}
/**
- * Prepends the specified values to the beginning of this list.
+ * Sets the specified setting value.
*
- * @param values The values to prepend to this list.
+ * @param name The setting name.
+ * @param value The setting value.
* @return This object.
*/
- public DefaultClassList add(Class<?>...values) {
- entries.addAll(0, asList(values));
+ public DefaultSettingsMap set(String name, Object value) {
+ entries.put(name, value);
return this;
}
/**
- * Returns the first class in this list which is a subclass of (or same
as) the specified type.
+ * Returns the value of the specified setting if it exists.
*
- * @param type The parent type to check for.
- * @return The first class in this list which is a subclass of the
specified type.
+ * @param type The setting type.
+ * @param name The setting name.
+ * @return The setting value.
*/
@SuppressWarnings("unchecked")
- public <T> Optional<Class<? extends T>> get(Class<T> type) {
- assertArgNotNull("type", type);
- for (Class<?> e : entries)
- if (e != null && type.isAssignableFrom(e))
- return Optional.of((Class<? extends T>)e);
- return Optional.empty();
+ public <T> Optional<T> get(Class<T> type, String name) {
+ return ofNullable((T)entries.get(name));
}
/**
- * Creates a copy of this list.
+ * Creates a copy of this map.
*
- * @return A copy of this list.
+ * @return A copy of this map.
*/
- public DefaultClassList copy() {
- return new DefaultClassList(this);
+ public DefaultSettingsMap copy() {
+ return new DefaultSettingsMap(this);
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ReflectionMap.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ReflectionMap.java
index 4a37ef1..d9cb03c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ReflectionMap.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ReflectionMap.java
@@ -12,6 +12,8 @@
//
***************************************************************************************************************************
package org.apache.juneau.utils;
+import static java.lang.Character.*;
+import static org.apache.juneau.internal.ExceptionUtils.*;
import static org.apache.juneau.internal.StringUtils.*;
import java.lang.reflect.*;
@@ -120,6 +122,129 @@ import org.apache.juneau.collections.*;
*/
public class ReflectionMap<V> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Static
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Static builder creator.
+ *
+ * @param <V> The type of object in this map.
+ * @param c The type of object in this map.
+ * @return A new instance of this object.
+ */
+ public static <V> Builder<V> create(Class<V> c) {
+ return new Builder<>();
+ }
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Builder
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Builder class.
+ * @param <V> The type of object in this map.
+ */
+ public static class Builder<V> {
+ final List<ClassEntry<V>> classEntries;
+ final List<MethodEntry<V>> methodEntries;
+ final List<FieldEntry<V>> fieldEntries;
+ final List<ConstructorEntry<V>> constructorEntries;
+
+ /**
+ * Constructor.
+ */
+ protected Builder() {
+ classEntries = new ArrayList<>();
+ methodEntries = new ArrayList<>();
+ fieldEntries = new ArrayList<>();
+ constructorEntries = new ArrayList<>();
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyFrom The builder being copied.
+ */
+ protected Builder(Builder<V> copyFrom) {
+ classEntries = new ArrayList<>(copyFrom.classEntries);
+ methodEntries = new ArrayList<>(copyFrom.methodEntries);
+ fieldEntries = new ArrayList<>(copyFrom.fieldEntries);
+ constructorEntries = new
ArrayList<>(copyFrom.constructorEntries);
+ }
+
+ /**
+ * Adds a mapping to this builder.
+ *
+ * @param key
+ * The mapping key.
+ * <br>Can be any of the following:
+ * <ul>
+ * <li>Full class name (e.g.
<js>"com.foo.MyClass"</js>).
+ * <li>Simple class name (e.g. <js>"MyClass"</js>).
+ * <li>All classes (e.g. <js>"*"</js>).
+ * <li>Full method name (e.g.
<js>"com.foo.MyClass.myMethod"</js>).
+ * <li>Simple method name (e.g.
<js>"MyClass.myMethod"</js>).
+ * <li>A comma-delimited list of anything on this
list.
+ * </ul>
+ * @param value The value for this mapping.
+ * @return This object (for method chaining).
+ */
+ public Builder<V> append(String key, V value) {
+ if (isEmpty(key))
+ throw runtimeException("Invalid reflection
signature: [{0}]", key);
+ try {
+ for (String k : ReflectionMap.splitNames(key)) {
+ if (k.endsWith(")")) {
+ int i = k.substring(0,
k.indexOf('(')).lastIndexOf('.');
+ if (i == -1 ||
isUpperCase(k.charAt(i+1))) {
+
constructorEntries.add(new ConstructorEntry<>(k, value));
+ } else {
+ methodEntries.add(new
MethodEntry<>(k, value));
+ }
+ } else {
+ int i = k.lastIndexOf('.');
+ if (i == -1) {
+ classEntries.add(new
ClassEntry<>(k, value));
+ } else if
(isUpperCase(k.charAt(i+1))) {
+ classEntries.add(new
ClassEntry<>(k, value));
+ fieldEntries.add(new
FieldEntry<>(k, value));
+ } else {
+ methodEntries.add(new
MethodEntry<>(k, value));
+ fieldEntries.add(new
FieldEntry<>(k, value));
+ }
+ }
+ }
+ } catch (IndexOutOfBoundsException e) {
+ throw runtimeException("Invalid reflection
signature: [{0}]", key);
+ }
+
+ return this;
+ }
+
+ /**
+ * Create new instance of {@link ReflectionMap} based on the
contents of this builder.
+ *
+ * @return A new {@link ReflectionMap} object.
+ */
+ public ReflectionMap<V> build() {
+ return new ReflectionMap<>(this);
+ }
+
+ /**
+ * Creates a copy of this builder.
+ *
+ * @return A copy of this builder.
+ */
+ public Builder<V> copy() {
+ return new Builder<>(this);
+ }
+ }
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
private final List<ClassEntry<V>> classEntries;
private final List<MethodEntry<V>> methodEntries;
private final List<FieldEntry<V>> fieldEntries;
@@ -131,7 +256,7 @@ public class ReflectionMap<V> {
*
* @param b Initializer object.
*/
- protected ReflectionMap(ReflectionMapBuilder<V> b) {
+ protected ReflectionMap(Builder<V> b) {
this.classEntries = Collections.unmodifiableList(new
ArrayList<>(b.classEntries));
this.methodEntries = Collections.unmodifiableList(new
ArrayList<>(b.methodEntries));
this.fieldEntries = Collections.unmodifiableList(new
ArrayList<>(b.fieldEntries));
@@ -142,17 +267,6 @@ public class ReflectionMap<V> {
this.noConstructorEntries = constructorEntries.isEmpty();
}
- /**
- * Static builder creator.
- *
- * @param <V> The type of object in this map.
- * @param c The type of object in this map.
- * @return A new instance of this object.
- */
- public static <V> ReflectionMapBuilder<V> create(Class<V> c) {
- return new ReflectionMapBuilder<>();
- }
-
static List<String> splitNames(String key) {
if (key.indexOf(',') == -1)
return Collections.singletonList(key.trim());
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ReflectionMapBuilder.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ReflectionMapBuilder.java
deleted file mode 100644
index d854f22..0000000
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/utils/ReflectionMapBuilder.java
+++ /dev/null
@@ -1,91 +0,0 @@
-//
***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
-// * with the License. You may obtain a copy of the License at
*
-// *
*
-// * http://www.apache.org/licenses/LICENSE-2.0
*
-// *
*
-// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
-// * specific language governing permissions and limitations under the
License. *
-//
***************************************************************************************************************************
-package org.apache.juneau.utils;
-
-import static java.lang.Character.*;
-import static org.apache.juneau.internal.ExceptionUtils.*;
-import static org.apache.juneau.internal.StringUtils.*;
-
-import java.util.*;
-
-import org.apache.juneau.utils.ReflectionMap.*;
-
-/**
- * A builder for {@link ReflectionMap} objects.
- *
- * @param <V> The type of object in this map.
- */
-public class ReflectionMapBuilder<V> {
- List<ClassEntry<V>> classEntries = new ArrayList<>();
- List<MethodEntry<V>> methodEntries = new ArrayList<>();
- List<FieldEntry<V>> fieldEntries = new ArrayList<>();
- List<ConstructorEntry<V>> constructorEntries = new ArrayList<>();
-
- /**
- * Adds a mapping to this builder.
- *
- * @param key
- * The mapping key.
- * <br>Can be any of the following:
- * <ul>
- * <li>Full class name (e.g. <js>"com.foo.MyClass"</js>).
- * <li>Simple class name (e.g. <js>"MyClass"</js>).
- * <li>All classes (e.g. <js>"*"</js>).
- * <li>Full method name (e.g.
<js>"com.foo.MyClass.myMethod"</js>).
- * <li>Simple method name (e.g.
<js>"MyClass.myMethod"</js>).
- * <li>A comma-delimited list of anything on this list.
- * </ul>
- * @param value The value for this mapping.
- * @return This object (for method chaining).
- */
- public ReflectionMapBuilder<V> append(String key, V value) {
- if (isEmpty(key))
- throw runtimeException("Invalid reflection signature:
[{0}]", key);
- try {
- for (String k : ReflectionMap.splitNames(key)) {
- if (k.endsWith(")")) {
- int i = k.substring(0,
k.indexOf('(')).lastIndexOf('.');
- if (i == -1 ||
isUpperCase(k.charAt(i+1))) {
- constructorEntries.add(new
ConstructorEntry<>(k, value));
- } else {
- methodEntries.add(new
MethodEntry<>(k, value));
- }
- } else {
- int i = k.lastIndexOf('.');
- if (i == -1) {
- classEntries.add(new
ClassEntry<>(k, value));
- } else if (isUpperCase(k.charAt(i+1))) {
- classEntries.add(new
ClassEntry<>(k, value));
- fieldEntries.add(new
FieldEntry<>(k, value));
- } else {
- methodEntries.add(new
MethodEntry<>(k, value));
- fieldEntries.add(new
FieldEntry<>(k, value));
- }
- }
- }
- } catch (IndexOutOfBoundsException e) {
- throw runtimeException("Invalid reflection signature:
[{0}]", key);
- }
-
- return this;
- }
-
- /**
- * Create new instance of {@link ReflectionMap} based on the contents
of this builder.
- *
- * @return A new {@link ReflectionMap} object.
- */
- public ReflectionMap<V> build() {
- return new ReflectionMap<>(this);
- }
-}
\ No newline at end of file
diff --git
a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockRestClient.java
b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockRestClient.java
index 851ef4e..8386d44 100644
---
a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockRestClient.java
+++
b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockRestClient.java
@@ -281,9 +281,9 @@ public class MockRestClient extends RestClient implements
HttpClientConnection {
Object o = isClass ?
((Class<?>)restBean).newInstance() : restBean;
RestContext rc = RestContext
.create(o.getClass(), null, null)
- .init(o)
.defaultClasses(BasicTestRestLogger.class)
.debugDefault(CONDITIONAL)
+ .init(o)
.build()
.postInit()
.postInitChildFirst();
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicDebugEnablement.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicDebugEnablement.java
index a65b9fa..32891f5 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicDebugEnablement.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/BasicDebugEnablement.java
@@ -40,7 +40,7 @@ public class BasicDebugEnablement implements DebugEnablement {
*
* @param builder The builder containing the settings for this bean.
*/
- public BasicDebugEnablement(DebugEnablementBuilder builder) {
+ public BasicDebugEnablement(DebugEnablement.Builder builder) {
this.defaultEnablement =
firstNonNull(builder.defaultEnablement, NEVER);
this.enablementMap = builder.mapBuilder.build();
this.conditionalPredicate =
firstNonNull(builder.conditionalPredicate, x ->
"true".equalsIgnoreCase(x.getHeader("Debug")));
@@ -68,7 +68,7 @@ public class BasicDebugEnablement implements DebugEnablement {
*
* <p>
* Subclasses can override this method to provide their own
implementation.
- * The default implementation is provided by {@link
DebugEnablementBuilder#conditionalPredicate(Predicate)}
+ * The default implementation is provided by {@link
DebugEnablement.Builder#conditionalPredicate(Predicate)}
* which has a default predicate of <c><jv>x</jv> ->
<js>"true"</js>.equalsIgnoreCase(<jv>x</jv>.getHeader(<js>"Debug"</js>)</c>.
*
* @param req The incoming HTTP request.
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/DebugEnablement.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/DebugEnablement.java
index 6b1f233..971440a 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/DebugEnablement.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/DebugEnablement.java
@@ -12,15 +12,29 @@
//
***************************************************************************************************************************
package org.apache.juneau.rest;
+import static org.apache.juneau.Enablement.*;
+import static org.apache.juneau.internal.ClassUtils.*;
+import static org.apache.juneau.rest.HttpRuntimeException.*;
+
+import java.util.function.*;
+
import javax.servlet.http.*;
+import org.apache.juneau.*;
+import org.apache.juneau.cp.*;
+import org.apache.juneau.http.response.*;
import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.utils.*;
/**
* Interface used for selectively turning on debug per request.
*/
public interface DebugEnablement {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Static
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Represents no DebugEnablement.
*/
@@ -31,13 +45,217 @@ public interface DebugEnablement {
*
* @return A new builder for this object.
*/
- public static DebugEnablementBuilder create() {
- return new DebugEnablementBuilder();
+ public static Builder create() {
+ return new Builder();
+ }
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Builder
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Builder class.
+ */
+ public class Builder {
+
+ ReflectionMap.Builder<Enablement> mapBuilder;
+ private Class<? extends DebugEnablement> type;
+ Enablement defaultEnablement = NEVER;
+ BeanStore beanStore;
+ Predicate<HttpServletRequest> conditionalPredicate;
+ DebugEnablement impl;
+
+ /**
+ * Constructor.
+ */
+ protected Builder() {
+ mapBuilder = ReflectionMap.create(Enablement.class);
+ defaultEnablement = NEVER;
+ conditionalPredicate = x ->
"true".equalsIgnoreCase(x.getHeader("Debug"));
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyFrom The builder being copied.
+ */
+ protected Builder(Builder copyFrom) {
+ mapBuilder = copyFrom.mapBuilder.copy();
+ type = copyFrom.type;
+ defaultEnablement = copyFrom.defaultEnablement;
+ beanStore = copyFrom.beanStore;
+ conditionalPredicate = copyFrom.conditionalPredicate;
+ impl = copyFrom.impl;
+ }
+
+ /**
+ * Creates a new {@link DebugEnablement} object from this
builder.
+ *s
+ * <p>
+ * Instantiates an instance of the {@link #type(Class)
implementation class} or
+ * else {@link BasicDebugEnablement} if implementation class
was not specified.
+ *
+ * @return A new {@link DebugEnablement} object.
+ */
+ public DebugEnablement build() {
+ try {
+ if (impl != null)
+ return impl;
+ Class<? extends DebugEnablement> ic =
isConcrete(type) ? type : getDefaultImplClass();
+ return
BeanStore.of(beanStore).addBeans(Builder.class, this).createBean(ic);
+ } catch (Exception e) {
+ throw toHttpException(e,
InternalServerError.class);
+ }
+ }
+
+ /**
+ * Specifies the default implementation class if not specified
via {@link #type(Class)}.
+ *
+ * @return The default implementation class if not specified
via {@link #type(Class)}.
+ */
+ protected Class<? extends DebugEnablement>
getDefaultImplClass() {
+ return BasicDebugEnablement.class;
+ }
+
+ /**
+ * Specifies the bean store to use for instantiating the {@link
DebugEnablement} object.
+ *
+ * @param value The new value for this setting.
+ * @return This object.
+ */
+ public Builder beanStore(BeanStore value) {
+ beanStore = value;
+ return this;
+ }
+
+ /**
+ * Specifies a subclass of {@link DebugEnablement} to create
when the {@link #build()} method is called.
+ *
+ * @param value The new value for this setting.
+ * @return This object.
+ */
+ public Builder type(Class<? extends DebugEnablement> value) {
+ type = value;
+ return this;
+ }
+
+ /**
+ * Specifies an already-instantiated bean for the {@link
#build()} method to return.
+ *
+ * @param value The setting value.
+ * @return This object.
+ */
+ public Builder impl(DebugEnablement value) {
+ impl = value;
+ return this;
+ }
+
+ /**
+ * Enables or disables debug on the specified classes and/or
methods.
+ *
+ * <p>
+ * Allows you to target specified debug enablement on specified
classes and/or methods.
+ *
+ * @param enablement
+ * The debug enablement setting to set on the specified
classes/methods.
+ * <br>Can be any of the following:
+ * <ul>
+ * <li>{@link Enablement#ALWAYS ALWAYS} - Debug is
always enabled.
+ * <li>{@link Enablement#NEVER NEVER} - Debug is
always disabled.
+ * <li>{@link Enablement#CONDITIONAL CONDITIONAL}
- Debug is enabled when the {@link #conditionalPredicate(Predicate)}
conditional predicate test} passes.
+ * </ul>
+ * @param keys
+ * The mapping keys.
+ * <br>Can be any of the following:
+ * <ul>
+ * <li>Full class name (e.g.
<js>"com.foo.MyClass"</js>).
+ * <li>Simple class name (e.g. <js>"MyClass"</js>).
+ * <li>All classes (e.g. <js>"*"</js>).
+ * <li>Full method name (e.g.
<js>"com.foo.MyClass.myMethod"</js>).
+ * <li>Simple method name (e.g.
<js>"MyClass.myMethod"</js>).
+ * <li>A comma-delimited list of anything on this
list.
+ * </ul>
+ * @return This object.
+ */
+ public Builder enable(Enablement enablement, String...keys) {
+ for (String k : keys)
+ mapBuilder.append(k, enablement);
+ return this;
+ }
+
+ /**
+ * Enables or disables debug on the specified classes.
+ *
+ * <p>
+ * Identical to {@link #enable(Enablement, String...)} but
allows you to specify specific classes.
+ *
+ * @param enablement
+ * The debug enablement setting to set on the specified
classes/methods.
+ * <br>Can be any of the following:
+ * <ul>
+ * <li>{@link Enablement#ALWAYS ALWAYS} - Debug is
always enabled.
+ * <li>{@link Enablement#NEVER NEVER} - Debug is
always disabled.
+ * <li>{@link Enablement#CONDITIONAL CONDITIONAL}
- Debug is enabled when the {@link #conditionalPredicate(Predicate)}
conditional predicate test} passes.
+ * </ul>
+ * @param classes
+ * The classes to set the debug enablement setting on.
+ * @return This object.
+ */
+ public Builder enable(Enablement enablement,
Class<?>...classes) {
+ for (Class<?> c : classes)
+ mapBuilder.append(c.getName(), enablement);
+ return this;
+ }
+
+ /**
+ * Specifies the default debug enablement setting if not
overridden per class/method.
+ *
+ * <p>
+ * The default value for this setting is {@link
Enablement#NEVER NEVER}.
+ *
+ * @param value The default debug enablement setting if not
overridden per class/method.
+ * @return This object.
+ */
+ public Builder defaultEnable(Enablement value) {
+ defaultEnablement = value;
+ return this;
+ }
+
+ /**
+ * Specifies the predicate to use for conditional debug
enablement.
+ *
+ * <p>
+ * Specifies the predicate to use to determine whether debug is
enabled when the resolved enablement value
+ * is {@link Enablement#CONDITIONAL CONDITIONAL}.
+ *
+ * <p>
+ * The default value for this setting is
<c>(<jv>x</jv>)-><js>"true"</js>.equalsIgnoreCase(<jv>x</jv>.getHeader(<js>"Debug"</js>))</c>.
+ *
+ * @param value The predicate.
+ * @return This object.
+ */
+ public Builder
conditionalPredicate(Predicate<HttpServletRequest> value) {
+ conditionalPredicate = value;
+ return this;
+ }
+
+ /**
+ * Creates a copy of this builder.
+ *
+ * @return A copy of this builder.
+ */
+ public Builder copy() {
+ return new Builder(this);
+ }
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Returns <jk>true</jk> if debug is enabled on the specified class and
request.
- *
+ *
* <p>
* This enables debug mode on requests once the matched class is found
and before the
* Java method is found.
@@ -54,7 +272,7 @@ public interface DebugEnablement {
* <p>
* This enables debug mode after the Java method is found and allows
you to enable
* debug on individual Java methods instead of the entire class.
- *
+ *
* @param context The context of the {@link RestOp}-annotated method.
* @param req The HTTP request.
* @return <jk>true</jk> if debug is enabled on the specified method
and request.
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/DebugEnablementBuilder.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/DebugEnablementBuilder.java
deleted file mode 100644
index f481849..0000000
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/DebugEnablementBuilder.java
+++ /dev/null
@@ -1,176 +0,0 @@
-//
***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
-// * with the License. You may obtain a copy of the License at
*
-// *
*
-// * http://www.apache.org/licenses/LICENSE-2.0
*
-// *
*
-// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
-// * specific language governing permissions and limitations under the
License. *
-//
***************************************************************************************************************************
-package org.apache.juneau.rest;
-
-import static org.apache.juneau.internal.ClassUtils.*;
-import static org.apache.juneau.rest.HttpRuntimeException.*;
-import static org.apache.juneau.Enablement.*;
-
-import java.util.function.*;
-
-import javax.servlet.http.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.cp.*;
-import org.apache.juneau.http.response.*;
-import org.apache.juneau.utils.*;
-
-/**
- * Builder for {@link DebugEnablement} objects.
- */
-public class DebugEnablementBuilder {
-
- ReflectionMapBuilder<Enablement> mapBuilder = new
ReflectionMapBuilder<>();
- private Class<? extends DebugEnablement> implClass;
- Enablement defaultEnablement = NEVER;
- BeanStore beanStore;
- Predicate<HttpServletRequest> conditionalPredicate = x ->
"true".equalsIgnoreCase(x.getHeader("Debug"));
-
- /**
- * Creates a new {@link DebugEnablement} object from this builder.
- *s
- * <p>
- * Instantiates an instance of the {@link #implClass(Class)
implementation class} or
- * else {@link BasicDebugEnablement} if implementation class was not
specified.
- *
- * @return A new {@link DebugEnablement} object.
- */
- public DebugEnablement build() {
- try {
- Class<? extends DebugEnablement> ic =
isConcrete(implClass) ? implClass : getDefaultImplClass();
- return
BeanStore.of(beanStore).addBeans(DebugEnablementBuilder.class,
this).createBean(ic);
- } catch (Exception e) {
- throw toHttpException(e, InternalServerError.class);
- }
- }
-
- /**
- * Specifies the default implementation class if not specified via
{@link #implClass(Class)}.
- *
- * @return The default implementation class if not specified via {@link
#implClass(Class)}.
- */
- protected Class<? extends DebugEnablement> getDefaultImplClass() {
- return BasicDebugEnablement.class;
- }
-
- /**
- * Specifies the bean store to use for instantiating the {@link
DebugEnablement} object.
- *
- * @param value The new value for this setting.
- * @return This object (for method chaining).
- */
- public DebugEnablementBuilder beanStore(BeanStore value) {
- this.beanStore = value;
- return this;
- }
-
- /**
- * Specifies a subclass of {@link DebugEnablement} to create when the
{@link #build()} method is called.
- *
- * @param value The new value for this setting.
- * @return This object (for method chaining).
- */
- public DebugEnablementBuilder implClass(Class<? extends
DebugEnablement> value) {
- this.implClass = value;
- return this;
- }
-
- /**
- * Enables or disables debug on the specified classes and/or methods.
- *
- * <p>
- * Allows you to target specified debug enablement on specified classes
and/or methods.
- *
- * @param enablement
- * The debug enablement setting to set on the specified
classes/methods.
- * <br>Can be any of the following:
- * <ul>
- * <li>{@link Enablement#ALWAYS ALWAYS} - Debug is always
enabled.
- * <li>{@link Enablement#NEVER NEVER} - Debug is always
disabled.
- * <li>{@link Enablement#CONDITIONAL CONDITIONAL} - Debug
is enabled when the {@link #conditionalPredicate(Predicate)} conditional
predicate test} passes.
- * </ul>
- * @param keys
- * The mapping keys.
- * <br>Can be any of the following:
- * <ul>
- * <li>Full class name (e.g. <js>"com.foo.MyClass"</js>).
- * <li>Simple class name (e.g. <js>"MyClass"</js>).
- * <li>All classes (e.g. <js>"*"</js>).
- * <li>Full method name (e.g.
<js>"com.foo.MyClass.myMethod"</js>).
- * <li>Simple method name (e.g.
<js>"MyClass.myMethod"</js>).
- * <li>A comma-delimited list of anything on this list.
- * </ul>
- * @return This object (for method chaining).
- */
- public DebugEnablementBuilder enable(Enablement enablement,
String...keys) {
- for (String k : keys)
- mapBuilder.append(k, enablement);
- return this;
- }
-
- /**
- * Enables or disables debug on the specified classes.
- *
- * <p>
- * Identical to {@link #enable(Enablement, String...)} but allows you
to specify specific classes.
- *
- * @param enablement
- * The debug enablement setting to set on the specified
classes/methods.
- * <br>Can be any of the following:
- * <ul>
- * <li>{@link Enablement#ALWAYS ALWAYS} - Debug is always
enabled.
- * <li>{@link Enablement#NEVER NEVER} - Debug is always
disabled.
- * <li>{@link Enablement#CONDITIONAL CONDITIONAL} - Debug
is enabled when the {@link #conditionalPredicate(Predicate)} conditional
predicate test} passes.
- * </ul>
- * @param classes
- * The classes to set the debug enablement setting on.
- * @return This object (for method chaining).
- */
- public DebugEnablementBuilder enable(Enablement enablement,
Class<?>...classes) {
- for (Class<?> c : classes)
- mapBuilder.append(c.getName(), enablement);
- return this;
- }
-
- /**
- * Specifies the default debug enablement setting if not overridden per
class/method.
- *
- * <p>
- * The default value for this setting is {@link Enablement#NEVER NEVER}.
- *
- * @param value The default debug enablement setting if not overridden
per class/method.
- * @return This object (for method chaining).
- */
- public DebugEnablementBuilder defaultEnable(Enablement value) {
- this.defaultEnablement = value;
- return this;
- }
-
- /**
- * Specifies the predicate to use for conditional debug enablement.
- *
- * <p>
- * Specifies the predicate to use to determine whether debug is enabled
when the resolved enablement value
- * is {@link Enablement#CONDITIONAL CONDITIONAL}.
- *
- * <p>
- * The default value for this setting is
<c>(<jv>x</jv>)-><js>"true"</js>.equalsIgnoreCase(<jv>x</jv>.getHeader(<js>"Debug"</js>))</c>.
- *
- * @param value The predicate.
- * @return This object (for method chaining).
- */
- public DebugEnablementBuilder
conditionalPredicate(Predicate<HttpServletRequest> value) {
- this.conditionalPredicate = value;
- return this;
- }
-}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/DebugEnablementMap.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/DebugEnablementMap.java
index edfb27c..ac45b28 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/DebugEnablementMap.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/DebugEnablementMap.java
@@ -20,21 +20,51 @@ import org.apache.juneau.utils.*;
*/
public class DebugEnablementMap extends ReflectionMap<Enablement> {
+
//-----------------------------------------------------------------------------------------------------------------
+ // Static
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Static builder creator.
*
* @return A new instance of the builder for this object.
*/
- public static DebugEnablementMapBuilder create() {
- return new DebugEnablementMapBuilder();
+ public static Builder create() {
+ return new Builder();
}
+
//-----------------------------------------------------------------------------------------------------------------
+ // Builder
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Builder class.
+ */
+ public static class Builder extends ReflectionMap.Builder<Enablement> {
+
+ /**
+ * Constructor.
+ */
+ protected Builder() {
+ super();
+ }
+
+ @Override /* ReflectionMapBuilder */
+ public DebugEnablementMap build() {
+ return new DebugEnablementMap(this);
+ }
+ }
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Instance
+
//-----------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
* @param builder The builder.
*/
- protected DebugEnablementMap(DebugEnablementMapBuilder builder) {
+ protected DebugEnablementMap(Builder builder) {
super(builder);
}
}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/DebugEnablementMapBuilder.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/DebugEnablementMapBuilder.java
deleted file mode 100644
index 1e534fe..0000000
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/DebugEnablementMapBuilder.java
+++ /dev/null
@@ -1,34 +0,0 @@
-//
***************************************************************************************************************************
-// * Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file *
-// * distributed with this work for additional information regarding copyright
ownership. The ASF licenses this file *
-// * to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance *
-// * with the License. You may obtain a copy of the License at
*
-// *
*
-// * http://www.apache.org/licenses/LICENSE-2.0
*
-// *
*
-// * Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an *
-// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied. See the License for the *
-// * specific language governing permissions and limitations under the
License. *
-//
***************************************************************************************************************************
-package org.apache.juneau.rest;
-
-import org.apache.juneau.*;
-import org.apache.juneau.utils.*;
-
-/**
- * Builder for {@link DebugEnablementMap} objects.
- */
-public class DebugEnablementMapBuilder extends
ReflectionMapBuilder<Enablement> {
-
- /**
- * Constructor.
- */
- protected DebugEnablementMapBuilder() {
- super();
- }
-
- @Override /* ReflectionMapBuilder */
- public DebugEnablementMap build() {
- return new DebugEnablementMap(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 61d3e9f..7fd683d 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
@@ -190,8 +190,8 @@ public class RestContext extends Context {
final Charset defaultCharset;
final long maxInput;
- final Enablement debugDefault;
final DefaultClassList defaultClasses;
+ final DefaultSettingsMap defaultSettings;
// Lifecycle methods
private final MethodInvoker[]
@@ -238,6 +238,7 @@ public class RestContext extends Context {
parentContext = builder.parentContext;
rootBeanStore = builder.beanStore();
defaultClasses = builder.defaultClasses();
+ defaultSettings = builder.defaultSettings();
BeanStore bs = beanStore = rootBeanStore.copy().build();
beanStore
@@ -247,6 +248,13 @@ public class RestContext extends Context {
.addBean(RestContextBuilder.class, builder)
.addBean(AnnotationWorkList.class,
builder.getApplied());
+ path = ofNullable(builder.path).orElse("");
+ fullPath = (parentContext == null ? "" :
(parentContext.fullPath + '/')) + path;
+ String p = path;
+ if (! p.endsWith("/*"))
+ p += "/*";
+ pathMatcher = UrlPathMatcher.of(p);
+
allowBodyParam = ! builder.disableBodyParam;
allowedHeaderParams =
newCaseInsensitiveSet(ofNullable(builder.allowedHeaderParams).map(x ->
"NONE".equals(x) ? "" : x).orElse(""));
allowedMethodParams =
newCaseInsensitiveSet(ofNullable(builder.allowedMethodParams).map(x ->
"NONE".equals(x) ? "" : x).orElse(""));
@@ -267,7 +275,6 @@ public class RestContext extends Context {
varResolver = bs.add(VarResolver.class,
builder.varResolver().bean(Messages.class, messages).build());
config = bs.add(Config.class,
builder.config().resolving(varResolver.createSession()));
responseProcessors = bs.add(ResponseProcessor[].class,
builder.responseProcessors().build().toArray());
- debugDefault = builder.debugDefault;
callLogger = bs.add(RestLogger.class,
builder.callLogger().beanStore(beanStore).loggerOnce(logger).thrownStoreOnce(thrownStore).build());
partSerializer = bs.add(HttpPartSerializer.class,
builder.partSerializer().create());
partParser = bs.add(HttpPartParser.class,
builder.partParser().create());
@@ -279,19 +286,10 @@ public class RestContext extends Context {
defaultRequestAttributes =
bs.add("RestContext.defaultRequestAttributes",
builder.defaultRequestAttributes());
restOpArgs = builder.restOpArgs().build().asArray();
hookMethodArgs =
builder.hookMethodArgs().build().asArray();
+ debugEnablement = builder.debugEnablement().build();
Object r = resource.get();
- debugEnablement = createDebugEnablement(r, builder, bs);
-
- path = ofNullable(builder.path).orElse("");
- fullPath = (parentContext == null ? "" :
(parentContext.fullPath + '/')) + path;
-
- String p = path;
- if (! p.endsWith("/*"))
- p += "/*";
- pathMatcher = UrlPathMatcher.of(p);
-
startCallMethods = createStartCallMethods(r, builder,
bs).stream().map(this::toMethodInvoker).toArray(MethodInvoker[]::new);
endCallMethods = createEndCallMethods(r, builder,
bs).stream().map(this::toMethodInvoker).toArray(MethodInvoker[]::new);
postInitMethods = createPostInitMethods(r, builder,
bs).stream().map(this::toMethodInvoker).toArray(MethodInvoker[]::new);
@@ -468,103 +466,6 @@ public class RestContext extends Context {
}
/**
- * Instantiates the debug enablement bean for this REST object.
- *
- * @param resource
- * The REST servlet or bean that this context defines.
- * @param builder
- * The builder for this object.
- * @param beanStore
- * The factory used for creating beans and retrieving injected
beans.
- * <br>Created by {@link RestContextBuilder#beanStore()}.
- * @return The debug enablement bean for this REST object.
- * @throws Exception If bean could not be created.
- */
- protected DebugEnablement createDebugEnablement(Object resource,
RestContextBuilder builder, BeanStore beanStore) throws Exception {
- DebugEnablement x = null;
-
- if (resource instanceof DebugEnablement)
- x = (DebugEnablement)resource;
-
- if (x == null)
- x = builder.debugEnablement.value().orElse(null);
-
- if (x == null)
- x =
beanStore.getBean(DebugEnablement.class).orElse(null);
-
- if (x == null)
- x = createDebugEnablementBuilder(resource, builder,
beanStore).build();
-
- x = BeanStore
- .of(beanStore, resource)
- .addBean(DebugEnablement.class, x)
- .beanCreateMethodFinder(DebugEnablement.class, resource)
- .find("createDebugEnablement")
- .withDefault(x)
- .run();
-
- return x;
- }
-
- /**
- * Instantiates the debug enablement bean builder for this REST object.
- *
- * @param resource
- * The REST servlet or bean that this context defines.
- * @param builder
- * The builder for this object.
- * <br>Consists of all properties gathered through the builder and
annotations on this class and all parent classes.
- * @param beanStore
- * The factory used for creating beans and retrieving injected
beans.
- * <br>Created by {@link RestContextBuilder#beanStore()}.
- * @return The debug enablement bean builder for this REST object.
- * @throws Exception If bean builder could not be created.
- */
- protected DebugEnablementBuilder createDebugEnablementBuilder(Object
resource, RestContextBuilder builder, BeanStore beanStore) throws Exception {
-
- Class<? extends DebugEnablement> c =
builder.debugEnablement.type().orElse(null);
-
- DebugEnablementBuilder x = DebugEnablement
- .create()
- .beanStore(beanStore)
- .implClass(c);
-
- x = BeanStore
- .of(beanStore, resource)
- .addBean(DebugEnablementBuilder.class, x)
- .beanCreateMethodFinder(DebugEnablementBuilder.class,
resource)
- .find("createDebugEnablementBuilder")
- .withDefault(x)
- .run();
-
- Enablement defaultDebug = builder.debug;
-
- if (defaultDebug == null)
- defaultDebug = builder.debugDefault;
-
- if (defaultDebug == null)
- defaultDebug = isDebug() ? Enablement.ALWAYS :
Enablement.NEVER;
-
- x.defaultEnable(defaultDebug);
-
- for (Map.Entry<String,String> e :
splitMap(ofNullable(builder.debugOn).orElse(""), true).entrySet()) {
- String k = e.getKey(), v = e.getValue();
- if (v.isEmpty())
- v = "ALWAYS";
- if (! k.isEmpty())
- x.enable(Enablement.fromString(v), k);
- }
-
- for (MethodInfo mi :
ClassInfo.ofProxy(resource).getPublicMethods()) {
- Optional<String> o =
mi.getAnnotationGroupList(RestOp.class).getValues(String.class,
"debug").stream().filter(y->!y.isEmpty()).findFirst();
- if (o.isPresent())
- x.enable(Enablement.fromString(o.get()),
mi.getFullName());
- }
-
- return x;
- }
-
- /**
* Creates the set of {@link RestOpContext} objects that represent the
methods on this resource.
*
* @param resource
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
index f2d1336..e279db2 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
@@ -123,6 +123,8 @@ public class RestContextBuilder extends ContextBuilder
implements ServletConfig
final RestContext parentContext;
private DefaultClassList defaultClasses;
+ private DefaultSettingsMap defaultSettings;
+
private BeanStore beanStore;
private Config config;
private VarResolver.Builder varResolver;
@@ -140,6 +142,7 @@ public class RestContextBuilder extends ContextBuilder
implements ServletConfig
private HeaderList.Builder defaultRequestHeaders,
defaultResponseHeaders;
private NamedAttributeList defaultRequestAttributes;
private RestOpArgList.Builder restOpArgs, hookMethodArgs;
+ private DebugEnablement.Builder debugEnablement;
String
allowedHeaderParams = env("RestContext.allowedHeaderParams",
"Accept,Content-Type"),
@@ -163,14 +166,10 @@ public class RestContextBuilder extends ContextBuilder
implements ServletConfig
Class<? extends RestOperations> operationsClass = RestOperations.class;
BeanRef<SwaggerProvider> swaggerProvider =
BeanRef.of(SwaggerProvider.class);
- BeanRef<DebugEnablement> debugEnablement =
BeanRef.of(DebugEnablement.class);
EncoderGroup.Builder encoders =
EncoderGroup.create().add(IdentityEncoder.INSTANCE);
SerializerGroup.Builder serializers = SerializerGroup.create();
ParserGroup.Builder parsers = ParserGroup.create();
- Enablement debugDefault, debug;
-
-
List<Object> children = new ArrayList<>();
/**
@@ -191,10 +190,11 @@ public class RestContextBuilder extends ContextBuilder
implements ServletConfig
// Pass-through default values.
if (parentContext != null) {
- debugDefault = parentContext.debugDefault;
defaultClasses =
parentContext.defaultClasses.copy();
+ defaultSettings =
parentContext.defaultSettings.copy();
} else {
defaultClasses = DefaultClassList.create();
+ defaultSettings = DefaultSettingsMap.create();
}
beanStore = createBeanStore(resourceClass,
parentContext)
@@ -313,11 +313,19 @@ public class RestContextBuilder extends ContextBuilder
implements ServletConfig
//-----------------------------------------------------------------------------------------------------------------
/**
- * Returns access to the default classes list.
+ * Returns the default classes list.
*
* <p>
* This defines the implementation classes for a variety of bean types.
*
+ * <p>
+ * Default classes are inherited from the parent REST object.
+ * Typically used on the top-level {@link RestContextBuilder} to affect
class types for that REST object and all children.
+ *
+ * <p>
+ * Modifying the default class list on this builder does not affect the
default class list on the parent builder, but changes made
+ * here are inherited by child builders.
+ *
* @return The default classes list for this builder.
*/
public DefaultClassList defaultClasses() {
@@ -327,8 +335,16 @@ public class RestContextBuilder extends ContextBuilder
implements ServletConfig
/**
* Adds default implementation classes to use.
*
+ * <p>
+ * A shortcut for the following code:
+ *
+ * <p class='bcode w800'>
+ * <jv>builder</jv>.defaultClasses().add(<jv>values</jv>);
+ * </p>
+ *
* @param values The values to add to the list of default classes.
* @return This object.
+ * @see #defaultClasses()
*/
public RestContextBuilder defaultClasses(Class<?>...values) {
defaultClasses().add(values);
@@ -336,6 +352,47 @@ public class RestContextBuilder extends ContextBuilder
implements ServletConfig
}
//-----------------------------------------------------------------------------------------------------------------
+ // defaultSettings
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Returns the default settings map.
+ *
+ * <p>
+ * Default settings are inherited from the parent REST object.
+ * Typically used on the top-level {@link RestContextBuilder} to affect
settings for that REST object and all children.
+ *
+ * <p>
+ * Modifying the default settings map on this builder does not affect
the default settings on the parent builder, but changes made
+ * here are inherited by child builders.
+ *
+ * @return The default settings map for this builder.
+ */
+ public DefaultSettingsMap defaultSettings() {
+ return defaultSettings;
+ }
+
+ /**
+ * Sets a default setting.
+ *
+ * <p>
+ * A shortcut for the following code:
+ *
+ * <p class='bcode w800'>
+ * <jv>builder</jv>.defaultSettings().add(<jv>key</jv>,
<jv>value</jv>);
+ *
+ * </p>
+ * @param key The setting key.
+ * @param value The setting value.
+ * @return This object.
+ * @see #defaultSettings()
+ */
+ public RestContextBuilder defaultSetting(String key, Object value) {
+ defaultSettings().set(key, value);
+ return this;
+ }
+
+
//-----------------------------------------------------------------------------------------------------------------
// beanStore
//-----------------------------------------------------------------------------------------------------------------
@@ -2579,7 +2636,6 @@ public class RestContextBuilder extends ContextBuilder
implements ServletConfig
*/
protected RestOpArgList.Builder createHookMethodArgs(BeanStore
beanStore, Supplier<?> resource) {
-
Value<RestOpArgList.Builder> v = Value.empty();
Object r = resource.get();
@@ -2633,6 +2689,153 @@ public class RestContextBuilder extends ContextBuilder
implements ServletConfig
}
//-----------------------------------------------------------------------------------------------------------------
+ // debugEnablement
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Returns the builder for the debug enablement bean in the REST
context.
+ *
+ * <p>
+ * Enables the following:
+ * <ul class='spaced-list'>
+ * <li>
+ * HTTP request/response bodies are cached in memory for
logging purposes.
+ * <li>
+ * Request/response messages are automatically logged
always or per request.
+ * </ul>
+ *
+ * @return The builder for the debug enablement bean in the REST
context.
+ */
+ public final DebugEnablement.Builder debugEnablement() {
+ if (debugEnablement == null)
+ debugEnablement = createDebugEnablement(beanStore(),
resource());
+ return debugEnablement;
+ }
+
+ /**
+ * Sets the debug default value.
+ *
+ * <p>
+ * The default debug value is the enablement value if not otherwise
overridden at the class or method level.
+ *
+ * @param value The debug default value.
+ * @return This object.
+ */
+ @FluentSetter
+ public RestContextBuilder debugDefault(Enablement value) {
+ defaultSettings().set("RestContext.debugDefault", value);
+ return this;
+ }
+
+ /**
+ * Specifies the debug level on this REST resource.
+ *
+ * @param value The value for this setting.
+ * @return This object.
+ */
+ public RestContextBuilder debug(Enablement value) {
+ debugEnablement().enable(value, this.resourceClass);
+ return this;
+ }
+
+ /**
+ * Debug mode on specified classes/methods.
+ *
+ * Enables the following:
+ * <ul class='spaced-list'>
+ * <li>
+ * HTTP request/response bodies are cached in memory for
logging purposes.
+ * <li>
+ * Request/response messages are automatically logged.
+ * </ul>
+ *
+ * <ul class='seealso'>
+ * <li class='ja'>{@link Rest#debugOn}
+ * </ul>
+ *
+ * @param value The new value for this setting.
+ * @return This object (for method chaining).
+ */
+ @FluentSetter
+ public RestContextBuilder debugOn(String value) {
+ for (Map.Entry<String,String> e :
splitMap(ofNullable(value).orElse(""), true).entrySet()) {
+ String k = e.getKey(), v = e.getValue();
+ if (v.isEmpty())
+ v = "ALWAYS";
+ if (! k.isEmpty())
+
debugEnablement().enable(Enablement.fromString(v), k);
+ }
+ return this;
+ }
+
+ /**
+ * Instantiates the debug enablement bean for this REST object.
+ *
+ * @param beanStore
+ * The factory used for creating beans and retrieving injected
beans.
+ * @param resource
+ * The REST servlet or bean that this context defines.
+ * @return The debug enablement bean for this REST object.
+ */
+ protected DebugEnablement.Builder createDebugEnablement(BeanStore
beanStore, Supplier<?> resource) {
+
+ Value<DebugEnablement.Builder> v = Value.empty();
+ Object r = resource.get();
+
+ beanStore.getBean(DebugEnablement.Builder.class).map(x ->
x.copy()).ifPresent(x -> v.set(x));
+
+ if (v.isEmpty()) {
+ DebugEnablement.Builder b = DebugEnablement
+ .create()
+ .beanStore(beanStore);
+
+ // Default debug enablement if not overridden at
class/method level.
+ Enablement debugDefault =
defaultSettings.get(Enablement.class,
"RestContext.debugDefault").orElse(isDebug() ? Enablement.ALWAYS :
Enablement.NEVER);
+ b.defaultEnable(debugDefault);
+
+ // Gather @RestOp(debug) settings.
+ for (MethodInfo mi :
ClassInfo.ofProxy(r).getPublicMethods()) {
+ mi
+ .getAnnotationGroupList(RestOp.class)
+ .getValues(String.class, "debug")
+ .stream()
+ .filter(y->!y.isEmpty())
+ .findFirst()
+ .ifPresent(x ->
b.enable(Enablement.fromString(x), mi.getFullName()));
+ }
+
+ v.set(b);
+ }
+
+ if (r instanceof DebugEnablement)
+ v.get().impl((DebugEnablement)r);
+
+ defaultClasses.get(DebugEnablement.class).ifPresent(x ->
v.get().type(x));
+
+ beanStore.getBean(DebugEnablement.class).ifPresent(x ->
v.get().impl(x));
+
+ BeanStore
+ .of(beanStore, r)
+ .addBean(DebugEnablement.Builder.class, v.get())
+ .beanCreateMethodFinder(DebugEnablement.Builder.class,
r)
+ .find("createDebugEnablement")
+ .execute()
+ .ifPresent(x -> v.set(x));
+
+ BeanStore
+ .of(beanStore, r)
+ .addBean(DebugEnablement.Builder.class, v.get())
+ .beanCreateMethodFinder(DebugEnablement.class, r)
+ .find("createDebugEnablement")
+ .execute()
+ .ifPresent(x -> v.get().impl(x));
+
+ return v.get();
+ }
+
+ private int TODO;
+
+
//-----------------------------------------------------------------------------------------------------------------
// Miscellaneous settings
//-----------------------------------------------------------------------------------------------------------------
@@ -3560,100 +3763,6 @@ public class RestContextBuilder extends ContextBuilder
implements ServletConfig
}
/**
- * Debug mode.
- *
- * <p>
- * Enables the following:
- * <ul class='spaced-list'>
- * <li>
- * HTTP request/response bodies are cached in memory for
logging purposes.
- * <li>
- * Request/response messages are automatically logged
always or per request.
- * </ul>
- *
- * <p>
- * The default can be overwritten by {@link
RestContextBuilder#debugDefault(Enablement)}.
- *
- * @param value The new value for this setting.
- * @return This object (for method chaining).
- */
- @FluentSetter
- public RestContextBuilder debug(Enablement value) {
- debug = value;
- return this;
- }
-
- /**
- * Default debug mode.
- *
- * <p>
- * The default value for the {@link #debug(Enablement)} setting.
- *
- * <p>
- * This setting is inherited from parent contexts.
- *
- * @param value The new value for this setting.
- * @return This object (for method chaining).
- */
- @FluentSetter
- public RestContextBuilder debugDefault(Enablement value) {
- debugDefault = value;
- return this;
- }
-
- /**
- * Debug enablement bean.
- *
- * TODO
- *
- * @param value The new value for this setting.
- * @return This object (for method chaining).
- */
- @FluentSetter
- public RestContextBuilder debugEnablement(Class<? extends
DebugEnablement> value) {
- debugEnablement.type(value);
- return this;
- }
-
- /**
- * Debug enablement bean.
- *
- * TODO
- *
- * @param value The new value for this setting.
- * @return This object (for method chaining).
- */
- @FluentSetter
- public RestContextBuilder debugEnablement(DebugEnablement value) {
- debugEnablement.value(value);
- return this;
- }
-
- /**
- * Debug mode on specified classes/methods.
- *
- * Enables the following:
- * <ul class='spaced-list'>
- * <li>
- * HTTP request/response bodies are cached in memory for
logging purposes.
- * <li>
- * Request/response messages are automatically logged.
- * </ul>
- *
- * <ul class='seealso'>
- * <li class='ja'>{@link Rest#debugOn}
- * </ul>
- *
- * @param value The new value for this setting.
- * @return This object (for method chaining).
- */
- @FluentSetter
- public RestContextBuilder debugOn(String value) {
- debugOn = value;
- return this;
- }
-
- /**
* <i><l>RestContext</l> configuration property: </i> Parser
listener.
*
* <p>
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Rest.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Rest.java
index 773ca09..8e4e610 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Rest.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Rest.java
@@ -346,7 +346,7 @@ public @interface Rest {
* </ul>
*
* <ul class='seealso'>
- * <li class='jm'>{@link RestContextBuilder#debug(Enablement)}
+ * <li class='jm'>{@link RestContextBuilder#debugEnablement()}
* </ul>
*/
String debug() default "";
@@ -357,8 +357,7 @@ public @interface Rest {
* TODO
*
* <ul class='seealso'>
- * <li class='jm'>{@link RestContextBuilder#debugEnablement(Class)}
- * <li class='jm'>{@link
RestContextBuilder#debugEnablement(DebugEnablement)}
+ * <li class='jm'>{@link RestContextBuilder#debugEnablement()}
* </ul>
*/
Class<? extends DebugEnablement> debugEnablement() default
DebugEnablement.Null.class;
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestAnnotation.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestAnnotation.java
index 592c36b..a9c5410 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestAnnotation.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestAnnotation.java
@@ -1092,7 +1092,7 @@ public class RestAnnotation {
type(a.restOpContextClass()).ifPresent(x ->
b.restOpContextClass(x));
type(a.restChildrenClass()).ifPresent(x ->
b.restChildrenClass(x));
type(a.restOperationsClass()).ifPresent(x ->
b.restOperationsClass(x));
- type(a.debugEnablement()).ifPresent(x ->
b.debugEnablement(x));
+ type(a.debugEnablement()).ifPresent(x ->
b.debugEnablement().type(x));
string(a.disableBodyParam()).map(Boolean::parseBoolean).ifPresent(x ->
b.disableBodyParam(x));
string(a.allowedHeaderParams()).ifPresent(x ->
b.allowedHeaderParams(x));
string(a.allowedMethodHeaders()).ifPresent(x ->
b.allowedMethodHeaders(x));
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDelete.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDelete.java
index 77e61a0..bb39a14 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDelete.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestDelete.java
@@ -18,7 +18,6 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
import java.nio.charset.*;
-import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.dto.swagger.*;
@@ -139,7 +138,7 @@ public @interface RestDelete {
* </ul>
*
* <ul class='seealso'>
- * <li class='jm'>{@link RestContextBuilder#debug(Enablement)}
+ * <li class='jm'>{@link RestContextBuilder#debugEnablement()}
* </ul>
*/
String debug() default "";
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestGet.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestGet.java
index 0948554..f04aa80 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestGet.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestGet.java
@@ -18,7 +18,6 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
import java.nio.charset.*;
-import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.serializer.*;
@@ -155,7 +154,7 @@ public @interface RestGet {
* </ul>
*
* <ul class='seealso'>
- * <li class='jm'>{@link RestContextBuilder#debug(Enablement)}
+ * <li class='jm'>{@link RestContextBuilder#debugEnablement()}
* </ul>
*/
String debug() default "";
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestOp.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestOp.java
index 2478138..0fad7a8 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestOp.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestOp.java
@@ -18,7 +18,6 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
import java.nio.charset.*;
-import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.serializer.*;
@@ -172,7 +171,7 @@ public @interface RestOp {
* </ul>
*
* <ul class='seealso'>
- * <li class='jm'>{@link RestContextBuilder#debug(Enablement)}
+ * <li class='jm'>{@link RestContextBuilder#debugEnablement()}
* </ul>
*/
String debug() default "";
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPost.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPost.java
index 4d606b9..061266b 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPost.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPost.java
@@ -18,7 +18,6 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
import java.nio.charset.*;
-import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.serializer.*;
@@ -174,7 +173,7 @@ public @interface RestPost {
* </ul>
*
* <ul class='seealso'>
- * <li class='jm'>{@link RestContextBuilder#debug(Enablement)}
+ * <li class='jm'>{@link RestContextBuilder#debugEnablement()}
* </ul>
*/
String debug() default "";
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPut.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPut.java
index 01d4141..1b138ca 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPut.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestPut.java
@@ -18,7 +18,6 @@ import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
import java.nio.charset.*;
-import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.rest.*;
import org.apache.juneau.serializer.*;
@@ -174,7 +173,7 @@ public @interface RestPut {
* </ul>
*
* <ul class='seealso'>
- * <li class='jm'>{@link RestContextBuilder#debug(Enablement)}
+ * <li class='jm'>{@link RestContextBuilder#debugEnablement()}
* </ul>
*/
String debug() default "";
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/logging/BasicRestLogger.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/logging/BasicRestLogger.java
index 373e416..f602edf 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/logging/BasicRestLogger.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/logging/BasicRestLogger.java
@@ -83,7 +83,7 @@ import org.apache.juneau.rest.util.*;
*
* <ul class='seealso'>
* <li class='jm'>{@link RestContextBuilder#callLogger()}
- * <li class='jm'>{@link RestContextBuilder#debug(Enablement)}
+ * <li class='jm'>{@link RestContextBuilder#debugEnablement()}
* <li class='jm'>{@link RestContextBuilder#debugOn(String)}
* <li class='ja'>{@link Rest#debug}
* <li class='ja'>{@link RestOp#debug}
@@ -270,7 +270,7 @@ public class BasicRestLogger implements RestLogger {
*
* @param req The HTTP request being logged.
* @return <jk>true</jk> if debug is enabled on this request.
- * @see RestContextBuilder#debug(Enablement)
+ * @see RestContextBuilder#debugEnablement()
* @see RestContextBuilder#debugOn(String)
* @see Rest#debug()
* @see RestOp#debug()
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/logging/RestLogger.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/logging/RestLogger.java
index 01d46f7..2587e99 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/logging/RestLogger.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/logging/RestLogger.java
@@ -47,7 +47,7 @@ import org.apache.juneau.rest.annotation.*;
*
* <ul class='seealso'>
* <li class='jm'>{@link RestContextBuilder#callLogger()}
- * <li class='jm'>{@link RestContextBuilder#debug(Enablement)}
+ * <li class='jm'>{@link RestContextBuilder#debugEnablement()}
* <li class='jm'>{@link RestContextBuilder#debugOn(String)}
* <li class='ja'>{@link Rest#debug}
* <li class='ja'>{@link RestOp#debug}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/utils/ReflectionMapTest.java
b/juneau-utest/src/test/java/org/apache/juneau/utils/ReflectionMapTest.java
index 04e82ae..a6b23fe 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/utils/ReflectionMapTest.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/utils/ReflectionMapTest.java
@@ -23,7 +23,7 @@ import org.junit.*;
@FixMethodOrder(NAME_ASCENDING)
public class ReflectionMapTest {
- private static ReflectionMapBuilder<Number> create() {
+ private static ReflectionMap.Builder<Number> create() {
return ReflectionMap.create(Number.class);
}