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 5f42895 JUNEAU-197
5f42895 is described below
commit 5f428958492c44d340758148965ac11efb2dee39
Author: JamesBognar <[email protected]>
AuthorDate: Sun Mar 8 11:22:51 2020 -0400
JUNEAU-197
@BeanConfig(bpi) does not override @Bean(bpi)
---
.../apache/juneau/reflection/ParamInfoTest.java | 34 ---------
.../juneau/httppart/bean/ResponseBeanMeta.java | 2 +-
.../java/org/apache/juneau/reflect/MethodInfo.java | 2 +-
.../java/org/apache/juneau/reflect/ParamInfo.java | 18 +----
.../org/apache/juneau/rest/RestParamDefaults.java | 86 ++++++++++++++--------
5 files changed, 61 insertions(+), 81 deletions(-)
diff --git
a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/reflection/ParamInfoTest.java
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/reflection/ParamInfoTest.java
index 8a531f4..adf8754 100644
---
a/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/reflection/ParamInfoTest.java
+++
b/juneau-core/juneau-core-utest/src/test/java/org/apache/juneau/reflection/ParamInfoTest.java
@@ -223,29 +223,6 @@ public class ParamInfoTest {
}
@Test
- public void getAnnotations() throws Exception {
- check("@CA(5),@CA(1),@CA(2),@CA(3),@CA(4)",
cb_a1.getAnnotations(CA.class));
- check("@CA(5),@CA(1),@CA(2),@CA(3),@CA(4)",
cb_a2.getAnnotations(CA.class));
- check("@CA(5),@CA(1),@CA(2),@CA(3),@CA(4)",
cc_a1.getAnnotations(CA.class));
- check("@CA(6),@CA(5),@CA(1),@CA(2),@CA(3),@CA(4)",
cc_a2.getAnnotations(CA.class));
- }
-
- @Test
- public void getAnnotations_notFound() throws Exception {
- check("", cb_a1.getAnnotations(DA.class));
- }
-
- @Test
- public void getAnnotations_constructor() throws Exception {
- check("@CA(9),@CA(1),@CA(2),@CA(3),@CA(4)",
cc_cc.getAnnotations(CA.class));
- }
-
- @Test
- public void getAnnotations_notFound_constructor() throws Exception {
- check("", cc_cc.getAnnotations(DA.class));
- }
-
- @Test
public void getAnnotationsParentFirst() throws Exception {
check("@CA(4),@CA(3),@CA(2),@CA(1),@CA(5)",
cb_a1.getAnnotationsParentFirst(CA.class));
check("@CA(4),@CA(3),@CA(2),@CA(1),@CA(5)",
cb_a2.getAnnotationsParentFirst(CA.class));
@@ -345,17 +322,6 @@ public class ParamInfoTest {
dc_a1 = dc.getMethod("a1", D1.class).getParam(0);
@Test
- public void getAnnotations_inherited() throws Exception {
- check("@DA(0),@DA(1),@DA(2),@DA(3),@DA(4)",
db_a1.getAnnotations(DA.class));
- check("@DA(5),@DA(0),@DA(1),@DA(2),@DA(3),@DA(4)",
dc_a1.getAnnotations(DA.class));
- }
-
- @Test
- public void getAnnotations_inherited_notFound() throws Exception {
- check("", db_a1.getAnnotations(CA.class));
- }
-
- @Test
public void getAnnotationsParentFirst_inherited() throws Exception {
check("@DA(4),@DA(3),@DA(2),@DA(1),@DA(0)",
db_a1.getAnnotationsParentFirst(DA.class));
check("@DA(4),@DA(3),@DA(2),@DA(1),@DA(0),@DA(5)",
dc_a1.getAnnotationsParentFirst(DA.class));
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java
index 8f3ee3e..d941f7f 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/bean/ResponseBeanMeta.java
@@ -90,7 +90,7 @@ public class ResponseBeanMeta {
return null;
Builder b = new Builder(ps);
b.apply(mpi.getParameterType().resolved().innerType());
- for (Response r : mpi.getAnnotations(Response.class))
+ for (Response r : mpi.getAnnotationsParentFirst(Response.class))
b.apply(r);
return b.build();
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/MethodInfo.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/MethodInfo.java
index 437c908..aa7853d 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/MethodInfo.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/MethodInfo.java
@@ -234,7 +234,7 @@ public final class MethodInfo extends ExecutableInfo
implements Comparable<Metho
for (Annotation a2 : m2.getDeclaredAnnotations())
if (a.isInstance(a2))
l.add((T)a2);
- getReturnType().resolved().appendAnnotations(l, a);
+ getReturnType().resolved().appendAnnotationsParentFirst(l, a);
return l;
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ParamInfo.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ParamInfo.java
index 9c126b6..e970364 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ParamInfo.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ParamInfo.java
@@ -174,18 +174,8 @@ public final class ParamInfo {
* <p>
* Searches all methods with the same signature on the parent classes
or interfaces
* and the return type on the method.
- *
- * @param a
- * The annotation to search for.
- * @return
- * A list of all matching annotations found in child-to-parent
order, or an empty list if none found.
- */
- public <T extends Annotation> List<T> getAnnotations(Class<T> a) {
- return appendAnnotations(new ArrayList<>(), a, false);
- }
-
- /**
- * Identical to {@link #getAnnotations(Class)} but returns the list in
reverse (parent-to-child) order.
+ * <p>
+ * Results are in parent-to-child order.
*
* @param a
* The annotation to search for.
@@ -193,11 +183,11 @@ public final class ParamInfo {
* A list of all matching annotations found or an empty list if
none found.
*/
public <T extends Annotation> List<T>
getAnnotationsParentFirst(Class<T> a) {
- return appendAnnotations(new ArrayList<>(), a, true);
+ return appendAnnotationsParentFirst(new ArrayList<>(), a, true);
}
@SuppressWarnings("unchecked")
- private <T extends Annotation> List<T> appendAnnotations(List<T> l,
Class<T> a, boolean parentFirst) {
+ private <T extends Annotation> List<T>
appendAnnotationsParentFirst(List<T> l, Class<T> a, boolean parentFirst) {
if (eInfo.isConstructor) {
ClassInfo ci = eInfo.getParamType(index).resolved();
Annotation[] annotations =
eInfo.getParameterAnnotations(index);
diff --git
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
index 8c18aa2..385ba0a 100644
---
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
+++
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestParamDefaults.java
@@ -202,12 +202,15 @@ class RestParamDefaults {
}
private static String getName(ParamInfo mpi, UrlPathPattern
pathPattern) {
- for (Path h : mpi.getAnnotations(Path.class)) {
+ String p = null;
+ for (Path h :
mpi.getAnnotationsParentFirst(Path.class)) {
if (! h.name().isEmpty())
- return h.name();
+ p = h.name();
if (! h.value().isEmpty())
- return h.value();
+ p = h.value();
}
+ if (p != null)
+ return p;
if (pathPattern != null) {
int idx = 0;
int i = mpi.getIndex();
@@ -263,13 +266,16 @@ class RestParamDefaults {
}
private static String getName(ParamInfo mpi) {
- for (Header h : mpi.getAnnotations(Header.class)) {
+ String n = null;
+ for (Header h :
mpi.getAnnotationsParentFirst(Header.class)) {
if (! h.name().isEmpty())
- return h.name();
+ n = h.name();
if (! h.value().isEmpty())
- return h.value();
+ n = h.value();
}
- throw new InternalServerError("@Header used without
name or value on method parameter ''{0}''.", mpi);
+ if (n == null)
+ throw new InternalServerError("@Header used
without name or value on method parameter ''{0}''.", mpi);
+ return n;
}
@Override /* RestMethodParam */
@@ -285,13 +291,16 @@ class RestParamDefaults {
}
private static String getName(ParamInfo mpi) {
- for (Attr h : mpi.getAnnotations(Attr.class)) {
+ String n = null;
+ for (Attr h :
mpi.getAnnotationsParentFirst(Attr.class)) {
if (! h.name().isEmpty())
- return h.name();
+ n = h.name();
if (! h.value().isEmpty())
- return h.value();
+ n = h.value();
}
- throw new InternalServerError("@Attr used without name
or value on method parameter ''{0}''.", mpi);
+ if (n == null)
+ throw new InternalServerError("@Attr used
without name or value on method parameter ''{0}''.", mpi);
+ return n;
}
@Override /* RestMethodParam */
@@ -327,13 +336,16 @@ class RestParamDefaults {
}
private static String getName(ParamInfo mpi) {
- for (ResponseHeader h :
mpi.getAnnotations(ResponseHeader.class)) {
+ String n = null;
+ for (ResponseHeader h :
mpi.getAnnotationsParentFirst(ResponseHeader.class)) {
if (! h.name().isEmpty())
- return h.name();
+ n = h.name();
if (! h.value().isEmpty())
- return h.value();
+ n = h.value();
}
- throw new InternalServerError("@ResponseHeader used
without name or value on method parameter ''{0}''.", mpi);
+ if (n == null)
+ throw new InternalServerError("@ResponseHeader
used without name or value on method parameter ''{0}''.", mpi);
+ return n;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -437,13 +449,16 @@ class RestParamDefaults {
}
private static String getName(ParamInfo mpi) {
- for (FormData h : mpi.getAnnotations(FormData.class)) {
+ String n = null;
+ for (FormData h :
mpi.getAnnotationsParentFirst(FormData.class)) {
if (! h.name().isEmpty())
- return h.name();
+ n = h.name();
if (! h.value().isEmpty())
- return h.value();
+ n = h.value();
}
- throw new InternalServerError("@FormData used without
name or value on method parameter ''{0}''.", mpi);
+ if (n == null)
+ throw new InternalServerError("@FormData used
without name or value on method parameter ''{0}''.", mpi);
+ return n;
}
@Override /* RestMethodParam */
@@ -470,13 +485,16 @@ class RestParamDefaults {
}
private static String getName(ParamInfo mpi) {
- for (Query h : mpi.getAnnotations(Query.class)) {
+ String n = null;
+ for (Query h :
mpi.getAnnotationsParentFirst(Query.class)) {
if (! h.name().isEmpty())
- return h.name();
+ n = h.name();
if (! h.value().isEmpty())
- return h.value();
+ n = h.value();
}
- throw new InternalServerError("@Query used without name
or value on method param ''{0}''.", mpi);
+ if (n == null)
+ throw new InternalServerError("@Query used
without name or value on method param ''{0}''.", mpi);
+ return n;
}
@Override /* RestMethodParam */
@@ -496,13 +514,16 @@ class RestParamDefaults {
}
private static String getName(ParamInfo mpi) {
- for (HasFormData h :
mpi.getAnnotations(HasFormData.class)) {
+ String n = null;
+ for (HasFormData h :
mpi.getAnnotationsParentFirst(HasFormData.class)) {
if (! h.name().isEmpty())
- return h.name();
+ n = h.name();
if (! h.value().isEmpty())
- return h.value();
+ n = h.value();
}
- throw new InternalServerError("@HasFormData used
without name or value on method parameter ''{o}''.", mpi);
+ if (n == null)
+ throw new InternalServerError("@HasFormData
used without name or value on method parameter ''{o}''.", mpi);
+ return n;
}
@Override /* RestMethodParam */
@@ -521,13 +542,16 @@ class RestParamDefaults {
}
private static String getName(ParamInfo mpi) {
- for (HasQuery h : mpi.getAnnotations(HasQuery.class)) {
+ String n = null;
+ for (HasQuery h :
mpi.getAnnotationsParentFirst(HasQuery.class)) {
if (! h.name().isEmpty())
- return h.name();
+ n = h.name();
if (! h.value().isEmpty())
- return h.value();
+ n = h.value();
}
- throw new InternalServerError("@HasQuery used without
name or value on method parameter ''{0}''.", mpi);
+ if (n == null)
+ throw new InternalServerError("@HasQuery used
without name or value on method parameter ''{0}''.", mpi);
+ return n;
}
@Override /* RestMethodParam */