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 b3e33f8 Clean up builders.
b3e33f8 is described below
commit b3e33f8281ece2253bdad5affc02d9e476a8ce94
Author: JamesBognar <[email protected]>
AuthorDate: Sun Aug 8 15:27:03 2021 -0400
Clean up builders.
---
.../juneau/jena/annotation/RdfAnnotation.java | 4 +-
.../main/java/org/apache/juneau/BeanContext.java | 307 +------------------
.../java/org/apache/juneau/BeanContextBuilder.java | 228 ++------------
.../src/main/java/org/apache/juneau/Context.java | 341 ++++++++++++++++++++-
.../java/org/apache/juneau/ContextBuilder.java | 209 ++++++++++++-
.../apache/juneau/annotation/BeanAnnotation.java | 3 +-
.../juneau/annotation/BeanConfigAnnotation.java | 2 +-
.../juneau/annotation/BeanIgnoreAnnotation.java | 3 +-
.../apache/juneau/annotation/BeancAnnotation.java | 3 +-
.../apache/juneau/annotation/BeanpAnnotation.java | 3 +-
.../juneau/annotation/ExampleAnnotation.java | 4 +-
.../juneau/annotation/MarshalledAnnotation.java | 4 +-
.../juneau/annotation/NamePropertyAnnotation.java | 4 +-
.../annotation/ParentPropertyAnnotation.java | 4 +-
.../apache/juneau/annotation/SwapAnnotation.java | 3 +-
.../apache/juneau/annotation/UriAnnotation.java | 4 +-
.../juneau/csv/annotation/CsvAnnotation.java | 2 +-
.../juneau/html/annotation/HtmlAnnotation.java | 2 +-
.../juneau/html/annotation/HtmlLinkAnnotation.java | 2 +-
.../juneau/http/annotation/BodyAnnotation.java | 3 +-
.../juneau/http/annotation/FormDataAnnotation.java | 3 +-
.../juneau/http/annotation/HeaderAnnotation.java | 3 +-
.../juneau/http/annotation/PathAnnotation.java | 3 +-
.../juneau/http/annotation/QueryAnnotation.java | 3 +-
.../juneau/http/annotation/RequestAnnotation.java | 4 +-
.../juneau/http/annotation/ResponseAnnotation.java | 3 +-
.../http/annotation/ResponseBodyAnnotation.java | 4 +-
.../http/annotation/ResponseHeaderAnnotation.java | 3 +-
.../http/annotation/ResponseStatusAnnotation.java | 4 +-
.../juneau/jso/annotation/JsoAnnotation.java | 2 +-
.../juneau/json/annotation/JsonAnnotation.java | 2 +-
.../jsonschema/annotation/SchemaAnnotation.java | 2 +-
.../msgpack/annotation/MsgPackAnnotation.java | 2 +-
.../juneau/oapi/annotation/OpenApiAnnotation.java | 2 +-
.../plaintext/annotation/PlainTextAnnotation.java | 2 +-
.../juneau/soap/annotation/SoapXmlAnnotation.java | 2 +-
.../juneau/uon/annotation/UonAnnotation.java | 2 +-
.../annotation/UrlEncodingAnnotation.java | 2 +-
.../juneau/xml/annotation/XmlAnnotation.java | 2 +-
39 files changed, 612 insertions(+), 573 deletions(-)
diff --git
a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfAnnotation.java
b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfAnnotation.java
index 1160d9e..a25a516 100644
---
a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfAnnotation.java
+++
b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/annotation/RdfAnnotation.java
@@ -247,7 +247,7 @@ public class RdfAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.prependTo(CONTEXT_annotations, copy(a, vr()));
}
}
@@ -273,7 +273,7 @@ public class RdfAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.prependTo(CONTEXT_annotations, copy(a, vr()));
}
}
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 f2cfdcd..899434c 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
@@ -19,7 +19,6 @@ import static org.apache.juneau.internal.StringUtils.*;
import static org.apache.juneau.internal.ExceptionUtils.*;
import java.io.*;
-import java.lang.annotation.*;
import java.lang.reflect.*;
import java.util.*;
import java.util.concurrent.*;
@@ -31,8 +30,6 @@ import org.apache.juneau.json.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.transform.*;
-import org.apache.juneau.utils.*;
-import org.apache.juneau.utils.ReflectionMapBuilder;
/**
* Core class of the Juneau architecture.
@@ -155,32 +152,11 @@ import org.apache.juneau.utils.ReflectionMapBuilder;
*/
@SuppressWarnings({"unchecked","rawtypes"})
@ConfigurableContext
-public class BeanContext extends Context implements MetaProvider {
+public class BeanContext extends Context {
static final String PREFIX = "BeanContext";
/**
- * Configuration property: Annotations.
- *
- * <p>
- * Defines annotations to apply to specific classes and methods.
- *
- * <h5 class='section'>Property:</h5>
- * <ul class='spaced-list'>
- * <li><b>ID:</b> {@link
org.apache.juneau.BeanContext#BEAN_annotations BEAN_annotations}
- * <li><b>Name:</b> <js>"BeanContext.annotations.lo"</js>
- * <li><b>Description:</b>
- * <li><b>Data type:</b> <c>List<{@link
java.lang.annotation.Annotation}></c>
- * <li><b>Default:</b> Empty list.
- * <li><b>Methods:</b>
- * <ul>
- * <li class='jm'>{@link
org.apache.juneau.BeanContextBuilder#annotations(Annotation...)}
- * </ul>
- * </ul>
- */
- public static final String BEAN_annotations = PREFIX +
".annotations.lo";
-
- /**
* Configuration property: Minimum bean class visibility.
*
* <p>
@@ -1085,7 +1061,6 @@ public class BeanContext extends Context implements
MetaProvider {
private final BeanRegistry beanRegistry;
private final PropertyNamer propertyNamer;
private final String typePropertyName;
- private final ReflectionMap<Annotation> annotations;
private final Locale locale;
private final TimeZone timeZone;
@@ -1114,33 +1089,6 @@ public class BeanContext extends Context implements
MetaProvider {
cp = cp.subset(new String[]{"Context","BeanContext"});
- ReflectionMapBuilder<Annotation> rmb =
ReflectionMap.create(Annotation.class);
- for (Annotation a : cp.getList(BEAN_annotations,
Annotation.class).orElse(emptyList())) {
- try {
- ClassInfo ci = ClassInfo.of(a.getClass());
-
- MethodInfo mi = ci.getMethod("onClass");
- if (mi != null) {
- if (!
mi.getReturnType().is(Class[].class))
- throw new
ConfigException("Invalid annotation @{0} used in BEAN_annotations property.
Annotation must define an onClass() method that returns a Class array.",
a.getClass().getSimpleName());
- for (Class<?> c :
(Class<?>[])mi.accessible().invoke(a))
- rmb.append(c.getName(), a);
- }
-
- mi = ci.getMethod("on");
- if (mi != null) {
- if (!
mi.getReturnType().is(String[].class))
- throw new
ConfigException("Invalid annotation @{0} used in BEAN_annotations property.
Annotation must define an on() method that returns a String array.",
a.getClass().getSimpleName());
- for (String s :
(String[])mi.accessible().invoke(a))
- rmb.append(s, a);
- }
-
- } catch (Exception e) {
- throw new ConfigException(e, "Invalid
annotation @{0} used in BEAN_annotations property.", className(a));
- }
- }
- this.annotations = rmb.build();
-
beansRequireDefaultConstructor =
cp.getBoolean(BEAN_beansRequireDefaultConstructor).orElse(false);
beansRequireSerializable =
cp.getBoolean(BEAN_beansRequireSerializable).orElse(false);
beansRequireSettersForGetters =
cp.getBoolean(BEAN_beansRequireSettersForGetters).orElse(false);
@@ -1821,259 +1769,6 @@ public class BeanContext extends Context implements
MetaProvider {
}
//-----------------------------------------------------------------------------------------------------------------
- // MetaProvider methods
-
//-----------------------------------------------------------------------------------------------------------------
-
- private static final boolean DISABLE_ANNOTATION_CACHING = !
Boolean.getBoolean("juneau.disableAnnotationCaching");
-
- private TwoKeyConcurrentCache<Class<?>,Class<? extends
Annotation>,List<Annotation>> classAnnotationCache = new
TwoKeyConcurrentCache<>(DISABLE_ANNOTATION_CACHING);
- private TwoKeyConcurrentCache<Class<?>,Class<? extends
Annotation>,List<Annotation>> declaredClassAnnotationCache = new
TwoKeyConcurrentCache<>(DISABLE_ANNOTATION_CACHING);
- private TwoKeyConcurrentCache<Method,Class<? extends
Annotation>,List<Annotation>> methodAnnotationCache = new
TwoKeyConcurrentCache<>(DISABLE_ANNOTATION_CACHING);
- private TwoKeyConcurrentCache<Field,Class<? extends
Annotation>,List<Annotation>> fieldAnnotationCache = new
TwoKeyConcurrentCache<>(DISABLE_ANNOTATION_CACHING);
- private TwoKeyConcurrentCache<Constructor<?>,Class<? extends
Annotation>,List<Annotation>> constructorAnnotationCache = new
TwoKeyConcurrentCache<>(DISABLE_ANNOTATION_CACHING);
-
- /**
- * Finds the specified annotations on the specified class.
- *
- * @param <A> The annotation type to find.
- * @param a The annotation type to find.
- * @param c The class to search on.
- * @return The annotations in an unmodifiable list, or an empty list if
not found.
- */
- @Override /* MetaProvider */
- public <A extends Annotation> List<A> getAnnotations(Class<A> a,
Class<?> c) {
- if (a == null || c == null)
- return emptyList();
- List<Annotation> aa = classAnnotationCache.get(c, a);
- if (aa == null) {
- A[] x = c.getAnnotationsByType(a);
- AList<Annotation> l = new AList<>(Arrays.asList(x));
- annotations.appendAll(c, a, l);
- aa = l.unmodifiable();
- classAnnotationCache.put(c, a, aa);
- }
- return (List<A>)aa;
- }
-
- /**
- * Finds the specified declared annotations on the specified class.
- *
- * @param <A> The annotation type to find.
- * @param a The annotation type to find.
- * @param c The class to search on.
- * @return The annotations in an unmodifiable list, or an empty list if
not found.
- */
- @Override /* MetaProvider */
- public <A extends Annotation> List<A> getDeclaredAnnotations(Class<A>
a, Class<?> c) {
- if (a == null || c == null)
- return emptyList();
- List<Annotation> aa = declaredClassAnnotationCache.get(c, a);
- if (aa == null) {
- A[] x = c.getDeclaredAnnotationsByType(a);
- AList<Annotation> l = new AList<>(Arrays.asList(x));
- annotations.appendAll(c, a, l);
- aa = l.unmodifiable();
- declaredClassAnnotationCache.put(c, a, aa);
- }
- return (List<A>)aa;
- }
-
- /**
- * Finds the specified annotations on the specified method.
- *
- * @param <A> The annotation type to find.
- * @param a The annotation type to find.
- * @param m The method to search on.
- * @return The annotations in an unmodifiable list, or an empty list if
not found.
- */
- @Override /* MetaProvider */
- public <A extends Annotation> List<A> getAnnotations(Class<A> a, Method
m) {
- if (a == null || m == null)
- return emptyList();
- List<Annotation> aa = methodAnnotationCache.get(m, a);
- if (aa == null) {
- A[] x = m.getAnnotationsByType(a);
- AList<Annotation> l = new AList<>(Arrays.asList(x));
- annotations.appendAll(m, a, l);
- aa = l.unmodifiable();
- methodAnnotationCache.put(m, a, aa);
- }
- return (List<A>)aa;
- }
-
- /**
- * Finds the specified annotations on the specified method.
- *
- * @param <A> The annotation type to find.
- * @param a The annotation type to find.
- * @param m The method to search on.
- * @return The annotations in an unmodifiable list, or an empty list if
not found.
- */
- public <A extends Annotation> List<A> getAnnotations(Class<A> a,
MethodInfo m) {
- return getAnnotations(a, m == null ? null : m.inner());
- }
-
- /**
- * Finds the last specified annotations on the specified method.
- *
- * @param <A> The annotation type to find.
- * @param a The annotation type to find.
- * @param m The method to search on.
- * @return The annotation, or <jk>null</jk> if not found.
- */
- public <A extends Annotation> A getLastAnnotation(Class<A> a, Method m)
{
- return last(getAnnotations(a, m));
- }
-
- /**
- * Finds the last specified annotations on the specified method.
- *
- * @param <A> The annotation type to find.
- * @param a The annotation type to find.
- * @param m The method to search on.
- * @return The annotation, or <jk>null</jk> if not found.
- */
- public <A extends Annotation> A getLastAnnotation(Class<A> a,
MethodInfo m) {
- return last(getAnnotations(a, m));
- }
-
- /**
- * Finds the specified annotations on the specified field.
- *
- * @param <A> The annotation type to find.
- * @param a The annotation type to find.
- * @param f The field to search on.
- * @return The annotations in an unmodifiable list, or an empty list if
not found.
- */
- @Override /* MetaProvider */
- public <A extends Annotation> List<A> getAnnotations(Class<A> a, Field
f) {
- if (a == null || f == null)
- return emptyList();
- List<Annotation> aa = fieldAnnotationCache.get(f, a);
- if (aa == null) {
- A[] x = f.getAnnotationsByType(a);
- AList<Annotation> l = new AList<>(Arrays.asList(x));
- annotations.appendAll(f, a, l);
- aa = l.unmodifiable();
- fieldAnnotationCache.put(f, a, aa);
- }
- return (List<A>)aa;
- }
-
- /**
- * Finds the specified annotations on the specified field.
- *
- * @param <A> The annotation type to find.
- * @param a The annotation type to find.
- * @param f The field to search on.
- * @return The annotations in an unmodifiable list, or an empty list if
not found.
- */
- public <A extends Annotation> List<A> getAnnotations(Class<A> a,
FieldInfo f) {
- return getAnnotations(a, f == null ? null: f.inner());
- }
-
- /**
- * Finds the specified annotations on the specified constructor.
- *
- * @param <A> The annotation type to find.
- * @param a The annotation type to find.
- * @param c The constructor to search on.
- * @return The annotations in an unmodifiable list, or an empty list if
not found.
- */
- @Override /* MetaProvider */
- public <A extends Annotation> List<A> getAnnotations(Class<A> a,
Constructor<?> c) {
- if (a == null || c == null)
- return emptyList();
- List<Annotation> aa = constructorAnnotationCache.get(c, a);
- if (aa == null) {
- A[] x = c.getAnnotationsByType(a);
- AList<Annotation> l = new AList(Arrays.asList(x));
- annotations.appendAll(c, a, l);
- aa = l.unmodifiable();
- constructorAnnotationCache.put(c, a, l);
- }
- return (List<A>)aa;
- }
-
- /**
- * Finds the specified annotations on the specified constructor.
- *
- * @param <A> The annotation type to find.
- * @param a The annotation type to find.
- * @param c The constructor to search on.
- * @return The annotations in an unmodifiable list, or an empty list if
not found.
- */
- public <A extends Annotation> List<A> getAnnotations(Class<A> a,
ConstructorInfo c) {
- return getAnnotations(a, c == null ? null : c.inner());
- }
-
- /**
- * Returns <jk>true</jk> if <c>getAnnotation(a,c)</c> returns a
non-null value.
- *
- * @param a The annotation being checked for.
- * @param c The class being checked on.
- * @return <jk>true</jk> if the annotation exists on the specified
class.
- */
- public <A extends Annotation> boolean hasAnnotation(Class<A> a,
Class<?> c) {
- return getAnnotations(a, c).size() > 0;
- }
-
- /**
- * Returns <jk>true</jk> if <c>getAnnotation(a,c)</c> returns a
non-null value.
- *
- * @param a The annotation being checked for.
- * @param c The class being checked on.
- * @return <jk>true</jk> if the annotation exists on the specified
class.
- */
- public <A extends Annotation> boolean hasAnnotation(Class<A> a,
ClassInfo c) {
- return getAnnotations(a, c == null ? null : c.inner()).size() >
0;
- }
-
- /**
- * Returns <jk>true</jk> if <c>getAnnotation(a,m)</c> returns a
non-null value.
- *
- * @param a The annotation being checked for.
- * @param m The method being checked on.
- * @return <jk>true</jk> if the annotation exists on the specified
method.
- */
- public <A extends Annotation> boolean hasAnnotation(Class<A> a, Method
m) {
- return getAnnotations(a, m).size() > 0;
- }
-
- /**
- * Returns <jk>true</jk> if <c>getAnnotation(a,m)</c> returns a
non-null value.
- *
- * @param a The annotation being checked for.
- * @param m The method being checked on.
- * @return <jk>true</jk> if the annotation exists on the specified
method.
- */
- public <A extends Annotation> boolean hasAnnotation(Class<A> a,
MethodInfo m) {
- return getAnnotations(a, m == null ? null : m.inner()).size() >
0;
- }
-
- /**
- * Returns <jk>true</jk> if <c>getAnnotation(a,f)</c> returns a
non-null value.
- *
- * @param a The annotation being checked for.
- * @param f The field being checked on.
- * @return <jk>true</jk> if the annotation exists on the specified
field.
- */
- public <A extends Annotation> boolean hasAnnotation(Class<A> a,
FieldInfo f) {
- return getAnnotations(a, f == null ? null : f.inner()).size() >
0;
- }
-
- /**
- * Returns <jk>true</jk> if <c>getAnnotation(a,c)</c> returns a
non-null value.
- *
- * @param a The annotation being checked for.
- * @param c The constructor being checked on.
- * @return <jk>true</jk> if the annotation exists on the specified
constructor.
- */
- public <A extends Annotation> boolean hasAnnotation(Class<A> a,
ConstructorInfo c) {
- return getAnnotations(a, c == null ? null : c.inner()).size() >
0;
- }
-
-
//-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
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 47d4fd1..284c317 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
@@ -82,184 +82,6 @@ public class BeanContextBuilder extends ContextBuilder {
//-----------------------------------------------------------------------------------------------------------------
/**
- * 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}
- * <li class='jf'>{@link BeanContext#BEAN_annotations}
- * </ul>
- *
- * @param values
- * The annotations to register with the context.
- * @return This object (for method chaining).
- */
- @FluentSetter
- public BeanContextBuilder annotations(Annotation...values) {
- return prependTo(BEAN_annotations, values);
- }
-
- /**
* Minimum bean class visibility.
*
* <p>
@@ -464,7 +286,7 @@ public class BeanContextBuilder extends ContextBuilder {
*/
@FluentSetter
public BeanContextBuilder beanInterceptor(Class<?> on, Class<? extends
BeanInterceptor<?>> value) {
- return prependTo(BEAN_annotations,
BeanAnnotation.create(on).interceptor(value).build());
+ return
annotations(BeanAnnotation.create(on).interceptor(value).build());
}
/**
@@ -797,7 +619,7 @@ public class BeanContextBuilder extends ContextBuilder {
*/
@FluentSetter
public BeanContextBuilder beanProperties(Class<?> beanClass, String
properties) {
- return prependTo(BEAN_annotations,
BeanAnnotation.create(beanClass).p(properties).build());
+ return
annotations(BeanAnnotation.create(beanClass).p(properties).build());
}
/**
@@ -860,7 +682,7 @@ public class BeanContextBuilder extends ContextBuilder {
@FluentSetter
public BeanContextBuilder beanProperties(Map<String,Object> values) {
for (Map.Entry<String,Object> e : values.entrySet())
- prependTo(BEAN_annotations,
BeanAnnotation.create(e.getKey()).p(stringify(e.getValue())).build());
+
annotations(BeanAnnotation.create(e.getKey()).p(stringify(e.getValue())).build());
return this;
}
@@ -923,7 +745,7 @@ public class BeanContextBuilder extends ContextBuilder {
*/
@FluentSetter
public BeanContextBuilder beanProperties(String beanClassName, String
properties) {
- return prependTo(BEAN_annotations,
BeanAnnotation.create(beanClassName).p(properties).build());
+ return
annotations(BeanAnnotation.create(beanClassName).p(properties).build());
}
/**
@@ -975,7 +797,7 @@ public class BeanContextBuilder extends ContextBuilder {
*/
@FluentSetter
public BeanContextBuilder beanPropertiesExcludes(Class<?> beanClass,
String properties) {
- return prependTo(BEAN_annotations,
BeanAnnotation.create(beanClass).xp(properties).build());
+ return
annotations(BeanAnnotation.create(beanClass).xp(properties).build());
}
/**
@@ -1030,7 +852,7 @@ public class BeanContextBuilder extends ContextBuilder {
@FluentSetter
public BeanContextBuilder beanPropertiesExcludes(Map<String,Object>
values) {
for (Map.Entry<String,Object> e : values.entrySet())
- prependTo(BEAN_annotations,
BeanAnnotation.create(e.getKey()).xp(stringify(e.getValue())).build());
+
annotations(BeanAnnotation.create(e.getKey()).xp(stringify(e.getValue())).build());
return this;
}
@@ -1085,7 +907,7 @@ public class BeanContextBuilder extends ContextBuilder {
*/
@FluentSetter
public BeanContextBuilder beanPropertiesExcludes(String beanClassName,
String properties) {
- return prependTo(BEAN_annotations,
BeanAnnotation.create(beanClassName).xp(properties).build());
+ return
annotations(BeanAnnotation.create(beanClassName).xp(properties).build());
}
/**
@@ -1140,7 +962,7 @@ public class BeanContextBuilder extends ContextBuilder {
*/
@FluentSetter
public BeanContextBuilder beanPropertiesReadOnly(Class<?> beanClass,
String properties) {
- return prependTo(BEAN_annotations,
BeanAnnotation.create(beanClass).ro(properties).build());
+ return
annotations(BeanAnnotation.create(beanClass).ro(properties).build());
}
/**
@@ -1198,7 +1020,7 @@ public class BeanContextBuilder extends ContextBuilder {
@FluentSetter
public BeanContextBuilder beanPropertiesReadOnly(Map<String,Object>
values) {
for (Map.Entry<String,Object> e : values.entrySet())
- prependTo(BEAN_annotations,
BeanAnnotation.create(e.getKey()).ro(stringify(e.getValue())).build());
+
annotations(BeanAnnotation.create(e.getKey()).ro(stringify(e.getValue())).build());
return this;
}
@@ -1256,7 +1078,7 @@ public class BeanContextBuilder extends ContextBuilder {
*/
@FluentSetter
public BeanContextBuilder beanPropertiesReadOnly(String beanClassName,
String properties) {
- return prependTo(BEAN_annotations,
BeanAnnotation.create(beanClassName).ro(properties).build());
+ return
annotations(BeanAnnotation.create(beanClassName).ro(properties).build());
}
/**
@@ -1310,7 +1132,7 @@ public class BeanContextBuilder extends ContextBuilder {
*/
@FluentSetter
public BeanContextBuilder beanPropertiesWriteOnly(Class<?> beanClass,
String properties) {
- return prependTo(BEAN_annotations,
BeanAnnotation.create(beanClass).wo(properties).build());
+ return
annotations(BeanAnnotation.create(beanClass).wo(properties).build());
}
/**
@@ -1367,7 +1189,7 @@ public class BeanContextBuilder extends ContextBuilder {
@FluentSetter
public BeanContextBuilder beanPropertiesWriteOnly(Map<String,Object>
values) {
for (Map.Entry<String,Object> e : values.entrySet())
- prependTo(BEAN_annotations,
BeanAnnotation.create(e.getKey()).wo(stringify(e.getValue())).build());
+
annotations(BeanAnnotation.create(e.getKey()).wo(stringify(e.getValue())).build());
return this;
}
@@ -1424,7 +1246,7 @@ public class BeanContextBuilder extends ContextBuilder {
*/
@FluentSetter
public BeanContextBuilder beanPropertiesWriteOnly(String beanClassName,
String properties) {
- return prependTo(BEAN_annotations,
BeanAnnotation.create(beanClassName).wo(properties).build());
+ return
annotations(BeanAnnotation.create(beanClassName).wo(properties).build());
}
/**
@@ -1592,7 +1414,7 @@ public class BeanContextBuilder extends ContextBuilder {
*/
@FluentSetter
public BeanContextBuilder dictionaryOn(Class<?> on, Class<?>...values) {
- return prependTo(BEAN_annotations,
BeanAnnotation.create(on).dictionary(values).build());
+ return
annotations(BeanAnnotation.create(on).dictionary(values).build());
}
/**
@@ -1779,7 +1601,7 @@ public class BeanContextBuilder extends ContextBuilder {
*/
@FluentSetter
public BeanContextBuilder findFluentSetters(Class<?> on) {
- return prependTo(BEAN_annotations,
BeanAnnotation.create(on).findFluentSetters(true).build());
+ return
annotations(BeanAnnotation.create(on).findFluentSetters(true).build());
}
/**
@@ -2134,7 +1956,7 @@ public class BeanContextBuilder extends ContextBuilder {
*/
@FluentSetter
public BeanContextBuilder interfaceClass(Class<?> on, Class<?> value) {
- return prependTo(BEAN_annotations,
BeanAnnotation.create(on).interfaceClass(value).build());
+ return
annotations(BeanAnnotation.create(on).interfaceClass(value).build());
}
/**
@@ -2180,7 +2002,7 @@ public class BeanContextBuilder extends ContextBuilder {
@FluentSetter
public BeanContextBuilder interfaces(Class<?>...value) {
for (Class<?> v : value)
- prependTo(BEAN_annotations,
BeanAnnotation.create(v).interfaceClass(v).build());
+
annotations(BeanAnnotation.create(v).interfaceClass(v).build());
return this;
}
@@ -2506,7 +2328,7 @@ public class BeanContextBuilder extends ContextBuilder {
*/
@FluentSetter
public BeanContextBuilder propertyNamer(Class<?> on, Class<? extends
PropertyNamer> value) {
- return prependTo(BEAN_annotations,
BeanAnnotation.create(on).propertyNamer(value).build());
+ return
annotations(BeanAnnotation.create(on).propertyNamer(value).build());
}
/**
@@ -2593,7 +2415,7 @@ public class BeanContextBuilder extends ContextBuilder {
@FluentSetter
public BeanContextBuilder sortProperties(Class<?>...on) {
for (Class<?> c : on)
- prependTo(BEAN_annotations,
BeanAnnotation.create(c).sort(true).build());
+
annotations(BeanAnnotation.create(c).sort(true).build());
return this;
}
@@ -2639,7 +2461,7 @@ public class BeanContextBuilder extends ContextBuilder {
*/
@FluentSetter
public BeanContextBuilder stopClass(Class<?> on, Class<?> value) {
- return prependTo(BEAN_annotations,
BeanAnnotation.create(on).stopClass(value).build());
+ return
annotations(BeanAnnotation.create(on).stopClass(value).build());
}
/**
@@ -2825,7 +2647,7 @@ public class BeanContextBuilder extends ContextBuilder {
*/
@FluentSetter
public BeanContextBuilder typeName(Class<?> on, String value) {
- return prependTo(BEAN_annotations,
BeanAnnotation.create(on).typeName(value).build());
+ return
annotations(BeanAnnotation.create(on).typeName(value).build());
}
/**
@@ -2928,7 +2750,7 @@ public class BeanContextBuilder extends ContextBuilder {
*/
@FluentSetter
public BeanContextBuilder typePropertyName(Class<?> on, String value) {
- return prependTo(BEAN_annotations,
BeanAnnotation.create(on).typePropertyName(value).build());
+ return
annotations(BeanAnnotation.create(on).typePropertyName(value).build());
}
/**
@@ -3038,6 +2860,12 @@ public class BeanContextBuilder extends ContextBuilder {
}
@Override /* GENERATED - ContextBuilder */
+ public BeanContextBuilder annotations(Annotation...value) {
+ super.annotations(value);
+ return this;
+ }
+
+ @Override /* GENERATED - ContextBuilder */
public BeanContextBuilder appendTo(String name, Object value) {
super.appendTo(name, value);
return this;
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 116b40a..ee63a49 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
@@ -13,14 +13,19 @@
package org.apache.juneau;
import static org.apache.juneau.internal.ClassUtils.*;
+import static org.apache.juneau.internal.CollectionUtils.*;
+import java.lang.annotation.*;
+import java.lang.reflect.*;
import java.util.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.collections.*;
import org.apache.juneau.internal.*;
import org.apache.juneau.json.*;
+import org.apache.juneau.reflect.*;
import org.apache.juneau.serializer.*;
+import org.apache.juneau.utils.*;
/**
* A reusable stateless thread-safe read-only configuration, typically used
for creating one-time use {@link Session}
@@ -45,11 +50,32 @@ import org.apache.juneau.serializer.*;
* @see ContextProperties
*/
@ConfigurableContext
-public abstract class Context {
+public abstract class Context implements MetaProvider {
static final String PREFIX = "Context";
/**
+ * Configuration property: Annotations.
+ *
+ * <p>
+ * Defines annotations to apply to specific classes and methods.
+ *
+ * <h5 class='section'>Property:</h5>
+ * <ul class='spaced-list'>
+ * <li><b>ID:</b> {@link
org.apache.juneau.Context#CONTEXT_annotations CONTEXT_annotations}
+ * <li><b>Name:</b> <js>"BeanContext.annotations.lo"</js>
+ * <li><b>Description:</b>
+ * <li><b>Data type:</b> <c>List<{@link
java.lang.annotation.Annotation}></c>
+ * <li><b>Default:</b> Empty list.
+ * <li><b>Methods:</b>
+ * <ul>
+ * <li class='jm'>{@link
org.apache.juneau.ContextBuilder#annotations(Annotation...)}
+ * </ul>
+ * </ul>
+ */
+ public static final String CONTEXT_annotations = PREFIX +
".annotations.lo";
+
+ /**
* Configuration property: Debug mode.
*
* <p>
@@ -87,6 +113,7 @@ public abstract class Context {
final ContextProperties properties;
private final int identityCode;
+ private final ReflectionMap<Annotation> annotations;
final boolean debug;
@@ -104,6 +131,33 @@ public abstract class Context {
cp = properties;
this.identityCode = allowReuse ? new
HashCode().add(className(this)).add(cp).get() : System.identityHashCode(this);
debug = cp.getBoolean(CONTEXT_debug).orElse(false);
+
+ ReflectionMapBuilder<Annotation> rmb =
ReflectionMap.create(Annotation.class);
+ for (Annotation a : cp.getList(CONTEXT_annotations,
Annotation.class).orElse(emptyList())) {
+ try {
+ ClassInfo ci = ClassInfo.of(a.getClass());
+
+ MethodInfo mi = ci.getMethod("onClass");
+ if (mi != null) {
+ if (!
mi.getReturnType().is(Class[].class))
+ throw new
ConfigException("Invalid annotation @{0} used in BEAN_annotations property.
Annotation must define an onClass() method that returns a Class array.",
a.getClass().getSimpleName());
+ for (Class<?> c :
(Class<?>[])mi.accessible().invoke(a))
+ rmb.append(c.getName(), a);
+ }
+
+ mi = ci.getMethod("on");
+ if (mi != null) {
+ if (!
mi.getReturnType().is(String[].class))
+ throw new
ConfigException("Invalid annotation @{0} used in BEAN_annotations property.
Annotation must define an on() method that returns a String array.",
a.getClass().getSimpleName());
+ for (String s :
(String[])mi.accessible().invoke(a))
+ rmb.append(s, a);
+ }
+
+ } catch (Exception e) {
+ throw new ConfigException(e, "Invalid
annotation @{0} used in BEAN_annotations property.", className(a));
+ }
+ }
+ this.annotations = rmb.build();
}
/**
@@ -115,6 +169,33 @@ public abstract class Context {
debug = builder.debug;
identityCode = System.identityHashCode(this);
properties = ContextProperties.DEFAULT;
+
+ ReflectionMapBuilder<Annotation> rmb =
ReflectionMap.create(Annotation.class);
+ for (Annotation a :
builder.getContextProperties().getList(CONTEXT_annotations,
Annotation.class).orElse(emptyList())) {
+ try {
+ ClassInfo ci = ClassInfo.of(a.getClass());
+
+ MethodInfo mi = ci.getMethod("onClass");
+ if (mi != null) {
+ if (!
mi.getReturnType().is(Class[].class))
+ throw new
ConfigException("Invalid annotation @{0} used in BEAN_annotations property.
Annotation must define an onClass() method that returns a Class array.",
a.getClass().getSimpleName());
+ for (Class<?> c :
(Class<?>[])mi.accessible().invoke(a))
+ rmb.append(c.getName(), a);
+ }
+
+ mi = ci.getMethod("on");
+ if (mi != null) {
+ if (!
mi.getReturnType().is(String[].class))
+ throw new
ConfigException("Invalid annotation @{0} used in BEAN_annotations property.
Annotation must define an on() method that returns a String array.",
a.getClass().getSimpleName());
+ for (String s :
(String[])mi.accessible().invoke(a))
+ rmb.append(s, a);
+ }
+
+ } catch (Exception e) {
+ throw new ConfigException(e, "Invalid
annotation @{0} used in BEAN_annotations property.", className(a));
+ }
+ }
+ this.annotations = rmb.build();
}
/**
@@ -222,6 +303,264 @@ public abstract class Context {
}
//-----------------------------------------------------------------------------------------------------------------
+ // MetaProvider methods
+
//-----------------------------------------------------------------------------------------------------------------
+
+ private static final boolean DISABLE_ANNOTATION_CACHING = !
Boolean.getBoolean("juneau.disableAnnotationCaching");
+
+ private TwoKeyConcurrentCache<Class<?>,Class<? extends
Annotation>,List<Annotation>> classAnnotationCache = new
TwoKeyConcurrentCache<>(DISABLE_ANNOTATION_CACHING);
+ private TwoKeyConcurrentCache<Class<?>,Class<? extends
Annotation>,List<Annotation>> declaredClassAnnotationCache = new
TwoKeyConcurrentCache<>(DISABLE_ANNOTATION_CACHING);
+ private TwoKeyConcurrentCache<Method,Class<? extends
Annotation>,List<Annotation>> methodAnnotationCache = new
TwoKeyConcurrentCache<>(DISABLE_ANNOTATION_CACHING);
+ private TwoKeyConcurrentCache<Field,Class<? extends
Annotation>,List<Annotation>> fieldAnnotationCache = new
TwoKeyConcurrentCache<>(DISABLE_ANNOTATION_CACHING);
+ private TwoKeyConcurrentCache<Constructor<?>,Class<? extends
Annotation>,List<Annotation>> constructorAnnotationCache = new
TwoKeyConcurrentCache<>(DISABLE_ANNOTATION_CACHING);
+
+ /**
+ * Finds the specified annotations on the specified class.
+ *
+ * @param <A> The annotation type to find.
+ * @param a The annotation type to find.
+ * @param c The class to search on.
+ * @return The annotations in an unmodifiable list, or an empty list if
not found.
+ */
+ @SuppressWarnings("unchecked")
+ @Override /* MetaProvider */
+ public <A extends Annotation> List<A> getAnnotations(Class<A> a,
Class<?> c) {
+ if (a == null || c == null)
+ return emptyList();
+ List<Annotation> aa = classAnnotationCache.get(c, a);
+ if (aa == null) {
+ A[] x = c.getAnnotationsByType(a);
+ AList<Annotation> l = new AList<>(Arrays.asList(x));
+ annotations.appendAll(c, a, l);
+ aa = l.unmodifiable();
+ classAnnotationCache.put(c, a, aa);
+ }
+ return (List<A>)aa;
+ }
+
+ /**
+ * Finds the specified declared annotations on the specified class.
+ *
+ * @param <A> The annotation type to find.
+ * @param a The annotation type to find.
+ * @param c The class to search on.
+ * @return The annotations in an unmodifiable list, or an empty list if
not found.
+ */
+ @SuppressWarnings("unchecked")
+ @Override /* MetaProvider */
+ public <A extends Annotation> List<A> getDeclaredAnnotations(Class<A>
a, Class<?> c) {
+ if (a == null || c == null)
+ return emptyList();
+ List<Annotation> aa = declaredClassAnnotationCache.get(c, a);
+ if (aa == null) {
+ A[] x = c.getDeclaredAnnotationsByType(a);
+ AList<Annotation> l = new AList<>(Arrays.asList(x));
+ annotations.appendAll(c, a, l);
+ aa = l.unmodifiable();
+ declaredClassAnnotationCache.put(c, a, aa);
+ }
+ return (List<A>)aa;
+ }
+
+ /**
+ * Finds the specified annotations on the specified method.
+ *
+ * @param <A> The annotation type to find.
+ * @param a The annotation type to find.
+ * @param m The method to search on.
+ * @return The annotations in an unmodifiable list, or an empty list if
not found.
+ */
+ @SuppressWarnings("unchecked")
+ @Override /* MetaProvider */
+ public <A extends Annotation> List<A> getAnnotations(Class<A> a, Method
m) {
+ if (a == null || m == null)
+ return emptyList();
+ List<Annotation> aa = methodAnnotationCache.get(m, a);
+ if (aa == null) {
+ A[] x = m.getAnnotationsByType(a);
+ AList<Annotation> l = new AList<>(Arrays.asList(x));
+ annotations.appendAll(m, a, l);
+ aa = l.unmodifiable();
+ methodAnnotationCache.put(m, a, aa);
+ }
+ return (List<A>)aa;
+ }
+
+ /**
+ * Finds the specified annotations on the specified method.
+ *
+ * @param <A> The annotation type to find.
+ * @param a The annotation type to find.
+ * @param m The method to search on.
+ * @return The annotations in an unmodifiable list, or an empty list if
not found.
+ */
+ public <A extends Annotation> List<A> getAnnotations(Class<A> a,
MethodInfo m) {
+ return getAnnotations(a, m == null ? null : m.inner());
+ }
+
+ /**
+ * Finds the last specified annotations on the specified method.
+ *
+ * @param <A> The annotation type to find.
+ * @param a The annotation type to find.
+ * @param m The method to search on.
+ * @return The annotation, or <jk>null</jk> if not found.
+ */
+ public <A extends Annotation> A getLastAnnotation(Class<A> a, Method m)
{
+ return last(getAnnotations(a, m));
+ }
+
+ /**
+ * Finds the last specified annotations on the specified method.
+ *
+ * @param <A> The annotation type to find.
+ * @param a The annotation type to find.
+ * @param m The method to search on.
+ * @return The annotation, or <jk>null</jk> if not found.
+ */
+ public <A extends Annotation> A getLastAnnotation(Class<A> a,
MethodInfo m) {
+ return last(getAnnotations(a, m));
+ }
+
+ /**
+ * Finds the specified annotations on the specified field.
+ *
+ * @param <A> The annotation type to find.
+ * @param a The annotation type to find.
+ * @param f The field to search on.
+ * @return The annotations in an unmodifiable list, or an empty list if
not found.
+ */
+ @SuppressWarnings("unchecked")
+ @Override /* MetaProvider */
+ public <A extends Annotation> List<A> getAnnotations(Class<A> a, Field
f) {
+ if (a == null || f == null)
+ return emptyList();
+ List<Annotation> aa = fieldAnnotationCache.get(f, a);
+ if (aa == null) {
+ A[] x = f.getAnnotationsByType(a);
+ AList<Annotation> l = new AList<>(Arrays.asList(x));
+ annotations.appendAll(f, a, l);
+ aa = l.unmodifiable();
+ fieldAnnotationCache.put(f, a, aa);
+ }
+ return (List<A>)aa;
+ }
+
+ /**
+ * Finds the specified annotations on the specified field.
+ *
+ * @param <A> The annotation type to find.
+ * @param a The annotation type to find.
+ * @param f The field to search on.
+ * @return The annotations in an unmodifiable list, or an empty list if
not found.
+ */
+ public <A extends Annotation> List<A> getAnnotations(Class<A> a,
FieldInfo f) {
+ return getAnnotations(a, f == null ? null: f.inner());
+ }
+
+ /**
+ * Finds the specified annotations on the specified constructor.
+ *
+ * @param <A> The annotation type to find.
+ * @param a The annotation type to find.
+ * @param c The constructor to search on.
+ * @return The annotations in an unmodifiable list, or an empty list if
not found.
+ */
+ @SuppressWarnings("unchecked")
+ @Override /* MetaProvider */
+ public <A extends Annotation> List<A> getAnnotations(Class<A> a,
Constructor<?> c) {
+ if (a == null || c == null)
+ return emptyList();
+ List<Annotation> aa = constructorAnnotationCache.get(c, a);
+ if (aa == null) {
+ A[] x = c.getAnnotationsByType(a);
+ AList<Annotation> l = new AList<>(Arrays.asList(x));
+ annotations.appendAll(c, a, l);
+ aa = l.unmodifiable();
+ constructorAnnotationCache.put(c, a, l);
+ }
+ return (List<A>)aa;
+ }
+
+ /**
+ * Finds the specified annotations on the specified constructor.
+ *
+ * @param <A> The annotation type to find.
+ * @param a The annotation type to find.
+ * @param c The constructor to search on.
+ * @return The annotations in an unmodifiable list, or an empty list if
not found.
+ */
+ public <A extends Annotation> List<A> getAnnotations(Class<A> a,
ConstructorInfo c) {
+ return getAnnotations(a, c == null ? null : c.inner());
+ }
+
+ /**
+ * Returns <jk>true</jk> if <c>getAnnotation(a,c)</c> returns a
non-null value.
+ *
+ * @param a The annotation being checked for.
+ * @param c The class being checked on.
+ * @return <jk>true</jk> if the annotation exists on the specified
class.
+ */
+ public <A extends Annotation> boolean hasAnnotation(Class<A> a,
Class<?> c) {
+ return getAnnotations(a, c).size() > 0;
+ }
+
+ /**
+ * Returns <jk>true</jk> if <c>getAnnotation(a,c)</c> returns a
non-null value.
+ *
+ * @param a The annotation being checked for.
+ * @param c The class being checked on.
+ * @return <jk>true</jk> if the annotation exists on the specified
class.
+ */
+ public <A extends Annotation> boolean hasAnnotation(Class<A> a,
ClassInfo c) {
+ return getAnnotations(a, c == null ? null : c.inner()).size() >
0;
+ }
+
+ /**
+ * Returns <jk>true</jk> if <c>getAnnotation(a,m)</c> returns a
non-null value.
+ *
+ * @param a The annotation being checked for.
+ * @param m The method being checked on.
+ * @return <jk>true</jk> if the annotation exists on the specified
method.
+ */
+ public <A extends Annotation> boolean hasAnnotation(Class<A> a, Method
m) {
+ return getAnnotations(a, m).size() > 0;
+ }
+
+ /**
+ * Returns <jk>true</jk> if <c>getAnnotation(a,m)</c> returns a
non-null value.
+ *
+ * @param a The annotation being checked for.
+ * @param m The method being checked on.
+ * @return <jk>true</jk> if the annotation exists on the specified
method.
+ */
+ public <A extends Annotation> boolean hasAnnotation(Class<A> a,
MethodInfo m) {
+ return getAnnotations(a, m == null ? null : m.inner()).size() >
0;
+ }
+
+ /**
+ * Returns <jk>true</jk> if <c>getAnnotation(a,f)</c> returns a
non-null value.
+ *
+ * @param a The annotation being checked for.
+ * @param f The field being checked on.
+ * @return <jk>true</jk> if the annotation exists on the specified
field.
+ */
+ public <A extends Annotation> boolean hasAnnotation(Class<A> a,
FieldInfo f) {
+ return getAnnotations(a, f == null ? null : f.inner()).size() >
0;
+ }
+
+ /**
+ * Returns <jk>true</jk> if <c>getAnnotation(a,c)</c> returns a
non-null value.
+ *
+ * @param a The annotation being checked for.
+ * @param c The constructor being checked on.
+ * @return <jk>true</jk> if the annotation exists on the specified
constructor.
+ */
+ public <A extends Annotation> boolean hasAnnotation(Class<A> a,
ConstructorInfo c) {
+ return getAnnotations(a, c == null ? null : c.inner()).size() >
0;
+ }
+
+
//-----------------------------------------------------------------------------------------------------------------
// Properties
//-----------------------------------------------------------------------------------------------------------------
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java
index 49eb13c..f73c49b 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ContextBuilder.java
@@ -15,6 +15,7 @@ package org.apache.juneau;
import static org.apache.juneau.Context.*;
import static org.apache.juneau.internal.ExceptionUtils.*;
+import java.lang.annotation.*;
import java.lang.reflect.*;
import java.nio.charset.*;
import java.util.*;
@@ -53,7 +54,7 @@ public abstract class ContextBuilder {
private final ContextPropertiesBuilder cpb;
boolean debug;
- Class<? extends Context> contextClass;
+ Class<?> contextClass;
/**
* Constructor.
@@ -65,6 +66,16 @@ public abstract class ContextBuilder {
}
/**
+ * Constructor.
+ * Default settings.
+ * @param contextClass The class being built.
+ */
+ public ContextBuilder(Class<?> contextClass) {
+ this();
+ this.contextClass = contextClass;
+ }
+
+ /**
* Copy constructor.
*
* @param copyFrom The bean to copy from.
@@ -72,6 +83,7 @@ public abstract class ContextBuilder {
public ContextBuilder(Context copyFrom) {
this.cpb = copyFrom == null ? ContextProperties.DEFAULT.copy()
: copyFrom.properties.copy();
this.debug = copyFrom == null ? env("Context.debug", false) :
copyFrom.debug;
+ this.contextClass = copyFrom == null ? null :
copyFrom.getClass();
}
/**
@@ -81,7 +93,22 @@ public abstract class ContextBuilder {
* The built object.
* <br>Subsequent calls to this method will create new instances
(unless context object is cacheable).
*/
- public abstract Context build();
+ public Context build() {
+ if (contextClass == null)
+ throw runtimeException("Context class not specified.");
+ try {
+ ClassInfo ci = ClassInfo.of(contextClass);
+ ConstructorInfo cc = ci.getPublicConstructor(this);
+ if (cc != null)
+ return cc.invoke(this);
+ cc = ci.getPublicConstructor(cpb);
+ if (cc != null)
+ return cc.invoke(cpb);
+ throw runtimeException("Constructor not found for class
{0}", contextClass);
+ } catch (ExecutableException e) {
+ throw runtimeException(e, "Error occurred trying to
create context.");
+ }
+ }
/**
* Associates a context class with this builder.
@@ -335,6 +362,184 @@ public abstract class ContextBuilder {
//-----------------------------------------------------------------------------------------------------------------
/**
+ * 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}
+ * <li class='jf'>{@link BeanContext#CONTEXT_annotations}
+ * </ul>
+ *
+ * @param values
+ * The annotations to register with the context.
+ * @return This object (for method chaining).
+ */
+ @FluentSetter
+ public ContextBuilder annotations(Annotation...values) {
+ return prependTo(CONTEXT_annotations, values);
+ }
+
+ /**
* <i><l>Context</l> configuration property: </i> Debug mode.
*
* <p>
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanAnnotation.java
index 1ea53a2..bea0bb6 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanAnnotation.java
@@ -14,7 +14,6 @@ package org.apache.juneau.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
import static org.apache.juneau.internal.ArrayUtils.*;
import java.lang.annotation.*;
@@ -509,7 +508,7 @@ public class BeanAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfigAnnotation.java
index a3c471a..fcb4847 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfigAnnotation.java
@@ -65,7 +65,7 @@ public class BeanConfigAnnotation {
b.setIfNotEmpty(BEAN_disableIgnoreTransientFields,
bool(a.disableIgnoreTransientFields()));
b.setIfNotEmpty(BEAN_ignoreUnknownBeanProperties,
bool(a.ignoreUnknownBeanProperties()));
b.setIfNotEmpty(BEAN_disableIgnoreUnknownNullBeanProperties,
bool(a.disableIgnoreUnknownNullBeanProperties()));
- asList(a.interfaces()).stream().map(x ->
BeanAnnotation.create(x).interfaceClass(x).build()).forEach(x ->
b.prependTo(BEAN_annotations, x));
+ asList(a.interfaces()).stream().map(x ->
BeanAnnotation.create(x).interfaceClass(x).build()).forEach(x ->
b.annotations(x));
b.setIfNotEmpty(BEAN_locale, locale(a.locale()));
b.setIfNotEmpty(BEAN_mediaType,
mediaType(a.mediaType()));
b.setIfNotEmpty(BEAN_notBeanClasses,
a.notBeanClasses());
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanIgnoreAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanIgnoreAnnotation.java
index abc1a0d..5f993e6 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanIgnoreAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanIgnoreAnnotation.java
@@ -14,7 +14,6 @@ package org.apache.juneau.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
@@ -170,7 +169,7 @@ public class BeanIgnoreAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeancAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeancAnnotation.java
index d569c56..f11e799 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeancAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeancAnnotation.java
@@ -14,7 +14,6 @@ package org.apache.juneau.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
import java.lang.annotation.*;
@@ -156,7 +155,7 @@ public class BeancAnnotation {
if (isEmpty(a.on()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanpAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanpAnnotation.java
index 89fc992..ed61524 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanpAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanpAnnotation.java
@@ -14,7 +14,6 @@ package org.apache.juneau.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
import static org.apache.juneau.internal.ArrayUtils.*;
import java.lang.annotation.*;
@@ -312,7 +311,7 @@ public class BeanpAnnotation {
if (isEmpty(a.on()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ExampleAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ExampleAnnotation.java
index 6e6c74f..2fff9b1 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ExampleAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ExampleAnnotation.java
@@ -14,8 +14,6 @@ package org.apache.juneau.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
-
import java.lang.annotation.*;
import java.lang.reflect.*;
@@ -186,7 +184,7 @@ public class ExampleAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/MarshalledAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/MarshalledAnnotation.java
index b11cee1..7949bc8 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/MarshalledAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/MarshalledAnnotation.java
@@ -14,8 +14,6 @@ package org.apache.juneau.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
-
import java.lang.annotation.*;
import org.apache.juneau.*;
@@ -192,7 +190,7 @@ public class MarshalledAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/NamePropertyAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/NamePropertyAnnotation.java
index 62ec819..5cc6d4c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/NamePropertyAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/NamePropertyAnnotation.java
@@ -14,8 +14,6 @@ package org.apache.juneau.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
-
import java.lang.annotation.*;
import java.lang.reflect.*;
@@ -141,7 +139,7 @@ public class NamePropertyAnnotation {
if (isEmpty(a.on()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ParentPropertyAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ParentPropertyAnnotation.java
index aca10bf..efbecad 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ParentPropertyAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/ParentPropertyAnnotation.java
@@ -14,8 +14,6 @@ package org.apache.juneau.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
-
import java.lang.annotation.*;
import java.lang.reflect.*;
@@ -141,7 +139,7 @@ public class ParentPropertyAnnotation {
if (isEmpty(a.on()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SwapAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SwapAnnotation.java
index 72d1560..6c1d34d 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SwapAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SwapAnnotation.java
@@ -14,7 +14,6 @@ package org.apache.juneau.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
import static org.apache.juneau.internal.ArrayUtils.*;
import java.lang.annotation.*;
@@ -245,7 +244,7 @@ public class SwapAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/UriAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/UriAnnotation.java
index 3272bb4..348e609 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/UriAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/UriAnnotation.java
@@ -14,8 +14,6 @@ package org.apache.juneau.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
-
import java.lang.annotation.*;
import java.lang.reflect.*;
@@ -164,7 +162,7 @@ public class UriAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
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 1587473..2533957 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
@@ -165,7 +165,7 @@ public class CsvAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.prependTo(CONTEXT_annotations, copy(a, vr()));
}
}
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 36b6aec..05ba0e9 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
@@ -285,7 +285,7 @@ public class HtmlAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.prependTo(CONTEXT_annotations, copy(a, vr()));
}
}
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 636a48c..ff0b5b5 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
@@ -192,7 +192,7 @@ public class HtmlLinkAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.prependTo(CONTEXT_annotations, copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/BodyAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/BodyAnnotation.java
index c5f0e93..d282ea5 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/BodyAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/BodyAnnotation.java
@@ -14,7 +14,6 @@ package org.apache.juneau.http.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
import static org.apache.juneau.internal.ArrayUtils.*;
import java.lang.annotation.*;
@@ -377,7 +376,7 @@ public class BodyAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormDataAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormDataAnnotation.java
index 5007f83..65eb026 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormDataAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/FormDataAnnotation.java
@@ -14,7 +14,6 @@ package org.apache.juneau.http.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
import static org.apache.juneau.internal.ArrayUtils.*;
import java.lang.annotation.*;
@@ -1094,7 +1093,7 @@ public class FormDataAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HeaderAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HeaderAnnotation.java
index 91c22cf..866adeb 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HeaderAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/HeaderAnnotation.java
@@ -14,7 +14,6 @@ package org.apache.juneau.http.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
import static org.apache.juneau.internal.ArrayUtils.*;
import java.lang.annotation.*;
@@ -1095,7 +1094,7 @@ public class HeaderAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathAnnotation.java
index ba1dbfe..c784010 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/PathAnnotation.java
@@ -14,7 +14,6 @@ package org.apache.juneau.http.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
import static org.apache.juneau.internal.ArrayUtils.*;
import java.lang.annotation.*;
@@ -1005,7 +1004,7 @@ public class PathAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/QueryAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/QueryAnnotation.java
index eaedc76..a3003d0 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/QueryAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/QueryAnnotation.java
@@ -14,7 +14,6 @@ package org.apache.juneau.http.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
import static org.apache.juneau.internal.ArrayUtils.*;
import java.lang.annotation.*;
@@ -1094,7 +1093,7 @@ public class QueryAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/RequestAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/RequestAnnotation.java
index fdf4d52..a0ce214 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/RequestAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/RequestAnnotation.java
@@ -14,8 +14,6 @@ package org.apache.juneau.http.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
-
import java.lang.annotation.*;
import org.apache.juneau.*;
@@ -195,7 +193,7 @@ public class RequestAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseAnnotation.java
index 11b454a..14c1392 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseAnnotation.java
@@ -14,7 +14,6 @@ package org.apache.juneau.http.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
import static org.apache.juneau.internal.ArrayUtils.*;
import java.lang.annotation.*;
@@ -421,7 +420,7 @@ public class ResponseAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseBodyAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseBodyAnnotation.java
index 1a82413..a674ea8 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseBodyAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseBodyAnnotation.java
@@ -14,8 +14,6 @@ package org.apache.juneau.http.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
-
import java.lang.annotation.*;
import java.lang.reflect.*;
@@ -159,7 +157,7 @@ public class ResponseBodyAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeaderAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeaderAnnotation.java
index f03ac24..7df627b 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeaderAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseHeaderAnnotation.java
@@ -14,7 +14,6 @@ package org.apache.juneau.http.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
import static org.apache.juneau.internal.ArrayUtils.*;
import java.lang.annotation.*;
@@ -995,7 +994,7 @@ public class ResponseHeaderAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseStatusAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseStatusAnnotation.java
index c575664..0f4a50c 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseStatusAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/http/annotation/ResponseStatusAnnotation.java
@@ -14,8 +14,6 @@ package org.apache.juneau.http.annotation;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
-import static org.apache.juneau.BeanContext.*;
-
import java.lang.annotation.*;
import java.lang.reflect.*;
@@ -159,7 +157,7 @@ public class ResponseStatusAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.annotations(copy(a, vr()));
}
}
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 5e0f5a2..a098963 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
@@ -165,7 +165,7 @@ public class JsoAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.prependTo(CONTEXT_annotations, copy(a, vr()));
}
}
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 4157838..f508694 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
@@ -187,7 +187,7 @@ public class JsonAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.prependTo(CONTEXT_annotations, copy(a, vr()));
}
}
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 0309252..838b56f 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
@@ -1298,7 +1298,7 @@ public class SchemaAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.prependTo(CONTEXT_annotations, copy(a, vr()));
}
}
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 0ab68e4..d64083b 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
@@ -165,7 +165,7 @@ public class MsgPackAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.prependTo(CONTEXT_annotations, copy(a, vr()));
}
}
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 e3322d1..58f229b 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
@@ -165,7 +165,7 @@ public class OpenApiAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.prependTo(CONTEXT_annotations, copy(a, vr()));
}
}
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 6c6e4f5..922940f 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
@@ -165,7 +165,7 @@ public class PlainTextAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.prependTo(CONTEXT_annotations, copy(a, vr()));
}
}
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 e645b02..3570e64 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
@@ -165,7 +165,7 @@ public class SoapXmlAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.prependTo(CONTEXT_annotations, copy(a, vr()));
}
}
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 49cb53f..250c07b 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
@@ -165,7 +165,7 @@ public class UonAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.prependTo(CONTEXT_annotations, copy(a, vr()));
}
}
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 074c3e3..f382171 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
@@ -189,7 +189,7 @@ public class UrlEncodingAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.prependTo(CONTEXT_annotations, copy(a, vr()));
}
}
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 f3c335f..08f1b4f 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
@@ -243,7 +243,7 @@ public class XmlAnnotation {
if (isEmpty(a.on()) && isEmpty(a.onClass()))
return;
- b.prependTo(BEAN_annotations, copy(a, vr()));
+ b.prependTo(CONTEXT_annotations, copy(a, vr()));
}
}