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 5c37f3d  Context API refactoring.
5c37f3d is described below

commit 5c37f3d19646c0f04cade13a72f7550dd9faad43
Author: JamesBognar <[email protected]>
AuthorDate: Thu Sep 9 19:42:56 2021 -0400

    Context API refactoring.
---
 .../java/org/apache/juneau/rest/RestContext.java   | 67 +---------------------
 .../org/apache/juneau/rest/RestContextBuilder.java | 17 ++----
 .../org/apache/juneau/rest/annotation/Rest.java    |  4 --
 .../juneau/rest/annotation/RestAnnotation.java     |  4 +-
 4 files changed, 8 insertions(+), 84 deletions(-)

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 adf7c27..0e0f741 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
@@ -238,71 +238,6 @@ public class RestContext extends BeanContext {
         */
        public static final String REST_messages = PREFIX + ".messages.lo";
 
-       /**
-        * Configuration property:  Render response stack traces in responses.
-        *
-        * <h5 class='section'>Property:</h5>
-        * <ul class='spaced-list'>
-        *      <li><b>ID:</b>  {@link 
org.apache.juneau.rest.RestContext#REST_renderResponseStackTraces 
REST_renderResponseStackTraces}
-        *      <li><b>Name:</b>  
<js>"RestContext.renderResponseStackTraces.b"</js>
-        *      <li><b>Data type:</b>  <jk>boolean</jk>
-        *      <li><b>System property:</b>  
<c>RestContext.renderResponseStackTraces</c>
-        *      <li><b>Environment variable:</b>  
<c>RESTCONTEXT_RENDERRESPONSESTACKTRACES</c>
-        *      <li><b>Default:</b>  <jk>false</jk>
-        *      <li><b>Session property:</b>  <jk>false</jk>
-        *      <li><b>Annotations:</b>
-        *              <ul>
-        *                      <li class='ja'>{@link 
org.apache.juneau.rest.annotation.Rest#renderResponseStackTraces()}
-        *              </ul>
-        *      <li><b>Methods:</b>
-        *              <ul>
-        *                      <li class='jm'>{@link 
org.apache.juneau.rest.RestContextBuilder#renderResponseStackTraces(boolean)}
-        *                      <li class='jm'>{@link 
org.apache.juneau.rest.RestContextBuilder#renderResponseStackTraces()}
-        *              </ul>
-        * </ul>
-        *
-        * <h5 class='section'>Description:</h5>
-        * <p>
-        * Render stack traces in HTTP response bodies when errors occur.
-        *
-        * <h5 class='section'>Example:</h5>
-        * <p class='bcode w800'>
-        *      <jc>// Option #1 - Defined via annotation.</jc>
-        *      <ja>@Rest</ja>(renderResponseStackTraces=<jk>true</jk>)
-        *      <jk>public class</jk> MyResource {
-        *
-        *              <jc>// Option #2 - Defined via builder passed in 
through resource constructor.</jc>
-        *              <jk>public</jk> MyResource(RestContextBuilder 
<jv>builder</jv>) <jk>throws</jk> Exception {
-        *
-        *                      <jc>// Using method on builder.</jc>
-        *                      <jv>builder</jv>.renderResponseStackTraces();
-        *
-        *                      <jc>// Same, but using property.</jc>
-        *                      
<jv>builder</jv>.set(<jsf>REST_renderResponseStackTraces</jsf>);
-        *              }
-        *
-        *              <jc>// Option #3 - Defined via builder passed in 
through init method.</jc>
-        *              <ja>@RestHook</ja>(<jsf>INIT</jsf>)
-        *              <jk>public void</jk> init(RestContextBuilder 
<jv>builder</jv>) <jk>throws</jk> Exception {
-        *                      <jv>builder</jv>.renderResponseStackTraces();
-        *              }
-        *      }
-        * </p>
-        *
-        * <ul class='notes'>
-        *      <li>
-        *              Useful for debugging, although allowing stack traces to 
be rendered may cause security concerns so use
-        *              caution when enabling.
-        *      <li>
-        *              This setting is available through the following method:
-        *              <ul>
-        *                      <li class='jm'>{@link 
RestContext#isRenderResponseStackTraces() 
RestContext.isRenderResponseStackTraces()}
-        *              </ul>
-        *              That method is used by {@link #handleError(RestCall, 
Throwable)}.
-        * </ul>
-        */
-       public static final String REST_renderResponseStackTraces = PREFIX + 
".renderResponseStackTraces.b";
-
        
//-------------------------------------------------------------------------------------------------------------------
        // Static
        
//-------------------------------------------------------------------------------------------------------------------
@@ -518,7 +453,7 @@ public class RestContext extends BeanContext {
                        allowedHeaderParams = 
newCaseInsensitiveSet(ofNullable(builder.allowedHeaderParams).map(x -> 
"NONE".equals(x) ? "" : x).orElse(""));
                        allowedMethodParams = 
newCaseInsensitiveSet(ofNullable(builder.allowedMethodParams).map(x -> 
"NONE".equals(x) ? "" : x).orElse(""));
                        allowedMethodHeaders = 
newCaseInsensitiveSet(ofNullable(builder.allowedMethodHeaders).map(x -> 
"NONE".equals(x) ? "" : x).orElse(""));
-                       renderResponseStackTraces = 
cp.getBoolean(REST_renderResponseStackTraces).orElse(false);
+                       renderResponseStackTraces = 
builder.renderResponseStackTraces;
                        clientVersionHeader = builder.clientVersionHeader;
                        defaultCharset = builder.defaultCharset;
                        maxInput = builder.maxInput;
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 12552cf..834b1c9 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
@@ -129,7 +129,8 @@ public class RestContextBuilder extends BeanContextBuilder 
implements ServletCon
        Charset defaultCharset = env("RestContext.defaultCharset", 
IOUtils.UTF8);
        long maxInput = parseLongWithSuffix(env("RestContext.maxInput", 
"100M"));
        List<MediaType> consumes, produces;
-       Boolean disableBodyParam = env("RestContext.disableBodyParam", false);
+       boolean disableBodyParam = env("RestContext.disableBodyParam", false);
+       boolean renderResponseStackTraces = 
env("RestContext.renderResponseStackTraces", false);
 
        Class<? extends RestChildren> childrenClass = RestChildren.class;
        Class<? extends RestOpContext> opContextClass = RestOpContext.class;
@@ -1952,10 +1953,6 @@ public class RestContextBuilder extends 
BeanContextBuilder implements ServletCon
         * <p>
         * Render stack traces in HTTP response bodies when errors occur.
         *
-        * <ul class='seealso'>
-        *      <li class='jf'>{@link 
RestContext#REST_renderResponseStackTraces}
-        * </ul>
-        *
         * @param value
         *      The new value for this setting.
         *      <br>The default is <jk>false</jk>.
@@ -1963,7 +1960,8 @@ public class RestContextBuilder extends 
BeanContextBuilder implements ServletCon
         */
        @FluentSetter
        public RestContextBuilder renderResponseStackTraces(boolean value) {
-               return set(REST_renderResponseStackTraces, value);
+               renderResponseStackTraces = value;
+               return this;
        }
 
        /**
@@ -1972,15 +1970,12 @@ public class RestContextBuilder extends 
BeanContextBuilder implements ServletCon
         * <p>
         * Shortcut for calling 
<code>renderResponseStackTraces(<jk>true</jk>)</code>.
         *
-        * <ul class='seealso'>
-        *      <li class='jf'>{@link 
RestContext#REST_renderResponseStackTraces}
-        * </ul>
-        *
         * @return This object (for method chaining).
         */
        @FluentSetter
        public RestContextBuilder renderResponseStackTraces() {
-               return set(REST_renderResponseStackTraces);
+               renderResponseStackTraces = true;
+               return this;
        }
 
        /**
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Rest.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Rest.java
index 21cf019..b30bbfe 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Rest.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/Rest.java
@@ -987,10 +987,6 @@ public @interface Rest {
         *              Supports {@doc RestSvlVariables}
         *              (e.g. <js>"$L{my.localized.variable}"</js>).
         * </ul>
-        *
-        * <ul class='seealso'>
-        *      <li class='jf'>{@link 
RestContext#REST_renderResponseStackTraces}
-        * </ul>
         */
        String renderResponseStackTraces() default "";
 
diff --git 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestAnnotation.java
 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestAnnotation.java
index 6fdd1f1..ffb8acc 100644
--- 
a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestAnnotation.java
+++ 
b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/annotation/RestAnnotation.java
@@ -1077,7 +1077,7 @@ public class RestAnnotation {
                        string(a.allowedHeaderParams()).ifPresent(x -> 
b.allowedHeaderParams(x));
                        string(a.allowedMethodHeaders()).ifPresent(x -> 
b.allowedMethodHeaders(x));
                        string(a.allowedMethodParams()).ifPresent(x -> 
b.allowedMethodParams(x));
-                       bool(a.renderResponseStackTraces()).ifPresent(x -> 
b.set(REST_renderResponseStackTraces, x));
+                       bool(a.renderResponseStackTraces()).ifPresent(x -> 
b.renderResponseStackTraces(x));
                        
string(a.debug()).map(Enablement::fromString).ifPresent(x -> b.debug(x));
                        string(a.debugOn()).ifPresent(x -> b.debugOn(x));
                }
@@ -1101,8 +1101,6 @@ public class RestAnnotation {
                public void apply(AnnotationInfo<Rest> ai, RestOpContextBuilder 
b) {
                        Rest a = ai.getAnnotation();
 
-//                     type(a.partSerializer()).ifPresent(x -> 
b.set(REST_partSerializer, x));
-//                     type(a.partParser()).ifPresent(x -> 
b.set(REST_partParser, x));
                        strings(a.produces()).map(MediaType::of).forEach(x -> 
b.produces(x));
                        strings(a.consumes()).map(MediaType::of).forEach(x -> 
b.consumes(x));
                        b.converters(a.converters());

Reply via email to