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 5e8c6a2 Move bean traverse settings in @Bean to @Serializer.
5e8c6a2 is described below
commit 5e8c6a230a610ebfafde7e4e1aafccc36af7547f
Author: JamesBognar <[email protected]>
AuthorDate: Sat Aug 7 12:01:00 2021 -0400
Move bean traverse settings in @Bean to @Serializer.
---
.../org/apache/juneau/BeanTraverseContext.java | 12 ++-
.../org/apache/juneau/annotation/BeanConfig.java | 118 ---------------------
.../juneau/annotation/BeanConfigAnnotation.java | 5 -
.../jsonschema/annotation/JsonSchemaConfig.java | 118 +++++++++++++++++++++
.../annotation/JsonSchemaConfigAnnotation.java | 5 +
.../serializer/annotation/SerializerConfig.java | 118 +++++++++++++++++++++
.../annotation/SerializerConfigAnnotation.java | 5 +
.../juneau/examples/rest/RequestEchoResource.java | 7 +-
.../annotation/BeanConfigAnnotation_Test.java | 10 +-
.../serializer/SerializerConfigAnnotationTest.java | 12 +++
10 files changed, 272 insertions(+), 138 deletions(-)
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseContext.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseContext.java
index ce64d10..a85a297 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseContext.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanTraverseContext.java
@@ -50,7 +50,8 @@ public abstract class BeanTraverseContext extends BeanContext
{
* <li><b>Session property:</b> <jk>false</jk>
* <li><b>Annotations:</b>
* <ul>
- * <li class='ja'>{@link
org.apache.juneau.annotation.BeanConfig#detectRecursions()}
+ * <li class='ja'>{@link
org.apache.juneau.serializer.annotation.SerializerConfig#detectRecursions()}
+ * <li class='ja'>{@link
org.apache.juneau.jsonschema.annotation.JsonSchemaConfig#detectRecursions()}
* </ul>
* <li><b>Methods:</b>
* <ul>
@@ -77,7 +78,8 @@ public abstract class BeanTraverseContext extends BeanContext
{
* <li><b>Session property:</b> <jk>false</jk>
* <li><b>Annotations:</b>
* <ul>
- * <li class='ja'>{@link
org.apache.juneau.annotation.BeanConfig#ignoreRecursions()}
+ * <li class='ja'>{@link
org.apache.juneau.serializer.annotation.SerializerConfig#ignoreRecursions()}
+ * <li class='ja'>{@link
org.apache.juneau.jsonschema.annotation.JsonSchemaConfig#ignoreRecursions()}
* </ul>
* <li><b>Methods:</b>
* <ul>
@@ -104,7 +106,8 @@ public abstract class BeanTraverseContext extends
BeanContext {
* <li><b>Session property:</b> <jk>false</jk>
* <li><b>Annotations:</b>
* <ul>
- * <li class='ja'>{@link
org.apache.juneau.annotation.BeanConfig#initialDepth()}
+ * <li class='ja'>{@link
org.apache.juneau.serializer.annotation.SerializerConfig#initialDepth()}
+ * <li class='ja'>{@link
org.apache.juneau.jsonschema.annotation.JsonSchemaConfig#initialDepth()}
* </ul>
* <li><b>Methods:</b>
* <ul>
@@ -132,7 +135,8 @@ public abstract class BeanTraverseContext extends
BeanContext {
* <li><b>Session property:</b> <jk>false</jk>
* <li><b>Annotations:</b>
* <ul>
- * <li class='ja'>{@link
org.apache.juneau.annotation.BeanConfig#maxDepth()}
+ * <li class='ja'>{@link
org.apache.juneau.serializer.annotation.SerializerConfig#maxDepth()}
+ * <li class='ja'>{@link
org.apache.juneau.jsonschema.annotation.JsonSchemaConfig#maxDepth()}
* </ul>
* <li><b>Methods:</b>
* <ul>
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfig.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfig.java
index 6418e47..b0164f4 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfig.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfig.java
@@ -22,7 +22,6 @@ import java.util.*;
import org.apache.juneau.*;
import org.apache.juneau.http.header.*;
-import org.apache.juneau.parser.*;
import org.apache.juneau.serializer.*;
import org.apache.juneau.transform.*;
@@ -931,121 +930,4 @@ public @interface BeanConfig {
* </ul>
*/
String useJavaBeanIntrospector() default "";
-
-
//-----------------------------------------------------------------------------------------------------------------
- // BeanTraverseContext
-
//-----------------------------------------------------------------------------------------------------------------
-
- /**
- * Configuration property: Automatically detect POJO recursions.
- *
- * <p>
- * Specifies that recursions should be checked for during traversal.
- *
- * <p>
- * Recursions can occur when traversing models that aren't true trees
but rather contain loops.
- * <br>In general, unchecked recursions cause stack-overflow-errors.
- * <br>These show up as {@link ParseException ParseExceptions} with the
message <js>"Depth too deep. Stack overflow occurred."</js>.
- *
- * <p>
- * The behavior when recursions are detected depends on the value for
{@link BeanTraverseContext#BEANTRAVERSE_ignoreRecursions}.
- *
- * <p>
- * For example, if a model contains the links A->B->C->A, then
the JSON generated will look like
- * the following when <jsf>BEANTRAVERSE_ignoreRecursions</jsf> is
<jk>true</jk>...
- *
- * <p class='bcode w800'>
- * {A:{B:{C:<jk>null</jk>}}}
- * </p>
- *
- * <ul class='notes'>
- * <li>
- * Checking for recursion can cause a small performance
penalty.
- * <li>
- * Possible values:
- * <ul>
- * <li><js>"true"</js>
- * <li><js>"false"</js> (default)
- * </ul>
- * <li>
- * Supports {@doc DefaultVarResolver} (e.g.
<js>"$C{myConfigVar}"</js>).
- * </ul>
- *
- * <ul class='seealso'>
- * <li class='jf'>{@link
BeanTraverseContext#BEANTRAVERSE_detectRecursions}
- * </ul>
- */
- String detectRecursions() default "";
-
- /**
- * Configuration property: Ignore recursion errors.
- *
- * <p>
- * Used in conjunction with {@link
BeanTraverseContext#BEANTRAVERSE_detectRecursions}.
- * <br>Setting is ignored if <jsf>BEANTRAVERSE_detectRecursions</jsf>
is <js>"false"</js>.
- *
- * <p>
- * If <js>"true"</js>, when we encounter the same object when
traversing a tree, we set the value to <jk>null</jk>.
- * <br>Otherwise, a {@link BeanRecursionException} is thrown with the
message <js>"Recursion occurred, stack=..."</js>.
- *
- * <ul class='notes'>
- * <li>
- * Possible values:
- * <ul>
- * <li><js>"true"</js>
- * <li><js>"false"</js> (default)
- * </ul>
- * <li>
- * Supports {@doc DefaultVarResolver} (e.g.
<js>"$C{myConfigVar}"</js>).
- * </ul>
- *
- * <ul class='seealso'>
- * <li class='jf'>{@link
BeanTraverseContext#BEANTRAVERSE_ignoreRecursions}
- * </ul>
- */
- String ignoreRecursions() default "";
-
- /**
- * Configuration property: Initial depth.
- *
- * <p>
- * The initial indentation level at the root.
- * <br>Useful when constructing document fragments that need to be
indented at a certain level.
- *
- * <ul class='notes'>
- * <li>
- * Format: integer
- * <li>
- * Default value: <js>"0"</js>
- * <li>
- * Supports {@doc DefaultVarResolver} (e.g.
<js>"$C{myConfigVar}"</js>).
- * </ul>
- *
- * <ul class='seealso'>
- * <li class='jf'>{@link
BeanTraverseContext#BEANTRAVERSE_initialDepth}
- * </ul>
- */
- String initialDepth() default "";
-
- /**
- * Configuration property: Max traversal depth.
- *
- * <p>
- * Abort traversal if specified depth is reached in the POJO tree.
- * <br>If this depth is exceeded, an exception is thrown.
- *
- * <ul class='notes'>
- * <li>
- * Format: integer
- * <li>
- * Default value: <js>"100"</js>
- * <li>
- * Supports {@doc DefaultVarResolver} (e.g.
<js>"$C{myConfigVar}"</js>).
- * </ul>
- *
- * <ul class='seealso'>
- * <li class='jf'>{@link BeanTraverseContext#BEANTRAVERSE_maxDepth}
- * </ul>
- */
- String maxDepth() default "";
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfigAnnotation.java
index 1fdefc5..fdf7f76 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/BeanConfigAnnotation.java
@@ -13,7 +13,6 @@
package org.apache.juneau.annotation;
import static org.apache.juneau.BeanContext.*;
-import static org.apache.juneau.BeanTraverseContext.*;
import static java.util.Arrays.*;
import java.util.*;
@@ -82,10 +81,6 @@ public class BeanConfigAnnotation {
cpb.setIfNotEmpty(BEAN_useEnumNames,
bool(a.useEnumNames()));
cpb.setIfNotEmpty(BEAN_disableInterfaceProxies,
bool(a.disableInterfaceProxies()));
cpb.setIfNotEmpty(BEAN_useJavaBeanIntrospector,
bool(a.useJavaBeanIntrospector()));
- cpb.setIfNotEmpty(BEANTRAVERSE_detectRecursions,
bool(a.detectRecursions()));
- cpb.setIfNotEmpty(BEANTRAVERSE_ignoreRecursions,
bool(a.ignoreRecursions()));
- cpb.setIfNotEmpty(BEANTRAVERSE_initialDepth,
integer(a.initialDepth(), "initialDepth"));
- cpb.setIfNotEmpty(BEANTRAVERSE_maxDepth,
integer(a.maxDepth(), "maxDepth"));
}
private Locale locale(String in) {
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfig.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfig.java
index a53458d..50fa7df 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfig.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfig.java
@@ -21,6 +21,7 @@ import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
import org.apache.juneau.collections.*;
import org.apache.juneau.jsonschema.*;
+import org.apache.juneau.parser.*;
/**
* Annotation for specifying config properties defined in {@link
JsonSchemaGenerator}.
@@ -237,4 +238,121 @@ public @interface JsonSchemaConfig {
* </ul>
*/
String useBeanDefs() default "";
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // BeanTraverseContext
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Configuration property: Automatically detect POJO recursions.
+ *
+ * <p>
+ * Specifies that recursions should be checked for during traversal.
+ *
+ * <p>
+ * Recursions can occur when traversing models that aren't true trees
but rather contain loops.
+ * <br>In general, unchecked recursions cause stack-overflow-errors.
+ * <br>These show up as {@link ParseException ParseExceptions} with the
message <js>"Depth too deep. Stack overflow occurred."</js>.
+ *
+ * <p>
+ * The behavior when recursions are detected depends on the value for
{@link BeanTraverseContext#BEANTRAVERSE_ignoreRecursions}.
+ *
+ * <p>
+ * For example, if a model contains the links A->B->C->A, then
the JSON generated will look like
+ * the following when <jsf>BEANTRAVERSE_ignoreRecursions</jsf> is
<jk>true</jk>...
+ *
+ * <p class='bcode w800'>
+ * {A:{B:{C:<jk>null</jk>}}}
+ * </p>
+ *
+ * <ul class='notes'>
+ * <li>
+ * Checking for recursion can cause a small performance
penalty.
+ * <li>
+ * Possible values:
+ * <ul>
+ * <li><js>"true"</js>
+ * <li><js>"false"</js> (default)
+ * </ul>
+ * <li>
+ * Supports {@doc DefaultVarResolver} (e.g.
<js>"$C{myConfigVar}"</js>).
+ * </ul>
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link
BeanTraverseContext#BEANTRAVERSE_detectRecursions}
+ * </ul>
+ */
+ String detectRecursions() default "";
+
+ /**
+ * Configuration property: Ignore recursion errors.
+ *
+ * <p>
+ * Used in conjunction with {@link
BeanTraverseContext#BEANTRAVERSE_detectRecursions}.
+ * <br>Setting is ignored if <jsf>BEANTRAVERSE_detectRecursions</jsf>
is <js>"false"</js>.
+ *
+ * <p>
+ * If <js>"true"</js>, when we encounter the same object when
traversing a tree, we set the value to <jk>null</jk>.
+ * <br>Otherwise, a {@link BeanRecursionException} is thrown with the
message <js>"Recursion occurred, stack=..."</js>.
+ *
+ * <ul class='notes'>
+ * <li>
+ * Possible values:
+ * <ul>
+ * <li><js>"true"</js>
+ * <li><js>"false"</js> (default)
+ * </ul>
+ * <li>
+ * Supports {@doc DefaultVarResolver} (e.g.
<js>"$C{myConfigVar}"</js>).
+ * </ul>
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link
BeanTraverseContext#BEANTRAVERSE_ignoreRecursions}
+ * </ul>
+ */
+ String ignoreRecursions() default "";
+
+ /**
+ * Configuration property: Initial depth.
+ *
+ * <p>
+ * The initial indentation level at the root.
+ * <br>Useful when constructing document fragments that need to be
indented at a certain level.
+ *
+ * <ul class='notes'>
+ * <li>
+ * Format: integer
+ * <li>
+ * Default value: <js>"0"</js>
+ * <li>
+ * Supports {@doc DefaultVarResolver} (e.g.
<js>"$C{myConfigVar}"</js>).
+ * </ul>
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link
BeanTraverseContext#BEANTRAVERSE_initialDepth}
+ * </ul>
+ */
+ String initialDepth() default "";
+
+ /**
+ * Configuration property: Max traversal depth.
+ *
+ * <p>
+ * Abort traversal if specified depth is reached in the POJO tree.
+ * <br>If this depth is exceeded, an exception is thrown.
+ *
+ * <ul class='notes'>
+ * <li>
+ * Format: integer
+ * <li>
+ * Default value: <js>"100"</js>
+ * <li>
+ * Supports {@doc DefaultVarResolver} (e.g.
<js>"$C{myConfigVar}"</js>).
+ * </ul>
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanTraverseContext#BEANTRAVERSE_maxDepth}
+ * </ul>
+ */
+ String maxDepth() default "";
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfigAnnotation.java
index ed02a7c..dc03450 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/annotation/JsonSchemaConfigAnnotation.java
@@ -12,6 +12,7 @@
//
***************************************************************************************************************************
package org.apache.juneau.jsonschema.annotation;
+import static org.apache.juneau.BeanTraverseContext.*;
import static org.apache.juneau.jsonschema.JsonSchemaGenerator.*;
import org.apache.juneau.*;
@@ -50,6 +51,10 @@ public class JsonSchemaConfigAnnotation {
cpb.setIf(a.beanDefMapper() !=
BeanDefMapper.Null.class, JSONSCHEMA_beanDefMapper, a.beanDefMapper());
cpb.setIfNotEmpty(JSONSCHEMA_ignoreTypes,
string(a.ignoreTypes()));
cpb.setIfNotEmpty(JSONSCHEMA_useBeanDefs,
bool(a.useBeanDefs()));
+ cpb.setIfNotEmpty(BEANTRAVERSE_detectRecursions,
bool(a.detectRecursions()));
+ cpb.setIfNotEmpty(BEANTRAVERSE_ignoreRecursions,
bool(a.ignoreRecursions()));
+ cpb.setIfNotEmpty(BEANTRAVERSE_initialDepth,
integer(a.initialDepth(), "initialDepth"));
+ cpb.setIfNotEmpty(BEANTRAVERSE_maxDepth,
integer(a.maxDepth(), "maxDepth"));
}
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/annotation/SerializerConfig.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/annotation/SerializerConfig.java
index 1d6daba..e9890e20 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/annotation/SerializerConfig.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/annotation/SerializerConfig.java
@@ -19,6 +19,7 @@ import java.lang.annotation.*;
import org.apache.juneau.*;
import org.apache.juneau.annotation.*;
+import org.apache.juneau.parser.*;
import org.apache.juneau.serializer.*;
/**
@@ -528,4 +529,121 @@ public @interface SerializerConfig {
* </ul>
*/
String useWhitespace() default "";
+
+
//-----------------------------------------------------------------------------------------------------------------
+ // BeanTraverseContext
+
//-----------------------------------------------------------------------------------------------------------------
+
+ /**
+ * Configuration property: Automatically detect POJO recursions.
+ *
+ * <p>
+ * Specifies that recursions should be checked for during traversal.
+ *
+ * <p>
+ * Recursions can occur when traversing models that aren't true trees
but rather contain loops.
+ * <br>In general, unchecked recursions cause stack-overflow-errors.
+ * <br>These show up as {@link ParseException ParseExceptions} with the
message <js>"Depth too deep. Stack overflow occurred."</js>.
+ *
+ * <p>
+ * The behavior when recursions are detected depends on the value for
{@link BeanTraverseContext#BEANTRAVERSE_ignoreRecursions}.
+ *
+ * <p>
+ * For example, if a model contains the links A->B->C->A, then
the JSON generated will look like
+ * the following when <jsf>BEANTRAVERSE_ignoreRecursions</jsf> is
<jk>true</jk>...
+ *
+ * <p class='bcode w800'>
+ * {A:{B:{C:<jk>null</jk>}}}
+ * </p>
+ *
+ * <ul class='notes'>
+ * <li>
+ * Checking for recursion can cause a small performance
penalty.
+ * <li>
+ * Possible values:
+ * <ul>
+ * <li><js>"true"</js>
+ * <li><js>"false"</js> (default)
+ * </ul>
+ * <li>
+ * Supports {@doc DefaultVarResolver} (e.g.
<js>"$C{myConfigVar}"</js>).
+ * </ul>
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link
BeanTraverseContext#BEANTRAVERSE_detectRecursions}
+ * </ul>
+ */
+ String detectRecursions() default "";
+
+ /**
+ * Configuration property: Ignore recursion errors.
+ *
+ * <p>
+ * Used in conjunction with {@link
BeanTraverseContext#BEANTRAVERSE_detectRecursions}.
+ * <br>Setting is ignored if <jsf>BEANTRAVERSE_detectRecursions</jsf>
is <js>"false"</js>.
+ *
+ * <p>
+ * If <js>"true"</js>, when we encounter the same object when
traversing a tree, we set the value to <jk>null</jk>.
+ * <br>Otherwise, a {@link BeanRecursionException} is thrown with the
message <js>"Recursion occurred, stack=..."</js>.
+ *
+ * <ul class='notes'>
+ * <li>
+ * Possible values:
+ * <ul>
+ * <li><js>"true"</js>
+ * <li><js>"false"</js> (default)
+ * </ul>
+ * <li>
+ * Supports {@doc DefaultVarResolver} (e.g.
<js>"$C{myConfigVar}"</js>).
+ * </ul>
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link
BeanTraverseContext#BEANTRAVERSE_ignoreRecursions}
+ * </ul>
+ */
+ String ignoreRecursions() default "";
+
+ /**
+ * Configuration property: Initial depth.
+ *
+ * <p>
+ * The initial indentation level at the root.
+ * <br>Useful when constructing document fragments that need to be
indented at a certain level.
+ *
+ * <ul class='notes'>
+ * <li>
+ * Format: integer
+ * <li>
+ * Default value: <js>"0"</js>
+ * <li>
+ * Supports {@doc DefaultVarResolver} (e.g.
<js>"$C{myConfigVar}"</js>).
+ * </ul>
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link
BeanTraverseContext#BEANTRAVERSE_initialDepth}
+ * </ul>
+ */
+ String initialDepth() default "";
+
+ /**
+ * Configuration property: Max traversal depth.
+ *
+ * <p>
+ * Abort traversal if specified depth is reached in the POJO tree.
+ * <br>If this depth is exceeded, an exception is thrown.
+ *
+ * <ul class='notes'>
+ * <li>
+ * Format: integer
+ * <li>
+ * Default value: <js>"100"</js>
+ * <li>
+ * Supports {@doc DefaultVarResolver} (e.g.
<js>"$C{myConfigVar}"</js>).
+ * </ul>
+ *
+ * <ul class='seealso'>
+ * <li class='jf'>{@link BeanTraverseContext#BEANTRAVERSE_maxDepth}
+ * </ul>
+ */
+ String maxDepth() default "";
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/annotation/SerializerConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/annotation/SerializerConfigAnnotation.java
index a692a90..28f3391 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/annotation/SerializerConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/annotation/SerializerConfigAnnotation.java
@@ -12,6 +12,7 @@
//
***************************************************************************************************************************
package org.apache.juneau.serializer.annotation;
+import static org.apache.juneau.BeanTraverseContext.*;
import static org.apache.juneau.serializer.OutputStreamSerializer.*;
import static org.apache.juneau.serializer.WriterSerializer.*;
@@ -64,6 +65,10 @@ public class SerializerConfigAnnotation {
cpb.setIfNotEmpty(WSERIALIZER_quoteChar,
character(a.quoteChar(), "quoteChar"));
cpb.setIfNotEmpty(WSERIALIZER_streamCharset,
charset(a.streamCharset()));
cpb.setIfNotEmpty(WSERIALIZER_useWhitespace,
bool(a.useWhitespace()));
+ cpb.setIfNotEmpty(BEANTRAVERSE_detectRecursions,
bool(a.detectRecursions()));
+ cpb.setIfNotEmpty(BEANTRAVERSE_ignoreRecursions,
bool(a.ignoreRecursions()));
+ cpb.setIfNotEmpty(BEANTRAVERSE_initialDepth,
integer(a.initialDepth(), "initialDepth"));
+ cpb.setIfNotEmpty(BEANTRAVERSE_maxDepth,
integer(a.maxDepth(), "maxDepth"));
}
private Object charset(String in) {
diff --git
a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RequestEchoResource.java
b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RequestEchoResource.java
index 2f8bbed..8f787b1 100644
---
a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RequestEchoResource.java
+++
b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/RequestEchoResource.java
@@ -23,6 +23,7 @@ import org.apache.juneau.rest.*;
import org.apache.juneau.rest.annotation.*;
import org.apache.juneau.rest.converters.*;
import org.apache.juneau.rest.widget.*;
+import org.apache.juneau.serializer.annotation.*;
import org.apache.juneau.transforms.*;
/**
@@ -67,13 +68,15 @@ import org.apache.juneau.transforms.*;
nowrap="false"
)
@BeanConfig(
- maxDepth="5",
- detectRecursions="true",
swaps={
// Add a special filter for Enumerations
EnumerationSwap.class
}
)
+@SerializerConfig(
+ maxDepth="5",
+ detectRecursions="true"
+)
@Bean(on="HttpServletRequest",interfaceClass=HttpServletRequest.class)
@Bean(on="HttpSession",interfaceClass=HttpSession.class)
@Bean(on="ServletContext",interfaceClass=ServletContext.class)
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/annotation/BeanConfigAnnotation_Test.java
b/juneau-utest/src/test/java/org/apache/juneau/annotation/BeanConfigAnnotation_Test.java
index f8b82ef..7576772 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/annotation/BeanConfigAnnotation_Test.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/annotation/BeanConfigAnnotation_Test.java
@@ -119,18 +119,14 @@ public class BeanConfigAnnotation_Test {
disableBeansRequireSomeProperties="$X{true}",
typePropertyName="$X{foo}",
debug="$X{true}",
- detectRecursions="$X{true}",
disableIgnoreUnknownNullBeanProperties="$X{true}",
disableIgnoreMissingSetters="$X{true}",
disableInterfaceProxies="$X{true}",
findFluentSetters="$X{true}",
ignoreInvocationExceptionsOnGetters="$X{true}",
ignoreInvocationExceptionsOnSetters="$X{true}",
- ignoreRecursions="$X{true}",
ignoreUnknownBeanProperties="$X{true}",
- initialDepth="$X{1}",
locale="$X{en-US}",
- maxDepth="$X{1}",
mediaType="$X{text/foo}",
notBeanClasses={A1.class,A2.class},
notBeanClasses_replace={A1.class,A2.class,A3.class},
@@ -150,7 +146,7 @@ public class BeanConfigAnnotation_Test {
@Test
public void a01_basic() throws Exception {
AnnotationList al = a.getAnnotationList();
- BeanTraverseSession bc =
JsonSerializer.create().applyAnnotations(al, sr).build().createSession();
+ BeanSession bc = JsonSerializer.create().applyAnnotations(al,
sr).build().createSession();
check("PRIVATE", bc.getBeanClassVisibility());
check("PRIVATE", bc.getBeanConstructorVisibility());
@@ -164,17 +160,13 @@ public class BeanConfigAnnotation_Test {
check("false", bc.isBeansRequireSomeProperties());
check("foo", bc.getBeanTypePropertyName());
check("true", bc.isDebug());
- check("true", bc.isDetectRecursions());
check("true", bc.isFindFluentSetters());
check("true", bc.isIgnoreInvocationExceptionsOnGetters());
check("true", bc.isIgnoreInvocationExceptionsOnSetters());
check("false", bc.isIgnoreMissingSetters());
- check("true", bc.isIgnoreRecursions());
check("true", bc.isIgnoreUnknownBeanProperties());
check("false", bc.isIgnoreUnknownNullBeanProperties());
- check("1", bc.getInitialDepth());
check("en_US", bc.getLocale());
- check("1", bc.getMaxDepth());
check("application/json", bc.getMediaType());
check("A1,A2,A3", bc.getNotBeanClasses());
check("foo1,foo2,foo3", bc.getNotBeanPackagesNames());
diff --git
a/juneau-utest/src/test/java/org/apache/juneau/serializer/SerializerConfigAnnotationTest.java
b/juneau-utest/src/test/java/org/apache/juneau/serializer/SerializerConfigAnnotationTest.java
index cb93827..6caee18 100644
---
a/juneau-utest/src/test/java/org/apache/juneau/serializer/SerializerConfigAnnotationTest.java
+++
b/juneau-utest/src/test/java/org/apache/juneau/serializer/SerializerConfigAnnotationTest.java
@@ -58,7 +58,11 @@ public class SerializerConfigAnnotationTest {
addBeanTypes="$X{true}",
addRootType="$X{true}",
binaryFormat="$X{HEX}",
+ detectRecursions="$X{true}",
+ ignoreRecursions="$X{true}",
+ initialDepth="$X{1}",
listener=AA.class,
+ maxDepth="$X{1}",
maxIndent="$X{1}",
quoteChar="$X{'}",
sortCollections="$X{true}",
@@ -81,7 +85,11 @@ public class SerializerConfigAnnotationTest {
JsonSerializerSession x =
JsonSerializer.create().applyAnnotations(al, sr).build().createSession();
check("true", ((SerializerSession)x).isAddBeanTypes());
check("true", x.isAddRootType());
+ check("true", x.isDetectRecursions());
+ check("true", x.isIgnoreRecursions());
+ check("1", x.getInitialDepth());
check("AA", x.getListener());
+ check("1", x.getMaxDepth());
check("1", x.getMaxIndent());
check("'", x.getQuoteChar());
check("true", x.isSortCollections());
@@ -103,7 +111,11 @@ public class SerializerConfigAnnotationTest {
check("true", ((SerializerSession)x).isAddBeanTypes());
check("true", x.isAddRootType());
check("HEX", x.getBinaryFormat());
+ check("true", x.isDetectRecursions());
+ check("true", x.isIgnoreRecursions());
+ check("1", x.getInitialDepth());
check("AA", x.getListener());
+ check("1", x.getMaxDepth());
check("true", x.isSortCollections());
check("true", x.isSortMaps());
check("true", x.isTrimEmptyCollections());