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

commit fbf5760bfb6f591e558d199cf2de03858c5fcf42
Author: JamesBognar <[email protected]>
AuthorDate: Fri Sep 24 15:25:22 2021 -0400

    Context API refactoring.
---
 .../org/apache/juneau/rest/client/RestClient.java  | 29 ++--------------------
 .../juneau/rest/client/RestClientBuilder.java      | 29 +++-------------------
 .../juneau/rest/mock/MockRestClientBuilder.java    |  6 -----
 .../rest/client/RestClient_Logging_Test.java       |  2 --
 4 files changed, 6 insertions(+), 60 deletions(-)

diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
index 8d42a05..068941f 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
@@ -23,6 +23,7 @@ import static java.util.logging.Level.*;
 import static org.apache.juneau.internal.ExceptionUtils.*;
 import static org.apache.juneau.internal.StateMachineState.*;
 import static java.lang.Character.*;
+import static java.util.Optional.*;
 
 import java.io.*;
 import java.lang.reflect.*;
@@ -1021,32 +1022,6 @@ public class RestClient extends BeanContextable 
implements HttpClient, Closeable
        private static final String PREFIX = "RestClient.";
 
        /**
-        * Configuration property:  Console print stream.
-        *
-        * <h5 class='section'>Property:</h5>
-        * <ul class='spaced-list'>
-        *      <li><b>ID:</b>  {@link 
org.apache.juneau.rest.client.RestClient#RESTCLIENT_console RESTCLIENT_console}
-        *      <li><b>Name:</b>  <js>"RestClient.console.o"</js>
-        *      <li><b>System property:</b>  <c>RestClient.console</c>
-        *      <li><b>Data type:</b>
-        *      <ul>
-        *              <li><b>Data type:</b>  <c>Class&lt;? <jk>extends</jk> 
{@link java.io.PrintStream}&gt; | {@link java.io.PrintStream}</c>
-        *      </ul>
-        *      <li><b>Default:</b>  <c>System.<jsf>out</jsf></c>
-        *      <li><b>Methods:</b>
-        *              <ul>
-        *                      <li class='jm'>{@link 
org.apache.juneau.rest.client.RestClientBuilder#console(PrintStream)}
-        *                      <li class='jm'>{@link 
org.apache.juneau.rest.client.RestClientBuilder#console(Class)}
-        *              </ul>
-        * </ul>
-        *
-        * <h5 class='section'>Description:</h5>
-        * <p>
-        * Allows you to redirect the console output to a different print 
stream.
-        */
-       public static final String RESTCLIENT_console = PREFIX + "console.o";
-
-       /**
         * Configuration property:  Executor service.
         *
         * <h5 class='section'>Property:</h5>
@@ -1584,6 +1559,7 @@ public class RestClient extends BeanContextable 
implements HttpClient, Closeable
                rootUri = builder.rootUri;
                errorCodes = builder.errorCodes;
                connectionManager = builder.connectionManager;
+               console = ofNullable(builder.console).orElse(System.err);
 
                ContextProperties cp = 
getContextProperties().copy().apply(getBeanContext().getContextProperties()).build();
 
@@ -1597,7 +1573,6 @@ public class RestClient extends BeanContextable 
implements HttpClient, Closeable
                this.logRequests = cp.getInstance(RESTCLIENT_logRequests, 
DetailLevel.class).orElse(isDebug() ? DetailLevel.FULL : DetailLevel.NONE);
                this.logRequestsLevel = 
cp.getInstance(RESTCLIENT_logRequestsLevel, Level.class).orElse(isDebug() ? 
Level.WARNING : Level.OFF);
                this.logToConsole = 
cp.getBoolean(RESTCLIENT_logToConsole).orElse(isDebug());
-               this.console = cp.getInstance(RESTCLIENT_console, 
PrintStream.class).orElse(System.err);
                this.logRequestsPredicate = 
cp.getInstance(RESTCLIENT_logRequestsPredicate, 
BiPredicate.class).orElse(LOG_REQUESTS_PREDICATE_DEFAULT);
 
                this.serializers = builder.serializerGroupBuilder.build();
diff --git 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClientBuilder.java
 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClientBuilder.java
index 19e385d..fb02940 100644
--- 
a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClientBuilder.java
+++ 
b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClientBuilder.java
@@ -105,6 +105,7 @@ public class RestClientBuilder extends 
BeanContextableBuilder {
        boolean skipEmptyHeaderData, skipEmptyFormData, skipEmptyQueryData;
        Predicate<Integer> errorCodes = x ->  x<=0 || x>=400;
        HttpClientConnectionManager connectionManager;
+       PrintStream console;
 
        SerializerGroup.Builder serializerGroupBuilder;
        ParserGroup.Builder parserGroupBuilder;
@@ -2272,41 +2273,19 @@ public class RestClientBuilder extends 
BeanContextableBuilder {
        
//-----------------------------------------------------------------------------------------------------------------
 
        /**
-        * <i><l>RestClient</l> configuration property:&emsp;</i>  Console 
print stream
+        * Console print stream
         *
         * <p>
         * Allows you to redirect the console output to a different print 
stream.
         *
-        * <ul class='seealso'>
-        *      <li class='jf'>{@link RestClient#RESTCLIENT_console}
-        * </ul>
-        *
-        * @param value
-        *      The new value for this setting.
-        * @return This object (for method chaining).
-        */
-       @FluentSetter
-       public RestClientBuilder console(Class<? extends PrintStream> value) {
-               return set(RESTCLIENT_console, value);
-       }
-
-       /**
-        * <i><l>RestClient</l> configuration property:&emsp;</i>  Console 
print stream
-        *
-        * <p>
-        * Allows you to redirect the console output to a different print 
stream.
-        *
-        * <ul class='seealso'>
-        *      <li class='jf'>{@link RestClient#RESTCLIENT_console}
-        * </ul>
-        *
         * @param value
         *      The new value for this setting.
         * @return This object (for method chaining).
         */
        @FluentSetter
        public RestClientBuilder console(PrintStream value) {
-               return set(RESTCLIENT_console, value);
+               console = value;
+               return this;
        }
 
        /**
diff --git 
a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockRestClientBuilder.java
 
b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockRestClientBuilder.java
index 68691b9..60ebd0e 100644
--- 
a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockRestClientBuilder.java
+++ 
b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockRestClientBuilder.java
@@ -773,12 +773,6 @@ public class MockRestClientBuilder extends 
RestClientBuilder {
        }
 
        @Override /* GENERATED - RestClientBuilder */
-       public MockRestClientBuilder console(Class<? extends 
java.io.PrintStream> value) {
-               super.console(value);
-               return this;
-       }
-
-       @Override /* GENERATED - RestClientBuilder */
        public MockRestClientBuilder 
contentDecoderRegistry(Map<String,InputStreamFactory> contentDecoderMap) {
                super.contentDecoderRegistry(contentDecoderMap);
                return this;
diff --git 
a/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Logging_Test.java
 
b/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Logging_Test.java
index 8520b5d..159d97c 100644
--- 
a/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Logging_Test.java
+++ 
b/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Logging_Test.java
@@ -134,8 +134,6 @@ public class RestClient_Logging_Test {
                
clientPlain().logRequests(DetailLevel.FULL,Level.SEVERE,(req,res)->false).logToConsole().logger(l).console(c).build().post("/stream",new
 InputStreamEntity(inputStream("foo"))).complete();
                c.assertContents().isEmpty();
                c.reset();
-
-               
client().logRequests(DetailLevel.NONE,Level.SEVERE,null).logToConsole().logger(l).console(MockConsole.class).build().post("/bean",bean).complete();
        }
 
        @Test

Reply via email to