You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2019/05/29 20:42:18 UTC
[juneau] branch master updated: Refactor RestMethodContext for
using PropertyStoreApplys
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 c67bb07 Refactor RestMethodContext for using PropertyStoreApplys
c67bb07 is described below
commit c67bb075b17ff54d782ffd783796d3cd45302441
Author: JamesBognar <ja...@apache.org>
AuthorDate: Wed May 29 16:41:57 2019 -0400
Refactor RestMethodContext for using PropertyStoreApplys
---
.../apache/juneau/BeanConfigAnnotationTest.java | 6 +-
.../apache/juneau/csv/CsvConfigAnnotationTest.java | 8 +-
.../juneau/html/HtmlConfigAnnotationTest.java | 12 +-
.../juneau/html/HtmlDocConfigAnnotationTest.java | 18 +-
.../juneau/jena/RdfConfigAnnotationTest.java | 12 +-
.../apache/juneau/jso/JsoConfigAnnotationTest.java | 8 +-
.../juneau/json/JsonConfigAnnotationTest.java | 12 +-
.../jsonschema/JsonSchemaConfigAnnotationTest.java | 6 +-
.../msgpack/MsgPackConfigAnnotationTest.java | 12 +-
.../juneau/oapi/OpenApiConfigAnnotationTest.java | 8 +-
.../juneau/parser/ParserConfigAnnotationTest.java | 12 +-
.../plaintext/PlainTextConfigAnnotationTest.java | 8 +-
.../apache/juneau/reflection/ClassInfoTest.java | 24 +-
.../apache/juneau/reflection/MethodInfoTest.java | 40 +--
.../serializer/SerializerConfigAnnotationTest.java | 12 +-
.../juneau/soap/SoapXmlConfigAnnotationTest.java | 6 +-
.../apache/juneau/uon/UonConfigAnnotationTest.java | 12 +-
.../UrlEncodingConfigAnnotationTest.java | 12 +-
.../apache/juneau/xml/XmlConfigAnnotationTest.java | 12 +-
.../java/org/apache/juneau/ContextBuilder.java | 4 +-
.../org/apache/juneau/PropertyStoreBuilder.java | 4 +-
.../org/apache/juneau/reflect/AnnotationInfo.java | 10 +
.../org/apache/juneau/reflect/AnnotationList.java | 34 +-
.../java/org/apache/juneau/reflect/ClassInfo.java | 51 +--
...tationList.java => ConfigAnnotationFilter.java} | 18 +-
.../java/org/apache/juneau/reflect/MethodInfo.java | 66 ++--
.../java/org/apache/juneau/rest/RestContext.java | 2 +-
.../org/apache/juneau/rest/RestContextBuilder.java | 2 +-
.../org/apache/juneau/rest/RestMethodContext.java | 338 +------------------
.../juneau/rest/RestMethodContextBuilder.java | 373 +++++++++++++++++++++
.../rest/annotation/RestMethodConfigApply.java | 2 +
31 files changed, 576 insertions(+), 568 deletions(-)
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanConfigAnnotationTest.java
index fd87da0..be608d5 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/BeanConfigAnnotationTest.java
@@ -157,7 +157,7 @@ public class BeanConfigAnnotationTest {
@Test
public void basic() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
BeanTraverseSession bc = JsonSerializer.create().applyAnnotations(al, sr).build().createSession();
System.err.println(bc.getImplClasses().values().iterator().next().getClass().getSimpleName());
@@ -212,7 +212,7 @@ public class BeanConfigAnnotationTest {
@Test
public void noValues() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
JsonSerializer bc = JsonSerializer.create().applyAnnotations(al, sr).build();
check("PUBLIC", bc.getBeanClassVisibility());
check("PUBLIC", bc.getBeanConstructorVisibility());
@@ -262,7 +262,7 @@ public class BeanConfigAnnotationTest {
@Test
public void noAnnotation() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
JsonSerializer bc = JsonSerializer.create().applyAnnotations(al, sr).build();
check("PUBLIC", bc.getBeanClassVisibility());
check("PUBLIC", bc.getBeanConstructorVisibility());
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/csv/CsvConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/csv/CsvConfigAnnotationTest.java
index 6ffbb43..6466ad0 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/csv/CsvConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/csv/CsvConfigAnnotationTest.java
@@ -31,13 +31,13 @@ public class CsvConfigAnnotationTest {
@Test
public void defaultsSerializer() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
CsvSerializer.create().applyAnnotations(al, null).build();
}
@Test
public void defaultsParser() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
CsvParser.create().applyAnnotations(al, null).build();
}
@@ -50,13 +50,13 @@ public class CsvConfigAnnotationTest {
@Test
public void noAnnotationSerializer() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
CsvSerializer.create().applyAnnotations(al, null).build();
}
@Test
public void noAnnotationParser() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
CsvParser.create().applyAnnotations(al, null).build();
}
}
\ No newline at end of file
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlConfigAnnotationTest.java
index 21eab19..9a14ea8 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlConfigAnnotationTest.java
@@ -59,7 +59,7 @@ public class HtmlConfigAnnotationTest {
@Test
public void basicSerializer() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
HtmlSerializerSession x = HtmlSerializer.create().applyAnnotations(al, sr).build().createSession();
check("true", x.isAddBeanTypes());
check("true", x.isAddKeyValueTableHeaders());
@@ -71,7 +71,7 @@ public class HtmlConfigAnnotationTest {
@Test
public void basicParser() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
HtmlParser.create().applyAnnotations(al, sr).build().createSession();
}
@@ -85,7 +85,7 @@ public class HtmlConfigAnnotationTest {
@Test
public void defaultsSerializer() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
HtmlSerializerSession x = HtmlSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isAddBeanTypes());
check("false", x.isAddKeyValueTableHeaders());
@@ -97,7 +97,7 @@ public class HtmlConfigAnnotationTest {
@Test
public void defaultsParser() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
HtmlParser.create().applyAnnotations(al, sr).build().createSession();
}
@@ -110,7 +110,7 @@ public class HtmlConfigAnnotationTest {
@Test
public void noAnnotationSerializer() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
HtmlSerializerSession x = HtmlSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isAddBeanTypes());
check("false", x.isAddKeyValueTableHeaders());
@@ -122,7 +122,7 @@ public class HtmlConfigAnnotationTest {
@Test
public void noAnnotationParser() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
HtmlParser.create().applyAnnotations(al, sr).build().createSession();
}
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlDocConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlDocConfigAnnotationTest.java
index 20cab3b..126e322 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlDocConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlDocConfigAnnotationTest.java
@@ -76,7 +76,7 @@ public class HtmlDocConfigAnnotationTest {
@Test
public void basic() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
HtmlDocSerializerSession x = HtmlDocSerializer.create().applyAnnotations(al, sr).build().createSession();
check("foo", x.getAside());
check("foo", x.getFooter());
@@ -102,7 +102,7 @@ public class HtmlDocConfigAnnotationTest {
@Test
public void defaults() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
HtmlDocSerializerSession x = HtmlDocSerializer.create().applyAnnotations(al, sr).build().createSession();
check("", x.getAside());
check("", x.getFooter());
@@ -127,7 +127,7 @@ public class HtmlDocConfigAnnotationTest {
@Test
public void noAnnotation() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
HtmlDocSerializerSession x = HtmlDocSerializer.create().applyAnnotations(al, sr).build().createSession();
check("", x.getAside());
check("", x.getFooter());
@@ -163,7 +163,7 @@ public class HtmlDocConfigAnnotationTest {
@Test
public void inheritance1() throws Exception {
- AnnotationList al = d1.getAnnotationListParentFirst();
+ AnnotationList al = d1.getAnnotationListParentFirst(null);
HtmlDocSerializerSession x = HtmlDocSerializer.create().applyAnnotations(al, sr).build().createSession();
check("foo2,foo", x.getAside());
check("foo2,foo", x.getFooter());
@@ -192,7 +192,7 @@ public class HtmlDocConfigAnnotationTest {
@Test
public void inheritance2() throws Exception {
- AnnotationList al = d2.getAnnotationListParentFirst();
+ AnnotationList al = d2.getAnnotationListParentFirst(null);
HtmlDocSerializerSession x = HtmlDocSerializer.create().applyAnnotations(al, sr).build().createSession();
check("foo,foo2", x.getAside());
check("foo,foo2", x.getFooter());
@@ -221,7 +221,7 @@ public class HtmlDocConfigAnnotationTest {
@Test
public void inheritance3() throws Exception {
- AnnotationList al = d3.getAnnotationListParentFirst();
+ AnnotationList al = d3.getAnnotationListParentFirst(null);
HtmlDocSerializerSession x = HtmlDocSerializer.create().applyAnnotations(al, sr).build().createSession();
check("foo2", x.getAside());
check("foo2", x.getFooter());
@@ -250,7 +250,7 @@ public class HtmlDocConfigAnnotationTest {
@Test
public void inheritance4() throws Exception {
- AnnotationList al = d4.getAnnotationListParentFirst();
+ AnnotationList al = d4.getAnnotationListParentFirst(null);
HtmlDocSerializerSession x = HtmlDocSerializer.create().applyAnnotations(al, sr).build().createSession();
check("", x.getAside());
check("", x.getFooter());
@@ -305,7 +305,7 @@ public class HtmlDocConfigAnnotationTest {
@Test
public void widgets_basic() throws Exception {
- AnnotationList al = e.getAnnotationListParentFirst();
+ AnnotationList al = e.getAnnotationListParentFirst(null);
HtmlDocSerializerSession x = HtmlDocSerializer.create().applyAnnotations(al, sr).build().createSession();
check("$W{E}", x.getAside());
check("$W{E}", x.getFooter());
@@ -323,7 +323,7 @@ public class HtmlDocConfigAnnotationTest {
@Test
public void widgets_resolution() throws Exception {
- AnnotationList al = e.getAnnotationListParentFirst();
+ AnnotationList al = e.getAnnotationListParentFirst(null);
HtmlDocSerializerSession x = HtmlDocSerializer.create().applyAnnotations(al, sr).build().createSession();
String r = x.serialize(null).replaceAll("[\r\n]+", "|");
assertContains(r,
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jena/RdfConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jena/RdfConfigAnnotationTest.java
index 27e1ef3..8b2e0bd 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jena/RdfConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jena/RdfConfigAnnotationTest.java
@@ -99,7 +99,7 @@ public class RdfConfigAnnotationTest {
@Test
public void basicSerializer() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
RdfSerializerSession x = RdfSerializer.create().applyAnnotations(al, sr).build().createSession();
check("true", x.isAddBeanTypes());
check("true", x.isAddLiteralTypes());
@@ -141,7 +141,7 @@ public class RdfConfigAnnotationTest {
@Test
public void basicParser() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
RdfParserSession x = RdfParser.create().applyAnnotations(al, sr).build().createSession();
check("SEQ", x.getCollectionFormat());
check("foo:http://foo", x.getJuneauBpNs());
@@ -185,7 +185,7 @@ public class RdfConfigAnnotationTest {
@Test
public void noValuesSerializer() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
RdfSerializerSession x = RdfSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isAddBeanTypes());
check("false", x.isAddLiteralTypes());
@@ -226,7 +226,7 @@ public class RdfConfigAnnotationTest {
@Test
public void noValuesParser() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
RdfParserSession x = RdfParser.create().applyAnnotations(al, sr).build().createSession();
check("DEFAULT", x.getCollectionFormat());
check("jp:http://www.apache.org/juneaubp/", x.getJuneauBpNs());
@@ -269,7 +269,7 @@ public class RdfConfigAnnotationTest {
@Test
public void noAnnotationSerializer() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
RdfSerializerSession x = RdfSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isAddBeanTypes());
check("false", x.isAddLiteralTypes());
@@ -310,7 +310,7 @@ public class RdfConfigAnnotationTest {
@Test
public void noAnnotationParser() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
RdfParserSession x = RdfParser.create().applyAnnotations(al, sr).build().createSession();
check("DEFAULT", x.getCollectionFormat());
check("jp:http://www.apache.org/juneaubp/", x.getJuneauBpNs());
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jso/JsoConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jso/JsoConfigAnnotationTest.java
index 952a852..5fccbb9 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jso/JsoConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jso/JsoConfigAnnotationTest.java
@@ -31,13 +31,13 @@ public class JsoConfigAnnotationTest {
@Test
public void defaultsSerializer() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
JsoSerializer.create().applyAnnotations(al, null).build().createSession();
}
@Test
public void defaultsParser() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
JsoParser.create().applyAnnotations(al, null).build().createSession();
}
@@ -50,13 +50,13 @@ public class JsoConfigAnnotationTest {
@Test
public void noAnnotationSerializer() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
JsoSerializer.create().applyAnnotations(al, null).build().createSession();
}
@Test
public void noAnnotationParser() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
JsoParser.create().applyAnnotations(al, null).build().createSession();
}
}
\ No newline at end of file
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/json/JsonConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/json/JsonConfigAnnotationTest.java
index 80c2e81..393a47f 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/json/JsonConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/json/JsonConfigAnnotationTest.java
@@ -55,7 +55,7 @@ public class JsonConfigAnnotationTest {
@Test
public void basicSerializer() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
JsonSerializerSession x = JsonSerializer.create().applyAnnotations(al, sr).build().createSession();
check("true", x.isAddBeanTypes());
check("true", x.isEscapeSolidus());
@@ -64,7 +64,7 @@ public class JsonConfigAnnotationTest {
@Test
public void basicParser() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
JsonParserSession x = JsonParser.create().applyAnnotations(al, sr).build().createSession();
check("true", x.isValidateEnd());
}
@@ -79,7 +79,7 @@ public class JsonConfigAnnotationTest {
@Test
public void noValuesSerializer() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
JsonSerializerSession x = JsonSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isAddBeanTypes());
check("false", x.isEscapeSolidus());
@@ -88,7 +88,7 @@ public class JsonConfigAnnotationTest {
@Test
public void noValuesParser() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
JsonParserSession x = JsonParser.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isValidateEnd());
}
@@ -102,7 +102,7 @@ public class JsonConfigAnnotationTest {
@Test
public void noAnnotationSerializer() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
JsonSerializerSession x = JsonSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isAddBeanTypes());
check("false", x.isEscapeSolidus());
@@ -111,7 +111,7 @@ public class JsonConfigAnnotationTest {
@Test
public void noAnnotationParser() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
JsonParserSession x = JsonParser.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isValidateEnd());
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jsonschema/JsonSchemaConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jsonschema/JsonSchemaConfigAnnotationTest.java
index 431a948..acc94b8 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jsonschema/JsonSchemaConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/jsonschema/JsonSchemaConfigAnnotationTest.java
@@ -69,7 +69,7 @@ public class JsonSchemaConfigAnnotationTest {
@Test
public void basic() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
JsonSchemaGeneratorSession x = JsonSchemaGenerator.create().applyAnnotations(al, sr).build().createSession();
check("BEAN", x.getAddDescriptionsTo());
check("BEAN", x.getAddExamplesTo());
@@ -91,7 +91,7 @@ public class JsonSchemaConfigAnnotationTest {
@Test
public void noValues() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
JsonSchemaGeneratorSession x = JsonSchemaGenerator.create().applyAnnotations(al, sr).build().createSession();
check("", x.getAddDescriptionsTo());
check("", x.getAddExamplesTo());
@@ -112,7 +112,7 @@ public class JsonSchemaConfigAnnotationTest {
@Test
public void noAnnotation() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
JsonSchemaGeneratorSession x = JsonSchemaGenerator.create().applyAnnotations(al, sr).build().createSession();
check("", x.getAddDescriptionsTo());
check("", x.getAddExamplesTo());
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/msgpack/MsgPackConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/msgpack/MsgPackConfigAnnotationTest.java
index 9963c17..7408f59 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/msgpack/MsgPackConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/msgpack/MsgPackConfigAnnotationTest.java
@@ -52,14 +52,14 @@ public class MsgPackConfigAnnotationTest {
@Test
public void basicSerializer() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
MsgPackSerializerSession x = MsgPackSerializer.create().applyAnnotations(al, sr).build().createSession();
check("true", x.isAddBeanTypes());
}
@Test
public void basicParser() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
MsgPackParser.create().applyAnnotations(al, sr).build().createSession();
}
@@ -73,14 +73,14 @@ public class MsgPackConfigAnnotationTest {
@Test
public void noValuesSerializer() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
MsgPackSerializerSession x = MsgPackSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isAddBeanTypes());
}
@Test
public void noValuesParser() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
MsgPackParser.create().applyAnnotations(al, sr).build().createSession();
}
@@ -93,14 +93,14 @@ public class MsgPackConfigAnnotationTest {
@Test
public void noAnnotationSerializer() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
MsgPackSerializerSession x = MsgPackSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isAddBeanTypes());
}
@Test
public void noAnnotationParser() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
MsgPackParser.create().applyAnnotations(al, sr).build().createSession();
}
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/oapi/OpenApiConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/oapi/OpenApiConfigAnnotationTest.java
index ab14fea..1d9f054 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/oapi/OpenApiConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/oapi/OpenApiConfigAnnotationTest.java
@@ -35,13 +35,13 @@ public class OpenApiConfigAnnotationTest {
@Test
public void noValuesSerializer() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
OpenApiSerializer.create().applyAnnotations(al, sr).build().createSession();
}
@Test
public void noValuesParser() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
OpenApiParser.create().applyAnnotations(al, sr).build().createSession();
}
@@ -54,13 +54,13 @@ public class OpenApiConfigAnnotationTest {
@Test
public void noAnnotationSerializer() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
OpenApiSerializer.create().applyAnnotations(al, sr).build().createSession();
}
@Test
public void noAnnotationParser() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
OpenApiParser.create().applyAnnotations(al, sr).build().createSession();
}
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserConfigAnnotationTest.java
index e0a9ac0..0da800f 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/parser/ParserConfigAnnotationTest.java
@@ -68,7 +68,7 @@ public class ParserConfigAnnotationTest {
@Test
public void basicReaderParser() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
JsonParserSession x = JsonParser.create().applyAnnotations(al, sr).build().createSession();
check("true", x.isAutoCloseStreams());
check("1", x.getDebugOutputLines());
@@ -82,7 +82,7 @@ public class ParserConfigAnnotationTest {
@Test
public void basicInputStreamParser() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
MsgPackParserSession x = MsgPackParser.create().applyAnnotations(al, sr).build().createSession();
check("true", x.isAutoCloseStreams());
check("HEX", x.getBinaryFormat());
@@ -103,7 +103,7 @@ public class ParserConfigAnnotationTest {
@Test
public void noValuesReaderParser() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
JsonParserSession x = JsonParser.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isAutoCloseStreams());
check("5", x.getDebugOutputLines());
@@ -117,7 +117,7 @@ public class ParserConfigAnnotationTest {
@Test
public void noValuesInputStreamParser() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
MsgPackParserSession x = MsgPackParser.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isAutoCloseStreams());
check("HEX", x.getBinaryFormat());
@@ -137,7 +137,7 @@ public class ParserConfigAnnotationTest {
@Test
public void noAnnotationReaderParser() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
JsonParserSession x = JsonParser.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isAutoCloseStreams());
check("5", x.getDebugOutputLines());
@@ -151,7 +151,7 @@ public class ParserConfigAnnotationTest {
@Test
public void noAnnotationInputStreamParser() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
MsgPackParserSession x = MsgPackParser.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isAutoCloseStreams());
check("HEX", x.getBinaryFormat());
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/plaintext/PlainTextConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/plaintext/PlainTextConfigAnnotationTest.java
index 1865e46..a06cd03 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/plaintext/PlainTextConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/plaintext/PlainTextConfigAnnotationTest.java
@@ -35,13 +35,13 @@ public class PlainTextConfigAnnotationTest {
@Test
public void noValuesSerializer() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
PlainTextSerializer.create().applyAnnotations(al, sr).build().createSession();
}
@Test
public void noValuesParser() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
PlainTextParser.create().applyAnnotations(al, sr).build().createSession();
}
@@ -54,13 +54,13 @@ public class PlainTextConfigAnnotationTest {
@Test
public void noAnnotationSerializer() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
PlainTextSerializer.create().applyAnnotations(al, sr).build().createSession();
}
@Test
public void noAnnotationParser() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
PlainTextParser.create().applyAnnotations(al, sr).build().createSession();
}
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/reflection/ClassInfoTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/reflection/ClassInfoTest.java
index 3893a7e..29e568d 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/reflection/ClassInfoTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/reflection/ClassInfoTest.java
@@ -938,16 +938,16 @@ public class ClassInfoTest {
@Test
public void getAnnotationsMap() {
- check("@A(7),@A(6),@A(5),@A(3),@A(1),@A(2),@PA(10)", g3.getAnnotationList());
- check("@A(7),@A(6),@A(5),@A(3),@A(1),@A(2),@PA(10)", g4.getAnnotationList());
- check("@A(3),@PA(10)", g5.getAnnotationList());
+ check("@A(7),@A(6),@A(5),@A(3),@A(1),@A(2),@PA(10)", g3.getAnnotationList(null));
+ check("@A(7),@A(6),@A(5),@A(3),@A(1),@A(2),@PA(10)", g4.getAnnotationList(null));
+ check("@A(3),@PA(10)", g5.getAnnotationList(null));
}
@Test
public void getAnnotationsMapParentFirst() {
- check("@PA(10),@A(2),@A(1),@A(3),@A(5),@A(6),@A(7)", g3.getAnnotationListParentFirst());
- check("@PA(10),@A(2),@A(1),@A(3),@A(5),@A(6),@A(7)", g4.getAnnotationListParentFirst());
- check("@PA(10),@A(3)", g5.getAnnotationListParentFirst());
+ check("@PA(10),@A(2),@A(1),@A(3),@A(5),@A(6),@A(7)", g3.getAnnotationListParentFirst(null));
+ check("@PA(10),@A(2),@A(1),@A(3),@A(5),@A(6),@A(7)", g4.getAnnotationListParentFirst(null));
+ check("@PA(10),@A(3)", g5.getAnnotationListParentFirst(null));
}
@A(1) @AConfig(1) static interface GBI1 {}
@@ -964,16 +964,16 @@ public class ClassInfoTest {
@Test
public void getConfigAnnotationsMap() {
- check("@AConfig(7),@AConfig(6),@AConfig(5),@AConfig(3),@AConfig(1),@AConfig(2)", gb3.getConfigAnnotationList());
- check("@AConfig(7),@AConfig(6),@AConfig(5),@AConfig(3),@AConfig(1),@AConfig(2)", gb4.getConfigAnnotationList());
- check("@AConfig(3)", gb5.getConfigAnnotationList());
+ check("@AConfig(7),@AConfig(6),@AConfig(5),@AConfig(3),@AConfig(1),@AConfig(2)", gb3.getAnnotationList(ConfigAnnotationFilter.INSTANCE));
+ check("@AConfig(7),@AConfig(6),@AConfig(5),@AConfig(3),@AConfig(1),@AConfig(2)", gb4.getAnnotationList(ConfigAnnotationFilter.INSTANCE));
+ check("@AConfig(3)", gb5.getAnnotationList(ConfigAnnotationFilter.INSTANCE));
}
@Test
public void getConfigAnnotationsMapParentFirst() {
- check("@AConfig(2),@AConfig(1),@AConfig(3),@AConfig(5),@AConfig(6),@AConfig(7)", gb3.getConfigAnnotationListParentFirst());
- check("@AConfig(2),@AConfig(1),@AConfig(3),@AConfig(5),@AConfig(6),@AConfig(7)", gb4.getConfigAnnotationListParentFirst());
- check("@AConfig(3)", gb5.getConfigAnnotationListParentFirst());
+ check("@AConfig(2),@AConfig(1),@AConfig(3),@AConfig(5),@AConfig(6),@AConfig(7)", gb3.getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE));
+ check("@AConfig(2),@AConfig(1),@AConfig(3),@AConfig(5),@AConfig(6),@AConfig(7)", gb4.getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE));
+ check("@AConfig(3)", gb5.getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE));
}
//-----------------------------------------------------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/reflection/MethodInfoTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/reflection/MethodInfoTest.java
index 30c6a93..3e752fd 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/reflection/MethodInfoTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/reflection/MethodInfoTest.java
@@ -268,20 +268,20 @@ public class MethodInfoTest {
@Test
public void getAnnotationsMap() {
- check("@A(C3),@A(C2),@A(a1),@A(C1),@PA(10)", c_a1.getAnnotationList());
- check("@A(C3),@A(a2b),@A(C2),@A(a2a),@A(C1),@PA(10)", c_a2.getAnnotationList());
- check("@A(C3),@A(C2),@A(a3),@A(C1),@PA(10)", c_a3.getAnnotationList());
- check("@A(a4),@A(C3),@A(C2),@A(C1),@PA(10)", c_a4.getAnnotationList());
- check("@A(C3),@A(C2),@A(C1),@PA(10)", c_a5.getAnnotationList());
+ check("@A(C3),@A(C2),@A(a1),@A(C1),@PA(10)", c_a1.getAnnotationList(null));
+ check("@A(C3),@A(a2b),@A(C2),@A(a2a),@A(C1),@PA(10)", c_a2.getAnnotationList(null));
+ check("@A(C3),@A(C2),@A(a3),@A(C1),@PA(10)", c_a3.getAnnotationList(null));
+ check("@A(a4),@A(C3),@A(C2),@A(C1),@PA(10)", c_a4.getAnnotationList(null));
+ check("@A(C3),@A(C2),@A(C1),@PA(10)", c_a5.getAnnotationList(null));
}
@Test
public void getAnnotationsMapParentFirst() {
- check("@PA(10),@A(C1),@A(a1),@A(C2),@A(C3)", c_a1.getAnnotationListParentFirst());
- check("@PA(10),@A(C1),@A(a2a),@A(C2),@A(a2b),@A(C3)", c_a2.getAnnotationListParentFirst());
- check("@PA(10),@A(C1),@A(a3),@A(C2),@A(C3)", c_a3.getAnnotationListParentFirst());
- check("@PA(10),@A(C1),@A(C2),@A(C3),@A(a4)", c_a4.getAnnotationListParentFirst());
- check("@PA(10),@A(C1),@A(C2),@A(C3)", c_a5.getAnnotationListParentFirst());
+ check("@PA(10),@A(C1),@A(a1),@A(C2),@A(C3)", c_a1.getAnnotationListParentFirst(null));
+ check("@PA(10),@A(C1),@A(a2a),@A(C2),@A(a2b),@A(C3)", c_a2.getAnnotationListParentFirst(null));
+ check("@PA(10),@A(C1),@A(a3),@A(C2),@A(C3)", c_a3.getAnnotationListParentFirst(null));
+ check("@PA(10),@A(C1),@A(C2),@A(C3),@A(a4)", c_a4.getAnnotationListParentFirst(null));
+ check("@PA(10),@A(C1),@A(C2),@A(C3)", c_a5.getAnnotationListParentFirst(null));
}
@A("C1") @AConfig("C1")
@@ -320,20 +320,20 @@ public class MethodInfoTest {
@Test
public void getConfigAnnotationsMap() {
- check("@AConfig(C3),@AConfig(C2),@AConfig(a1),@AConfig(C1)", cb_a1.getConfigAnnotationList());
- check("@AConfig(C3),@AConfig(a2b),@AConfig(C2),@AConfig(a2a),@AConfig(C1)", cb_a2.getConfigAnnotationList());
- check("@AConfig(C3),@AConfig(C2),@AConfig(a3),@AConfig(C1)", cb_a3.getConfigAnnotationList());
- check("@AConfig(a4),@AConfig(C3),@AConfig(C2),@AConfig(C1)", cb_a4.getConfigAnnotationList());
- check("@AConfig(C3),@AConfig(C2),@AConfig(C1)", cb_a5.getConfigAnnotationList());
+ check("@AConfig(C3),@AConfig(C2),@AConfig(a1),@AConfig(C1)", cb_a1.getAnnotationList(ConfigAnnotationFilter.INSTANCE));
+ check("@AConfig(C3),@AConfig(a2b),@AConfig(C2),@AConfig(a2a),@AConfig(C1)", cb_a2.getAnnotationList(ConfigAnnotationFilter.INSTANCE));
+ check("@AConfig(C3),@AConfig(C2),@AConfig(a3),@AConfig(C1)", cb_a3.getAnnotationList(ConfigAnnotationFilter.INSTANCE));
+ check("@AConfig(a4),@AConfig(C3),@AConfig(C2),@AConfig(C1)", cb_a4.getAnnotationList(ConfigAnnotationFilter.INSTANCE));
+ check("@AConfig(C3),@AConfig(C2),@AConfig(C1)", cb_a5.getAnnotationList(ConfigAnnotationFilter.INSTANCE));
}
@Test
public void getConfigAnnotationsMapParentFirst() {
- check("@AConfig(C1),@AConfig(a1),@AConfig(C2),@AConfig(C3)", cb_a1.getConfigAnnotationListParentFirst());
- check("@AConfig(C1),@AConfig(a2a),@AConfig(C2),@AConfig(a2b),@AConfig(C3)", cb_a2.getConfigAnnotationListParentFirst());
- check("@AConfig(C1),@AConfig(a3),@AConfig(C2),@AConfig(C3)", cb_a3.getConfigAnnotationListParentFirst());
- check("@AConfig(C1),@AConfig(C2),@AConfig(C3),@AConfig(a4)", cb_a4.getConfigAnnotationListParentFirst());
- check("@AConfig(C1),@AConfig(C2),@AConfig(C3)", cb_a5.getConfigAnnotationListParentFirst());
+ check("@AConfig(C1),@AConfig(a1),@AConfig(C2),@AConfig(C3)", cb_a1.getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE));
+ check("@AConfig(C1),@AConfig(a2a),@AConfig(C2),@AConfig(a2b),@AConfig(C3)", cb_a2.getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE));
+ check("@AConfig(C1),@AConfig(a3),@AConfig(C2),@AConfig(C3)", cb_a3.getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE));
+ check("@AConfig(C1),@AConfig(C2),@AConfig(C3),@AConfig(a4)", cb_a4.getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE));
+ check("@AConfig(C1),@AConfig(C2),@AConfig(C3)", cb_a5.getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE));
}
//-----------------------------------------------------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerConfigAnnotationTest.java
index d3379fb..50fe21a 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/SerializerConfigAnnotationTest.java
@@ -75,7 +75,7 @@ public class SerializerConfigAnnotationTest {
@Test
public void basicWriterSerializer() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
JsonSerializerSession x = JsonSerializer.create().applyAnnotations(al, sr).build().createSession();
check("true", ((SerializerSession)x).isAddBeanTypes());
check("true", x.isAddRootType());
@@ -96,7 +96,7 @@ public class SerializerConfigAnnotationTest {
@Test
public void basicOutputStreamSerializer() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
MsgPackSerializerSession x = MsgPackSerializer.create().applyAnnotations(al, sr).build().createSession();
check("true", ((SerializerSession)x).isAddBeanTypes());
check("true", x.isAddRootType());
@@ -124,7 +124,7 @@ public class SerializerConfigAnnotationTest {
@Test
public void noValuesWriterSerializer() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
JsonSerializerSession x = JsonSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", ((SerializerSession)x).isAddBeanTypes());
check("false", x.isAddRootType());
@@ -145,7 +145,7 @@ public class SerializerConfigAnnotationTest {
@Test
public void noValuesOutputStreamSerializer() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
MsgPackSerializerSession x = MsgPackSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", ((SerializerSession)x).isAddBeanTypes());
check("false", x.isAddRootType());
@@ -172,7 +172,7 @@ public class SerializerConfigAnnotationTest {
@Test
public void noAnnotationWriterSerializer() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
JsonSerializerSession x = JsonSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", ((SerializerSession)x).isAddBeanTypes());
check("false", x.isAddRootType());
@@ -193,7 +193,7 @@ public class SerializerConfigAnnotationTest {
@Test
public void noAnnotationOutputStreamSerializer() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
MsgPackSerializerSession x = MsgPackSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", ((SerializerSession)x).isAddBeanTypes());
check("false", x.isAddRootType());
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/soap/SoapXmlConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/soap/SoapXmlConfigAnnotationTest.java
index 7cb6dbb..596edcb 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/soap/SoapXmlConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/soap/SoapXmlConfigAnnotationTest.java
@@ -52,7 +52,7 @@ public class SoapXmlConfigAnnotationTest {
@Test
public void basic() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
SoapXmlSerializerSession x = SoapXmlSerializer.create().applyAnnotations(al, sr).build().createSession();
check("foo", x.getSoapAction());
}
@@ -67,7 +67,7 @@ public class SoapXmlConfigAnnotationTest {
@Test
public void noValues() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
SoapXmlSerializerSession x = SoapXmlSerializer.create().applyAnnotations(al, sr).build().createSession();
check("http://www.w3.org/2003/05/soap-envelope", x.getSoapAction());
}
@@ -81,7 +81,7 @@ public class SoapXmlConfigAnnotationTest {
@Test
public void noAnnotation() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
SoapXmlSerializerSession x = SoapXmlSerializer.create().applyAnnotations(al, sr).build().createSession();
check("http://www.w3.org/2003/05/soap-envelope", x.getSoapAction());
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/uon/UonConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/uon/UonConfigAnnotationTest.java
index b38ef02..a79093d 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/uon/UonConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/uon/UonConfigAnnotationTest.java
@@ -56,7 +56,7 @@ public class UonConfigAnnotationTest {
@Test
public void basicSerializer() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
UonSerializerSession x = UonSerializer.create().applyAnnotations(al, sr).build().createSession();
check("true", x.isAddBeanTypes());
check("true", x.isEncoding());
@@ -65,7 +65,7 @@ public class UonConfigAnnotationTest {
@Test
public void basicParser() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
UonParserSession x = UonParser.create().applyAnnotations(al, sr).build().createSession();
check("true", x.isDecoding());
check("true", x.isValidateEnd());
@@ -81,7 +81,7 @@ public class UonConfigAnnotationTest {
@Test
public void noValuesSerializer() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
UonSerializerSession x = UonSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isAddBeanTypes());
check("false", x.isEncoding());
@@ -90,7 +90,7 @@ public class UonConfigAnnotationTest {
@Test
public void noValuesParser() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
UonParserSession x = UonParser.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isDecoding());
check("false", x.isValidateEnd());
@@ -105,7 +105,7 @@ public class UonConfigAnnotationTest {
@Test
public void noAnnotationSerializer() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
UonSerializerSession x = UonSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isAddBeanTypes());
check("false", x.isEncoding());
@@ -114,7 +114,7 @@ public class UonConfigAnnotationTest {
@Test
public void noAnnotationParser() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
UonParserSession x = UonParser.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isDecoding());
check("false", x.isValidateEnd());
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingConfigAnnotationTest.java
index a2c0515..af1c0bd 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/UrlEncodingConfigAnnotationTest.java
@@ -52,14 +52,14 @@ public class UrlEncodingConfigAnnotationTest {
@Test
public void basicSerializer() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
UrlEncodingSerializerSession x = UrlEncodingSerializer.create().applyAnnotations(al, sr).build().createSession();
check("true", x.isExpandedParams());
}
@Test
public void basicParser() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
UrlEncodingParserSession x = UrlEncodingParser.create().applyAnnotations(al, sr).build().createSession();
check("true", x.isExpandedParams());
}
@@ -74,14 +74,14 @@ public class UrlEncodingConfigAnnotationTest {
@Test
public void noValuesSerializer() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
UrlEncodingSerializerSession x = UrlEncodingSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isExpandedParams());
}
@Test
public void noValuesParser() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
UrlEncodingParserSession x = UrlEncodingParser.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isExpandedParams());
}
@@ -95,14 +95,14 @@ public class UrlEncodingConfigAnnotationTest {
@Test
public void noAnnotationSerializer() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
UrlEncodingSerializerSession x = UrlEncodingSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isExpandedParams());
}
@Test
public void noAnnotationParser() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
UrlEncodingParserSession x = UrlEncodingParser.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isExpandedParams());
}
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlConfigAnnotationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlConfigAnnotationTest.java
index 9de97bf..d0afded 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlConfigAnnotationTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/xml/XmlConfigAnnotationTest.java
@@ -103,7 +103,7 @@ public class XmlConfigAnnotationTest {
@Test
public void basicSerializer() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
XmlSerializerSession x = XmlSerializer.create().applyAnnotations(al, sr).build().createSession();
check("true", x.isAddBeanTypes());
check("true", x.isAddNamespaceUrisToRoot());
@@ -116,7 +116,7 @@ public class XmlConfigAnnotationTest {
@Test
public void basicParser() throws Exception {
- AnnotationList al = a.getAnnotationList();
+ AnnotationList al = a.getAnnotationList(null);
XmlParserSession x = XmlParser.create().applyAnnotations(al, sr).build().createSession();
check("AA", x.getEventAllocator());
check("true", x.isPreserveRootElement());
@@ -135,7 +135,7 @@ public class XmlConfigAnnotationTest {
@Test
public void noValuesSerializer() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
XmlSerializerSession x = XmlSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isAddBeanTypes());
check("false", x.isAddNamespaceUrisToRoot());
@@ -148,7 +148,7 @@ public class XmlConfigAnnotationTest {
@Test
public void noValuesParser() throws Exception {
- AnnotationList al = b.getAnnotationList();
+ AnnotationList al = b.getAnnotationList(null);
XmlParserSession x = XmlParser.create().applyAnnotations(al, sr).build().createSession();
check(null, x.getEventAllocator());
check("false", x.isPreserveRootElement());
@@ -166,7 +166,7 @@ public class XmlConfigAnnotationTest {
@Test
public void noAnnotationSerializer() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
XmlSerializerSession x = XmlSerializer.create().applyAnnotations(al, sr).build().createSession();
check("false", x.isAddBeanTypes());
check("false", x.isAddNamespaceUrisToRoot());
@@ -179,7 +179,7 @@ public class XmlConfigAnnotationTest {
@Test
public void noAnnotationParser() throws Exception {
- AnnotationList al = c.getAnnotationList();
+ AnnotationList al = c.getAnnotationList(null);
XmlParserSession x = XmlParser.create().applyAnnotations(al, sr).build().createSession();
check(null, x.getEventAllocator());
check("false", x.isPreserveRootElement());
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 07e75ce..9e83a2d 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
@@ -154,7 +154,7 @@ public abstract class ContextBuilder {
* @return This object (for method chaining).
*/
public ContextBuilder applyAnnotations(Class<?> fromClass) {
- applyAnnotations(ClassInfo.of(fromClass).getConfigAnnotationListParentFirst(), VarResolver.DEFAULT.createSession());
+ applyAnnotations(ClassInfo.of(fromClass).getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE), VarResolver.DEFAULT.createSession());
return this;
}
@@ -197,7 +197,7 @@ public abstract class ContextBuilder {
* @return This object (for method chaining).
*/
public ContextBuilder applyAnnotations(Method fromMethod) {
- applyAnnotations(MethodInfo.of(fromMethod).getConfigAnnotationListParentFirst(), VarResolver.DEFAULT.createSession());
+ applyAnnotations(MethodInfo.of(fromMethod).getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE), VarResolver.DEFAULT.createSession());
return this;
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStoreBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStoreBuilder.java
index d2138e4..3c2b463 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStoreBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/PropertyStoreBuilder.java
@@ -174,7 +174,7 @@ public class PropertyStoreBuilder {
* @return This object (for method chaining).
*/
public PropertyStoreBuilder applyAnnotations(Class<?> fromClass) {
- applyAnnotations(ClassInfo.of(fromClass).getConfigAnnotationListParentFirst(), VarResolver.DEFAULT.createSession());
+ applyAnnotations(ClassInfo.of(fromClass).getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE), VarResolver.DEFAULT.createSession());
return this;
}
@@ -217,7 +217,7 @@ public class PropertyStoreBuilder {
* @return This object (for method chaining).
*/
public PropertyStoreBuilder applyAnnotations(Method fromMethod) {
- applyAnnotations(MethodInfo.of(fromMethod).getConfigAnnotationListParentFirst(), VarResolver.DEFAULT.createSession());
+ applyAnnotations(MethodInfo.of(fromMethod).getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE), VarResolver.DEFAULT.createSession());
return this;
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationInfo.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationInfo.java
index 7bd23d4..be87ddf 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationInfo.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationInfo.java
@@ -195,6 +195,16 @@ public class AnnotationInfo<T extends Annotation> {
return at == a;
}
+ /**
+ * Returns <jk>true</jk> if this annotation has the specified annotation defined on it.
+ *
+ * @param a The annotation to test for.
+ * @return <jk>true</jk> if this annotation has the specified annotation defined on it.
+ */
+ public boolean hasAnnotation(Class<? extends Annotation> a) {
+ return this.a.annotationType().getAnnotation(a) != null;
+ }
+
@Override
public String toString() {
return SimpleJson.DEFAULT_READABLE.toString(toObjectMap());
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationList.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationList.java
index 023acef..86240fa 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationList.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/AnnotationList.java
@@ -12,8 +12,8 @@
// ***************************************************************************************************************************
package org.apache.juneau.reflect;
-import java.lang.annotation.*;
import java.util.ArrayList;
+import java.util.function.*;
/**
* An ordered list of annotations and the classes/methods/packages they were found on.
@@ -21,22 +21,32 @@ import java.util.ArrayList;
public class AnnotationList extends ArrayList<AnnotationInfo<?>> {
private static final long serialVersionUID = 1L;
+ private final Predicate<AnnotationInfo<?>> filter;
+
+ /**
+ * Constructor.
+ *
+ * No filtering.
+ */
+ public AnnotationList() {
+ this(null);
+ }
+
+ /**
+ * Constructor with optional filter.
+ *
+ * @param filter The filter to use to filter entries added to this list.
+ */
+ public AnnotationList(Predicate<AnnotationInfo<?>> filter) {
+ this.filter = filter;
+ }
+
@Override /* List */
public boolean add(AnnotationInfo<?> ai) {
- if (accept(ai)) {
+ if (filter == null || filter.test(ai)) {
super.add(ai);
return true;
}
return false;
}
-
- /**
- * Overridable method for filtering annotations added to this list.
- *
- * @param a The annotation to check.
- * @return <jk>true</jk> if annotation should be added to this list.
- */
- protected boolean accept(AnnotationInfo<? extends Annotation> a) {
- return true;
- }
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ClassInfo.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ClassInfo.java
index afca73c..40c9ce6 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ClassInfo.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ClassInfo.java
@@ -20,6 +20,7 @@ import java.lang.annotation.*;
import java.lang.reflect.*;
import java.util.*;
import java.util.concurrent.*;
+import java.util.function.*;
import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
@@ -938,10 +939,13 @@ public final class ClassInfo {
* <li>On the package of this class.
* </ol>
*
+ * @param filter
+ * Optional filter to apply to limit which annotations are added to the list.
+ * <br>Can be <jk>null</jk> for no filtering.
* @return A new {@link AnnotationList} object on every call.
*/
- public AnnotationList getAnnotationList() {
- return appendAnnotationList(new AnnotationList());
+ public AnnotationList getAnnotationList(Predicate<AnnotationInfo<?>> filter) {
+ return appendAnnotationList(new AnnotationList(filter));
}
/**
@@ -956,46 +960,13 @@ public final class ClassInfo {
* <li>On this class.
* </ol>
*
+ * @param filter
+ * Optional filter to apply to limit which annotations are added to the list.
+ * <br>Can be <jk>null</jk> for no filtering.
* @return A new {@link AnnotationList} object on every call.
*/
- public AnnotationList getAnnotationListParentFirst() {
- return appendAnnotationListParentFirst(new AnnotationList());
- }
-
- /**
- * Constructs an {@link ConfigAnnotationList} of all annotations found on this class.
- *
- * <p>
- * Annotations are appended in the following orders:
- * <ol>
- * <li>On this class.
- * <li>On parent classes ordered child-to-parent.
- * <li>On interfaces ordered child-to-parent.
- * <li>On the package of this class.
- * </ol>
- *
- * @return A new {@link AnnotationList} object on every call.
- */
- public AnnotationList getConfigAnnotationList() {
- return appendAnnotationList(new ConfigAnnotationList());
- }
-
- /**
- * Constructs an {@link ConfigAnnotationList} of all annotations found on this class.
- *
- * <p>
- * Annotations are appended in the following order:
- * <ol>
- * <li>On the package of this class.
- * <li>On interfaces ordered parent-to-child.
- * <li>On parent classes ordered parent-to-child.
- * <li>On this class.
- * </ol>
- *
- * @return A new {@link AnnotationList} object on every call.
- */
- public AnnotationList getConfigAnnotationListParentFirst() {
- return appendAnnotationListParentFirst(new ConfigAnnotationList());
+ public AnnotationList getAnnotationListParentFirst(Predicate<AnnotationInfo<?>> filter) {
+ return appendAnnotationListParentFirst(new AnnotationList(filter));
}
/**
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ConfigAnnotationList.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ConfigAnnotationFilter.java
similarity index 78%
rename from juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ConfigAnnotationList.java
rename to juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ConfigAnnotationFilter.java
index f0ebdb8..31afb96 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ConfigAnnotationList.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflect/ConfigAnnotationFilter.java
@@ -13,18 +13,22 @@
package org.apache.juneau.reflect;
import java.lang.annotation.*;
+import java.util.function.*;
import org.apache.juneau.annotation.*;
/**
- * Subclass of {@link AnnotationList} that filters out annotations not annotated with {@link PropertyStoreApply}.
+ * Filter used to accept only annotations that themselves have the {@link PropertyStoreApply} annotation.
*/
-public class ConfigAnnotationList extends AnnotationList {
- private static final long serialVersionUID = 1L;
+public class ConfigAnnotationFilter implements Predicate<AnnotationInfo<?>> {
- @Override /* AnnotationList */
- public boolean accept(AnnotationInfo<? extends Annotation> a) {
- Class<? extends Annotation> aa = a.getAnnotation().annotationType();
- return aa.getAnnotation(PropertyStoreApply.class) != null;
+ /**
+ * Reusable instance.
+ */
+ public static final ConfigAnnotationFilter INSTANCE = new ConfigAnnotationFilter();
+
+ @Override
+ public boolean test(AnnotationInfo<? extends Annotation> t) {
+ return t.hasAnnotation(PropertyStoreApply.class);
}
}
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 1152723..da5a150 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
@@ -18,6 +18,7 @@ import java.beans.*;
import java.lang.annotation.*;
import java.lang.reflect.*;
import java.util.*;
+import java.util.function.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.internal.*;
@@ -230,10 +231,13 @@ public final class MethodInfo extends ExecutableInfo implements Comparable<Metho
* <li>On the package of this class.
* </ol>
*
+ * @param filter
+ * Optional filter to apply to limit which annotations are added to the list.
+ * <br>Can be <jk>null</jk> for no filtering.
* @return A new {@link AnnotationList} object on every call.
*/
- public AnnotationList getAnnotationList() {
- return appendAnnotationList(new AnnotationList());
+ public AnnotationList getAnnotationList(Predicate<AnnotationInfo<?>> filter) {
+ return appendAnnotationList(new AnnotationList(filter));
}
/**
@@ -249,57 +253,25 @@ public final class MethodInfo extends ExecutableInfo implements Comparable<Metho
* <li>On this method and matching methods ordered parent-to-child.
* </ol>
*
+ * @param filter
+ * Optional filter to apply to limit which annotations are added to the list.
+ * <br>Can be <jk>null</jk> for no filtering.
* @return A new {@link AnnotationList} object on every call.
*/
- public AnnotationList getAnnotationListParentFirst() {
- return appendAnnotationListParentFirst(new AnnotationList());
+ public AnnotationList getAnnotationListParentFirst(Predicate<AnnotationInfo<?>> filter) {
+ return appendAnnotationListParentFirst(new AnnotationList(filter));
}
/**
- * Constructs an {@link ConfigAnnotationList} of all annotations found on this class.
- *
- * <p>
- * Annotations are appended in the following orders:
- * <ol>
- * <li>On this method and matching methods ordered child-to-parent.
- * <li>On the method class.
- * <li>On parent classes ordered child-to-parent.
- * <li>On interfaces ordered child-to-parent.
- * <li>On the package of the method class.
- * </ol>
- *
- * @return A new {@link AnnotationList} object on every call.
- */
- public AnnotationList getConfigAnnotationList() {
- return appendAnnotationList(new ConfigAnnotationList());
- }
-
- /**
- * Constructs an {@link ConfigAnnotationList} of all annotations found on this class.
- *
- * <p>
- * Annotations are appended in the following orders:
- * <ol>
- * <li>On the package of the method class.
- * <li>On interfaces ordered parent-to-child.
- * <li>On parent classes ordered parent-to-child.
- * <li>On the method class.
- * <li>On this method and matching methods ordered parent-to-child.
- * </ol>
- *
- * @return A new {@link AnnotationList} object on every call.
- */
- public AnnotationList getConfigAnnotationListParentFirst() {
- return appendAnnotationListParentFirst(new ConfigAnnotationList());
- }
-
- /**
- * Same as {@link #getConfigAnnotationListParentFirst()} except only returns annotations defined on methods.
+ * Same as {@link #getAnnotationListParentFirst(Predicate)} except only returns annotations defined on methods.
*
+ * @param filter
+ * Optional filter to apply to limit which annotations are added to the list.
+ * <br>Can be <jk>null</jk> for no filtering.
* @return A new {@link AnnotationList} object on every call.
*/
- public AnnotationList getConfigAnnotationListMethodOnlyParentFirst() {
- return appendAnnotationListMethodOnlyParentFirst(new ConfigAnnotationList());
+ public AnnotationList getAnnotationListMethodOnlyParentFirst(Predicate<AnnotationInfo<?>> filter) {
+ return appendAnnotationListMethodOnlyParentFirst(new AnnotationList(filter));
}
/**
@@ -355,9 +327,9 @@ public final class MethodInfo extends ExecutableInfo implements Comparable<Metho
AnnotationList appendAnnotationListMethodOnlyParentFirst(AnnotationList al) {
ClassInfo c = this.declaringClass;
- for (ClassInfo ci : c.getInterfacesParentFirst())
+ for (ClassInfo ci : c.getInterfacesParentFirst())
appendMethodAnnotations(al, ci);
- for (ClassInfo ci : c.getParentsParentFirst())
+ for (ClassInfo ci : c.getParentsParentFirst())
appendMethodAnnotations(al, ci);
return al;
}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
index 4847575..e803aea 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContext.java
@@ -3255,7 +3255,7 @@ public final class RestContext extends BeanContext {
Class<?> resourceClass = resource.getClass();
ClassInfo rci = getClassInfo(resourceClass);
- configAnnotationList = rci.getConfigAnnotationListParentFirst();
+ configAnnotationList = rci.getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE);
PropertyStore ps = getPropertyStore();
uriContext = nullIfEmpty(getStringProperty(REST_uriContext, null));
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
index 8d5a484..9886fc0 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestContextBuilder.java
@@ -176,7 +176,7 @@ public class RestContextBuilder extends BeanContextBuilder implements ServletCon
}
}
- applyAnnotations(rci.getConfigAnnotationListParentFirst(), vr.createSession());
+ applyAnnotations(rci.getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE), vr.createSession());
// Load stuff from parent-to-child order.
// This allows child settings to overwrite parent settings.
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMethodContext.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMethodContext.java
index 65e684c..cfa4763 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMethodContext.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMethodContext.java
@@ -13,16 +13,11 @@
package org.apache.juneau.rest;
import static javax.servlet.http.HttpServletResponse.*;
-import static org.apache.juneau.BeanContext.*;
import static org.apache.juneau.internal.ClassUtils.*;
import static org.apache.juneau.internal.CollectionUtils.*;
-import static org.apache.juneau.internal.StringUtils.*;
import static org.apache.juneau.internal.ObjectUtils.*;
-import static org.apache.juneau.rest.RestContext.*;
-import static org.apache.juneau.rest.util.RestUtils.*;
import static org.apache.juneau.httppart.HttpPartType.*;
-import java.lang.annotation.*;
import java.lang.reflect.*;
import java.util.*;
import java.util.concurrent.*;
@@ -33,21 +28,14 @@ import org.apache.juneau.*;
import org.apache.juneau.encoders.*;
import org.apache.juneau.http.*;
import org.apache.juneau.http.annotation.*;
-import org.apache.juneau.http.annotation.FormData;
-import org.apache.juneau.http.annotation.Header;
-import org.apache.juneau.http.annotation.Query;
-import org.apache.juneau.http.annotation.Response;
import org.apache.juneau.httppart.*;
import org.apache.juneau.httppart.bean.*;
-import org.apache.juneau.internal.*;
-import org.apache.juneau.internal.HttpUtils;
import org.apache.juneau.jsonschema.*;
import org.apache.juneau.parser.*;
import org.apache.juneau.reflect.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.exception.*;
-import org.apache.juneau.rest.util.RestUtils;
-import org.apache.juneau.rest.util.UrlPathPattern;
+import org.apache.juneau.rest.util.*;
import org.apache.juneau.rest.widget.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.svl.*;
@@ -93,7 +81,7 @@ public class RestMethodContext implements Comparable<RestMethodContext> {
final ResponseBeanMeta responseMeta;
RestMethodContext(Object servlet, java.lang.reflect.Method method, RestContext context) throws RestServletException {
- Builder b = new Builder(servlet, method, context);
+ RestMethodContextBuilder b = new RestMethodContextBuilder(servlet, method, context);
this.context = context;
this.method = method;
this.info = MethodInfo.of(method);
@@ -125,328 +113,6 @@ public class RestMethodContext implements Comparable<RestMethodContext> {
this.widgets = unmodifiableMap(b.widgets);
}
- private static final class Builder {
- String httpMethod, defaultCharset;
- UrlPathPattern pathPattern;
- RestMethodParam[] methodParams;
- RestGuard[] guards;
- RestMatcher[] optionalMatchers, requiredMatchers;
- RestConverter[] converters;
- SerializerGroup serializers;
- ParserGroup parsers;
- EncoderGroup encoders;
- HttpPartParser partParser;
- HttpPartSerializer partSerializer;
- JsonSchemaGenerator jsonSchemaGenerator;
- BeanContext beanContext;
- RestMethodProperties properties;
- PropertyStore propertyStore;
- Map<String,Object> defaultRequestHeaders, defaultQuery, defaultFormData;
- long maxInput;
- Integer priority;
- Map<String,Widget> widgets;
- List<MediaType> supportedAcceptTypes, supportedContentTypes;
- ResponseBeanMeta responseMeta;
-
- @SuppressWarnings("deprecation")
- Builder(Object servlet, java.lang.reflect.Method method, RestContext context) throws RestServletException {
- String sig = method.getDeclaringClass().getName() + '.' + method.getName();
- MethodInfo mi = getMethodInfo(servlet.getClass(), method);
-
- try {
-
- RestMethod m = mi.getAnnotation(RestMethod.class);
- if (m == null)
- throw new RestServletException("@RestMethod annotation not found on method ''{0}''", sig);
-
- VarResolver vr = context.getVarResolver();
-
- // If this method doesn't have any config annotations (e.g. @BeanConfig), then we want to
- // reuse the serializers/parsers on the class.
- boolean hasConfigAnnotations = false;
- for (AnnotationInfo<?> ai : mi.getConfigAnnotationListMethodOnlyParentFirst()) {
- hasConfigAnnotations = ! ai.isType(RestMethod.class);
- if (hasConfigAnnotations)
- break;
- }
-
- serializers = context.getSerializers();
- parsers = context.getParsers();
- partSerializer = context.getPartSerializer();
- partParser = context.getPartParser();
- jsonSchemaGenerator = context.getJsonSchemaGenerator();
- beanContext = context.getBeanContext();
- encoders = context.getEncoders();
- properties = new RestMethodProperties(context.getProperties());
- defaultCharset = context.getDefaultCharset();
- maxInput = context.getMaxInput();
- AnnotationList configAnnotationList = hasConfigAnnotations ? mi.getConfigAnnotationListParentFirst() : context.getConfigAnnotationList();
-
- if (! m.defaultCharset().isEmpty())
- defaultCharset = vr.resolve(m.defaultCharset());
- if (! m.maxInput().isEmpty())
- maxInput = StringUtils.parseLongWithSuffix(vr.resolve(m.maxInput()));
-
- HtmlDocBuilder hdb = new HtmlDocBuilder(properties);
-
- HtmlDoc hd = m.htmldoc();
- hdb.process(hd);
-
- widgets = new HashMap<>(context.getWidgets());
- for (Class<? extends Widget> wc : hd.widgets()) {
- Widget w = castOrCreate(Widget.class, wc);
- widgets.put(w.getName(), w);
- hdb.script("INHERIT", "$W{"+w.getName()+".script}");
- hdb.style("INHERIT", "$W{"+w.getName()+".style}");
- }
-
- SerializerGroupBuilder sgb = null;
- ParserGroupBuilder pgb = null;
- ParserBuilder uepb = null;
- BeanContextBuilder bcb = null;
- JsonSchemaGeneratorBuilder jsgb = null;
- PropertyStore cps = context.getPropertyStore();
-
- Object[] mSerializers = merge(cps.getArrayProperty(REST_serializers, Object.class), m.serializers());
- Object[] mParsers = merge(cps.getArrayProperty(REST_parsers, Object.class), m.parsers());
- Object[] mPojoSwaps = merge(cps.getArrayProperty(BEAN_pojoSwaps, Object.class), m.pojoSwaps());
- Object[] mBeanFilters = merge(cps.getArrayProperty(BEAN_beanFilters, Object.class), m.beanFilters());
-
- if (m.serializers().length > 0 || m.parsers().length > 0 || m.properties().length > 0 || m.flags().length > 0
- || m.beanFilters().length > 0 || m.pojoSwaps().length > 0 || m.bpi().length > 0
- || m.bpx().length > 0 || hasConfigAnnotations) {
- sgb = SerializerGroup.create();
- pgb = ParserGroup.create();
- uepb = Parser.create();
- bcb = beanContext.builder();
- jsgb = JsonSchemaGenerator.create();
- sgb.append(mSerializers);
- pgb.append(mParsers);
- }
-
- //String p = trimTrailingSlashes(m.path());
- String p = fixMethodPath(m.path());
- if (isEmpty(p))
- p = HttpUtils.detectHttpPath(method, true);
-
- httpMethod = emptyIfNull(firstNonEmpty(m.name(), m.method())).toUpperCase(Locale.ENGLISH);
- if (httpMethod.isEmpty())
- httpMethod = HttpUtils.detectHttpMethod(method, true, "GET");
- if ("METHOD".equals(httpMethod))
- httpMethod = "*";
-
- priority = m.priority();
-
- converters = new RestConverter[m.converters().length];
- for (int i = 0; i < converters.length; i++)
- converters[i] = castOrCreate(RestConverter.class, m.converters()[i]);
-
- guards = new RestGuard[m.guards().length];
- for (int i = 0; i < guards.length; i++)
- guards[i] = castOrCreate(RestGuard.class, m.guards()[i]);
-
- List<RestMatcher> optionalMatchers = new LinkedList<>(), requiredMatchers = new LinkedList<>();
- for (int i = 0; i < m.matchers().length; i++) {
- Class<? extends RestMatcher> c = m.matchers()[i];
- RestMatcher matcher = castOrCreate(RestMatcher.class, c, true, servlet, method);
- if (matcher.mustMatch())
- requiredMatchers.add(matcher);
- else
- optionalMatchers.add(matcher);
- }
- if (! m.clientVersion().isEmpty())
- requiredMatchers.add(new ClientVersionMatcher(context.getClientVersionHeader(), mi));
-
- this.requiredMatchers = requiredMatchers.toArray(new RestMatcher[requiredMatchers.size()]);
- this.optionalMatchers = optionalMatchers.toArray(new RestMatcher[optionalMatchers.size()]);
-
- VarResolverSession sr = vr.createSession();
-
- PropertyStoreBuilder psb = PropertyStore.create().apply(context.getPropertyStore()).set(BEAN_beanFilters, mBeanFilters).set(BEAN_pojoSwaps, mPojoSwaps);
-
- for (Property p1 : m.properties())
- psb.set(p1.name(), p1.value());
- for (String p1 : m.flags())
- psb.set(p1, true);
- if (hasConfigAnnotations)
- psb.applyAnnotations(configAnnotationList, sr);
- this.propertyStore = psb.build();
-
- if (sgb != null) {
- sgb.apply(propertyStore);
- if (m.bpi().length > 0) {
- Map<String,String> bpiMap = new LinkedHashMap<>();
- for (String s : m.bpi()) {
- for (String s2 : split(s, ';')) {
- int i = s2.indexOf(':');
- if (i == -1)
- throw new RestServletException(
- "Invalid format for @RestMethod(bpi) on method ''{0}''. Must be in the format \"ClassName: comma-delimited-tokens\". \nValue: {1}", sig, s);
- bpiMap.put(s2.substring(0, i).trim(), s2.substring(i+1).trim());
- }
- }
- sgb.includeProperties(bpiMap);
- }
- if (m.bpx().length > 0) {
- Map<String,String> bpxMap = new LinkedHashMap<>();
- for (String s : m.bpx()) {
- for (String s2 : split(s, ';')) {
- int i = s2.indexOf(':');
- if (i == -1)
- throw new RestServletException(
- "Invalid format for @RestMethod(bpx) on method ''{0}''. Must be in the format \"ClassName: comma-delimited-tokens\". \nValue: {1}", sig, s);
- bpxMap.put(s2.substring(0, i).trim(), s2.substring(i+1).trim());
- }
- }
- sgb.excludeProperties(bpxMap);
- }
- sgb.beanFilters(mBeanFilters);
- sgb.pojoSwaps(mPojoSwaps);
- }
-
- if (pgb != null) {
- pgb.apply(propertyStore);
- pgb.beanFilters(mBeanFilters);
- pgb.pojoSwaps(mPojoSwaps);
- }
-
- if (uepb != null) {
- uepb.apply(propertyStore);
- uepb.beanFilters(mBeanFilters);
- uepb.pojoSwaps(mPojoSwaps);
- }
-
- if (bcb != null) {
- bcb.apply(propertyStore);
- bcb.beanFilters(mBeanFilters);
- bcb.pojoSwaps(mPojoSwaps);
- }
-
- if (jsgb != null) {
- jsgb.apply(propertyStore);
- jsgb.beanFilters(mBeanFilters);
- jsgb.pojoSwaps(mPojoSwaps);
- }
-
- if (m.properties().length > 0 || m.flags().length > 0) {
- properties = new RestMethodProperties(properties);
- for (Property p1 : m.properties())
- properties.put(p1.name(), p1.value());
- for (String p1 : m.flags())
- properties.put(p1, true);
- }
-
- if (m.encoders().length > 0) {
- EncoderGroupBuilder g = EncoderGroup.create().append(IdentityEncoder.INSTANCE);
- for (Class<?> c : m.encoders()) {
- try {
- g.append(c);
- } catch (Exception e) {
- throw new RestServletException(
- "Exception occurred while trying to instantiate ConfigEncoder on method ''{0}'': ''{1}''", sig, c.getSimpleName()).initCause(e);
- }
- }
- encoders = g.build();
- }
-
- defaultRequestHeaders = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
- for (String s : m.defaultRequestHeaders()) {
- String[] h = RestUtils.parseKeyValuePair(vr.resolve(s));
- if (h == null)
- throw new RestServletException(
- "Invalid default request header specified on method ''{0}'': ''{1}''. Must be in the format: ''name[:=]value''", sig, s);
- defaultRequestHeaders.put(h[0], h[1]);
- }
-
- String defaultAccept = vr.resolve(m.defaultAccept());
- if (isNotEmpty(defaultAccept))
- defaultRequestHeaders.put("Accept", defaultAccept);
-
- String defaultContentType = vr.resolve(m.defaultContentType());
- if (isNotEmpty(defaultContentType))
- defaultRequestHeaders.put("Content-Type", defaultAccept);
-
- defaultQuery = new LinkedHashMap<>();
- for (String s : m.defaultQuery()) {
- String[] h = RestUtils.parseKeyValuePair(vr.resolve(s));
- if (h == null)
- throw new RestServletException(
- "Invalid default query parameter specified on method ''{0}'': ''{1}''. Must be in the format: ''name[:=]value''", sig, s);
- defaultQuery.put(h[0], h[1]);
- }
-
- defaultFormData = new LinkedHashMap<>();
- for (String s : m.defaultFormData()) {
- String[] h = RestUtils.parseKeyValuePair(vr.resolve(s));
- if (h == null)
- throw new RestServletException(
- "Invalid default form data parameter specified on method ''{0}'': ''{1}''. Must be in the format: ''name[:=]value''", sig, s);
- defaultFormData.put(h[0], h[1]);
- }
-
- Type[] pt = method.getGenericParameterTypes();
- Annotation[][] pa = method.getParameterAnnotations();
- for (int i = 0; i < pt.length; i++) {
- for (Annotation a : pa[i]) {
- if (a instanceof Header) {
- Header h = (Header)a;
- if (h._default().length > 0)
- defaultRequestHeaders.put(firstNonEmpty(h.name(), h.value()), parseAnything(joinnl(h._default())));
- } else if (a instanceof Query) {
- Query q = (Query)a;
- if (q._default().length > 0)
- defaultQuery.put(firstNonEmpty(q.name(), q.value()), parseAnything(joinnl(q._default())));
- } else if (a instanceof FormData) {
- FormData f = (FormData)a;
- if (f._default().length > 0)
- defaultFormData.put(firstNonEmpty(f.name(), f.value()), parseAnything(joinnl(f._default())));
- }
- }
- }
-
- pathPattern = new UrlPathPattern(p);
-
- if (sgb != null)
- serializers = sgb.build();
- if (pgb != null)
- parsers = pgb.build();
- if (uepb != null && partParser instanceof Parser) {
- Parser pp = (Parser)partParser;
- partParser = (HttpPartParser)pp
- .builder()
- .apply(uepb.getPropertyStore())
- .applyAnnotations(configAnnotationList, sr)
- .build();
- }
- if (bcb != null)
- beanContext = bcb.build();
- if (jsgb != null)
- jsonSchemaGenerator = jsgb.build();
-
- supportedAcceptTypes =
- m.produces().length > 0
- ? immutableList(MediaType.forStrings(resolveVars(vr, m.produces())))
- : serializers.getSupportedMediaTypes();
- supportedContentTypes =
- m.consumes().length > 0
- ? immutableList(MediaType.forStrings(resolveVars(vr, m.consumes())))
- : parsers.getSupportedMediaTypes();
-
- methodParams = context.findParams(mi, false, pathPattern);
-
- if (mi.hasAnnotation(Response.class))
- responseMeta = ResponseBeanMeta.create(mi, serializers.getPropertyStore());
-
- // Need this to access methods in anonymous inner classes.
- mi.setAccessible();
- } catch (RestServletException e) {
- throw e;
- } catch (Exception e) {
- throw new RestServletException("Exception occurred while initializing method ''{0}''", sig).initCause(e);
- }
- }
- }
-
ResponseBeanMeta getResponseBeanMeta(Object o) {
if (o == null)
return null;
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMethodContextBuilder.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMethodContextBuilder.java
new file mode 100644
index 0000000..972be19
--- /dev/null
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestMethodContextBuilder.java
@@ -0,0 +1,373 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.rest;
+
+import static org.apache.juneau.BeanContext.*;
+import static org.apache.juneau.internal.ClassUtils.*;
+import static org.apache.juneau.internal.CollectionUtils.*;
+import static org.apache.juneau.internal.StringUtils.*;
+import static org.apache.juneau.rest.RestContext.*;
+import static org.apache.juneau.rest.util.RestUtils.*;
+
+import java.lang.annotation.*;
+import java.lang.reflect.*;
+import java.util.*;
+
+import org.apache.juneau.*;
+import org.apache.juneau.encoders.*;
+import org.apache.juneau.http.*;
+import org.apache.juneau.http.annotation.*;
+import org.apache.juneau.httppart.*;
+import org.apache.juneau.httppart.bean.*;
+import org.apache.juneau.internal.*;
+import org.apache.juneau.jsonschema.*;
+import org.apache.juneau.parser.*;
+import org.apache.juneau.reflect.*;
+import org.apache.juneau.rest.annotation.*;
+import org.apache.juneau.rest.util.*;
+import org.apache.juneau.rest.widget.*;
+import org.apache.juneau.serializer.*;
+import org.apache.juneau.svl.*;
+
+/**
+ * Builder class for {@link RestMethodContext} objects.
+ */
+public class RestMethodContextBuilder extends BeanContextBuilder {
+
+ String httpMethod, defaultCharset;
+ UrlPathPattern pathPattern;
+ RestMethodParam[] methodParams;
+ RestGuard[] guards;
+ RestMatcher[] optionalMatchers, requiredMatchers;
+ RestConverter[] converters;
+ SerializerGroup serializers;
+ ParserGroup parsers;
+ EncoderGroup encoders;
+ HttpPartParser partParser;
+ HttpPartSerializer partSerializer;
+ JsonSchemaGenerator jsonSchemaGenerator;
+ BeanContext beanContext;
+ RestMethodProperties properties;
+ PropertyStore propertyStore;
+ Map<String,Object> defaultRequestHeaders, defaultQuery, defaultFormData;
+ long maxInput;
+ Integer priority;
+ Map<String,Widget> widgets;
+ List<MediaType> supportedAcceptTypes, supportedContentTypes;
+ ResponseBeanMeta responseMeta;
+
+ @SuppressWarnings("deprecation")
+ RestMethodContextBuilder(Object servlet, java.lang.reflect.Method method, RestContext context) throws RestServletException {
+ String sig = method.getDeclaringClass().getName() + '.' + method.getName();
+ MethodInfo mi = getMethodInfo(servlet.getClass(), method);
+
+ try {
+
+ RestMethod m = mi.getAnnotation(RestMethod.class);
+ if (m == null)
+ throw new RestServletException("@RestMethod annotation not found on method ''{0}''", sig);
+
+ VarResolver vr = context.getVarResolver();
+ VarResolverSession vrs = vr.createSession();
+
+ // If this method doesn't have any config annotations (e.g. @BeanConfig), then we want to
+ // reuse the serializers/parsers on the class.
+ boolean hasConfigAnnotations = false;
+ for (AnnotationInfo<?> ai : mi.getAnnotationListMethodOnlyParentFirst(ConfigAnnotationFilter.INSTANCE)) {
+ hasConfigAnnotations = ! ai.isType(RestMethod.class);
+ if (hasConfigAnnotations)
+ break;
+ }
+
+ if (hasConfigAnnotations) {
+ applyAnnotations(mi.getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE), vrs);
+ } else {
+ applyAnnotations(mi.getAnnotationListMethodOnlyParentFirst(ConfigAnnotationFilter.INSTANCE), vrs);
+ }
+
+ serializers = context.getSerializers();
+ parsers = context.getParsers();
+ partSerializer = context.getPartSerializer();
+ partParser = context.getPartParser();
+ jsonSchemaGenerator = context.getJsonSchemaGenerator();
+ beanContext = context.getBeanContext();
+ encoders = context.getEncoders();
+ properties = new RestMethodProperties(context.getProperties());
+ defaultCharset = context.getDefaultCharset();
+ maxInput = context.getMaxInput();
+ AnnotationList configAnnotationList = hasConfigAnnotations ? mi.getAnnotationListParentFirst(ConfigAnnotationFilter.INSTANCE) : context.getConfigAnnotationList();
+
+ if (! m.defaultCharset().isEmpty())
+ defaultCharset = vr.resolve(m.defaultCharset());
+ if (! m.maxInput().isEmpty())
+ maxInput = StringUtils.parseLongWithSuffix(vr.resolve(m.maxInput()));
+
+ HtmlDocBuilder hdb = new HtmlDocBuilder(properties);
+
+ HtmlDoc hd = m.htmldoc();
+ hdb.process(hd);
+
+ widgets = new HashMap<>(context.getWidgets());
+ for (Class<? extends Widget> wc : hd.widgets()) {
+ Widget w = castOrCreate(Widget.class, wc);
+ widgets.put(w.getName(), w);
+ hdb.script("INHERIT", "$W{"+w.getName()+".script}");
+ hdb.style("INHERIT", "$W{"+w.getName()+".style}");
+ }
+
+ SerializerGroupBuilder sgb = null;
+ ParserGroupBuilder pgb = null;
+ ParserBuilder uepb = null;
+ BeanContextBuilder bcb = null;
+ JsonSchemaGeneratorBuilder jsgb = null;
+ PropertyStore cps = context.getPropertyStore();
+
+ Object[] mSerializers = merge(cps.getArrayProperty(REST_serializers, Object.class), m.serializers());
+ Object[] mParsers = merge(cps.getArrayProperty(REST_parsers, Object.class), m.parsers());
+ Object[] mPojoSwaps = merge(cps.getArrayProperty(BEAN_pojoSwaps, Object.class), m.pojoSwaps());
+ Object[] mBeanFilters = merge(cps.getArrayProperty(BEAN_beanFilters, Object.class), m.beanFilters());
+
+ if (m.serializers().length > 0 || m.parsers().length > 0 || m.properties().length > 0 || m.flags().length > 0
+ || m.beanFilters().length > 0 || m.pojoSwaps().length > 0 || m.bpi().length > 0
+ || m.bpx().length > 0 || hasConfigAnnotations) {
+ sgb = SerializerGroup.create();
+ pgb = ParserGroup.create();
+ uepb = Parser.create();
+ bcb = beanContext.builder();
+ jsgb = JsonSchemaGenerator.create();
+ sgb.append(mSerializers);
+ pgb.append(mParsers);
+ }
+
+ //String p = trimTrailingSlashes(m.path());
+ String p = fixMethodPath(m.path());
+ if (isEmpty(p))
+ p = HttpUtils.detectHttpPath(method, true);
+
+ httpMethod = emptyIfNull(firstNonEmpty(m.name(), m.method())).toUpperCase(Locale.ENGLISH);
+ if (httpMethod.isEmpty())
+ httpMethod = HttpUtils.detectHttpMethod(method, true, "GET");
+ if ("METHOD".equals(httpMethod))
+ httpMethod = "*";
+
+ priority = m.priority();
+
+ converters = new RestConverter[m.converters().length];
+ for (int i = 0; i < converters.length; i++)
+ converters[i] = castOrCreate(RestConverter.class, m.converters()[i]);
+
+ guards = new RestGuard[m.guards().length];
+ for (int i = 0; i < guards.length; i++)
+ guards[i] = castOrCreate(RestGuard.class, m.guards()[i]);
+
+ List<RestMatcher> optionalMatchers = new LinkedList<>(), requiredMatchers = new LinkedList<>();
+ for (int i = 0; i < m.matchers().length; i++) {
+ Class<? extends RestMatcher> c = m.matchers()[i];
+ RestMatcher matcher = castOrCreate(RestMatcher.class, c, true, servlet, method);
+ if (matcher.mustMatch())
+ requiredMatchers.add(matcher);
+ else
+ optionalMatchers.add(matcher);
+ }
+ if (! m.clientVersion().isEmpty())
+ requiredMatchers.add(new ClientVersionMatcher(context.getClientVersionHeader(), mi));
+
+ this.requiredMatchers = requiredMatchers.toArray(new RestMatcher[requiredMatchers.size()]);
+ this.optionalMatchers = optionalMatchers.toArray(new RestMatcher[optionalMatchers.size()]);
+
+ VarResolverSession sr = vr.createSession();
+
+ PropertyStoreBuilder psb = PropertyStore.create().apply(context.getPropertyStore()).set(BEAN_beanFilters, mBeanFilters).set(BEAN_pojoSwaps, mPojoSwaps);
+
+ for (Property p1 : m.properties())
+ psb.set(p1.name(), p1.value());
+ for (String p1 : m.flags())
+ psb.set(p1, true);
+ if (hasConfigAnnotations)
+ psb.applyAnnotations(configAnnotationList, sr);
+ this.propertyStore = psb.build();
+
+ if (sgb != null) {
+ sgb.apply(propertyStore);
+ if (m.bpi().length > 0) {
+ Map<String,String> bpiMap = new LinkedHashMap<>();
+ for (String s : m.bpi()) {
+ for (String s2 : split(s, ';')) {
+ int i = s2.indexOf(':');
+ if (i == -1)
+ throw new RestServletException(
+ "Invalid format for @RestMethod(bpi) on method ''{0}''. Must be in the format \"ClassName: comma-delimited-tokens\". \nValue: {1}", sig, s);
+ bpiMap.put(s2.substring(0, i).trim(), s2.substring(i+1).trim());
+ }
+ }
+ sgb.includeProperties(bpiMap);
+ }
+ if (m.bpx().length > 0) {
+ Map<String,String> bpxMap = new LinkedHashMap<>();
+ for (String s : m.bpx()) {
+ for (String s2 : split(s, ';')) {
+ int i = s2.indexOf(':');
+ if (i == -1)
+ throw new RestServletException(
+ "Invalid format for @RestMethod(bpx) on method ''{0}''. Must be in the format \"ClassName: comma-delimited-tokens\". \nValue: {1}", sig, s);
+ bpxMap.put(s2.substring(0, i).trim(), s2.substring(i+1).trim());
+ }
+ }
+ sgb.excludeProperties(bpxMap);
+ }
+ sgb.beanFilters(mBeanFilters);
+ sgb.pojoSwaps(mPojoSwaps);
+ }
+
+ if (pgb != null) {
+ pgb.apply(propertyStore);
+ pgb.beanFilters(mBeanFilters);
+ pgb.pojoSwaps(mPojoSwaps);
+ }
+
+ if (uepb != null) {
+ uepb.apply(propertyStore);
+ uepb.beanFilters(mBeanFilters);
+ uepb.pojoSwaps(mPojoSwaps);
+ }
+
+ if (bcb != null) {
+ bcb.apply(propertyStore);
+ bcb.beanFilters(mBeanFilters);
+ bcb.pojoSwaps(mPojoSwaps);
+ }
+
+ if (jsgb != null) {
+ jsgb.apply(propertyStore);
+ jsgb.beanFilters(mBeanFilters);
+ jsgb.pojoSwaps(mPojoSwaps);
+ }
+
+ if (m.properties().length > 0 || m.flags().length > 0) {
+ properties = new RestMethodProperties(properties);
+ for (Property p1 : m.properties())
+ properties.put(p1.name(), p1.value());
+ for (String p1 : m.flags())
+ properties.put(p1, true);
+ }
+
+ if (m.encoders().length > 0) {
+ EncoderGroupBuilder g = EncoderGroup.create().append(IdentityEncoder.INSTANCE);
+ for (Class<?> c : m.encoders()) {
+ try {
+ g.append(c);
+ } catch (Exception e) {
+ throw new RestServletException(
+ "Exception occurred while trying to instantiate ConfigEncoder on method ''{0}'': ''{1}''", sig, c.getSimpleName()).initCause(e);
+ }
+ }
+ encoders = g.build();
+ }
+
+ defaultRequestHeaders = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ for (String s : m.defaultRequestHeaders()) {
+ String[] h = RestUtils.parseKeyValuePair(vr.resolve(s));
+ if (h == null)
+ throw new RestServletException(
+ "Invalid default request header specified on method ''{0}'': ''{1}''. Must be in the format: ''name[:=]value''", sig, s);
+ defaultRequestHeaders.put(h[0], h[1]);
+ }
+
+ String defaultAccept = vr.resolve(m.defaultAccept());
+ if (isNotEmpty(defaultAccept))
+ defaultRequestHeaders.put("Accept", defaultAccept);
+
+ String defaultContentType = vr.resolve(m.defaultContentType());
+ if (isNotEmpty(defaultContentType))
+ defaultRequestHeaders.put("Content-Type", defaultAccept);
+
+ defaultQuery = new LinkedHashMap<>();
+ for (String s : m.defaultQuery()) {
+ String[] h = RestUtils.parseKeyValuePair(vr.resolve(s));
+ if (h == null)
+ throw new RestServletException(
+ "Invalid default query parameter specified on method ''{0}'': ''{1}''. Must be in the format: ''name[:=]value''", sig, s);
+ defaultQuery.put(h[0], h[1]);
+ }
+
+ defaultFormData = new LinkedHashMap<>();
+ for (String s : m.defaultFormData()) {
+ String[] h = RestUtils.parseKeyValuePair(vr.resolve(s));
+ if (h == null)
+ throw new RestServletException(
+ "Invalid default form data parameter specified on method ''{0}'': ''{1}''. Must be in the format: ''name[:=]value''", sig, s);
+ defaultFormData.put(h[0], h[1]);
+ }
+
+ Type[] pt = method.getGenericParameterTypes();
+ Annotation[][] pa = method.getParameterAnnotations();
+ for (int i = 0; i < pt.length; i++) {
+ for (Annotation a : pa[i]) {
+ if (a instanceof Header) {
+ Header h = (Header)a;
+ if (h._default().length > 0)
+ defaultRequestHeaders.put(firstNonEmpty(h.name(), h.value()), parseAnything(joinnl(h._default())));
+ } else if (a instanceof Query) {
+ Query q = (Query)a;
+ if (q._default().length > 0)
+ defaultQuery.put(firstNonEmpty(q.name(), q.value()), parseAnything(joinnl(q._default())));
+ } else if (a instanceof FormData) {
+ FormData f = (FormData)a;
+ if (f._default().length > 0)
+ defaultFormData.put(firstNonEmpty(f.name(), f.value()), parseAnything(joinnl(f._default())));
+ }
+ }
+ }
+
+ pathPattern = new UrlPathPattern(p);
+
+ if (sgb != null)
+ serializers = sgb.build();
+ if (pgb != null)
+ parsers = pgb.build();
+ if (uepb != null && partParser instanceof Parser) {
+ Parser pp = (Parser)partParser;
+ partParser = (HttpPartParser)pp
+ .builder()
+ .apply(uepb.getPropertyStore())
+ .applyAnnotations(configAnnotationList, sr)
+ .build();
+ }
+ if (bcb != null)
+ beanContext = bcb.build();
+ if (jsgb != null)
+ jsonSchemaGenerator = jsgb.build();
+
+ supportedAcceptTypes =
+ m.produces().length > 0
+ ? immutableList(MediaType.forStrings(RestMethodContext.resolveVars(vr, m.produces())))
+ : serializers.getSupportedMediaTypes();
+ supportedContentTypes =
+ m.consumes().length > 0
+ ? immutableList(MediaType.forStrings(RestMethodContext.resolveVars(vr, m.consumes())))
+ : parsers.getSupportedMediaTypes();
+
+ methodParams = context.findParams(mi, false, pathPattern);
+
+ if (mi.hasAnnotation(Response.class))
+ responseMeta = ResponseBeanMeta.create(mi, serializers.getPropertyStore());
+
+ // Need this to access methods in anonymous inner classes.
+ mi.setAccessible();
+ } catch (RestServletException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new RestServletException("Exception occurred while initializing method ''{0}''", sig).initCause(e);
+ }
+ }
+}
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethodConfigApply.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethodConfigApply.java
index 65287c4..a5c1760 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethodConfigApply.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestMethodConfigApply.java
@@ -36,8 +36,10 @@ public class RestMethodConfigApply extends ConfigApply<RestMethod> {
@Override
public void apply(AnnotationInfo<RestMethod> ai, PropertyStoreBuilder psb) {
RestMethod a = ai.getAnnotation();
+
if (! a.rolesDeclared().isEmpty())
psb.set(REST_rolesDeclared, string(a.rolesDeclared()));
+
if (! a.roleGuard().isEmpty())
psb.set(REST_roleGuard, string(a.roleGuard()));
}