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 ec40334 Context API refactoring.
ec40334 is described below
commit ec40334657076133889caee52dd9ebcd55065a99
Author: JamesBognar <[email protected]>
AuthorDate: Fri Oct 1 16:55:39 2021 -0400
Context API refactoring.
---
.../main/java/org/apache/juneau/config/Config.java | 4 +-
.../org/apache/juneau/config/ConfigBuilder.java | 2 +-
.../apache/juneau/config/store/ConfigStore.java | 4 +-
.../juneau/config/store/ConfigStoreBuilder.java | 2 +-
.../apache/juneau/jena/RdfSerializerSession.java | 5 -
.../main/java/org/apache/juneau/BeanContext.java | 2 +-
.../java/org/apache/juneau/BeanContextBuilder.java | 2 +-
.../java/org/apache/juneau/BeanContextable.java | 2 +-
.../org/apache/juneau/BeanContextableBuilder.java | 2 +-
.../main/java/org/apache/juneau/BeanSession.java | 2 +-
.../java/org/apache/juneau/BeanSessionArgs.java | 2 +-
.../src/main/java/org/apache/juneau/Context.java | 994 ++++++++++++++++++++-
.../java/org/apache/juneau/ContextBeanCreator.java | 6 +-
.../java/org/apache/juneau/ContextBuilder.java | 676 --------------
.../src/main/java/org/apache/juneau/Session.java | 201 -----
.../main/java/org/apache/juneau/SessionArgs.java | 146 ---
.../org/apache/juneau/annotation/BeanConfig.java | 5 +-
.../juneau/csv/annotation/CsvAnnotation.java | 8 +-
.../juneau/html/annotation/HtmlAnnotation.java | 8 +-
.../juneau/html/annotation/HtmlLinkAnnotation.java | 8 +-
.../juneau/jso/annotation/JsoAnnotation.java | 8 +-
.../juneau/json/annotation/JsonAnnotation.java | 8 +-
.../jsonschema/annotation/SchemaAnnotation.java | 8 +-
.../msgpack/annotation/MsgPackAnnotation.java | 8 +-
.../juneau/oapi/annotation/OpenApiAnnotation.java | 8 +-
.../java/org/apache/juneau/parser/ParserPipe.java | 2 +-
.../org/apache/juneau/parser/ParserSession.java | 2 +-
.../plaintext/annotation/PlainTextAnnotation.java | 8 +-
.../juneau/soap/annotation/SoapXmlAnnotation.java | 8 +-
.../juneau/uon/annotation/UonAnnotation.java | 8 +-
.../annotation/UrlEncodingAnnotation.java | 8 +-
.../juneau/xml/annotation/XmlAnnotation.java | 8 +-
.../org/apache/juneau/rest/client/RestClient.java | 2 +-
.../juneau/rest/client/RestClientBuilder.java | 2 +-
.../java/org/apache/juneau/rest/RestContext.java | 6 +-
.../org/apache/juneau/rest/RestContextBuilder.java | 2 +-
.../java/org/apache/juneau/rest/RestOpContext.java | 6 +-
.../apache/juneau/rest/RestOpContextBuilder.java | 2 +-
.../apache/juneau/reflection/ClassInfoTest.java | 6 +-
.../apache/juneau/reflection/MethodInfoTest.java | 6 +-
40 files changed, 1055 insertions(+), 1142 deletions(-)
diff --git
a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/Config.java
b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/Config.java
index d041b30..c18ffc5 100644
---
a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/Config.java
+++
b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/Config.java
@@ -1592,7 +1592,7 @@ public final class Config extends Context implements
ConfigEventListener, Writab
* Unused.
*/
@Override /* Context */
- public Session createSession(SessionArgs args) {
+ public Session createSession(Context.Args args) {
throw new UnsupportedOperationException();
}
@@ -1600,7 +1600,7 @@ public final class Config extends Context implements
ConfigEventListener, Writab
* Unused.
*/
@Override /* Context */
- public SessionArgs createDefaultSessionArgs() {
+ public Context.Args createDefaultSessionArgs() {
throw new UnsupportedOperationException();
}
diff --git
a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/ConfigBuilder.java
b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/ConfigBuilder.java
index 6f5118b..cf55358 100644
---
a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/ConfigBuilder.java
+++
b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/ConfigBuilder.java
@@ -41,7 +41,7 @@ import org.apache.juneau.svl.*;
* </ul>
*/
@FluentSetters
-public class ConfigBuilder extends ContextBuilder {
+public class ConfigBuilder extends Context.Builder {
String name;
ConfigStore store;
diff --git
a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/store/ConfigStore.java
b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/store/ConfigStore.java
index d982739..0d62f2d 100644
---
a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/store/ConfigStore.java
+++
b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/store/ConfigStore.java
@@ -189,7 +189,7 @@ public abstract class ConfigStore extends Context
implements Closeable {
* Unused.
*/
@Override /* Context */
- public final Session createSession(SessionArgs args) {
+ public final Session createSession(Context.Args args) {
throw new NoSuchMethodError();
}
@@ -197,7 +197,7 @@ public abstract class ConfigStore extends Context
implements Closeable {
* Unused.
*/
@Override /* Context */
- public final SessionArgs createDefaultSessionArgs() {
+ public final Context.Args createDefaultSessionArgs() {
throw new NoSuchMethodError();
}
diff --git
a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/store/ConfigStoreBuilder.java
b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/store/ConfigStoreBuilder.java
index 1f00c8b..b8e501f 100644
---
a/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/store/ConfigStoreBuilder.java
+++
b/juneau-core/juneau-config/src/main/java/org/apache/juneau/config/store/ConfigStoreBuilder.java
@@ -21,7 +21,7 @@ import org.apache.juneau.internal.*;
* {@review}
*/
@FluentSetters
-public abstract class ConfigStoreBuilder extends ContextBuilder {
+public abstract class ConfigStoreBuilder extends Context.Builder {
/**
* Constructor, default settings.
diff --git
a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
index 2dffac2..7af0f6e 100644
---
a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
+++
b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java
@@ -66,7 +66,6 @@ public final class RdfSerializerSession extends
WriterSerializerSession {
super(ctx, args);
this.ctx = ctx;
- SessionProperties sp = getSessionProperties();
namespaces = ctx.namespaces;
model = ModelFactory.createDefaultModel();
addModelPrefix(ctx.getJuneauNs());
@@ -91,10 +90,6 @@ public final class RdfSerializerSession extends
WriterSerializerSession {
for (Map.Entry<String,Object> e :
ctx.getJenaSettings().entrySet())
if (e.getKey().startsWith(propPrefix, 5))
writer.setProperty(e.getKey().substring(5 +
propPrefix.length()), e.getValue());
-
- for (String k : sp.keySet())
- if (k.startsWith("RdfCommon.jena.") &&
k.startsWith(propPrefix, 15))
- writer.setProperty(k.substring(15 +
propPrefix.length()), sp.get(k).orElse(null));
}
/*
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
index 82dad8a..924e7e0 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContext.java
@@ -360,7 +360,7 @@ public class BeanContext extends Context {
}
@Override /* Context */
- public final Session createSession(SessionArgs args) {
+ public final Session createSession(Context.Args args) {
throw new NoSuchMethodError();
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java
index 29add48..7e5105c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextBuilder.java
@@ -55,7 +55,7 @@ import org.apache.juneau.utils.*;
* </ul>
*/
@FluentSetters
-public class BeanContextBuilder extends ContextBuilder {
+public class BeanContextBuilder extends Context.Builder {
//-----------------------------------------------------------------------------------------------------------------
// Static
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextable.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextable.java
index 55a1834..cf89bf1 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextable.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextable.java
@@ -67,7 +67,7 @@ public abstract class BeanContextable extends Context {
}
@Override /* Context */
- public final Session createSession(SessionArgs args) {
+ public final Session createSession(Context.Args args) {
throw new NoSuchMethodError();
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextableBuilder.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextableBuilder.java
index 0cb3162..a3b5914 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextableBuilder.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanContextableBuilder.java
@@ -49,7 +49,7 @@ import org.apache.juneau.transform.*;
* </ul>
*/
@FluentSetters
-public abstract class BeanContextableBuilder extends ContextBuilder {
+public abstract class BeanContextableBuilder extends Context.Builder {
BeanContextBuilder bcBuilder;
BeanContext bc;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
index a62f027..be3c531 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java
@@ -46,7 +46,7 @@ import org.apache.juneau.transform.*;
* This class is NOT thread safe. It is meant to be discarded after one-time
use.
*/
@SuppressWarnings({"unchecked","rawtypes"})
-public class BeanSession extends Session {
+public class BeanSession extends Context.Session {
private static Logger LOG =
Logger.getLogger(BeanSession.class.getName());
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSessionArgs.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSessionArgs.java
index 993d675..5c6b2c6 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSessionArgs.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSessionArgs.java
@@ -24,7 +24,7 @@ import org.apache.juneau.internal.*;
* Runtime arguments common to all bean, serializer, and parser sessions.
*/
@FluentSetters
-public class BeanSessionArgs extends SessionArgs {
+public class BeanSessionArgs extends Context.Args {
/**
* Default empty session arguments.
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 8570005..b083365 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
@@ -12,40 +12,50 @@
//
***************************************************************************************************************************
package org.apache.juneau;
+import static org.apache.juneau.Visibility.*;
import static org.apache.juneau.internal.ClassUtils.*;
import static org.apache.juneau.internal.CollectionUtils.*;
import static org.apache.juneau.internal.ExceptionUtils.*;
+import static org.apache.juneau.internal.StringUtils.*;
+import static org.apache.juneau.internal.SystemEnv.*;
+import static org.apache.juneau.reflect.ReflectionFilters.*;
+import static java.util.Arrays.*;
import static java.util.Optional.*;
+import static java.util.stream.Collectors.*;
-import java.lang.annotation.*;
+import java.lang.annotation.Annotation;
import java.lang.reflect.*;
+import java.text.*;
import java.util.*;
import java.util.concurrent.*;
+import java.util.function.*;
+import org.apache.juneau.annotation.*;
import org.apache.juneau.collections.*;
+import org.apache.juneau.csv.annotation.*;
+import org.apache.juneau.html.annotation.*;
+import org.apache.juneau.internal.*;
+import org.apache.juneau.jso.annotation.*;
import org.apache.juneau.json.*;
+import org.apache.juneau.json.annotation.*;
+import org.apache.juneau.jsonschema.annotation.*;
+import org.apache.juneau.msgpack.annotation.*;
+import org.apache.juneau.oapi.annotation.*;
+import org.apache.juneau.parser.annotation.*;
+import org.apache.juneau.plaintext.annotation.*;
import org.apache.juneau.reflect.*;
+import org.apache.juneau.serializer.annotation.*;
+import org.apache.juneau.soap.annotation.*;
+import org.apache.juneau.svl.*;
+import org.apache.juneau.uon.annotation.*;
+import org.apache.juneau.urlencoding.annotation.*;
import org.apache.juneau.utils.*;
+import org.apache.juneau.xml.annotation.*;
/**
- * A reusable stateless thread-safe read-only configuration, typically used
for creating one-time use {@link Session}
- * objects.
- * {@review}
- *
- * <p>
- * Contexts are created through the {@link ContextBuilder#build()} method (and
subclasses of {@link ContextBuilder}).
- *
- * <p>
- * Subclasses MUST implement the following constructor:
- *
- * <p class='bcode w800'>
- * <jk>public</jk> T(ContextProperties);
- * </p>
+ * Base class for all Context beans.
*
- * <p>
- * Besides that restriction, a context object can do anything you desire.
- * <br>However, it MUST be thread-safe and all fields should be declared final
to prevent modification.
- * <br>It should NOT be used for storing temporary or state information.
+ * {@review}
*/
public abstract class Context implements MetaProvider {
@@ -65,7 +75,7 @@ public abstract class Context implements MetaProvider {
* @param type The builder to create.
* @return A new builder.
*/
- public static ContextBuilder createBuilder(Class<? extends Context>
type) {
+ public static Builder createBuilder(Class<? extends Context> type) {
try {
MethodInfo mi = BUILDER_CREATE_METHODS.get(type);
if (mi == null) {
@@ -74,7 +84,7 @@ public abstract class Context implements MetaProvider {
throw runtimeException("Could not find
builder create method on class {0}", type);
BUILDER_CREATE_METHODS.put(type, mi);
}
- ContextBuilder b = (ContextBuilder)mi.invoke(null);
+ Builder b = (Builder)mi.invoke(null);
b.type(type);
return b;
} catch (ExecutableException e) {
@@ -83,6 +93,939 @@ public abstract class Context implements MetaProvider {
}
//-----------------------------------------------------------------------------------------------------------------
+ // Builder
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Builder class.
+ */
+ @FluentSetters
+ public static abstract class Builder {
+
+ boolean debug;
+ Class<?> type;
+ Context impl;
+ List<Annotation> annotations;
+
+ private final List<Object> builders = new ArrayList<>();
+ private final AnnotationWorkList applied = new
AnnotationWorkList();
+
+ /**
+ * Constructor.
+ * Default settings.
+ */
+ protected Builder() {
+ debug = env("Context.debug", false);
+ annotations = null;
+ registerBuilders(this);
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyFrom The bean to copy from.
+ */
+ protected Builder(Context copyFrom) {
+ debug = copyFrom.debug;
+ type = copyFrom.getClass();
+ annotations = copyFrom.annotations.isEmpty() ? null :
new ArrayList<>(copyFrom.annotations);
+ registerBuilders(this);
+ }
+
+ /**
+ * Copy constructor.
+ *
+ * @param copyFrom The builder to copy from.
+ */
+ protected Builder(Builder copyFrom) {
+ debug = copyFrom.debug;
+ type = copyFrom.type;
+ annotations = copyFrom.annotations == null ? null : new
ArrayList<>(copyFrom.annotations);
+ registerBuilders(this);
+ }
+
+ /**
+ * Copy creator.
+ *
+ * @return A new mutable copy of this builder.
+ */
+ public abstract Builder copy();
+
+ /**
+ * Returns the hashkey of this builder.
+ *
+ * <p>
+ * Used to return previously instantiated context beans that
have matching hashkeys.
+ * The {@link HashKey} object is suitable for use as a hashmap
key of a map of context beans.
+ * A context bean is considered equivalent if the {@link
HashKey#equals(Object)} method is the same.
+ *
+ * @return The hashkey of this builder.
+ */
+ public HashKey hashKey() {
+ return HashKey.of(debug, type, annotations);
+ }
+
+ /**
+ * Returns the {@link #impl(Context)} bean if it's the
specified type.
+ *
+ * @param c The expected bean type.
+ * @return The impl bean, or <jk>null</jk> if an impl bean
wasn't specified.
+ */
+ protected <T extends Context> T impl(Class<T> c) {
+ if (impl != null && c.isInstance(impl))
+ return c.cast(impl);
+ return null;
+ }
+
+ /**
+ * Build the object.
+ *
+ * @return
+ * The built object.
+ * <br>Subsequent calls to this method will create new
instances (unless context object is cacheable).
+ */
+ public Context build() {
+ if (impl != null)
+ return impl;
+ if (type == null)
+ throw runtimeException("Context class not
specified.");
+ try {
+ ClassInfo ci = ClassInfo.of(type);
+ ConstructorInfo cc =
ci.getConstructor(isVisible(PROTECTED).and(hasParentArgs(this))).map(x ->
x.accessible()).orElse(null);
+ if (cc != null)
+ return cc.invoke(this);
+ throw runtimeException("Constructor not found
for class {0}", type);
+ } catch (ExecutableException e) {
+ throw runtimeException(e, "Error occurred
trying to create context.");
+ }
+ }
+
+ /**
+ * Apply a consumer to this builder.
+ *
+ * @param subtype The builder subtype that this consumer can be
applied to.
+ * @param consumer The consumer.
+ * @return This object.
+ */
+ @SuppressWarnings("unchecked")
+ public <T extends Builder> Builder apply(Class<T> subtype,
Consumer<T> consumer) {
+ if (subtype.isInstance(this))
+ consumer.accept((T)this);
+ return this;
+ }
+
+ /**
+ * Associates a context class with this builder.
+ *
+ * @param value The context class that this builder should
create.
+ * @return This object (for method chaining).
+ */
+ @FluentSetter
+ public Builder type(Class<? extends Context> value) {
+ this.type = value;
+ return this;
+ }
+
+ /**
+ * Returns the context class that this builder should create.
+ *
+ * @return The context class if it was specified.
+ */
+ public Optional<Class<?>> getType() {
+ return Optional.ofNullable(type);
+ }
+
+ /**
+ * Specifies a pre-instantiated bean for the {@link #build()}
method to return.
+ *
+ * @param value The value for this setting.
+ * @return This object.
+ */
+ @FluentSetter
+ public Builder impl(Context value) {
+ impl = value;
+ return this;
+ }
+
+ /**
+ * Returns <jk>true</jk> if any of the annotations/appliers can
be applied to this builder.
+ *
+ * @param work The work to check.
+ * @return <jk>true</jk> if any of the annotations/appliers can
be applied to this builder.
+ */
+ public boolean canApply(AnnotationWorkList work) {
+ for (AnnotationWork w : work)
+ for (Object b : builders)
+ if (w.canApply(b))
+ return true;
+ return false;
+ }
+
+ /**
+ * Applies a set of applied to this builder.
+ *
+ * <p>
+ * An {@link AnnotationWork} consists of a single pair of
{@link AnnotationInfo} that represents an annotation instance,
+ * and {@link AnnotationApplier} which represents the code used
to apply the values in that annotation to a specific builder.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// A class annotated with a config annotation.</jc>
+ *
<ja>@BeanConfig</ja>(sortProperties=<js>"$S{sortProperties,false}"</js>)
+ * <jk>public class</jk> MyClass {...}
+ *
+ * <jc>// Find all annotations that themselves are
annotated with @ContextPropertiesApply.</jc>
+ * List<AnnotationWork> <jv>work</jv> =
ClassInfo.<jsm>of</jsm>(MyClass.<jk>class</jk>)
+ *
.getAnnotationList(ConfigAnnotationFilter.<jsf>INSTANCE</jsf>)
+ *
.getWork(VarResolver.<jsf>DEFAULT</jsf>.createSession());
+ *
+ * <jc>// Apply any settings found on the annotations.</jc>
+ * WriterSerializer <jv>serializer</jv> = JsonSerializer
+ * .<jsm>create</jsm>()
+ * .apply(<jv>work</jv>)
+ * .build();
+ * </p>
+ *
+ * @param work The list of annotations and appliers to apply to
this builder.
+ * @return This object (for method chaining).
+ */
+ @FluentSetter
+ public Builder apply(AnnotationWorkList work) {
+ applied.addAll(work);
+ for (AnnotationWork w : work)
+ for (Object b : builders)
+ w.apply(b);
+ return this;
+ }
+
+ /**
+ * Returns all the annotations that have been applied to this
builder.
+ *
+ * @return All the annotations that have been applied to this
builder.
+ */
+ public AnnotationWorkList getApplied() {
+ return applied;
+ }
+
+ /**
+ * Registers the specified secondary builders with this context
builder.
+ *
+ * <p>
+ * When {@link #apply(AnnotationWorkList)} is called, it gets
called on all registered builders.
+ *
+ * @param builders The builders to add to the list of builders.
+ */
+ protected void registerBuilders(Object...builders) {
+ for (Object b : builders) {
+ if (b == this)
+ this.builders.add(b);
+ else if (b instanceof Builder)
+
this.builders.addAll(((Builder)b).builders);
+ else
+ this.builders.add(b);
+ }
+ }
+
+ /**
+ * Applies any of the various <ja>@XConfig</ja> annotations on
the specified class to this context.
+ *
+ * <p>
+ * Any annotations found that themselves are annotated with
{@link ContextApply} will be resolved and
+ * applied as properties to this builder. These annotations
include:
+ * <ul class='javatree'>
+ * <li class ='ja'>{@link BeanConfig}
+ * <li class ='ja'>{@link CsvConfig}
+ * <li class ='ja'>{@link HtmlConfig}
+ * <li class ='ja'>{@link HtmlDocConfig}
+ * <li class ='ja'>{@link JsoConfig}
+ * <li class ='ja'>{@link JsonConfig}
+ * <li class ='ja'>{@link JsonSchemaConfig}
+ * <li class ='ja'>{@link MsgPackConfig}
+ * <li class ='ja'>{@link OpenApiConfig}
+ * <li class ='ja'>{@link ParserConfig}
+ * <li class ='ja'>{@link PlainTextConfig}
+ * <li class ='ja'>{@link SerializerConfig}
+ * <li class ='ja'>{@link SoapXmlConfig}
+ * <li class ='ja'>{@link UonConfig}
+ * <li class ='ja'>{@link UrlEncodingConfig}
+ * <li class ='ja'>{@link XmlConfig}
+ * <li class ='ja'><c>RdfConfig</c>
+ * </ul>
+ *
+ * <p>
+ * Annotations on classes are appended in the following order:
+ * <ol>
+ * <li>On the package of this class.
+ * <li>On interfaces ordered parent-to-child.
+ * <li>On parent classes ordered parent-to-child.
+ * <li>On this class.
+ * </ol>
+ *
+ * <p>
+ * The default var resolver {@link VarResolver#DEFAULT} is used
to resolve any variables in annotation field values.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// A class annotated with a config annotation.</jc>
+ *
<ja>@BeanConfig</ja>(sortProperties=<js>"$S{sortProperties,false}"</js>)
+ * <jk>public class</jk> MyClass {...}
+ *
+ * <jc>// Apply any settings found on the annotations.</jc>
+ * WriterSerializer <jv>serializer</jv> = JsonSerializer
+ * .<jsm>create</jsm>()
+ * .applyAnnotations(MyClass.<jk>class</jk>)
+ * .build();
+ * </p>
+ *
+ * @param fromClasses The classes on which the annotations are
defined.
+ * @return This object (for method chaining).
+ */
+ @FluentSetter
+ public Builder applyAnnotations(Class<?>...fromClasses) {
+ VarResolverSession vrs =
VarResolver.DEFAULT.createSession();
+ AnnotationWorkList work = stream(fromClasses)
+ .map(ClassInfo::of)
+ .map(x ->
x.getAnnotationList(ContextApplyFilter.INSTANCE).getWork(vrs))
+ .flatMap(Collection::stream)
+ .collect(toCollection(AnnotationWorkList::new));
+ return apply(work);
+ }
+
+ /**
+ * Applies any of the various <ja>@XConfig</ja> annotations on
the specified method to this context.
+ *
+ * <p>
+ * Any annotations found that themselves are annotated with
{@link ContextApply} will be resolved and
+ * applied as properties to this builder. These annotations
include:
+ * <ul class='javatree'>
+ * <li class ='ja'>{@link BeanConfig}
+ * <li class ='ja'>{@link CsvConfig}
+ * <li class ='ja'>{@link HtmlConfig}
+ * <li class ='ja'>{@link HtmlDocConfig}
+ * <li class ='ja'>{@link JsoConfig}
+ * <li class ='ja'>{@link JsonConfig}
+ * <li class ='ja'>{@link JsonSchemaConfig}
+ * <li class ='ja'>{@link MsgPackConfig}
+ * <li class ='ja'>{@link OpenApiConfig}
+ * <li class ='ja'>{@link ParserConfig}
+ * <li class ='ja'>{@link PlainTextConfig}
+ * <li class ='ja'>{@link SerializerConfig}
+ * <li class ='ja'>{@link SoapXmlConfig}
+ * <li class ='ja'>{@link UonConfig}
+ * <li class ='ja'>{@link UrlEncodingConfig}
+ * <li class ='ja'>{@link XmlConfig}
+ * <li class ='ja'><c>RdfConfig</c>
+ * </ul>
+ *
+ * <p>
+ * Annotations on methods are appended in the following order:
+ * <ol>
+ * <li>On the package of the method class.
+ * <li>On interfaces ordered parent-to-child.
+ * <li>On parent classes ordered parent-to-child.
+ * <li>On the method class.
+ * <li>On this method and matching methods ordered
parent-to-child.
+ * </ol>
+ *
+ * <p>
+ * The default var resolver {@link VarResolver#DEFAULT} is used
to resolve any variables in annotation field values.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// A method annotated with a config annotation.</jc>
+ * <jk>public class</jk> MyClass {
+ *
<ja>@BeanConfig</ja>(sortProperties=<js>"$S{sortProperties,false}"</js>)
+ * <jk>public void</jk> myMethod() {...}
+ * }
+ *
+ * <jc>// Apply any settings found on the annotations.</jc>
+ * WriterSerializer <jv>serializer</jv> = JsonSerializer
+ * .<jsm>create</jsm>()
+ *
.applyAnnotations(MyClass.<jk>class</jk>.getMethod(<js>"myMethod"</js>))
+ * .build();
+ * </p>
+ *
+ * @param fromMethods The methods on which the annotations are
defined.
+ * @return This object (for method chaining).
+ */
+ @FluentSetter
+ public Builder applyAnnotations(Method...fromMethods) {
+ VarResolverSession vrs =
VarResolver.DEFAULT.createSession();
+ AnnotationWorkList work = stream(fromMethods)
+ .map(MethodInfo::of)
+ .map(x ->
x.getAnnotationList(ContextApplyFilter.INSTANCE).getWork(vrs))
+ .flatMap(Collection::stream)
+ .collect(toCollection(AnnotationWorkList::new));
+ return apply(work);
+ }
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Properties
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Defines annotations to apply to specific classes and methods.
+ *
+ * <p>
+ * Allows you to dynamically apply Juneau annotations typically
applied directly to classes and methods.
+ * Useful in cases where you want to use the functionality of
the annotation on beans and bean properties but
+ * do not have access to the code to do so.
+ *
+ * <p>
+ * As a rule, any Juneau annotation with an <l>on()</l> method
can be used with this setting.
+ *
+ * <p>
+ * The following example shows the equivalent methods for
applying the {@link Bean @Bean} annotation:
+ * <p class='bcode w800'>
+ * <jc>// Class with explicit annotation.</jc>
+ * <ja>@Bean</ja>(properties=<js>"street,city,state"</js>)
+ * <jk>public class</jk> A {...}
+ *
+ * <jc>// Class with annotation applied via
@BeanConfig</jc>
+ * <jk>public class</jk> B {...}
+ *
+ * <jc>// Java REST method with @BeanConfig
annotation.</jc>
+ * <ja>@RestGet</ja>(...)
+ * <ja>@Bean</ja>(on=<js>"B"</js>,
properties=<js>"street,city,state"</js>)
+ * <jk>public void</jk> doFoo() {...}
+ * </p>
+ *
+ * <p>
+ * In general, the underlying framework uses this method when
it finds dynamically applied annotations on
+ * config annotations. However, concrete implementations of
annotations are also provided that can be passed
+ * directly into builder classes like so:
+ * <p class='bcode w800'>
+ * <jc>// Create a concrete @Bean annotation.</jc>
+ * BeanAnnotation <jv>annotation</jv> =
BeanAnnotation.<jsm>create</jsm>(B.<jk>class</jk>).properties(<js>"street,city,state"</js>);
+ *
+ * <jc>// Apply it to a serializer.</jc>
+ * WriterSerializer <jv>serializer</jv> =
JsonSerializer.<jsm>create</jsm>().annotations(<jv>annotation</jv>).build();
+ *
+ * <jc>// Serialize a bean with the dynamically applied
annotation.</jc>
+ * String <jv>json</jv> =
<jv>serializer</jv>.serialize(<jk>new</jk> B());
+ * </p>
+ *
+ * <p>
+ * The following is the list of annotations builders provided
that can be constructed
+ * and passed into the builder class:
+ * <ul class='javatree'>
+ * <li class='ja'>{@link
org.apache.juneau.annotation.BeanAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.annotation.BeancAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.annotation.BeanIgnoreAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.annotation.BeanpAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.annotation.ExampleAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.annotation.NamePropertyAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.annotation.ParentPropertyAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.annotation.SwapAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.annotation.UriAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.csv.annotation.CsvAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.html.annotation.HtmlAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.jso.annotation.JsoAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.json.annotation.JsonAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.jsonschema.annotation.SchemaAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.msgpack.annotation.MsgPackAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.oapi.annotation.OpenApiAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.plaintext.annotation.PlainTextAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.soap.annotation.SoapXmlAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.uon.annotation.UonAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.urlencoding.annotation.UrlEncodingAnnotation}
+ * <li class='ja'>{@link
org.apache.juneau.xml.annotation.XmlAnnotation}
+ * </ul>
+ *
+ * <p>
+ * The syntax for the <l>on()</l> pattern match parameter
depends on whether it applies to a class, method, field, or constructor.
+ * The valid pattern matches are:
+ * <ul class='spaced-list'>
+ * <li>Classes:
+ * <ul>
+ * <li>Fully qualified:
+ * <ul>
+ *
<li><js>"com.foo.MyClass"</js>
+ * </ul>
+ * <li>Fully qualified inner class:
+ * <ul>
+ *
<li><js>"com.foo.MyClass$Inner1$Inner2"</js>
+ * </ul>
+ * <li>Simple:
+ * <ul>
+ * <li><js>"MyClass"</js>
+ * </ul>
+ * <li>Simple inner:
+ * <ul>
+ *
<li><js>"MyClass$Inner1$Inner2"</js>
+ *
<li><js>"Inner1$Inner2"</js>
+ * <li><js>"Inner2"</js>
+ * </ul>
+ * </ul>
+ * <li>Methods:
+ * <ul>
+ * <li>Fully qualified with args:
+ * <ul>
+ *
<li><js>"com.foo.MyClass.myMethod(String,int)"</js>
+ *
<li><js>"com.foo.MyClass.myMethod(java.lang.String,int)"</js>
+ *
<li><js>"com.foo.MyClass.myMethod()"</js>
+ * </ul>
+ * <li>Fully qualified:
+ * <ul>
+ *
<li><js>"com.foo.MyClass.myMethod"</js>
+ * </ul>
+ * <li>Simple with args:
+ * <ul>
+ *
<li><js>"MyClass.myMethod(String,int)"</js>
+ *
<li><js>"MyClass.myMethod(java.lang.String,int)"</js>
+ *
<li><js>"MyClass.myMethod()"</js>
+ * </ul>
+ * <li>Simple:
+ * <ul>
+ *
<li><js>"MyClass.myMethod"</js>
+ * </ul>
+ * <li>Simple inner class:
+ * <ul>
+ *
<li><js>"MyClass$Inner1$Inner2.myMethod"</js>
+ *
<li><js>"Inner1$Inner2.myMethod"</js>
+ *
<li><js>"Inner2.myMethod"</js>
+ * </ul>
+ * </ul>
+ * <li>Fields:
+ * <ul>
+ * <li>Fully qualified:
+ * <ul>
+ *
<li><js>"com.foo.MyClass.myField"</js>
+ * </ul>
+ * <li>Simple:
+ * <ul>
+ *
<li><js>"MyClass.myField"</js>
+ * </ul>
+ * <li>Simple inner class:
+ * <ul>
+ *
<li><js>"MyClass$Inner1$Inner2.myField"</js>
+ *
<li><js>"Inner1$Inner2.myField"</js>
+ *
<li><js>"Inner2.myField"</js>
+ * </ul>
+ * </ul>
+ * <li>Constructors:
+ * <ul>
+ * <li>Fully qualified with args:
+ * <ul>
+ *
<li><js>"com.foo.MyClass(String,int)"</js>
+ *
<li><js>"com.foo.MyClass(java.lang.String,int)"</js>
+ *
<li><js>"com.foo.MyClass()"</js>
+ * </ul>
+ * <li>Simple with args:
+ * <ul>
+ *
<li><js>"MyClass(String,int)"</js>
+ *
<li><js>"MyClass(java.lang.String,int)"</js>
+ * <li><js>"MyClass()"</js>
+ * </ul>
+ * <li>Simple inner class:
+ * <ul>
+ *
<li><js>"MyClass$Inner1$Inner2()"</js>
+ *
<li><js>"Inner1$Inner2()"</js>
+ * <li><js>"Inner2()"</js>
+ * </ul>
+ * </ul>
+ * <li>A comma-delimited list of anything on this list.
+ * </ul>
+ *
+ * <ul class='seealso'>
+ * <li class='ja'>{@link BeanConfig}
+ * </ul>
+ *
+ * @param values
+ * The annotations to register with the context.
+ * @return This object (for method chaining).
+ */
+ @FluentSetter
+ public Builder annotations(Annotation...values) {
+ if (annotations == null)
+ annotations = new ArrayList<>();
+ Collections.addAll(annotations, values);
+ return this;
+ }
+
+ /**
+ * <i><l>Context</l> configuration property: </i> Debug
mode.
+ *
+ * <p>
+ * Enables the following additional information during
serialization:
+ * <ul class='spaced-list'>
+ * <li>
+ * When bean getters throws exceptions, the
exception includes the object stack information
+ * in order to determine how that method was
invoked.
+ * <li>
+ * Enables {@link
BeanTraverseBuilder#detectRecursions()}.
+ * </ul>
+ *
+ * <p>
+ * Enables the following additional information during parsing:
+ * <ul class='spaced-list'>
+ * <li>
+ * When bean setters throws exceptions, the
exception includes the object stack information
+ * in order to determine how that method was
invoked.
+ * </ul>
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode w800'>
+ * <jc>// Create a serializer with debug enabled.</jc>
+ * WriterSerializer <jv>serializer</jv> = JsonSerializer
+ * .<jsm>create</jsm>()
+ * .debug()
+ * .build();
+ *
+ * <jc>// Create a POJO model with a recursive loop.</jc>
+ * <jk>public class</jk> MyBean {
+ * <jk>public</jk> Object <jf>f</jf>;
+ * }
+ * MyBean <jv>myBean</jv> = <jk>new</jk> MyBean();
+ * <jv>myBean</jv>.<jf>f</jf> = <jv>myBean</jv>;
+ *
+ * <jc>// Throws a SerializeException and not a
StackOverflowError</jc>
+ * String <jv>json</jv> =
<jv>serializer</jv>.serialize(<jv>myBean</jv>);
+ * </p>
+ *
+ * <ul class='seealso'>
+ * <li class='ja'>{@link
org.apache.juneau.annotation.BeanConfig#debug()}
+ * <li class='jm'>{@link
org.apache.juneau.Context.Args#debug(Boolean)}
+ * </ul>
+ *
+ * @return This object (for method chaining).
+ */
+ @FluentSetter
+ public Builder debug() {
+ return debug(true);
+ }
+
+ /**
+ * Same as {@link #debug()} but allows you to explicitly
specify the value.
+ *
+ * @param value The value for this setting.
+ * @return This object.
+ */
+ @FluentSetter
+ public Builder debug(boolean value) {
+ debug = value;
+ return this;
+ }
+
+ /**
+ * Returns <jk>true</jk> if debug is enabled.
+ *
+ * @return <jk>true</jk> if debug is enabled.
+ */
+ public boolean isDebug() {
+ return debug;
+ }
+
+ // <FluentSetters>
+
+ // </FluentSetters>
+ }
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Session
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * A one-time-use non-thread-safe object that's meant to be used once
and then thrown away.
+ */
+ public static abstract class Session {
+
+ private final SessionProperties properties;
+ private Map<String,Object> cache;
+ private List<String> warnings; // Any warnings
encountered.
+
+ private final Context ctx;
+ private final boolean debug;
+ private final boolean unmodifiable;
+
+
+ /**
+ * Default constructor.
+ *
+ * @param ctx The context object.
+ * @param args
+ * Runtime arguments.
+ */
+ protected Session(Context ctx, Args args) {
+ this.ctx = ctx;
+ this.unmodifiable = args.unmodifiable;
+ SessionProperties sp = args.properties;
+ if (args.unmodifiable)
+ sp = sp.unmodifiable();
+ properties = sp;
+ debug = ofNullable(args.debug).orElse(ctx.isDebug());
+ }
+
+ /**
+ * Returns the session properties on this session.
+ *
+ * @return The session properties on this session. Never
<jk>null</jk>.
+ */
+ public final SessionProperties getSessionProperties() {
+ return properties;
+ }
+
+ /**
+ * Returns the context that created this session.
+ *
+ * @return The context that created this session.
+ */
+ public Context getContext() {
+ return ctx;
+ }
+
+ /**
+ * Adds an arbitrary object to this session's cache.
+ *
+ * <p>
+ * Can be used to store objects for reuse during a session.
+ *
+ * @param key The key. Can be any string.
+ * @param val The cached object.
+ */
+ public final void addToCache(String key, Object val) {
+ if (unmodifiable)
+ return;
+ if (cache == null)
+ cache = new TreeMap<>();
+ cache.put(key, val);
+ }
+
+ /**
+ * Adds arbitrary objects to this session's cache.
+ *
+ * <p>
+ * Can be used to store objects for reuse during a session.
+ *
+ * @param cacheObjects
+ * The objects to add to this session's cache.
+ * No-op if <jk>null</jk>.
+ */
+ public final void addToCache(Map<String,Object> cacheObjects) {
+ if (unmodifiable)
+ return;
+ if (cacheObjects != null) {
+ if (cache == null)
+ cache = new TreeMap<>();
+ cache.putAll(cacheObjects);
+ }
+ }
+
+ /**
+ * Returns an object stored in the session cache.
+ *
+ * @param c The class type of the object.
+ * @param key The session object key.
+ * @return The cached object, or <jk>null</jk> if it doesn't
exist.
+ */
+ @SuppressWarnings("unchecked")
+ public final <T> T getFromCache(Class<T> c, String key) {
+ return cache == null ? null : (T)cache.get(key);
+ }
+
+ /**
+ * Logs a warning message.
+ *
+ * @param msg The warning message.
+ * @param args Optional {@link MessageFormat}-style arguments.
+ */
+ public void addWarning(String msg, Object... args) {
+ if (unmodifiable)
+ return;
+ if (warnings == null)
+ warnings = new LinkedList<>();
+ warnings.add((warnings.size() + 1) + ": " + format(msg,
args));
+ }
+
+ /**
+ * Returns <jk>true</jk> if warnings occurred in this session.
+ *
+ * @return <jk>true</jk> if warnings occurred in this session.
+ */
+ public final boolean hasWarnings() {
+ return warnings != null && warnings.size() > 0;
+ }
+
+ /**
+ * Returns the warnings that occurred in this session.
+ *
+ * @return The warnings that occurred in this session, or
<jk>null</jk> if no warnings occurred.
+ */
+ public final List<String> getWarnings() {
+ return warnings;
+ }
+
+ /**
+ * Throws a {@link BeanRuntimeException} if any warnings
occurred in this session.
+ */
+ public void checkForWarnings() {
+ if (warnings != null && ! warnings.isEmpty())
+ throw new BeanRuntimeException("Warnings
occurred in session: \n" + join(getWarnings(), "\n"));
+ }
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Configuration properties
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Configuration property: Debug mode.
+ *
+ * @see Context.Builder#debug()
+ * @return
+ * <jk>true</jk> if debug mode is enabled.
+ */
+ public boolean isDebug() {
+ return debug;
+ }
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Other methods
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Returns the properties defined on this bean as a simple map
for debugging purposes.
+ *
+ * <p>
+ * Use
<c>SimpleJson.<jsf>DEFAULT</jsf>.println(<jv>thisBean</jv>)</c> to dump the
contents of this bean to the console.
+ *
+ * @return A new map containing this bean's properties.
+ */
+ public OMap toMap() {
+ return OMap.create().filtered();
+ }
+
+ @Override /* Object */
+ public String toString() {
+ return
SimpleJsonSerializer.DEFAULT_READABLE.toString(toMap());
+ }
+ }
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Args
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Runtime arguments passed to the session object.
+ */
+ @FluentSetters
+ public static class Args {
+
+ SessionProperties properties = SessionProperties.create();
+ boolean unmodifiable;
+ Boolean debug;
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Properties
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Debug mode.
+ *
+ * <p>
+ * Enables the following additional information during parsing:
+ * <ul>
+ * <li> When bean setters throws exceptions, the exception
includes the object stack information in order to determine how that method was
invoked.
+ * </ul>
+ *
+ * <p>
+ * If not specified, defaults to {@link
Context.Builder#debug()}.
+ *
+ * <ul class='seealso'>
+ * <li class='ja'>{@link
org.apache.juneau.annotation.BeanConfig#debug()}
+ * <li class='jm'>{@link
org.apache.juneau.Context.Builder#debug()}
+ *
+ * @param value
+ * The new value for this property.
+ * <br>Can be <jk>null</jk>.
+ * @return This object (for method chaining).
+ */
+ @FluentSetter
+ public Args debug(Boolean value) {
+ debug = value;
+ return this;
+ }
+
+ /**
+ * Create an unmodifiable session.
+ *
+ * <p>
+ * The created Session object will be unmodifiable which makes
it suitable for caching and reuse.
+ *
+ * @return This object (for method chaining).
+ */
+ @FluentSetter
+ public Args unmodifiable() {
+ this.unmodifiable = true;
+ return this;
+ }
+
+ /**
+ * Session-level properties.
+ *
+ * <p>
+ * Overrides context-level properties.
+ *
+ * @param value
+ * The new value for this property.
+ * <br>Can be <jk>null</jk>.
+ * @return This object (for method chaining).
+ */
+ @FluentSetter
+ public Args properties(Map<String,Object> value) {
+ this.properties = SessionProperties.create(value);
+ return this;
+ }
+
+ /**
+ * Adds a property to this session.
+ *
+ * @param key The property key.
+ * @param value The property value.
+ * @return This object (for method chaining).
+ */
+ @FluentSetter
+ public Args property(String key, Object value) {
+ if (value == null) {
+ properties.remove(key);
+ } else {
+ properties.put(key, value);
+ }
+ return this;
+ }
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // Other methods
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Returns the properties defined on this bean as a simple map
for debugging purposes.
+ *
+ * <p>
+ * Use
<c>SimpleJson.<jsf>DEFAULT</jsf>.println(<jv>thisBean</jv>)</c> to dump the
contents of this bean to the console.
+ *
+ * @return A new map containing this bean's properties.
+ */
+ public OMap toMap() {
+ return OMap
+ .create()
+ .filtered()
+ .append("Args", OMap.create().filtered()
+ .append("properties",
properties.asMap())
+ );
+ }
+
+ @Override /* Object */
+ public String toString() {
+ return
SimpleJsonSerializer.DEFAULT_READABLE.toString(toMap());
+ }
+
+ // <FluentSetters>
+
+ // </FluentSetters>
+ }
+
+
+
//-----------------------------------------------------------------------------------------------------------------
// Instance
//-----------------------------------------------------------------------------------------------------------------
@@ -107,7 +1050,7 @@ public abstract class Context implements MetaProvider {
*
* @param builder The builder for this class.
*/
- protected Context(ContextBuilder builder) {
+ protected Context(Builder builder) {
debug = builder.debug;
annotations =
ofNullable(builder.annotations).orElse(emptyList());
@@ -148,7 +1091,7 @@ public abstract class Context implements MetaProvider {
*
* @return A new ContextBuilder object.
*/
- public abstract ContextBuilder copy();
+ public abstract Builder copy();
/**
* Create a new bean session based on the properties defined on this
context.
@@ -175,14 +1118,14 @@ public abstract class Context implements MetaProvider {
* The session arguments.
* @return A new session object.
*/
- public abstract Session createSession(SessionArgs args);
+ public abstract Session createSession(Args args);
/**
* Defines default session arguments used when calling the {@link
#createSession()} method.
*
* @return A SessionArgs object, possibly a read-only reusable instance.
*/
- public abstract SessionArgs createDefaultSessionArgs();
+ public abstract Args createDefaultSessionArgs();
//-----------------------------------------------------------------------------------------------------------------
// Properties
@@ -191,7 +1134,7 @@ public abstract class Context implements MetaProvider {
/**
* Debug mode.
*
- * @see ContextBuilder#debug()
+ * @see Context.Builder#debug()
* @return
* <jk>true</jk> if debug mode is enabled.
*/
@@ -457,7 +1400,6 @@ public abstract class Context implements MetaProvider {
return getAnnotations(a, c == null ? null : c.inner()).size() >
0;
}
-
//-----------------------------------------------------------------------------------------------------------------
// Other methods
//-----------------------------------------------------------------------------------------------------------------
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBeanCreator.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBeanCreator.java
index 6612eaf..b7d7d8c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBeanCreator.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBeanCreator.java
@@ -41,7 +41,7 @@ public class ContextBeanCreator<T> {
private Class<T> type;
private T impl;
- private ContextBuilder builder;
+ private Context.Builder builder;
/**
* Constructor.
@@ -98,7 +98,7 @@ public class ContextBeanCreator<T> {
* @return An optional containing the builder if it exists.
*/
@SuppressWarnings("unchecked")
- public <T2 extends ContextBuilder> Optional<T2> builder(Class<T2> c) {
+ public <T2 extends Context.Builder> Optional<T2> builder(Class<T2> c) {
return ofNullable(c.isInstance(builder) ? (T2)builder : null);
}
@@ -114,7 +114,7 @@ public class ContextBeanCreator<T> {
* @return This object.
*/
@SuppressWarnings("unchecked")
- public <T2 extends ContextBuilder> ContextBeanCreator<T>
builder(Class<T2> c, Consumer<T2> operation) {
+ public <T2 extends Context.Builder> ContextBeanCreator<T>
builder(Class<T2> c, Consumer<T2> operation) {
if (c.isInstance(builder))
operation.accept((T2)builder);
return this;
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
deleted file mode 100644
index b23f3d3..0000000
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java
+++ /dev/null
@@ -1,676 +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;
-
-import static org.apache.juneau.internal.ExceptionUtils.*;
-import static org.apache.juneau.reflect.ReflectionFilters.*;
-import static org.apache.juneau.Visibility.*;
-import static java.util.stream.Collectors.*;
-import static java.util.Arrays.*;
-import static org.apache.juneau.internal.SystemEnv.*;
-
-import java.lang.annotation.*;
-import java.lang.reflect.*;
-import java.util.*;
-import java.util.function.*;
-
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.csv.annotation.*;
-import org.apache.juneau.html.annotation.*;
-import org.apache.juneau.internal.*;
-import org.apache.juneau.jso.annotation.*;
-import org.apache.juneau.json.annotation.*;
-import org.apache.juneau.jsonschema.annotation.*;
-import org.apache.juneau.msgpack.annotation.*;
-import org.apache.juneau.oapi.annotation.*;
-import org.apache.juneau.parser.annotation.*;
-import org.apache.juneau.plaintext.annotation.*;
-import org.apache.juneau.reflect.*;
-import org.apache.juneau.serializer.annotation.*;
-import org.apache.juneau.soap.annotation.*;
-import org.apache.juneau.svl.*;
-import org.apache.juneau.uon.annotation.*;
-import org.apache.juneau.urlencoding.annotation.*;
-import org.apache.juneau.utils.*;
-import org.apache.juneau.xml.annotation.*;
-
-/**
- * Base builder class for building instances of any context objects configured
through property stores.
- * {@review}
- */
-@FluentSetters
-public abstract class ContextBuilder {
-
- boolean debug;
- Class<?> type;
- Context impl;
- List<Annotation> annotations;
-
- private final List<Object> builders = new ArrayList<>();
- private final AnnotationWorkList applied = new AnnotationWorkList();
-
- /**
- * Constructor.
- * Default settings.
- */
- protected ContextBuilder() {
- debug = env("Context.debug", false);
- annotations = null;
- registerBuilders(this);
- }
-
- /**
- * Copy constructor.
- *
- * @param copyFrom The bean to copy from.
- */
- protected ContextBuilder(Context copyFrom) {
- debug = copyFrom.debug;
- type = copyFrom.getClass();
- annotations = copyFrom.annotations.isEmpty() ? null : new
ArrayList<>(copyFrom.annotations);
- registerBuilders(this);
- }
-
- /**
- * Copy constructor.
- *
- * @param copyFrom The builder to copy from.
- */
- protected ContextBuilder(ContextBuilder copyFrom) {
- debug = copyFrom.debug;
- type = copyFrom.type;
- annotations = copyFrom.annotations == null ? null : new
ArrayList<>(copyFrom.annotations);
- registerBuilders(this);
- }
-
- /**
- * Copy creator.
- *
- * @return A new mutable copy of this builder.
- */
- public abstract ContextBuilder copy();
-
- /**
- * Returns the hashkey of this builder.
- *
- * <p>
- * Used to return previously instantiated context beans that have
matching hashkeys.
- * The {@link HashKey} object is suitable for use as a hashmap key of a
map of context beans.
- * A context bean is considered equivalent if the {@link
HashKey#equals(Object)} method is the same.
- *
- * @return The hashkey of this builder.
- */
- public HashKey hashKey() {
- return HashKey.of(debug, type, annotations);
- }
-
- /**
- * Returns the {@link #impl(Context)} bean if it's the specified type.
- *
- * @param c The expected bean type.
- * @return The impl bean, or <jk>null</jk> if an impl bean wasn't
specified.
- */
- protected <T extends Context> T impl(Class<T> c) {
- if (impl != null && c.isInstance(impl))
- return c.cast(impl);
- return null;
- }
-
- /**
- * Build the object.
- *
- * @return
- * The built object.
- * <br>Subsequent calls to this method will create new instances
(unless context object is cacheable).
- */
- public Context build() {
- if (impl != null)
- return impl;
- if (type == null)
- throw runtimeException("Context class not specified.");
- try {
- ClassInfo ci = ClassInfo.of(type);
- ConstructorInfo cc =
ci.getConstructor(isVisible(PROTECTED).and(hasParentArgs(this))).map(x ->
x.accessible()).orElse(null);
- if (cc != null)
- return cc.invoke(this);
- throw runtimeException("Constructor not found for class
{0}", type);
- } catch (ExecutableException e) {
- throw runtimeException(e, "Error occurred trying to
create context.");
- }
- }
-
- /**
- * Apply a consumer to this builder.
- *
- * @param subtype The builder subtype that this consumer can be applied
to.
- * @param consumer The consumer.
- * @return This object.
- */
- @SuppressWarnings("unchecked")
- public <T extends ContextBuilder> ContextBuilder apply(Class<T>
subtype, Consumer<T> consumer) {
- if (subtype.isInstance(this))
- consumer.accept((T)this);
- return this;
- }
-
- /**
- * Associates a context class with this builder.
- *
- * @param value The context class that this builder should create.
- * @return This object (for method chaining).
- */
- @FluentSetter
- public ContextBuilder type(Class<? extends Context> value) {
- this.type = value;
- return this;
- }
-
- /**
- * Returns the context class that this builder should create.
- *
- * @return The context class if it was specified.
- */
- public Optional<Class<?>> getType() {
- return Optional.ofNullable(type);
- }
-
- /**
- * Specifies a pre-instantiated bean for the {@link #build()} method to
return.
- *
- * @param value The value for this setting.
- * @return This object.
- */
- @FluentSetter
- public ContextBuilder impl(Context value) {
- impl = value;
- return this;
- }
-
- /**
- * Returns <jk>true</jk> if any of the annotations/appliers can be
applied to this builder.
- *
- * @param work The work to check.
- * @return <jk>true</jk> if any of the annotations/appliers can be
applied to this builder.
- */
- public boolean canApply(AnnotationWorkList work) {
- for (AnnotationWork w : work)
- for (Object b : builders)
- if (w.canApply(b))
- return true;
- return false;
- }
-
- /**
- * Applies a set of applied to this builder.
- *
- * <p>
- * An {@link AnnotationWork} consists of a single pair of {@link
AnnotationInfo} that represents an annotation instance,
- * and {@link AnnotationApplier} which represents the code used to
apply the values in that annotation to a specific builder.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// A class annotated with a config annotation.</jc>
- *
<ja>@BeanConfig</ja>(sortProperties=<js>"$S{sortProperties,false}"</js>)
- * <jk>public class</jk> MyClass {...}
- *
- * <jc>// Find all annotations that themselves are annotated with
@ContextPropertiesApply.</jc>
- * List<AnnotationWork> <jv>work</jv> =
ClassInfo.<jsm>of</jsm>(MyClass.<jk>class</jk>)
- *
.getAnnotationList(ConfigAnnotationFilter.<jsf>INSTANCE</jsf>)
- *
.getWork(VarResolver.<jsf>DEFAULT</jsf>.createSession());
- *
- * <jc>// Apply any settings found on the annotations.</jc>
- * WriterSerializer <jv>serializer</jv> = JsonSerializer
- * .<jsm>create</jsm>()
- * .apply(<jv>work</jv>)
- * .build();
- * </p>
- *
- * @param work The list of annotations and appliers to apply to this
builder.
- * @return This object (for method chaining).
- */
- @FluentSetter
- public ContextBuilder apply(AnnotationWorkList work) {
- applied.addAll(work);
- for (AnnotationWork w : work)
- for (Object b : builders)
- w.apply(b);
- return this;
- }
-
- /**
- * Returns all the annotations that have been applied to this builder.
- *
- * @return All the annotations that have been applied to this builder.
- */
- public AnnotationWorkList getApplied() {
- return applied;
- }
-
- /**
- * Registers the specified secondary builders with this context builder.
- *
- * <p>
- * When {@link #apply(AnnotationWorkList)} is called, it gets called on
all registered builders.
- *
- * @param builders The builders to add to the list of builders.
- */
- protected void registerBuilders(Object...builders) {
- for (Object b : builders) {
- if (b == this)
- this.builders.add(b);
- else if (b instanceof ContextBuilder)
-
this.builders.addAll(((ContextBuilder)b).builders);
- else
- this.builders.add(b);
- }
- }
-
- /**
- * Applies any of the various <ja>@XConfig</ja> annotations on the
specified class to this context.
- *
- * <p>
- * Any annotations found that themselves are annotated with {@link
ContextApply} will be resolved and
- * applied as properties to this builder. These annotations include:
- * <ul class='javatree'>
- * <li class ='ja'>{@link BeanConfig}
- * <li class ='ja'>{@link CsvConfig}
- * <li class ='ja'>{@link HtmlConfig}
- * <li class ='ja'>{@link HtmlDocConfig}
- * <li class ='ja'>{@link JsoConfig}
- * <li class ='ja'>{@link JsonConfig}
- * <li class ='ja'>{@link JsonSchemaConfig}
- * <li class ='ja'>{@link MsgPackConfig}
- * <li class ='ja'>{@link OpenApiConfig}
- * <li class ='ja'>{@link ParserConfig}
- * <li class ='ja'>{@link PlainTextConfig}
- * <li class ='ja'>{@link SerializerConfig}
- * <li class ='ja'>{@link SoapXmlConfig}
- * <li class ='ja'>{@link UonConfig}
- * <li class ='ja'>{@link UrlEncodingConfig}
- * <li class ='ja'>{@link XmlConfig}
- * <li class ='ja'><c>RdfConfig</c>
- * </ul>
- *
- * <p>
- * Annotations on classes are appended in the following order:
- * <ol>
- * <li>On the package of this class.
- * <li>On interfaces ordered parent-to-child.
- * <li>On parent classes ordered parent-to-child.
- * <li>On this class.
- * </ol>
- *
- * <p>
- * The default var resolver {@link VarResolver#DEFAULT} is used to
resolve any variables in annotation field values.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// A class annotated with a config annotation.</jc>
- *
<ja>@BeanConfig</ja>(sortProperties=<js>"$S{sortProperties,false}"</js>)
- * <jk>public class</jk> MyClass {...}
- *
- * <jc>// Apply any settings found on the annotations.</jc>
- * WriterSerializer <jv>serializer</jv> = JsonSerializer
- * .<jsm>create</jsm>()
- * .applyAnnotations(MyClass.<jk>class</jk>)
- * .build();
- * </p>
- *
- * @param fromClasses The classes on which the annotations are defined.
- * @return This object (for method chaining).
- */
- @FluentSetter
- public ContextBuilder applyAnnotations(Class<?>...fromClasses) {
- VarResolverSession vrs = VarResolver.DEFAULT.createSession();
- AnnotationWorkList work = stream(fromClasses)
- .map(ClassInfo::of)
- .map(x ->
x.getAnnotationList(ContextApplyFilter.INSTANCE).getWork(vrs))
- .flatMap(Collection::stream)
- .collect(toCollection(AnnotationWorkList::new));
- return apply(work);
- }
-
- /**
- * Applies any of the various <ja>@XConfig</ja> annotations on the
specified method to this context.
- *
- * <p>
- * Any annotations found that themselves are annotated with {@link
ContextApply} will be resolved and
- * applied as properties to this builder. These annotations include:
- * <ul class='javatree'>
- * <li class ='ja'>{@link BeanConfig}
- * <li class ='ja'>{@link CsvConfig}
- * <li class ='ja'>{@link HtmlConfig}
- * <li class ='ja'>{@link HtmlDocConfig}
- * <li class ='ja'>{@link JsoConfig}
- * <li class ='ja'>{@link JsonConfig}
- * <li class ='ja'>{@link JsonSchemaConfig}
- * <li class ='ja'>{@link MsgPackConfig}
- * <li class ='ja'>{@link OpenApiConfig}
- * <li class ='ja'>{@link ParserConfig}
- * <li class ='ja'>{@link PlainTextConfig}
- * <li class ='ja'>{@link SerializerConfig}
- * <li class ='ja'>{@link SoapXmlConfig}
- * <li class ='ja'>{@link UonConfig}
- * <li class ='ja'>{@link UrlEncodingConfig}
- * <li class ='ja'>{@link XmlConfig}
- * <li class ='ja'><c>RdfConfig</c>
- * </ul>
- *
- * <p>
- * Annotations on methods are appended in the following order:
- * <ol>
- * <li>On the package of the method class.
- * <li>On interfaces ordered parent-to-child.
- * <li>On parent classes ordered parent-to-child.
- * <li>On the method class.
- * <li>On this method and matching methods ordered parent-to-child.
- * </ol>
- *
- * <p>
- * The default var resolver {@link VarResolver#DEFAULT} is used to
resolve any variables in annotation field values.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// A method annotated with a config annotation.</jc>
- * <jk>public class</jk> MyClass {
- *
<ja>@BeanConfig</ja>(sortProperties=<js>"$S{sortProperties,false}"</js>)
- * <jk>public void</jk> myMethod() {...}
- * }
- *
- * <jc>// Apply any settings found on the annotations.</jc>
- * WriterSerializer <jv>serializer</jv> = JsonSerializer
- * .<jsm>create</jsm>()
- *
.applyAnnotations(MyClass.<jk>class</jk>.getMethod(<js>"myMethod"</js>))
- * .build();
- * </p>
- *
- * @param fromMethods The methods on which the annotations are defined.
- * @return This object (for method chaining).
- */
- @FluentSetter
- public ContextBuilder applyAnnotations(Method...fromMethods) {
- VarResolverSession vrs = VarResolver.DEFAULT.createSession();
- AnnotationWorkList work = stream(fromMethods)
- .map(MethodInfo::of)
- .map(x ->
x.getAnnotationList(ContextApplyFilter.INSTANCE).getWork(vrs))
- .flatMap(Collection::stream)
- .collect(toCollection(AnnotationWorkList::new));
- return apply(work);
- }
-
-
//-----------------------------------------------------------------------------------------------------------------
- // Properties
-
//-----------------------------------------------------------------------------------------------------------------
-
- /**
- * Defines annotations to apply to specific classes and methods.
- *
- * <p>
- * Allows you to dynamically apply Juneau annotations typically applied
directly to classes and methods.
- * Useful in cases where you want to use the functionality of the
annotation on beans and bean properties but
- * do not have access to the code to do so.
- *
- * <p>
- * As a rule, any Juneau annotation with an <l>on()</l> method can be
used with this setting.
- *
- * <p>
- * The following example shows the equivalent methods for applying the
{@link Bean @Bean} annotation:
- * <p class='bcode w800'>
- * <jc>// Class with explicit annotation.</jc>
- * <ja>@Bean</ja>(properties=<js>"street,city,state"</js>)
- * <jk>public class</jk> A {...}
- *
- * <jc>// Class with annotation applied via @BeanConfig</jc>
- * <jk>public class</jk> B {...}
- *
- * <jc>// Java REST method with @BeanConfig annotation.</jc>
- * <ja>@RestGet</ja>(...)
- * <ja>@Bean</ja>(on=<js>"B"</js>,
properties=<js>"street,city,state"</js>)
- * <jk>public void</jk> doFoo() {...}
- * </p>
- *
- * <p>
- * In general, the underlying framework uses this method when it finds
dynamically applied annotations on
- * config annotations. However, concrete implementations of
annotations are also provided that can be passed
- * directly into builder classes like so:
- * <p class='bcode w800'>
- * <jc>// Create a concrete @Bean annotation.</jc>
- * BeanAnnotation <jv>annotation</jv> =
BeanAnnotation.<jsm>create</jsm>(B.<jk>class</jk>).properties(<js>"street,city,state"</js>);
- *
- * <jc>// Apply it to a serializer.</jc>
- * WriterSerializer <jv>serializer</jv> =
JsonSerializer.<jsm>create</jsm>().annotations(<jv>annotation</jv>).build();
- *
- * <jc>// Serialize a bean with the dynamically applied
annotation.</jc>
- * String <jv>json</jv> =
<jv>serializer</jv>.serialize(<jk>new</jk> B());
- * </p>
- *
- * <p>
- * The following is the list of annotations builders provided that can
be constructed
- * and passed into the builder class:
- * <ul class='javatree'>
- * <li class='ja'>{@link
org.apache.juneau.annotation.BeanAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.annotation.BeancAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.annotation.BeanIgnoreAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.annotation.BeanpAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.annotation.ExampleAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.annotation.NamePropertyAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.annotation.ParentPropertyAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.annotation.SwapAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.annotation.UriAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.csv.annotation.CsvAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.html.annotation.HtmlAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.jso.annotation.JsoAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.json.annotation.JsonAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.jsonschema.annotation.SchemaAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.msgpack.annotation.MsgPackAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.oapi.annotation.OpenApiAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.plaintext.annotation.PlainTextAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.soap.annotation.SoapXmlAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.uon.annotation.UonAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.urlencoding.annotation.UrlEncodingAnnotation}
- * <li class='ja'>{@link
org.apache.juneau.xml.annotation.XmlAnnotation}
- * </ul>
- *
- * <p>
- * The syntax for the <l>on()</l> pattern match parameter depends on
whether it applies to a class, method, field, or constructor.
- * The valid pattern matches are:
- * <ul class='spaced-list'>
- * <li>Classes:
- * <ul>
- * <li>Fully qualified:
- * <ul>
- * <li><js>"com.foo.MyClass"</js>
- * </ul>
- * <li>Fully qualified inner class:
- * <ul>
- *
<li><js>"com.foo.MyClass$Inner1$Inner2"</js>
- * </ul>
- * <li>Simple:
- * <ul>
- * <li><js>"MyClass"</js>
- * </ul>
- * <li>Simple inner:
- * <ul>
- *
<li><js>"MyClass$Inner1$Inner2"</js>
- * <li><js>"Inner1$Inner2"</js>
- * <li><js>"Inner2"</js>
- * </ul>
- * </ul>
- * <li>Methods:
- * <ul>
- * <li>Fully qualified with args:
- * <ul>
- *
<li><js>"com.foo.MyClass.myMethod(String,int)"</js>
- *
<li><js>"com.foo.MyClass.myMethod(java.lang.String,int)"</js>
- *
<li><js>"com.foo.MyClass.myMethod()"</js>
- * </ul>
- * <li>Fully qualified:
- * <ul>
- *
<li><js>"com.foo.MyClass.myMethod"</js>
- * </ul>
- * <li>Simple with args:
- * <ul>
- *
<li><js>"MyClass.myMethod(String,int)"</js>
- *
<li><js>"MyClass.myMethod(java.lang.String,int)"</js>
- *
<li><js>"MyClass.myMethod()"</js>
- * </ul>
- * <li>Simple:
- * <ul>
- * <li><js>"MyClass.myMethod"</js>
- * </ul>
- * <li>Simple inner class:
- * <ul>
- *
<li><js>"MyClass$Inner1$Inner2.myMethod"</js>
- *
<li><js>"Inner1$Inner2.myMethod"</js>
- * <li><js>"Inner2.myMethod"</js>
- * </ul>
- * </ul>
- * <li>Fields:
- * <ul>
- * <li>Fully qualified:
- * <ul>
- *
<li><js>"com.foo.MyClass.myField"</js>
- * </ul>
- * <li>Simple:
- * <ul>
- * <li><js>"MyClass.myField"</js>
- * </ul>
- * <li>Simple inner class:
- * <ul>
- *
<li><js>"MyClass$Inner1$Inner2.myField"</js>
- *
<li><js>"Inner1$Inner2.myField"</js>
- * <li><js>"Inner2.myField"</js>
- * </ul>
- * </ul>
- * <li>Constructors:
- * <ul>
- * <li>Fully qualified with args:
- * <ul>
- *
<li><js>"com.foo.MyClass(String,int)"</js>
- *
<li><js>"com.foo.MyClass(java.lang.String,int)"</js>
- * <li><js>"com.foo.MyClass()"</js>
- * </ul>
- * <li>Simple with args:
- * <ul>
- *
<li><js>"MyClass(String,int)"</js>
- *
<li><js>"MyClass(java.lang.String,int)"</js>
- * <li><js>"MyClass()"</js>
- * </ul>
- * <li>Simple inner class:
- * <ul>
- *
<li><js>"MyClass$Inner1$Inner2()"</js>
- * <li><js>"Inner1$Inner2()"</js>
- * <li><js>"Inner2()"</js>
- * </ul>
- * </ul>
- * <li>A comma-delimited list of anything on this list.
- * </ul>
- *
- * <ul class='seealso'>
- * <li class='ja'>{@link BeanConfig}
- * </ul>
- *
- * @param values
- * The annotations to register with the context.
- * @return This object (for method chaining).
- */
- @FluentSetter
- public ContextBuilder annotations(Annotation...values) {
- if (annotations == null)
- annotations = new ArrayList<>();
- Collections.addAll(annotations, values);
- return this;
- }
-
- /**
- * <i><l>Context</l> configuration property: </i> Debug mode.
- *
- * <p>
- * Enables the following additional information during serialization:
- * <ul class='spaced-list'>
- * <li>
- * When bean getters throws exceptions, the exception
includes the object stack information
- * in order to determine how that method was invoked.
- * <li>
- * Enables {@link BeanTraverseBuilder#detectRecursions()}.
- * </ul>
- *
- * <p>
- * Enables the following additional information during parsing:
- * <ul class='spaced-list'>
- * <li>
- * When bean setters throws exceptions, the exception
includes the object stack information
- * in order to determine how that method was invoked.
- * </ul>
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode w800'>
- * <jc>// Create a serializer with debug enabled.</jc>
- * WriterSerializer <jv>serializer</jv> = JsonSerializer
- * .<jsm>create</jsm>()
- * .debug()
- * .build();
- *
- * <jc>// Create a POJO model with a recursive loop.</jc>
- * <jk>public class</jk> MyBean {
- * <jk>public</jk> Object <jf>f</jf>;
- * }
- * MyBean <jv>myBean</jv> = <jk>new</jk> MyBean();
- * <jv>myBean</jv>.<jf>f</jf> = <jv>myBean</jv>;
- *
- * <jc>// Throws a SerializeException and not a
StackOverflowError</jc>
- * String <jv>json</jv> =
<jv>serializer</jv>.serialize(<jv>myBean</jv>);
- * </p>
- *
- * <ul class='seealso'>
- * <li class='ja'>{@link
org.apache.juneau.annotation.BeanConfig#debug()}
- * <li class='jm'>{@link
org.apache.juneau.SessionArgs#debug(Boolean)}
- * </ul>
- *
- * @return This object (for method chaining).
- */
- @FluentSetter
- public ContextBuilder debug() {
- return debug(true);
- }
-
- /**
- * Same as {@link #debug()} but allows you to explicitly specify the
value.
- *
- * @param value The value for this setting.
- * @return This object.
- */
- @FluentSetter
- public ContextBuilder debug(boolean value) {
- debug = value;
- return this;
- }
-
- /**
- * Returns <jk>true</jk> if debug is enabled.
- *
- * @return <jk>true</jk> if debug is enabled.
- */
- public boolean isDebug() {
- return debug;
- }
-
-
//-----------------------------------------------------------------------------------------------------------------
- // Helper methods.
-
//-----------------------------------------------------------------------------------------------------------------
-
-
- // <FluentSetters>
-
- // </FluentSetters>
-}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Session.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Session.java
deleted file mode 100644
index 4b0b949..0000000
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/Session.java
+++ /dev/null
@@ -1,201 +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;
-
-import static org.apache.juneau.internal.StringUtils.*;
-import static java.util.Optional.*;
-
-import java.text.*;
-import java.util.*;
-
-import org.apache.juneau.collections.*;
-import org.apache.juneau.json.*;
-
-/**
- * A one-time-use non-thread-safe object that's meant to be used once and then
thrown away.
- *
- * <p>
- * Serializers and parsers use session objects to retrieve config properties
and to use it as a scratchpad during
- * serialize and parse actions.
- */
-public abstract class Session {
-
- private final SessionProperties properties;
- private Map<String,Object> cache;
- private List<String> warnings; // Any warnings
encountered.
-
- private final Context ctx;
- private final boolean debug;
- private final boolean unmodifiable;
-
-
- /**
- * Default constructor.
- *
- * @param ctx The context object.
- * @param args
- * Runtime arguments.
- */
- protected Session(Context ctx, SessionArgs args) {
- this.ctx = ctx;
- this.unmodifiable = args.unmodifiable;
- SessionProperties sp = args.properties;
- if (args.unmodifiable)
- sp = sp.unmodifiable();
- properties = sp;
- debug = ofNullable(args.debug).orElse(ctx.isDebug());
- }
-
- /**
- * Returns the session properties on this session.
- *
- * @return The session properties on this session. Never <jk>null</jk>.
- */
- public final SessionProperties getSessionProperties() {
- return properties;
- }
-
- /**
- * Returns the context that created this session.
- *
- * @return The context that created this session.
- */
- public Context getContext() {
- return ctx;
- }
-
- /**
- * Adds an arbitrary object to this session's cache.
- *
- * <p>
- * Can be used to store objects for reuse during a session.
- *
- * @param key The key. Can be any string.
- * @param val The cached object.
- */
- public final void addToCache(String key, Object val) {
- if (unmodifiable)
- return;
- if (cache == null)
- cache = new TreeMap<>();
- cache.put(key, val);
- }
-
- /**
- * Adds arbitrary objects to this session's cache.
- *
- * <p>
- * Can be used to store objects for reuse during a session.
- *
- * @param cacheObjects
- * The objects to add to this session's cache.
- * No-op if <jk>null</jk>.
- */
- public final void addToCache(Map<String,Object> cacheObjects) {
- if (unmodifiable)
- return;
- if (cacheObjects != null) {
- if (cache == null)
- cache = new TreeMap<>();
- cache.putAll(cacheObjects);
- }
- }
-
- /**
- * Returns an object stored in the session cache.
- *
- * @param c The class type of the object.
- * @param key The session object key.
- * @return The cached object, or <jk>null</jk> if it doesn't exist.
- */
- @SuppressWarnings("unchecked")
- public final <T> T getFromCache(Class<T> c, String key) {
- return cache == null ? null : (T)cache.get(key);
- }
-
- /**
- * Logs a warning message.
- *
- * @param msg The warning message.
- * @param args Optional {@link MessageFormat}-style arguments.
- */
- public void addWarning(String msg, Object... args) {
- if (unmodifiable)
- return;
- if (warnings == null)
- warnings = new LinkedList<>();
- warnings.add((warnings.size() + 1) + ": " + format(msg, args));
- }
-
- /**
- * Returns <jk>true</jk> if warnings occurred in this session.
- *
- * @return <jk>true</jk> if warnings occurred in this session.
- */
- public final boolean hasWarnings() {
- return warnings != null && warnings.size() > 0;
- }
-
- /**
- * Returns the warnings that occurred in this session.
- *
- * @return The warnings that occurred in this session, or <jk>null</jk>
if no warnings occurred.
- */
- public final List<String> getWarnings() {
- return warnings;
- }
-
- /**
- * Throws a {@link BeanRuntimeException} if any warnings occurred in
this session.
- */
- public void checkForWarnings() {
- if (warnings != null && ! warnings.isEmpty())
- throw new BeanRuntimeException("Warnings occurred in
session: \n" + join(getWarnings(), "\n"));
- }
-
-
//-----------------------------------------------------------------------------------------------------------------
- // Configuration properties
-
//-----------------------------------------------------------------------------------------------------------------
-
- /**
- * Configuration property: Debug mode.
- *
- * @see ContextBuilder#debug()
- * @return
- * <jk>true</jk> if debug mode is enabled.
- */
- public boolean isDebug() {
- return debug;
- }
-
-
//-----------------------------------------------------------------------------------------------------------------
- // Other methods
-
//-----------------------------------------------------------------------------------------------------------------
-
- /**
- * Returns the properties defined on this bean as a simple map for
debugging purposes.
- *
- * <p>
- * Use <c>SimpleJson.<jsf>DEFAULT</jsf>.println(<jv>thisBean</jv>)</c>
to dump the contents of this bean to the console.
- *
- * @return A new map containing this bean's properties.
- */
- public OMap toMap() {
- return OMap.create().filtered();
- }
-
- @Override /* Object */
- public String toString() {
- return SimpleJsonSerializer.DEFAULT_READABLE.toString(toMap());
- }
-}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/SessionArgs.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/SessionArgs.java
deleted file mode 100644
index 4a3a2e6..0000000
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/SessionArgs.java
+++ /dev/null
@@ -1,146 +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;
-
-import java.util.*;
-
-import org.apache.juneau.collections.*;
-import org.apache.juneau.internal.*;
-import org.apache.juneau.json.*;
-
-/**
- * Runtime arguments common to all bean, serializer, and parser sessions.
- * {@review}
- */
-@FluentSetters
-public class SessionArgs {
-
- SessionProperties properties = SessionProperties.create();
- boolean unmodifiable;
- Boolean debug;
-
- /**
- * Constructor.
- */
- public SessionArgs() {}
-
-
//-----------------------------------------------------------------------------------------------------------------
- // Properties
-
//-----------------------------------------------------------------------------------------------------------------
-
- /**
- * Debug mode.
- *
- * <p>
- * Enables the following additional information during parsing:
- * <ul>
- * <li> When bean setters throws exceptions, the exception
includes the object stack information in order to determine how that method was
invoked.
- * </ul>
- *
- * <p>
- * If not specified, defaults to {@link ContextBuilder#debug()}.
- *
- * <ul class='seealso'>
- * <li class='ja'>{@link
org.apache.juneau.annotation.BeanConfig#debug()}
- * <li class='jm'>{@link org.apache.juneau.ContextBuilder#debug()}
- * <li class='jm'>{@link ContextBuilder#debug()}
- *
- * @param value
- * The new value for this property.
- * <br>Can be <jk>null</jk>.
- * @return This object (for method chaining).
- */
- @FluentSetter
- public SessionArgs debug(Boolean value) {
- debug = value;
- return this;
- }
-
- /**
- * Create an unmodifiable session.
- *
- * <p>
- * The created Session object will be unmodifiable which makes it
suitable for caching and reuse.
- *
- * @return This object (for method chaining).
- */
- @FluentSetter
- public SessionArgs unmodifiable() {
- this.unmodifiable = true;
- return this;
- }
-
- /**
- * Session-level properties.
- *
- * <p>
- * Overrides context-level properties.
- *
- * @param value
- * The new value for this property.
- * <br>Can be <jk>null</jk>.
- * @return This object (for method chaining).
- */
- @FluentSetter
- public SessionArgs properties(Map<String,Object> value) {
- this.properties = SessionProperties.create(value);
- return this;
- }
-
- /**
- * Adds a property to this session.
- *
- * @param key The property key.
- * @param value The property value.
- * @return This object (for method chaining).
- */
- @FluentSetter
- public SessionArgs property(String key, Object value) {
- if (value == null) {
- properties.remove(key);
- } else {
- properties.put(key, value);
- }
- return this;
- }
-
-
//-----------------------------------------------------------------------------------------------------------------
- // Other methods
-
//-----------------------------------------------------------------------------------------------------------------
-
- /**
- * Returns the properties defined on this bean as a simple map for
debugging purposes.
- *
- * <p>
- * Use <c>SimpleJson.<jsf>DEFAULT</jsf>.println(<jv>thisBean</jv>)</c>
to dump the contents of this bean to the console.
- *
- * @return A new map containing this bean's properties.
- */
- public OMap toMap() {
- return OMap
- .create()
- .filtered()
- .append("SessionArgs", OMap.create().filtered()
- .append("properties", properties.asMap())
- );
- }
-
- @Override /* Object */
- public String toString() {
- return SimpleJsonSerializer.DEFAULT_READABLE.toString(toMap());
- }
-
- // <FluentSetters>
-
- // </FluentSetters>
-}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfig.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfig.java
index 695be76..84891f4 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfig.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfig.java
@@ -349,9 +349,8 @@ public @interface BeanConfig {
* </ul>
*
* <ul class='seealso'>
- * <li class='jm'>{@link ContextBuilder#debug()}
- * <li class='jm'>{@link SessionArgs#debug(Boolean)}
- * <li class='jm'>{@link ContextBuilder#debug()}
+ * <li class='jm'>{@link org.apache.juneau.Context.Builder#debug()}
+ * <li class='jm'>{@link
org.apache.juneau.Context.Args#debug(Boolean)}
* </ul>
*/
String debug() default "";
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvAnnotation.java
index 0281809..deb3b3a 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/csv/annotation/CsvAnnotation.java
@@ -160,9 +160,9 @@ public class CsvAnnotation {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Applies targeted {@link Csv} annotations to a {@link ContextBuilder}.
+ * Applies targeted {@link Csv} annotations to a {@link
org.apache.juneau.Context.Builder}.
*/
- public static class Apply extends AnnotationApplier<Csv,ContextBuilder>
{
+ public static class Apply extends
AnnotationApplier<Csv,Context.Builder> {
/**
* Constructor.
@@ -170,11 +170,11 @@ public class CsvAnnotation {
* @param vr The resolver for resolving values in annotations.
*/
public Apply(VarResolverSession vr) {
- super(Csv.class, ContextBuilder.class, vr);
+ super(Csv.class, Context.Builder.class, vr);
}
@Override
- public void apply(AnnotationInfo<Csv> ai, ContextBuilder b) {
+ public void apply(AnnotationInfo<Csv> ai, Context.Builder b) {
Csv a = ai.getAnnotation();
if (isEmpty(a.on()) && isEmpty(a.onClass()))
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlAnnotation.java
index 1ad708b..d6925c0 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlAnnotation.java
@@ -279,9 +279,9 @@ public class HtmlAnnotation {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Applies targeted {@link Html} annotations to a {@link
ContextBuilder}.
+ * Applies targeted {@link Html} annotations to a {@link
org.apache.juneau.Context.Builder}.
*/
- public static class Apply extends
AnnotationApplier<Html,ContextBuilder> {
+ public static class Apply extends
AnnotationApplier<Html,Context.Builder> {
/**
* Constructor.
@@ -289,11 +289,11 @@ public class HtmlAnnotation {
* @param vr The resolver for resolving values in annotations.
*/
public Apply(VarResolverSession vr) {
- super(Html.class, ContextBuilder.class, vr);
+ super(Html.class, Context.Builder.class, vr);
}
@Override
- public void apply(AnnotationInfo<Html> ai, ContextBuilder b) {
+ public void apply(AnnotationInfo<Html> ai, Context.Builder b) {
Html a = ai.getAnnotation();
if (isEmpty(a.on()) && isEmpty(a.onClass()))
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlLinkAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlLinkAnnotation.java
index e76fe57..a125e4d 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlLinkAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/annotation/HtmlLinkAnnotation.java
@@ -186,9 +186,9 @@ public class HtmlLinkAnnotation {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Applies targeted {@link HtmlLink} annotations to a {@link
ContextBuilder}.
+ * Applies targeted {@link HtmlLink} annotations to a {@link
org.apache.juneau.Context.Builder}.
*/
- public static class Apply extends
AnnotationApplier<HtmlLink,ContextBuilder> {
+ public static class Apply extends
AnnotationApplier<HtmlLink,Context.Builder> {
/**
* Constructor.
@@ -196,11 +196,11 @@ public class HtmlLinkAnnotation {
* @param vr The resolver for resolving values in annotations.
*/
public Apply(VarResolverSession vr) {
- super(HtmlLink.class, ContextBuilder.class, vr);
+ super(HtmlLink.class, Context.Builder.class, vr);
}
@Override
- public void apply(AnnotationInfo<HtmlLink> ai, ContextBuilder
b) {
+ public void apply(AnnotationInfo<HtmlLink> ai, Context.Builder
b) {
HtmlLink a = ai.getAnnotation();
if (isEmpty(a.on()) && isEmpty(a.onClass()))
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoAnnotation.java
index 192d693..8599345 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/annotation/JsoAnnotation.java
@@ -159,9 +159,9 @@ public class JsoAnnotation {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Applies targeted {@link Jso} annotations to a {@link ContextBuilder}.
+ * Applies targeted {@link Jso} annotations to a {@link
org.apache.juneau.Context.Builder}.
*/
- public static class Apply extends AnnotationApplier<Jso,ContextBuilder>
{
+ public static class Apply extends
AnnotationApplier<Jso,Context.Builder> {
/**
* Constructor.
@@ -169,11 +169,11 @@ public class JsoAnnotation {
* @param vr The resolver for resolving values in annotations.
*/
public Apply(VarResolverSession vr) {
- super(Jso.class, ContextBuilder.class, vr);
+ super(Jso.class, Context.Builder.class, vr);
}
@Override
- public void apply(AnnotationInfo<Jso> ai, ContextBuilder b) {
+ public void apply(AnnotationInfo<Jso> ai, Context.Builder b) {
Jso a = ai.getAnnotation();
if (isEmpty(a.on()) && isEmpty(a.onClass()))
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonAnnotation.java
index 6479240..b7c3a5c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/annotation/JsonAnnotation.java
@@ -181,9 +181,9 @@ public class JsonAnnotation {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Applies targeted {@link Json} annotations to a {@link
ContextBuilder}.
+ * Applies targeted {@link Json} annotations to a {@link
org.apache.juneau.Context.Builder}.
*/
- public static class Apply extends
AnnotationApplier<Json,ContextBuilder> {
+ public static class Apply extends
AnnotationApplier<Json,Context.Builder> {
/**
* Constructor.
@@ -191,11 +191,11 @@ public class JsonAnnotation {
* @param vr The resolver for resolving values in annotations.
*/
public Apply(VarResolverSession vr) {
- super(Json.class, ContextBuilder.class, vr);
+ super(Json.class, Context.Builder.class, vr);
}
@Override
- public void apply(AnnotationInfo<Json> ai, ContextBuilder b) {
+ public void apply(AnnotationInfo<Json> ai, Context.Builder b) {
Json a = ai.getAnnotation();
if (isEmpty(a.on()) && isEmpty(a.onClass()))
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/SchemaAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/SchemaAnnotation.java
index e90fa10..937f542 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/SchemaAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/SchemaAnnotation.java
@@ -1293,9 +1293,9 @@ public class SchemaAnnotation {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Applies targeted {@link Schema} annotations to a {@link
ContextBuilder}.
+ * Applies targeted {@link Schema} annotations to a {@link
org.apache.juneau.Context.Builder}.
*/
- public static class Apply extends
AnnotationApplier<Schema,ContextBuilder> {
+ public static class Apply extends
AnnotationApplier<Schema,Context.Builder> {
/**
* Constructor.
@@ -1303,11 +1303,11 @@ public class SchemaAnnotation {
* @param vr The resolver for resolving values in annotations.
*/
public Apply(VarResolverSession vr) {
- super(Schema.class, ContextBuilder.class, vr);
+ super(Schema.class, Context.Builder.class, vr);
}
@Override
- public void apply(AnnotationInfo<Schema> ai, ContextBuilder b) {
+ public void apply(AnnotationInfo<Schema> ai, Context.Builder b)
{
Schema a = ai.getAnnotation();
if (isEmpty(a.on()) && isEmpty(a.onClass()))
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/annotation/MsgPackAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/annotation/MsgPackAnnotation.java
index 28c0773..f4d14fe 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/annotation/MsgPackAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/annotation/MsgPackAnnotation.java
@@ -159,9 +159,9 @@ public class MsgPackAnnotation {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Applies targeted {@link MsgPack} annotations to a {@link
ContextBuilder}.
+ * Applies targeted {@link MsgPack} annotations to a {@link
org.apache.juneau.Context.Builder}.
*/
- public static class Apply extends
AnnotationApplier<MsgPack,ContextBuilder> {
+ public static class Apply extends
AnnotationApplier<MsgPack,Context.Builder> {
/**
* Constructor.
@@ -169,11 +169,11 @@ public class MsgPackAnnotation {
* @param vr The resolver for resolving values in annotations.
*/
public Apply(VarResolverSession vr) {
- super(MsgPack.class, ContextBuilder.class, vr);
+ super(MsgPack.class, Context.Builder.class, vr);
}
@Override
- public void apply(AnnotationInfo<MsgPack> ai, ContextBuilder b)
{
+ public void apply(AnnotationInfo<MsgPack> ai, Context.Builder
b) {
MsgPack a = ai.getAnnotation();
if (isEmpty(a.on()) && isEmpty(a.onClass()))
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/annotation/OpenApiAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/annotation/OpenApiAnnotation.java
index 593f4c3..73a420d 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/annotation/OpenApiAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/oapi/annotation/OpenApiAnnotation.java
@@ -159,9 +159,9 @@ public class OpenApiAnnotation {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Applies targeted {@link OpenApi} annotations to a {@link
ContextBuilder}.
+ * Applies targeted {@link OpenApi} annotations to a {@link
org.apache.juneau.Context.Builder}.
*/
- public static class Apply extends
AnnotationApplier<OpenApi,ContextBuilder> {
+ public static class Apply extends
AnnotationApplier<OpenApi,Context.Builder> {
/**
* Constructor.
@@ -169,11 +169,11 @@ public class OpenApiAnnotation {
* @param vr The resolver for resolving values in annotations.
*/
public Apply(VarResolverSession vr) {
- super(OpenApi.class, ContextBuilder.class, vr);
+ super(OpenApi.class, Context.Builder.class, vr);
}
@Override
- public void apply(AnnotationInfo<OpenApi> ai, ContextBuilder b)
{
+ public void apply(AnnotationInfo<OpenApi> ai, Context.Builder
b) {
OpenApi a = ai.getAnnotation();
if (isEmpty(a.on()) && isEmpty(a.onClass()))
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserPipe.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserPipe.java
index 9a2cb02..a5f879c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserPipe.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserPipe.java
@@ -284,7 +284,7 @@ public final class ParserPipe implements Closeable {
* Returns the input to this parser as a plain string.
*
* <p>
- * This method only returns a value if {@link ContextBuilder#debug()}
is enabled.
+ * This method only returns a value if {@link
org.apache.juneau.Context.Builder#debug()} is enabled.
*
* @return The input as a string, or <jk>null</jk> if debug mode not
enabled.
*/
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java
index b71f6c5..f35ee8e 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java
@@ -893,7 +893,7 @@ public abstract class ParserSession extends BeanSession {
*
* <p>
* This always returns a value for input of type {@link CharSequence}.
- * <br>For other input types, use {@link ContextBuilder#debug()}
setting to enable caching to a string
+ * <br>For other input types, use {@link
org.apache.juneau.Context.Builder#debug()} setting to enable caching to a string
* before parsing so that this method returns the input.
*
* @return The input as a string, or <jk>null</jk> if no pipe has been
created or we're reading from an uncached reader or input stream source.
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/plaintext/annotation/PlainTextAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/plaintext/annotation/PlainTextAnnotation.java
index 5fe6004..f66b301 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/plaintext/annotation/PlainTextAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/plaintext/annotation/PlainTextAnnotation.java
@@ -159,9 +159,9 @@ public class PlainTextAnnotation {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Applies targeted {@link PlainText} annotations to a {@link
ContextBuilder}.
+ * Applies targeted {@link PlainText} annotations to a {@link
org.apache.juneau.Context.Builder}.
*/
- public static class Apply extends
AnnotationApplier<PlainText,ContextBuilder> {
+ public static class Apply extends
AnnotationApplier<PlainText,Context.Builder> {
/**
* Constructor.
@@ -169,11 +169,11 @@ public class PlainTextAnnotation {
* @param vr The resolver for resolving values in annotations.
*/
public Apply(VarResolverSession vr) {
- super(PlainText.class, ContextBuilder.class, vr);
+ super(PlainText.class, Context.Builder.class, vr);
}
@Override
- public void apply(AnnotationInfo<PlainText> ai, ContextBuilder
b) {
+ public void apply(AnnotationInfo<PlainText> ai, Context.Builder
b) {
PlainText a = ai.getAnnotation();
if (isEmpty(a.on()) && isEmpty(a.onClass()))
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/annotation/SoapXmlAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/annotation/SoapXmlAnnotation.java
index 5d95248..8aae1c2 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/annotation/SoapXmlAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/soap/annotation/SoapXmlAnnotation.java
@@ -159,9 +159,9 @@ public class SoapXmlAnnotation {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Applies targeted {@link SoapXml} annotations to a {@link
ContextBuilder}.
+ * Applies targeted {@link SoapXml} annotations to a {@link
org.apache.juneau.Context.Builder}.
*/
- public static class Apply extends
AnnotationApplier<SoapXml,ContextBuilder> {
+ public static class Apply extends
AnnotationApplier<SoapXml,Context.Builder> {
/**
* Constructor.
@@ -169,11 +169,11 @@ public class SoapXmlAnnotation {
* @param vr The resolver for resolving values in annotations.
*/
public Apply(VarResolverSession vr) {
- super(SoapXml.class, ContextBuilder.class, vr);
+ super(SoapXml.class, Context.Builder.class, vr);
}
@Override
- public void apply(AnnotationInfo<SoapXml> ai, ContextBuilder b)
{
+ public void apply(AnnotationInfo<SoapXml> ai, Context.Builder
b) {
SoapXml a = ai.getAnnotation();
if (isEmpty(a.on()) && isEmpty(a.onClass()))
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/annotation/UonAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/annotation/UonAnnotation.java
index 373c1d9..26f95ad 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/annotation/UonAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/annotation/UonAnnotation.java
@@ -159,9 +159,9 @@ public class UonAnnotation {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Applies targeted {@link Uon} annotations to a {@link ContextBuilder}.
+ * Applies targeted {@link Uon} annotations to a {@link
org.apache.juneau.Context.Builder}.
*/
- public static class Apply extends AnnotationApplier<Uon,ContextBuilder>
{
+ public static class Apply extends
AnnotationApplier<Uon,Context.Builder> {
/**
* Constructor.
@@ -169,11 +169,11 @@ public class UonAnnotation {
* @param vr The resolver for resolving values in annotations.
*/
public Apply(VarResolverSession vr) {
- super(Uon.class, ContextBuilder.class, vr);
+ super(Uon.class, Context.Builder.class, vr);
}
@Override
- public void apply(AnnotationInfo<Uon> ai, ContextBuilder b) {
+ public void apply(AnnotationInfo<Uon> ai, Context.Builder b) {
Uon a = ai.getAnnotation();
if (isEmpty(a.on()) && isEmpty(a.onClass()))
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/annotation/UrlEncodingAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/annotation/UrlEncodingAnnotation.java
index aa460fa..ef8837d 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/annotation/UrlEncodingAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/annotation/UrlEncodingAnnotation.java
@@ -183,9 +183,9 @@ public class UrlEncodingAnnotation {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Applies targeted {@link UrlEncoding} annotations to a {@link
ContextBuilder}.
+ * Applies targeted {@link UrlEncoding} annotations to a {@link
org.apache.juneau.Context.Builder}.
*/
- public static class Apply extends
AnnotationApplier<UrlEncoding,ContextBuilder> {
+ public static class Apply extends
AnnotationApplier<UrlEncoding,Context.Builder> {
/**
* Constructor.
@@ -193,11 +193,11 @@ public class UrlEncodingAnnotation {
* @param vr The resolver for resolving values in annotations.
*/
public Apply(VarResolverSession vr) {
- super(UrlEncoding.class, ContextBuilder.class, vr);
+ super(UrlEncoding.class, Context.Builder.class, vr);
}
@Override
- public void apply(AnnotationInfo<UrlEncoding> ai,
ContextBuilder b) {
+ public void apply(AnnotationInfo<UrlEncoding> ai,
Context.Builder b) {
UrlEncoding a = ai.getAnnotation();
if (isEmpty(a.on()) && isEmpty(a.onClass()))
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlAnnotation.java
index 3de7b9c..d6988a3 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlAnnotation.java
@@ -237,9 +237,9 @@ public class XmlAnnotation {
//-----------------------------------------------------------------------------------------------------------------
/**
- * Applies targeted {@link Xml} annotations to a {@link ContextBuilder}.
+ * Applies targeted {@link Xml} annotations to a {@link
org.apache.juneau.Context.Builder}.
*/
- public static class Apply extends AnnotationApplier<Xml,ContextBuilder>
{
+ public static class Apply extends
AnnotationApplier<Xml,Context.Builder> {
/**
* Constructor.
@@ -247,11 +247,11 @@ public class XmlAnnotation {
* @param vr The resolver for resolving values in annotations.
*/
public Apply(VarResolverSession vr) {
- super(Xml.class, ContextBuilder.class, vr);
+ super(Xml.class, Context.Builder.class, vr);
}
@Override
- public void apply(AnnotationInfo<Xml> ai, ContextBuilder b) {
+ public void apply(AnnotationInfo<Xml> ai, Context.Builder b) {
Xml a = ai.getAnnotation();
if (isEmpty(a.on()) && isEmpty(a.onClass()))
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
index b3e5e65..31012bb 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
@@ -879,7 +879,7 @@ import org.apache.juneau.utils.*;
* <p class='w900'>
* Enabling debug mode has the following effects:
* <ul>
- * <li>{@link ContextBuilder#debug()} is enabled.
+ * <li>{@link org.apache.juneau.Context.Builder#debug()} is enabled.
* <li>{@link RestClientBuilder#detectLeaks()} is enabled.
* <li>{@link RestClientBuilder#logToConsole()} is called.
* </ul>
diff --git
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClientBuilder.java
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClientBuilder.java
index 8d5af3c..35f36a2 100644
---
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClientBuilder.java
+++
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClientBuilder.java
@@ -3213,7 +3213,7 @@ public class RestClientBuilder extends
BeanContextableBuilder {
* when the <c>finalize</c> methods are invoked.
*
* <p>
- * Automatically enabled with {@link ContextBuilder#debug()}.
+ * Automatically enabled with {@link
org.apache.juneau.Context.Builder#debug()}.
*
* <h5 class='section'>Example:</h5>
* <p class='bcode w800'>
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 af913c1..09f155a 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
@@ -1616,17 +1616,17 @@ public class RestContext extends Context {
//-----------------------------------------------------------------------------------------------------------------
@Override /* Context */
- public ContextBuilder copy() {
+ public Context.Builder copy() {
throw unsupportedOperationException("Method not implemented.");
}
@Override /* Context */
- public Session createSession(SessionArgs args) {
+ public Session createSession(Context.Args args) {
throw unsupportedOperationException("Method not implemented.");
}
@Override /* Context */
- public SessionArgs createDefaultSessionArgs() {
+ public Context.Args createDefaultSessionArgs() {
throw unsupportedOperationException("Method not implemented.");
}
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 9f008bf..290c46a 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
@@ -95,7 +95,7 @@ import org.apache.juneau.svl.vars.*;
* </ul>
*/
@FluentSetters(ignore={"set"})
-public class RestContextBuilder extends ContextBuilder implements
ServletConfig {
+public class RestContextBuilder extends Context.Builder implements
ServletConfig {
/**
* Represents a <jk>null</jk> value for the {@link Rest#builder()}
annotation.
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 46021da..24dcd21 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
@@ -586,17 +586,17 @@ public class RestOpContext extends Context implements
Comparable<RestOpContext>
//-----------------------------------------------------------------------------------------------------------------
@Override /* Context */
- public ContextBuilder copy() {
+ public Context.Builder copy() {
throw unsupportedOperationException("Method not implemented.");
}
@Override /* Context */
- public Session createSession(SessionArgs args) {
+ public Session createSession(Context.Args args) {
throw unsupportedOperationException("Method not implemented.");
}
@Override /* Context */
- public SessionArgs createDefaultSessionArgs() {
+ public Context.Args createDefaultSessionArgs() {
throw unsupportedOperationException("Method not implemented.");
}
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContextBuilder.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContextBuilder.java
index 007389b..c5574dc 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContextBuilder.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestOpContextBuilder.java
@@ -55,7 +55,7 @@ import java.nio.charset.*;
* Builder class for {@link RestOpContext} objects.
*/
@FluentSetters
-public class RestOpContextBuilder extends ContextBuilder {
+public class RestOpContextBuilder extends Context.Builder {
RestContext restContext;
RestContextBuilder parent;
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflection/ClassInfoTest.java
b/juneau-utest/src/test/java/org/apache/juneau/reflection/ClassInfoTest.java
index 7b184f4..d76bd08 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/reflection/ClassInfoTest.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/reflection/ClassInfoTest.java
@@ -63,12 +63,12 @@ public class ClassInfoTest {
int value();
}
- public static class AConfigApply extends
AnnotationApplier<AConfig,ContextBuilder> {
+ public static class AConfigApply extends
AnnotationApplier<AConfig,Context.Builder> {
protected AConfigApply(VarResolverSession vr) {
- super(AConfig.class, ContextBuilder.class, vr);
+ super(AConfig.class, Context.Builder.class, vr);
}
@Override
- public void apply(AnnotationInfo<AConfig> a, ContextBuilder b) {
+ public void apply(AnnotationInfo<AConfig> a, Context.Builder b)
{
}
}
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/reflection/MethodInfoTest.java
b/juneau-utest/src/test/java/org/apache/juneau/reflection/MethodInfoTest.java
index 37d7eab..59717cd 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/reflection/MethodInfoTest.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/reflection/MethodInfoTest.java
@@ -58,12 +58,12 @@ public class MethodInfoTest {
String value();
}
- public static class AConfigApply extends
AnnotationApplier<AConfig,ContextBuilder> {
+ public static class AConfigApply extends
AnnotationApplier<AConfig,Context.Builder> {
protected AConfigApply(VarResolverSession vr) {
- super(AConfig.class, ContextBuilder.class, vr);
+ super(AConfig.class, Context.Builder.class, vr);
}
@Override
- public void apply(AnnotationInfo<AConfig> ai, ContextBuilder b)
{
+ public void apply(AnnotationInfo<AConfig> ai, Context.Builder
b) {
}
}