001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.rest.client; 014 015import static org.apache.juneau.internal.StringUtils.*; 016import static org.apache.juneau.parser.InputStreamParser.*; 017import static org.apache.juneau.parser.ReaderParser.*; 018import static org.apache.juneau.rest.client.RestClient.*; 019import static org.apache.juneau.BeanTraverseContext.*; 020import static org.apache.juneau.serializer.OutputStreamSerializer.*; 021import static org.apache.juneau.serializer.WriterSerializer.*; 022import static org.apache.juneau.uon.UonSerializer.*; 023 024import java.lang.annotation.*; 025import java.lang.reflect.*; 026import java.net.*; 027import java.net.URI; 028import java.security.*; 029import java.util.*; 030import java.util.concurrent.*; 031import java.util.logging.*; 032 033import javax.net.ssl.*; 034 035import org.apache.http.*; 036import org.apache.http.auth.*; 037import org.apache.http.client.*; 038import org.apache.http.client.CookieStore; 039import org.apache.http.client.config.*; 040import org.apache.http.client.entity.*; 041import org.apache.http.config.*; 042import org.apache.http.conn.*; 043import org.apache.http.conn.routing.*; 044import org.apache.http.conn.socket.*; 045import org.apache.http.conn.ssl.*; 046import org.apache.http.conn.util.*; 047import org.apache.http.cookie.*; 048import org.apache.http.impl.client.*; 049import org.apache.http.impl.conn.*; 050import org.apache.http.protocol.*; 051import org.apache.juneau.*; 052import org.apache.juneau.html.*; 053import org.apache.juneau.http.*; 054import org.apache.juneau.httppart.*; 055import org.apache.juneau.internal.*; 056import org.apache.juneau.json.*; 057import org.apache.juneau.marshall.*; 058import org.apache.juneau.msgpack.*; 059import org.apache.juneau.oapi.*; 060import org.apache.juneau.parser.*; 061import org.apache.juneau.plaintext.*; 062import org.apache.juneau.reflect.*; 063import org.apache.juneau.serializer.*; 064import org.apache.juneau.svl.*; 065import org.apache.juneau.uon.*; 066import org.apache.juneau.urlencoding.*; 067import org.apache.juneau.xml.*; 068 069/** 070 * Builder class for the {@link RestClient} class. 071 * 072 * <p> 073 * Instances of this class are created by the following methods: 074 * <ul> 075 * <li>{@link RestClient#create()} - Create from scratch. 076 * <li>{@link RestClient#create(Serializer,Parser)} - Create from scratch using specified serializer/parser. 077 * <li>{@link RestClient#create(Class,Class)} - Create from scratch using specified serializer/parser classes. 078 * <li>{@link RestClient#builder()} - Copy settings from an existing client. 079 * </ul> 080 * 081 * <ul class='seealso'> 082 * <li class='link'>{@doc juneau-rest-client} 083 * </ul> 084 * 085 * @deprecated Use {@link org.apache.juneau.rest.client2.RestClientBuilder} 086 */ 087@Deprecated 088public class RestClientBuilder extends BeanContextBuilder { 089 090 private HttpClientBuilder httpClientBuilder; 091 private CloseableHttpClient httpClient; 092 093 // Deprecated 094 @Deprecated private HttpClientConnectionManager httpClientConnectionManager; 095 @Deprecated private boolean enableSsl = false; 096 @Deprecated private HostnameVerifier hostnameVerifier; 097 @Deprecated private KeyManager[] keyManagers; 098 @Deprecated private TrustManager[] trustManagers; 099 @Deprecated private SecureRandom secureRandom; 100 @Deprecated private String[] sslProtocols, cipherSuites; 101 @Deprecated private boolean pooled; 102 103 /** 104 * Constructor. 105 * @param ps 106 * Initial configuration properties for this builder. 107 * <br>Can be <jk>null</jk>. 108 * @param httpClientBuilder 109 * The HTTP client builder to use for this REST client builder. 110 * <br>Can be <jk>null</jk> to just call {@link #createHttpClientBuilder()} to instantiate it again. 111 */ 112 protected RestClientBuilder(PropertyStore ps, HttpClientBuilder httpClientBuilder) { 113 super(ps); 114 this.httpClientBuilder = httpClientBuilder != null ? httpClientBuilder : createHttpClientBuilder(); 115 } 116 117 @Override /* ContextBuilder */ 118 public RestClient build() { 119 return new RestClient(this); 120 } 121 122 //------------------------------------------------------------------------------------------------------------------ 123 // Convenience marshalling support methods. 124 //------------------------------------------------------------------------------------------------------------------ 125 126 /** 127 * Convenience method for specifying JSON as the transmission media type. 128 * 129 * <p> 130 * Identical to calling <code>serializer(JsonSerializer.<jk>class</jk>).parser(JsonParser.<jk>class</jk>)</code>. 131 * 132 * @return This object (for method chaining). 133 */ 134 public RestClientBuilder json() { 135 return serializer(JsonSerializer.class).parser(JsonParser.class); 136 } 137 138 /** 139 * Convenience method for specifying Simple JSON as the transmission media type. 140 * 141 * <p> 142 * Identical to calling <code>serializer(SimpleJsonSerializer.<jk>class</jk>).parser(JsonParser.<jk>class</jk>)</code>. 143 * 144 * @return This object (for method chaining). 145 */ 146 public RestClientBuilder simpleJson() { 147 return serializer(SimpleJsonSerializer.class).parser(JsonParser.class); 148 } 149 150 /** 151 * Convenience method for specifying XML as the transmission media type. 152 * 153 * <p> 154 * Identical to calling <code>serializer(XmlSerializer.<jk>class</jk>).parser(XmlParser.<jk>class</jk>)</code>. 155 * 156 * @return This object (for method chaining). 157 */ 158 public RestClientBuilder xml() { 159 return serializer(XmlSerializer.class).parser(XmlParser.class); 160 } 161 162 /** 163 * Convenience method for specifying HTML as the transmission media type. 164 * 165 * <p> 166 * Identical to calling <code>serializer(HtmlSerializer.<jk>class</jk>).parser(HtmlParser.<jk>class</jk>)</code>. 167 * 168 * @return This object (for method chaining). 169 */ 170 public RestClientBuilder html() { 171 return serializer(HtmlSerializer.class).parser(HtmlParser.class); 172 } 173 174 /** 175 * Convenience method for specifying plain-text as the transmission media type. 176 * 177 * <p> 178 * Identical to calling <code>serializer(PlainTextSerializer.<jk>class</jk>).parser(PlainTextParser.<jk>class</jk>)</code>. 179 * 180 * @return This object (for method chaining). 181 */ 182 public RestClientBuilder plainText() { 183 return serializer(PlainTextSerializer.class).parser(PlainTextParser.class); 184 } 185 186 /** 187 * Convenience method for specifying MessagePack as the transmission media type. 188 * 189 * <p> 190 * Identical to calling <code>serializer(MsgPackSerializer.<jk>class</jk>).parser(MsgPackParser.<jk>class</jk>)</code>. 191 * 192 * @return This object (for method chaining). 193 */ 194 public RestClientBuilder msgpack() { 195 return serializer(MsgPackSerializer.class).parser(MsgPackParser.class); 196 } 197 198 /** 199 * Convenience method for specifying UON as the transmission media type. 200 * 201 * <p> 202 * Identical to calling <code>serializer(UonSerializer.<jk>class</jk>).parser(UonParser.<jk>class</jk>)</code>. 203 * 204 * @return This object (for method chaining). 205 */ 206 public RestClientBuilder uon() { 207 return serializer(UonSerializer.class).parser(UonParser.class); 208 } 209 210 /** 211 * Convenience method for specifying URL-Encoding as the transmission media type. 212 * 213 * <p> 214 * Identical to calling <code>serializer(UrlEncodingSerializer.<jk>class</jk>).parser(UrlEncodingParser.<jk>class</jk>)</code>. 215 * 216 * @return This object (for method chaining). 217 */ 218 public RestClientBuilder urlEnc() { 219 return serializer(UrlEncodingSerializer.class).parser(UrlEncodingParser.class); 220 } 221 222 /** 223 * Convenience method for specifying URL-Encoding as the transmission media type. 224 * 225 * <p> 226 * Identical to calling <code>serializer(OpenApiSerializer.<jk>class</jk>).parser(OpenApiParser.<jk>class</jk>)</code>. 227 * 228 * @return This object (for method chaining). 229 */ 230 public RestClientBuilder openapi() { 231 return serializer(OpenApiSerializer.class).parser(OpenApiParser.class); 232 } 233 234 //------------------------------------------------------------------------------------------------------------------ 235 // HttpClientBuilder 236 //------------------------------------------------------------------------------------------------------------------ 237 238 /** 239 * Creates an instance of an {@link HttpClientBuilder} to be used to create the {@link HttpClient}. 240 * 241 * <p> 242 * Subclasses can override this method to provide their own client builder. 243 * The builder can also be specified using the {@link #httpClientBuilder(HttpClientBuilder)} method. 244 * 245 * <p> 246 * The predefined method returns an {@link HttpClientBuilder} with the following settings: 247 * <ul> 248 * <li>Lax redirect strategy. 249 * </ul> 250 * 251 * @return The HTTP client builder to use to create the HTTP client. 252 */ 253 protected HttpClientBuilder createHttpClientBuilder() { 254 return HttpClientBuilder.create().setRedirectStrategy(new AllowAllRedirects()); 255 } 256 257 /** 258 * Returns the {@link HttpClientBuilder} that will be used to create the {@link HttpClient} used by {@link RestClient}. 259 * 260 * <p> 261 * This method can be used to make customizations to the {@link HttpClient}. 262 * 263 * <p> 264 * If not set via {@link #httpClientBuilder(HttpClientBuilder)}, then this object is the one created by {@link #createHttpClientBuilder()}. 265 * 266 * @return The {@link HttpClientBuilder} that will be used to create the {@link HttpClient} used by {@link RestClient}. 267 */ 268 public HttpClientBuilder getHttpClientBuilder() { 269 if (httpClientBuilder == null) 270 httpClientBuilder = createHttpClientBuilder(); 271 return httpClientBuilder; 272 } 273 274 /** 275 * Sets the {@link HttpClientBuilder} that will be used to create the {@link HttpClient} used by {@link RestClient}. 276 * 277 * <p> 278 * This can be used to bypass the builder created by {@link #createHttpClientBuilder()} method. 279 * 280 * @param value The {@link HttpClientBuilder} that will be used to create the {@link HttpClient} used by {@link RestClient}. 281 * @return This object (for method chaining). 282 */ 283 public RestClientBuilder httpClientBuilder(HttpClientBuilder value) { 284 this.httpClientBuilder = value; 285 return this; 286 } 287 288 //------------------------------------------------------------------------------------------------------------------ 289 // HttpClient 290 //------------------------------------------------------------------------------------------------------------------ 291 292 /** 293 * Creates an instance of an {@link HttpClient} to be used to handle all HTTP communications with the target server. 294 * 295 * <p> 296 * This HTTP client is used when the HTTP client is not specified through one of the constructors or the 297 * {@link #httpClient(CloseableHttpClient, boolean)} method. 298 * 299 * <p> 300 * Subclasses can override this method to provide specially-configured HTTP clients to handle stuff such as 301 * SSL/TLS certificate handling, authentication, etc. 302 * 303 * <p> 304 * The default implementation returns an instance of {@link HttpClient} using the client builder returned by 305 * {@link #createHttpClientBuilder()}. 306 * 307 * @return The HTTP client to use. 308 * @throws Exception Error occurred. 309 */ 310 protected CloseableHttpClient createHttpClient() throws Exception { 311 // Don't call createConnectionManager() if RestClient.setConnectionManager() was called. 312 if (httpClientConnectionManager == null) 313 httpClientBuilder.setConnectionManager(createConnectionManager()); 314 else 315 httpClientBuilder.setConnectionManager(httpClientConnectionManager); 316 return httpClientBuilder.build(); 317 } 318 319 /** 320 * Returns the {@link HttpClient} to be used to handle all HTTP communications with the target server. 321 * 322 * @return The {@link HttpClient} to be used to handle all HTTP communications with the target server. 323 */ 324 public CloseableHttpClient getHttpClient() { 325 try { 326 return httpClient != null ? httpClient : createHttpClient(); 327 } catch (Exception e) { 328 throw new RuntimeException(e); 329 } 330 } 331 332 /** 333 * Sets the {@link HttpClient} to be used to handle all HTTP communications with the target server. 334 * 335 * <p> 336 * This can be used to bypass the client created by {@link #createHttpClient()} method. 337 * 338 * @param value The {@link HttpClient} to be used to handle all HTTP communications with the target server. 339 * @return This object (for method chaining). 340 */ 341 public RestClientBuilder httpClient(CloseableHttpClient value) { 342 this.httpClient = value; 343 return this; 344 } 345 346 /** 347 * Sets the internal {@link HttpClient} to use for handling HTTP communications. 348 * 349 * <div class='warn'> 350 * <b>Deprecated</b> - Use {@link #httpClient(CloseableHttpClient)} and {@link #keepHttpClientOpen(boolean)} 351 * </div> 352 * 353 * @param httpClient The HTTP client. 354 * @param keepHttpClientOpen Don't close this client when the {@link RestClient#close()} method is called. 355 * @return This object (for method chaining). 356 */ 357 @Deprecated 358 public RestClientBuilder httpClient(CloseableHttpClient httpClient, boolean keepHttpClientOpen) { 359 this.httpClient = httpClient; 360 set(RESTCLIENT_keepHttpClientOpen, keepHttpClientOpen); 361 return this; 362 } 363 364 //------------------------------------------------------------------------------------------------------------------ 365 // Logging. 366 //------------------------------------------------------------------------------------------------------------------ 367 368 /** 369 * Adds a {@link RestCallLogger} to the list of interceptors on this class. 370 * 371 * @param level The log level to log messages at. 372 * @param log The logger to log messages to. 373 * @return This object (for method chaining). 374 */ 375 public RestClientBuilder logTo(Level level, Logger log) { 376 return interceptors(new RestCallLogger(level, log)); 377 } 378 379 /** 380 * Sets the internal {@link HttpClientConnectionManager}. 381 * 382 * @param httpClientConnectionManager The HTTP client connection manager. 383 * @return This object (for method chaining). 384 */ 385 public RestClientBuilder httpClientConnectionManager(HttpClientConnectionManager httpClientConnectionManager) { 386 this.httpClientConnectionManager = httpClientConnectionManager; 387 return this; 388 } 389 390 //------------------------------------------------------------------------------------------------------------------ 391 // Deprecated HttpClientBuilder methods. 392 //------------------------------------------------------------------------------------------------------------------ 393 394 /** 395 * Creates the {@link HttpClientConnectionManager} returned by {@link #createConnectionManager()}. 396 * 397 * <div class='warn'> 398 * <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)} 399 * </div> 400 * 401 * <p> 402 * Subclasses can override this method to provide their own connection manager. 403 * 404 * <p> 405 * The default implementation returns an instance of a {@link PoolingHttpClientConnectionManager}. 406 * 407 * @return The HTTP client builder to use to create the HTTP client. 408 * @throws NoSuchAlgorithmException Unknown cryptographic algorithm. 409 * @throws KeyManagementException General key management exception. 410 */ 411 @SuppressWarnings("resource") 412 @Deprecated 413 protected HttpClientConnectionManager createConnectionManager() throws KeyManagementException, NoSuchAlgorithmException { 414 if (enableSsl) { 415 416 HostnameVerifier hv = hostnameVerifier != null ? hostnameVerifier : new DefaultHostnameVerifier(); 417 TrustManager[] tm = trustManagers; 418 String[] sslp = sslProtocols == null ? getDefaultProtocols() : sslProtocols; 419 SecureRandom sr = secureRandom; 420 KeyManager[] km = keyManagers; 421 String[] cs = cipherSuites; 422 423 RegistryBuilder<ConnectionSocketFactory> rb = RegistryBuilder.<ConnectionSocketFactory>create(); 424 rb.register("http", PlainConnectionSocketFactory.getSocketFactory()); 425 426 SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom().build(); 427 sslContext.init(km, tm, sr); 428 429 SSLConnectionSocketFactory sslcsf = new SSLConnectionSocketFactory(sslContext, sslp, cs, hv); 430 rb.register("https", sslcsf).build(); 431 432 return (pooled ? new PoolingHttpClientConnectionManager(rb.build()) : new BasicHttpClientConnectionManager(rb.build())); 433 } 434 435 // Using pooling connection so that this client is threadsafe. 436 return (pooled ? new PoolingHttpClientConnectionManager() : new BasicHttpClientConnectionManager()); 437 } 438 439 private static String[] getDefaultProtocols() { 440 String sp = System.getProperty("transport.client.protocol"); 441 if (isEmpty(sp)) 442 return new String[] {"SSL_TLS","TLS","SSL"}; 443 return StringUtils.split(sp, ','); 444 } 445 446 /** 447 * Enable SSL support on this client. 448 * 449 * <div class='warn'> 450 * <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)} 451 * </div> 452 * 453 * <p> 454 * Used in conjunction with the following methods for setting up SSL parameters: 455 * <ul class='javatree'> 456 * <li class='jf'>{@link #sslProtocols(String...)} 457 * <li class='jf'>{@link #cipherSuites(String...)} 458 * <li class='jf'>{@link #hostnameVerifier(HostnameVerifier)} 459 * <li class='jf'>{@link #keyManagers(KeyManager...)} 460 * <li class='jf'>{@link #trustManagers(TrustManager...)} 461 * <li class='jf'>{@link #secureRandom(SecureRandom)} 462 * </ul> 463 * 464 * @return This object (for method chaining). 465 */ 466 @Deprecated 467 public RestClientBuilder enableSSL() { 468 this.enableSsl = true; 469 return this; 470 } 471 472 /** 473 * Enable LARestClientBuilder SSL support. 474 * 475 * <div class='warn'> 476 * <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)} 477 * </div> 478 * 479 * <p> 480 * Same as calling the following: 481 * <p class='bcode w800'> 482 * builder 483 * .enableSSL() 484 * .hostnameVerifier(<jk>new</jk> NoopHostnameVerifier()) 485 * .trustManagers(<jk>new</jk> SimpleX509TrustManager(<jk>true</jk>)); 486 * </p> 487 * 488 * @return This object (for method chaining). 489 * @throws KeyStoreException Generic keystore exception. 490 * @throws NoSuchAlgorithmException Unknown cryptographic algorithm. 491 */ 492 @Deprecated 493 public RestClientBuilder enableLaxSSL() throws KeyStoreException, NoSuchAlgorithmException { 494 this.enableSsl = true; 495 hostnameVerifier(new NoopHostnameVerifier()); 496 trustManagers(new SimpleX509TrustManager(true)); 497 return this; 498 } 499 500 /** 501 * Supported SSL protocols. 502 * 503 * <div class='warn'> 504 * <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)} 505 * </div> 506 * 507 * <p> 508 * This is the value passed to the <c>supportedProtocols</c> parameter of the 509 * {@link SSLConnectionSocketFactory#SSLConnectionSocketFactory(SSLContext,String[],String[],HostnameVerifier)} 510 * constructor. 511 * 512 * <p> 513 * The default value is taken from the system property <js>"transport.client.protocol"</js>. 514 * <br>If system property is not defined, defaults to <code>{<js>"SSL_TLS"</js>,<js>"TLS"</js>,<js>"SSL"</js>}</code>. 515 * 516 * <p> 517 * This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager 518 * has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}. 519 * 520 * @param sslProtocols The supported SSL protocols. 521 * @return This object (for method chaining). 522 */ 523 @Deprecated 524 public RestClientBuilder sslProtocols(String...sslProtocols) { 525 this.sslProtocols = sslProtocols; 526 return this; 527 } 528 529 /** 530 * Supported cipher suites. 531 * 532 * <div class='warn'> 533 * <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)} 534 * </div> 535 * 536 * <p> 537 * This is the value passed to the <c>supportedCipherSuites</c> parameter of the 538 * {@link SSLConnectionSocketFactory#SSLConnectionSocketFactory(SSLContext,String[],String[],HostnameVerifier)} 539 * constructor. 540 * 541 * <p> 542 * The default value is <jk>null</jk>. 543 * 544 * <p> 545 * This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager 546 * has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}. 547 * 548 * @param cipherSuites The supported cipher suites. 549 * @return This object (for method chaining). 550 */ 551 @Deprecated 552 public RestClientBuilder cipherSuites(String...cipherSuites) { 553 this.cipherSuites = cipherSuites; 554 return this; 555 } 556 557 /** 558 * Hostname verifier. 559 * 560 * <div class='warn'> 561 * <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)} 562 * </div> 563 * 564 * <p> 565 * This is the value passed to the <c>hostnameVerifier</c> parameter of the 566 * {@link SSLConnectionSocketFactory#SSLConnectionSocketFactory(SSLContext,String[],String[],HostnameVerifier)} 567 * constructor. 568 * 569 * <p> 570 * The default value is <jk>null</jk>. 571 * 572 * <p> 573 * This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager 574 * has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}. 575 * 576 * @param hostnameVerifier The hostname verifier. 577 * @return This object (for method chaining). 578 */ 579 @Deprecated 580 public RestClientBuilder hostnameVerifier(HostnameVerifier hostnameVerifier) { 581 this.hostnameVerifier = hostnameVerifier; 582 return this; 583 } 584 585 /** 586 * Key managers. 587 * 588 * <div class='warn'> 589 * <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)} 590 * </div> 591 * 592 * <p> 593 * This is the value passed to the <c>keyManagers</c> parameter of the 594 * {@link SSLContext#init(KeyManager[],TrustManager[],SecureRandom)} method. 595 * 596 * <p> 597 * The default value is <jk>null</jk>. 598 * 599 * <p> 600 * This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager 601 * has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}. 602 * 603 * @param keyManagers The key managers. 604 * @return This object (for method chaining). 605 */ 606 @Deprecated 607 public RestClientBuilder keyManagers(KeyManager...keyManagers) { 608 this.keyManagers = keyManagers; 609 return this; 610 } 611 612 /** 613 * Trust managers. 614 * 615 * <div class='warn'> 616 * <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)} 617 * </div> 618 * 619 * <p> 620 * This is the value passed to the <c>trustManagers</c> parameter of the 621 * {@link SSLContext#init(KeyManager[],TrustManager[],SecureRandom)} method. 622 * 623 * <p> 624 * The default value is <jk>null</jk>. 625 * 626 * <p> 627 * This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager 628 * has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}. 629 * 630 * @param trustManagers The trust managers. 631 * @return This object (for method chaining). 632 */ 633 @Deprecated 634 public RestClientBuilder trustManagers(TrustManager...trustManagers) { 635 this.trustManagers = trustManagers; 636 return this; 637 } 638 639 /** 640 * Trust managers. 641 * 642 * <div class='warn'> 643 * <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)} 644 * </div> 645 * 646 * <p> 647 * This is the value passed to the <c>random</c> parameter of the 648 * {@link SSLContext#init(KeyManager[],TrustManager[],SecureRandom)} method. 649 * 650 * <p> 651 * The default value is <jk>null</jk>. 652 * 653 * <p> 654 * This method is effectively ignored if {@link #enableSSL()} has not been called or the client connection manager 655 * has been defined via {@link #httpClientConnectionManager(HttpClientConnectionManager)}. 656 * 657 * @param secureRandom The random number generator. 658 * @return This object (for method chaining). 659 */ 660 @Deprecated 661 public RestClientBuilder secureRandom(SecureRandom secureRandom) { 662 this.secureRandom = secureRandom; 663 return this; 664 } 665 666 /** 667 * When called, the {@link #createConnectionManager()} method will return a {@link PoolingHttpClientConnectionManager} 668 * instead of a {@link BasicHttpClientConnectionManager}. 669 * 670 * <div class='warn'> 671 * <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)} 672 * </div> 673 * 674 * @return This object (for method chaining). 675 */ 676 @Deprecated 677 public RestClientBuilder pooled() { 678 this.pooled = true; 679 return this; 680 } 681 682 /** 683 * Set up this client to use BASIC auth. 684 * 685 * <div class='warn'> 686 * <b>Deprecated</b> - Use {@link #getHttpClientBuilder()} and modify the client builder directly using {@link HttpClientBuilder#setConnectionManager(HttpClientConnectionManager)} 687 * </div> 688 * 689 * @param host The auth scope hostname. 690 * @param port The auth scope port. 691 * @param user The username. 692 * @param pw The password. 693 * @return This object (for method chaining). 694 */ 695 @Deprecated 696 public RestClientBuilder basicAuth(String host, int port, String user, String pw) { 697 AuthScope scope = new AuthScope(host, port); 698 Credentials up = new UsernamePasswordCredentials(user, pw); 699 CredentialsProvider p = new BasicCredentialsProvider(); 700 p.setCredentials(scope, up); 701 defaultCredentialsProvider(p); 702 return this; 703 } 704 705 //----------------------------------------------------------------------------------------------------------------- 706 // HTTP headers 707 //----------------------------------------------------------------------------------------------------------------- 708 709 /** 710 * Sets arbitrary request headers. 711 * 712 * @param headers The headers to set on requests. 713 * @return This object (for method chaining). 714 */ 715 public RestClientBuilder headers(Map<String,Object> headers) { 716 if (headers != null) 717 for (Map.Entry<String,Object> e : headers.entrySet()) 718 header(e.getKey(), e.getValue()); 719 return this; 720 } 721 722 /** 723 * Sets the value for the <c>Accept</c> request header. 724 * 725 * <p> 726 * This overrides the media type specified on the parser, but is overridden by calling 727 * <code>header(<js>"Accept"</js>, value);</code> 728 * 729 * @param value The new header value. 730 * @return This object (for method chaining). 731 */ 732 public RestClientBuilder accept(Object value) { 733 return header("Accept", value); 734 } 735 736 /** 737 * Sets the value for the <c>Accept-Charset</c> request header. 738 * 739 * <p> 740 * This is a shortcut for calling <code>header(<js>"Accept-Charset"</js>, value);</code> 741 * 742 * @param value The new header value. 743 * @return This object (for method chaining). 744 */ 745 public RestClientBuilder acceptCharset(Object value) { 746 return header("Accept-Charset", value); 747 } 748 749 /** 750 * Sets the value for the <c>Accept-Encoding</c> request header. 751 * 752 * <p> 753 * This is a shortcut for calling <code>header(<js>"Accept-Encoding"</js>, value);</code> 754 * 755 * @param value The new header value. 756 * @return This object (for method chaining). 757 */ 758 public RestClientBuilder acceptEncoding(Object value) { 759 return header("Accept-Encoding", value); 760 } 761 762 /** 763 * Sets the value for the <c>Accept-Language</c> request header. 764 * 765 * <p> 766 * This is a shortcut for calling <code>header(<js>"Accept-Language"</js>, value);</code> 767 * 768 * @param value The new header value. 769 * @return This object (for method chaining). 770 */ 771 public RestClientBuilder acceptLanguage(Object value) { 772 return header("Accept-Language", value); 773 } 774 775 /** 776 * Sets the value for the <c>Authorization</c> request header. 777 * 778 * <p> 779 * This is a shortcut for calling <code>header(<js>"Authorization"</js>, value);</code> 780 * 781 * @param value The new header value. 782 * @return This object (for method chaining). 783 */ 784 public RestClientBuilder authorization(Object value) { 785 return header("Authorization", value); 786 } 787 788 /** 789 * Sets the value for the <c>Cache-Control</c> request header. 790 * 791 * <p> 792 * This is a shortcut for calling <code>header(<js>"Cache-Control"</js>, value);</code> 793 * 794 * @param value The new header value. 795 * @return This object (for method chaining). 796 */ 797 public RestClientBuilder cacheControl(Object value) { 798 return header("Cache-Control", value); 799 } 800 801 /** 802 * Sets the client version by setting the value for the <js>"X-Client-Version"</js> header. 803 * 804 * @param version The version string (e.g. <js>"1.2.3"</js>) 805 * @return This object (for method chaining). 806 */ 807 public RestClientBuilder clientVersion(String version) { 808 return header("X-Client-Version", version); 809 } 810 811 /** 812 * Sets the value for the <c>Connection</c> request header. 813 * 814 * <p> 815 * This is a shortcut for calling <code>header(<js>"Connection"</js>, value);</code> 816 * 817 * @param value The new header value. 818 * @return This object (for method chaining). 819 */ 820 public RestClientBuilder connection(Object value) { 821 return header("Connection", value); 822 } 823 824 /** 825 * Sets the value for the <c>Content-Length</c> request header. 826 * 827 * <p> 828 * This is a shortcut for calling <code>header(<js>"Content-Length"</js>, value);</code> 829 * 830 * @param value The new header value. 831 * @return This object (for method chaining). 832 */ 833 public RestClientBuilder contentLength(Object value) { 834 return header("Content-Length", value); 835 } 836 837 /** 838 * Sets the value for the <c>Content-Type</c> request header. 839 * 840 * <p> 841 * This overrides the media type specified on the serializer, but is overridden by calling 842 * <code>header(<js>"Content-Type"</js>, value);</code> 843 * 844 * @param value The new header value. 845 * @return This object (for method chaining). 846 */ 847 public RestClientBuilder contentType(Object value) { 848 return header("Content-Type", value); 849 } 850 851 /** 852 * Sets the value for the <c>Date</c> request header. 853 * 854 * <p> 855 * This is a shortcut for calling <code>header(<js>"Date"</js>, value);</code> 856 * 857 * @param value The new header value. 858 * @return This object (for method chaining). 859 */ 860 public RestClientBuilder date(Object value) { 861 return header("Date", value); 862 } 863 864 /** 865 * Sets the value for the <c>Expect</c> request header. 866 * 867 * <p> 868 * This is a shortcut for calling <code>header(<js>"Expect"</js>, value);</code> 869 * 870 * @param value The new header value. 871 * @return This object (for method chaining). 872 */ 873 public RestClientBuilder expect(Object value) { 874 return header("Expect", value); 875 } 876 877 /** 878 * Sets the value for the <c>Forwarded</c> request header. 879 * 880 * <p> 881 * This is a shortcut for calling <code>header(<js>"Forwarded"</js>, value);</code> 882 * 883 * @param value The new header value. 884 * @return This object (for method chaining). 885 */ 886 public RestClientBuilder forwarded(Object value) { 887 return header("Forwarded", value); 888 } 889 890 /** 891 * Sets the value for the <c>From</c> request header. 892 * 893 * <p> 894 * This is a shortcut for calling <code>header(<js>"From"</js>, value);</code> 895 * 896 * @param value The new header value. 897 * @return This object (for method chaining). 898 */ 899 public RestClientBuilder from(Object value) { 900 return header("From", value); 901 } 902 903 /** 904 * Sets the value for the <c>Host</c> request header. 905 * 906 * <p> 907 * This is a shortcut for calling <code>header(<js>"Host"</js>, value);</code> 908 * 909 * @param value The new header value. 910 * @return This object (for method chaining). 911 */ 912 public RestClientBuilder host(Object value) { 913 return header("Host", value); 914 } 915 916 /** 917 * Sets the value for the <c>If-Match</c> request header. 918 * 919 * <p> 920 * This is a shortcut for calling <code>header(<js>"If-Match"</js>, value);</code> 921 * 922 * @param value The new header value. 923 * @return This object (for method chaining). 924 */ 925 public RestClientBuilder ifMatch(Object value) { 926 return header("If-Match", value); 927 } 928 929 /** 930 * Sets the value for the <c>If-Modified-Since</c> request header. 931 * 932 * <p> 933 * This is a shortcut for calling <code>header(<js>"If-Modified-Since"</js>, value);</code> 934 * 935 * @param value The new header value. 936 * @return This object (for method chaining). 937 */ 938 public RestClientBuilder ifModifiedSince(Object value) { 939 return header("If-Modified-Since", value); 940 } 941 942 /** 943 * Sets the value for the <c>If-None-Match</c> request header. 944 * 945 * <p> 946 * This is a shortcut for calling <code>header(<js>"If-None-Match"</js>, value);</code> 947 * 948 * @param value The new header value. 949 * @return This object (for method chaining). 950 */ 951 public RestClientBuilder ifNoneMatch(Object value) { 952 return header("If-None-Match", value); 953 } 954 955 /** 956 * Sets the value for the <c>If-Range</c> request header. 957 * 958 * <p> 959 * This is a shortcut for calling <code>header(<js>"If-Range"</js>, value);</code> 960 * 961 * @param value The new header value. 962 * @return This object (for method chaining). 963 */ 964 public RestClientBuilder ifRange(Object value) { 965 return header("If-Range", value); 966 } 967 968 /** 969 * Sets the value for the <c>If-Unmodified-Since</c> request header. 970 * 971 * <p> 972 * This is a shortcut for calling <code>header(<js>"If-Unmodified-Since"</js>, value);</code> 973 * 974 * @param value The new header value. 975 * @return This object (for method chaining). 976 */ 977 public RestClientBuilder ifUnmodifiedSince(Object value) { 978 return header("If-Unmodified-Since", value); 979 } 980 981 /** 982 * Sets the value for the <c>Max-Forwards</c> request header. 983 * 984 * <p> 985 * This is a shortcut for calling <code>header(<js>"Max-Forwards"</js>, value);</code> 986 * 987 * @param value The new header value. 988 * @return This object (for method chaining). 989 */ 990 public RestClientBuilder maxForwards(Object value) { 991 return header("If-Unmodified-Since", value); 992 } 993 994 /** 995 * When called, <c>No-Trace: true</c> is added to requests. 996 * 997 * <p> 998 * This gives the opportunity for the servlet to not log errors on invalid requests. 999 * This is useful for testing purposes when you don't want your log file to show lots of errors that are simply the 1000 * results of testing. 1001 * 1002 * @return This object (for method chaining). 1003 */ 1004 public RestClientBuilder noTrace() { 1005 return header("No-Trace", true); 1006 } 1007 1008 /** 1009 * Sets the value for the <c>Origin</c> request header. 1010 * 1011 * <p> 1012 * This is a shortcut for calling <code>header(<js>"Origin"</js>, value);</code> 1013 * 1014 * @param value The new header value. 1015 * @return This object (for method chaining). 1016 */ 1017 public RestClientBuilder origin(Object value) { 1018 return header("If-Unmodified-Since", value); 1019 } 1020 1021 /** 1022 * Sets the value for the <c>Pragma</c> request header. 1023 * 1024 * <p> 1025 * This is a shortcut for calling <code>header(<js>"Pragma"</js>, value);</code> 1026 * 1027 * @param value The new header value. 1028 * @return This object (for method chaining). 1029 */ 1030 public RestClientBuilder pragma(Object value) { 1031 return header("Pragma", value); 1032 } 1033 1034 /** 1035 * Sets the value for the <c>Proxy-Authorization</c> request header. 1036 * 1037 * <p> 1038 * This is a shortcut for calling <code>header(<js>"Proxy-Authorization"</js>, value);</code> 1039 * 1040 * @param value The new header value. 1041 * @return This object (for method chaining). 1042 */ 1043 public RestClientBuilder proxyAuthorization(Object value) { 1044 return header("Proxy-Authorization", value); 1045 } 1046 1047 /** 1048 * Sets the value for the <c>Range</c> request header. 1049 * 1050 * <p> 1051 * This is a shortcut for calling <code>header(<js>"Range"</js>, value);</code> 1052 * 1053 * @param value The new header value. 1054 * @return This object (for method chaining). 1055 */ 1056 public RestClientBuilder range(Object value) { 1057 return header("Range", value); 1058 } 1059 1060 /** 1061 * Sets the value for the <c>Referer</c> request header. 1062 * 1063 * <p> 1064 * This is a shortcut for calling <code>header(<js>"Referer"</js>, value);</code> 1065 * 1066 * @param value The new header value. 1067 * @return This object (for method chaining). 1068 */ 1069 public RestClientBuilder referer(Object value) { 1070 return header("Referer", value); 1071 } 1072 1073 /** 1074 * Sets the value for the <c>TE</c> request header. 1075 * 1076 * <p> 1077 * This is a shortcut for calling <code>header(<js>"TE"</js>, value);</code> 1078 * 1079 * @param value The new header value. 1080 * @return This object (for method chaining). 1081 */ 1082 public RestClientBuilder te(Object value) { 1083 return header("TE", value); 1084 } 1085 1086 /** 1087 * Sets the value for the <c>User-Agent</c> request header. 1088 * 1089 * <p> 1090 * This is a shortcut for calling <code>header(<js>"User-Agent"</js>, value);</code> 1091 * 1092 * @param value The new header value. 1093 * @return This object (for method chaining). 1094 */ 1095 public RestClientBuilder userAgent(Object value) { 1096 return header("User-Agent", value); 1097 } 1098 1099 /** 1100 * Sets the value for the <c>Upgrade</c> request header. 1101 * 1102 * <p> 1103 * This is a shortcut for calling <code>header(<js>"Upgrade"</js>, value);</code> 1104 * 1105 * @param value The new header value. 1106 * @return This object (for method chaining). 1107 */ 1108 public RestClientBuilder upgrade(Object value) { 1109 return header("Upgrade", value); 1110 } 1111 1112 /** 1113 * Sets the value for the <c>Via</c> request header. 1114 * 1115 * <p> 1116 * This is a shortcut for calling <code>header(<js>"Via"</js>, value);</code> 1117 * 1118 * @param value The new header value. 1119 * @return This object (for method chaining). 1120 */ 1121 public RestClientBuilder via(Object value) { 1122 return header("Via", value); 1123 } 1124 1125 /** 1126 * Sets the value for the <c>Warning</c> request header. 1127 * 1128 * <p> 1129 * This is a shortcut for calling <code>header(<js>"Warning"</js>, value);</code> 1130 * 1131 * @param value The new header value. 1132 * @return This object (for method chaining). 1133 */ 1134 public RestClientBuilder warning(Object value) { 1135 return header("Warning", value); 1136 } 1137 1138 //----------------------------------------------------------------------------------------------------------------- 1139 // Properties 1140 //----------------------------------------------------------------------------------------------------------------- 1141 1142 /** 1143 * Configuration property: REST call handler. 1144 * 1145 * <p> 1146 * Allows you to provide a custom handler for making HTTP calls. 1147 * 1148 * <ul class='seealso'> 1149 * <li class='jf'>{@link RestClient#RESTCLIENT_callHandler} 1150 * </ul> 1151 * 1152 * @param value 1153 * The new value for this setting. 1154 * <br>The default value is <jk>null</jk>. 1155 * @return This object (for method chaining). 1156 */ 1157 public RestClientBuilder callHandler(Class<? extends RestCallHandler> value) { 1158 return set(RESTCLIENT_callHandler, value); 1159 } 1160 1161 /** 1162 * Configuration property: REST call handler. 1163 * 1164 * <p> 1165 * Allows you to provide a custom handler for making HTTP calls. 1166 * 1167 * <ul class='seealso'> 1168 * <li class='jf'>{@link RestClient#RESTCLIENT_callHandler} 1169 * </ul> 1170 * 1171 * @param value 1172 * The new value for this setting. 1173 * <br>The default value is <jk>null</jk>. 1174 * @return This object (for method chaining). 1175 */ 1176 public RestClientBuilder callHandler(RestCallHandler value) { 1177 return set(RESTCLIENT_callHandler, value); 1178 } 1179 1180 /** 1181 * Configuration property: Executor service. 1182 * 1183 * <p> 1184 * Defines the executor service to use when calling future methods on the {@link RestCall} class. 1185 * 1186 * <p> 1187 * This executor service is used to create {@link Future} objects on the following methods: 1188 * <ul> 1189 * <li>{@link RestCall#runFuture()} 1190 * <li>{@link RestCall#getResponseFuture(Class)} 1191 * <li>{@link RestCall#getResponseFuture(Type,Type...)} 1192 * <li>{@link RestCall#getResponseAsString()} 1193 * </ul> 1194 * 1195 * <p> 1196 * The default executor service is a single-threaded {@link ThreadPoolExecutor} with a 30 second timeout 1197 * and a queue size of 10. 1198 * 1199 * <ul class='seealso'> 1200 * <li class='jf'>{@link RestClient#RESTCLIENT_executorService} 1201 * <li class='jf'>{@link RestClient#RESTCLIENT_executorServiceShutdownOnClose} 1202 * </ul> 1203 * 1204 * @param executorService The executor service. 1205 * @param shutdownOnClose Call {@link ExecutorService#shutdown()} when {@link RestClient#close()} is called. 1206 * @return This object (for method chaining). 1207 */ 1208 public RestClientBuilder executorService(ExecutorService executorService, boolean shutdownOnClose) { 1209 set(RESTCLIENT_executorService, executorService); 1210 set(RESTCLIENT_executorServiceShutdownOnClose, shutdownOnClose); 1211 return this; 1212 } 1213 1214 /** 1215 * Configuration property: Request headers. 1216 * 1217 * <ul class='seealso'> 1218 * <li class='jf'>{@link RestClient#RESTCLIENT_headers} 1219 * </ul> 1220 * 1221 * @param key The header name. 1222 * @param value The header value. 1223 * @return This object (for method chaining). 1224 */ 1225 public RestClientBuilder header(String key, Object value) { 1226 return putTo(RESTCLIENT_headers, key, value); 1227 } 1228 1229 /** 1230 * Configuration property: Keep HttpClient open. 1231 * 1232 * <p> 1233 * Don't close this client when the {@link RestClient#close()} method is called. 1234 * 1235 * <ul class='seealso'> 1236 * <li class='jf'>{@link RestClient#RESTCLIENT_keepHttpClientOpen} 1237 * </ul> 1238 * 1239 * @param value 1240 * The new value for this property. 1241 * <br>The default value is <jk>false</jk>. 1242 * @return This object (for method chaining). 1243 */ 1244 public RestClientBuilder keepHttpClientOpen(boolean value) { 1245 return set(RESTCLIENT_keepHttpClientOpen, value); 1246 } 1247 1248 /** 1249 * Configuration property: Keep HttpClient open. 1250 * 1251 * <p> 1252 * Don't close this client when the {@link RestClient#close()} method is called. 1253 * 1254 * <ul class='seealso'> 1255 * <li class='jf'>{@link RestClient#RESTCLIENT_keepHttpClientOpen} 1256 * </ul> 1257 * 1258 * @return This object (for method chaining). 1259 */ 1260 public RestClientBuilder keepHttpClientOpen() { 1261 return keepHttpClientOpen(true); 1262 } 1263 1264 /** 1265 * Configuration property: Call interceptors. 1266 * 1267 * <p> 1268 * Adds an interceptor that gets called immediately after a connection is made. 1269 * 1270 * <ul class='seealso'> 1271 * <li class='jf'>{@link RestClient#RESTCLIENT_interceptors} 1272 * </ul> 1273 * 1274 * @param value The values to add to this setting. 1275 * @return This object (for method chaining). 1276 */ 1277 public RestClientBuilder interceptors(RestCallInterceptor...value) { 1278 return prependTo(RESTCLIENT_interceptors, value); 1279 } 1280 1281 /** 1282 * Configuration property: Marshall 1283 * 1284 * <p> 1285 * Shortcut for specifying the {@link RestClient#RESTCLIENT_serializer} and {@link RestClient#RESTCLIENT_parser} 1286 * using the serializer and parser defined in a marshall. 1287 * 1288 * @param value The values to add to this setting. 1289 * @return This object (for method chaining). 1290 */ 1291 public RestClientBuilder marshall(Marshall value) { 1292 if (value == null) 1293 serializer((Serializer)null).parser((Parser)null); 1294 else 1295 serializer(value.getSerializer()).parser(value.getParser()); 1296 return this; 1297 } 1298 1299 /** 1300 * Configuration property: Parser. 1301 * 1302 * <p> 1303 * The parser to use for parsing POJOs in response bodies. 1304 * 1305 * <ul class='seealso'> 1306 * <li class='jf'>{@link RestClient#RESTCLIENT_parser} 1307 * </ul> 1308 * 1309 * @param value 1310 * The new value for this setting. 1311 * <br>The default value is {@link JsonParser#DEFAULT}. 1312 * @return This object (for method chaining). 1313 */ 1314 public RestClientBuilder parser(Class<? extends Parser> value) { 1315 return set(RESTCLIENT_parser, value); 1316 } 1317 1318 /** 1319 * Configuration property: Parser. 1320 * 1321 * <p> 1322 * Same as {@link #parser(Parser)} except takes in a parser instance. 1323 * 1324 * <ul class='seealso'> 1325 * <li class='jf'>{@link RestClient#RESTCLIENT_parser} 1326 * </ul> 1327 * 1328 * @param value 1329 * The new value for this setting. 1330 * <br>The default value is {@link JsonParser#DEFAULT}. 1331 * @return This object (for method chaining). 1332 */ 1333 public RestClientBuilder parser(Parser value) { 1334 return set(RESTCLIENT_parser, value); 1335 } 1336 1337 /** 1338 * Configuration property: Part parser. 1339 * 1340 * <p> 1341 * The parser to use for parsing POJOs from form data, query parameters, headers, and path variables. 1342 * 1343 * <ul class='seealso'> 1344 * <li class='jf'>{@link RestClient#RESTCLIENT_partParser} 1345 * </ul> 1346 * 1347 * @param value 1348 * The new value for this setting. 1349 * <br>The default value is {@link OpenApiParser}. 1350 * @return This object (for method chaining). 1351 */ 1352 public RestClientBuilder partParser(Class<? extends HttpPartParser> value) { 1353 return set(RESTCLIENT_partParser, value); 1354 } 1355 1356 /** 1357 * Configuration property: Part parser. 1358 * 1359 * <p> 1360 * Same as {@link #partParser(Class)} but takes in a parser instance. 1361 * 1362 * <ul class='seealso'> 1363 * <li class='jf'>{@link RestClient#RESTCLIENT_partParser} 1364 * </ul> 1365 * 1366 * @param value 1367 * The new value for this setting. 1368 * <br>The default value is {@link OpenApiParser}. 1369 * @return This object (for method chaining). 1370 */ 1371 public RestClientBuilder partParser(HttpPartParser value) { 1372 return set(RESTCLIENT_partParser, value); 1373 } 1374 1375 /** 1376 * Configuration property: Part serializer. 1377 * 1378 * <p> 1379 * The serializer to use for serializing POJOs in form data, query parameters, headers, and path variables. 1380 * 1381 * <ul class='seealso'> 1382 * <li class='jf'>{@link RestClient#RESTCLIENT_partSerializer} 1383 * </ul> 1384 * 1385 * @param value 1386 * The new value for this setting. 1387 * <br>The default value is {@link OpenApiSerializer}. 1388 * @return This object (for method chaining). 1389 */ 1390 public RestClientBuilder partSerializer(Class<? extends HttpPartSerializer> value) { 1391 return set(RESTCLIENT_partSerializer, value); 1392 } 1393 1394 /** 1395 * Configuration property: Part serializer. 1396 * 1397 * <p> 1398 * Same as {@link #partSerializer(Class)} but takes in a parser instance. 1399 * 1400 * <ul class='seealso'> 1401 * <li class='jf'>{@link RestClient#RESTCLIENT_partSerializer} 1402 * </ul> 1403 * 1404 * @param value 1405 * The new value for this setting. 1406 * <br>The default value is {@link OpenApiSerializer}. 1407 * @return This object (for method chaining). 1408 */ 1409 public RestClientBuilder partSerializer(HttpPartSerializer value) { 1410 return set(RESTCLIENT_partSerializer, value); 1411 } 1412 1413 /** 1414 * Make HTTP calls retryable if an error response (>=400) is received. 1415 * 1416 * <ul class='seealso'> 1417 * <li class='jf'>{@link RestClient#RESTCLIENT_retries} 1418 * <li class='jf'>{@link RestClient#RESTCLIENT_retryInterval} 1419 * <li class='jf'>{@link RestClient#RESTCLIENT_retryOn} 1420 * </ul> 1421 * 1422 * @param retries The number of retries to attempt. 1423 * @param interval The time in milliseconds between attempts. 1424 * @param retryOn 1425 * Optional object used for determining whether a retry should be attempted. 1426 * If <jk>null</jk>, uses {@link RetryOn#DEFAULT}. 1427 * @return This object (for method chaining). 1428 */ 1429 public RestClientBuilder retryable(int retries, int interval, RetryOn retryOn) { 1430 set(RESTCLIENT_retries, retries); 1431 set(RESTCLIENT_retryInterval, interval); 1432 set(RESTCLIENT_retryOn, retryOn); 1433 return this; 1434 } 1435 1436 /** 1437 * Configuration property: Root URI. 1438 * 1439 * <p> 1440 * When set, relative URL strings passed in through the various rest call methods (e.g. {@link RestClient#doGet(Object)} 1441 * will be prefixed with the specified root. 1442 * <br>This root URL is ignored on those methods if you pass in a {@link URL}, {@link URI}, or an absolute URL string. 1443 * 1444 * <ul class='seealso'> 1445 * <li class='jf'>{@link RestClient#RESTCLIENT_rootUri} 1446 * </ul> 1447 * 1448 * @param value 1449 * The root URL to prefix to relative URL strings. 1450 * <br>Trailing slashes are trimmed. 1451 * <br>Usually a <c>String</c> but you can also pass in <c>URI</c> and <c>URL</c> objects as well. 1452 * @return This object (for method chaining). 1453 */ 1454 public RestClientBuilder rootUrl(Object value) { 1455 return set(RESTCLIENT_rootUri, value); 1456 } 1457 1458 /** 1459 * Configuration property: Request query parameters. 1460 * 1461 * <ul class='seealso'> 1462 * <li class='jf'>{@link RestClient#RESTCLIENT_query} 1463 * </ul> 1464 * 1465 * @param key The query parameter name. 1466 * @param value The query parameter value value. 1467 * @return This object (for method chaining). 1468 */ 1469 public RestClientBuilder query(String key, Object value) { 1470 return putTo(RESTCLIENT_query, key, value); 1471 } 1472 1473 /** 1474 * Configuration property: Serializer. 1475 * 1476 * <p> 1477 * The serializer to use for serializing POJOs in request bodies. 1478 * 1479 * <ul class='seealso'> 1480 * <li class='jf'>{@link RestClient#RESTCLIENT_serializer} 1481 * </ul> 1482 * 1483 * @param value 1484 * The new value for this setting. 1485 * <br>The default is {@link JsonSerializer}. 1486 * @return This object (for method chaining). 1487 */ 1488 public RestClientBuilder serializer(Class<? extends Serializer> value) { 1489 return set(RESTCLIENT_serializer, value); 1490 } 1491 1492 /** 1493 * Configuration property: Serializer. 1494 * 1495 * <p> 1496 * Same as {@link #serializer(Class)} but takes in a serializer instance. 1497 * 1498 * <ul class='seealso'> 1499 * <li class='jf'>{@link RestClient#RESTCLIENT_serializer} 1500 * </ul> 1501 * 1502 * @param value 1503 * The new value for this setting. 1504 * <br>The default is {@link JsonSerializer}. 1505 * @return This object (for method chaining). 1506 */ 1507 public RestClientBuilder serializer(Serializer value) { 1508 return set(RESTCLIENT_serializer, value); 1509 } 1510 1511 /** 1512 * Configuration property: Add <js>"_type"</js> properties when needed. 1513 * 1514 * <p> 1515 * If <jk>true</jk>, then <js>"_type"</js> properties will be added to beans if their type cannot be inferred 1516 * through reflection. 1517 * 1518 * <ul class='seealso'> 1519 * <li class='jf'>{@link Serializer#SERIALIZER_addBeanTypes} 1520 * </ul> 1521 * 1522 * @param value 1523 * The new value for this property. 1524 * <br>The default is <jk>false</jk>. 1525 * @return This object (for method chaining). 1526 */ 1527 public RestClientBuilder addBeanTypes(boolean value) { 1528 return set(SERIALIZER_addBeanTypes, value); 1529 } 1530 1531 /** 1532 * Configuration property: Add <js>"_type"</js> properties when needed. 1533 * 1534 * <p> 1535 * Shortcut for calling <code>addBeanTypes(<jk>true</jk>)</code>. 1536 * 1537 * <ul class='seealso'> 1538 * <li class='jf'>{@link Serializer#SERIALIZER_addBeanTypes} 1539 * </ul> 1540 * 1541 * @return This object (for method chaining). 1542 */ 1543 public RestClientBuilder addBeanTypes() { 1544 return set(SERIALIZER_addBeanTypes, true); 1545 } 1546 1547 /** 1548 * Configuration property: Add type attribute to root nodes. 1549 * 1550 * <p> 1551 * When disabled, it is assumed that the parser knows the exact Java POJO type being parsed, and therefore top-level 1552 * type information that might normally be included to determine the data type will not be serialized. 1553 * 1554 * <ul class='seealso'> 1555 * <li class='jf'>{@link Serializer#SERIALIZER_addRootType} 1556 * </ul> 1557 * 1558 * @param value 1559 * The new value for this property. 1560 * <br>The default is <jk>false</jk>. 1561 * @return This object (for method chaining). 1562 */ 1563 public RestClientBuilder addRootType(boolean value) { 1564 return set(SERIALIZER_addRootType, value); 1565 } 1566 1567 /** 1568 * Configuration property: Add type attribute to root nodes. 1569 * 1570 * <p> 1571 * Shortcut for calling <code>addRootType(<jk>true</jk>)</code>. 1572 * 1573 * <ul class='seealso'> 1574 * <li class='jf'>{@link Serializer#SERIALIZER_addRootType} 1575 * </ul> 1576 * 1577 * @return This object (for method chaining). 1578 */ 1579 public RestClientBuilder addRootType() { 1580 return set(SERIALIZER_addRootType, true); 1581 } 1582 1583 /** 1584 * Configuration property: Automatically detect POJO recursions. 1585 * 1586 * <p> 1587 * Specifies that recursions should be checked for during serialization. 1588 * 1589 * <ul class='notes'> 1590 * <li> 1591 * Checking for recursion can cause a small performance penalty. 1592 * </ul> 1593 * 1594 * <ul class='seealso'> 1595 * <li class='jf'>{@link BeanTraverseContext#BEANTRAVERSE_detectRecursions} 1596 * </ul> 1597 * 1598 * @param value 1599 * The new value for this property. 1600 * <br>The default is <jk>false</jk>. 1601 * @return This object (for method chaining). 1602 */ 1603 public RestClientBuilder detectRecursions(boolean value) { 1604 return set(BEANTRAVERSE_detectRecursions, value); 1605 } 1606 1607 /** 1608 * Configuration property: Automatically detect POJO recursions. 1609 * 1610 * <p> 1611 * Shortcut for calling <code>detectRecursions(<jk>true</jk>)</code>. 1612 * 1613 * <ul class='seealso'> 1614 * <li class='jf'>{@link BeanTraverseContext#BEANTRAVERSE_detectRecursions} 1615 * </ul> 1616 * 1617 * @return This object (for method chaining). 1618 */ 1619 public RestClientBuilder detectRecursions() { 1620 return set(BEANTRAVERSE_detectRecursions, true); 1621 } 1622 1623 /** 1624 * Configuration property: Ignore recursion errors. 1625 * 1626 * <p> 1627 * If <jk>true</jk>, when we encounter the same object when serializing a tree, we set the value to <jk>null</jk>. 1628 * Otherwise, an exception is thrown. 1629 * 1630 * <ul class='notes'> 1631 * <li> 1632 * Checking for recursion can cause a small performance penalty. 1633 * </ul> 1634 * 1635 * <ul class='seealso'> 1636 * <li class='jf'>{@link BeanTraverseContext#BEANTRAVERSE_ignoreRecursions} 1637 * </ul> 1638 * 1639 * @param value 1640 * The new value for this property. 1641 * <br>The default is <jk>false</jk>. 1642 * @return This object (for method chaining). 1643 */ 1644 public RestClientBuilder ignoreRecursions(boolean value) { 1645 return set(BEANTRAVERSE_ignoreRecursions, value); 1646 } 1647 1648 /** 1649 * Configuration property: Ignore recursion errors. 1650 * 1651 * <p> 1652 * Shortcut for calling <code>ignoreRecursions(<jk>true</jk>)</code>. 1653 * 1654 * <ul class='seealso'> 1655 * <li class='jf'>{@link BeanTraverseContext#BEANTRAVERSE_ignoreRecursions} 1656 * </ul> 1657 * 1658 * @return This object (for method chaining). 1659 */ 1660 public RestClientBuilder ignoreRecursions() { 1661 return set(BEANTRAVERSE_ignoreRecursions, true); 1662 } 1663 1664 /** 1665 * Configuration property: Initial depth. 1666 * 1667 * <p> 1668 * The initial indentation level at the root. 1669 * 1670 * <ul class='seealso'> 1671 * <li class='jf'>{@link BeanTraverseContext#BEANTRAVERSE_initialDepth} 1672 * </ul> 1673 * 1674 * @param value 1675 * The new value for this property. 1676 * <br>The default is <c>0</c>. 1677 * @return This object (for method chaining). 1678 */ 1679 public RestClientBuilder initialDepth(int value) { 1680 return set(BEANTRAVERSE_initialDepth, value); 1681 } 1682 1683 /** 1684 * Configuration property: Serializer listener. 1685 * 1686 * <p> 1687 * Class used to listen for errors and warnings that occur during serialization. 1688 * 1689 * <ul class='seealso'> 1690 * <li class='jf'>{@link Serializer#SERIALIZER_listener} 1691 * </ul> 1692 * 1693 * @param value 1694 * The new value for this property. 1695 * @return This object (for method chaining). 1696 */ 1697 public RestClientBuilder listenerS(Class<? extends SerializerListener> value) { 1698 return set(SERIALIZER_listener, value); 1699 } 1700 1701 /** 1702 * Configuration property: Max serialization depth. 1703 * 1704 * <p> 1705 * Abort serialization if specified depth is reached in the POJO tree. 1706 * <br>If this depth is exceeded, an exception is thrown. 1707 * <br>This prevents stack overflows from occurring when trying to serialize models with recursive references. 1708 * 1709 * <ul class='seealso'> 1710 * <li class='jf'>{@link BeanTraverseContext#BEANTRAVERSE_maxDepth} 1711 * </ul> 1712 * 1713 * @param value 1714 * The new value for this property. 1715 * <br>The default is <c>100</c>. 1716 * @return This object (for method chaining). 1717 */ 1718 public RestClientBuilder maxDepth(int value) { 1719 return set(BEANTRAVERSE_maxDepth, value); 1720 } 1721 1722 /** 1723 * Configuration property: Sort arrays and collections alphabetically. 1724 * 1725 * <p> 1726 * Copies and sorts the contents of arrays and collections before serializing them. 1727 * 1728 * <ul class='seealso'> 1729 * <li class='jf'>{@link Serializer#SERIALIZER_sortCollections} 1730 * </ul> 1731 * 1732 * @param value 1733 * The new value for this property. 1734 * <br>The default is <jk>false</jk>. 1735 * @return This object (for method chaining). 1736 */ 1737 public RestClientBuilder sortCollections(boolean value) { 1738 return set(SERIALIZER_sortCollections, value); 1739 } 1740 1741 /** 1742 * Configuration property: Sort arrays and collections alphabetically. 1743 * 1744 * <p> 1745 * Shortcut for calling <code>sortCollections(<jk>true</jk>)</code>. 1746 * 1747 * <ul class='seealso'> 1748 * <li class='jf'>{@link Serializer#SERIALIZER_sortCollections} 1749 * </ul> 1750 * 1751 * @return This object (for method chaining). 1752 */ 1753 public RestClientBuilder sortCollections() { 1754 return set(SERIALIZER_sortCollections, true); 1755 } 1756 1757 /** 1758 * Sets the {@link Serializer#SERIALIZER_sortMaps} property on all serializers in this group. 1759 * 1760 * <p> 1761 * Copies and sorts the contents of maps before serializing them. 1762 * 1763 * <ul class='seealso'> 1764 * <li class='jf'>{@link Serializer#SERIALIZER_sortMaps} 1765 * </ul> 1766 * 1767 * @param value The new value for this property. 1768 * @return This object (for method chaining). 1769 */ 1770 public RestClientBuilder sortMaps(boolean value) { 1771 return set(SERIALIZER_sortMaps, value); 1772 } 1773 1774 /** 1775 * Configuration property: Sort maps alphabetically. 1776 * 1777 * <p> 1778 * Shortcut for calling <code>sortMaps(<jk>true</jk>)</code>. 1779 * 1780 * <ul class='seealso'> 1781 * <li class='jf'>{@link Serializer#SERIALIZER_sortMaps} 1782 * </ul> 1783 * 1784 * @return This object (for method chaining). 1785 */ 1786 public RestClientBuilder sortMaps() { 1787 return set(SERIALIZER_sortMaps, true); 1788 } 1789 1790 /** 1791 * Configuration property: Trim empty lists and arrays. 1792 * 1793 * <p> 1794 * If <jk>true</jk>, empty list values will not be serialized to the output. 1795 * 1796 * <ul class='seealso'> 1797 * <li class='jf'>{@link Serializer#SERIALIZER_trimEmptyCollections} 1798 * </ul> 1799 * 1800 * @param value 1801 * The new value for this property. 1802 * <br>The default is <jk>false</jk>. 1803 * @return This object (for method chaining). 1804 */ 1805 public RestClientBuilder trimEmptyCollections(boolean value) { 1806 return set(SERIALIZER_trimEmptyCollections, value); 1807 } 1808 1809 /** 1810 * Configuration property: Trim empty lists and arrays. 1811 * 1812 * <p> 1813 * Shortcut for calling <code>trimEmptyCollections(<jk>true</jk>)</code>. 1814 * 1815 * <ul class='seealso'> 1816 * <li class='jf'>{@link Serializer#SERIALIZER_trimEmptyCollections} 1817 * </ul> 1818 * 1819 * @return This object (for method chaining). 1820 */ 1821 public RestClientBuilder trimEmptyCollections() { 1822 return set(SERIALIZER_trimEmptyCollections, true); 1823 } 1824 1825 /** 1826 * Configuration property: Trim empty maps. 1827 * 1828 * <p> 1829 * If <jk>true</jk>, empty map values will not be serialized to the output. 1830 * 1831 * <ul class='seealso'> 1832 * <li class='jf'>{@link Serializer#SERIALIZER_trimEmptyMaps} 1833 * </ul> 1834 * 1835 * @param value 1836 * The new value for this property. 1837 * <br>The default is <jk>false</jk>. 1838 * @return This object (for method chaining). 1839 */ 1840 public RestClientBuilder trimEmptyMaps(boolean value) { 1841 return set(SERIALIZER_trimEmptyMaps, value); 1842 } 1843 1844 /** 1845 * Configuration property: Trim empty maps. 1846 * 1847 * <p> 1848 * Shortcut for calling <code>trimEmptyMaps(<jk>true</jk>)</code>. 1849 * 1850 * <ul class='seealso'> 1851 * <li class='jf'>{@link Serializer#SERIALIZER_trimEmptyMaps} 1852 * </ul> 1853 * 1854 * @return This object (for method chaining). 1855 */ 1856 public RestClientBuilder trimEmptyMaps() { 1857 return set(SERIALIZER_trimEmptyMaps, true); 1858 } 1859 1860 /** 1861 * Configuration property: Trim null bean property values. 1862 * 1863 * <p> 1864 * If <jk>true</jk>, null bean values will not be serialized to the output. 1865 * 1866 * <ul class='seealso'> 1867 * <li class='jf'>{@link Serializer#SERIALIZER_trimNullProperties} 1868 * </ul> 1869 * 1870 * @param value 1871 * The new value for this property. 1872 * <br>The default is <jk>true</jk>. 1873 * @return This object (for method chaining). 1874 */ 1875 public RestClientBuilder trimNullProperties(boolean value) { 1876 return set(SERIALIZER_trimNullProperties, value); 1877 } 1878 1879 /** 1880 * Configuration property: Trim strings. 1881 * 1882 * <p> 1883 * If <jk>true</jk>, string values will be trimmed of whitespace using {@link String#trim()} before being serialized. 1884 * 1885 * <ul class='seealso'> 1886 * <li class='jf'>{@link Serializer#SERIALIZER_trimStrings} 1887 * </ul> 1888 * 1889 * @param value 1890 * The new value for this property. 1891 * <br>The default is <jk>false</jk>. 1892 * @return This object (for method chaining). 1893 */ 1894 public RestClientBuilder trimStringsS(boolean value) { 1895 return set(SERIALIZER_trimStrings, value); 1896 } 1897 1898 /** 1899 * Configuration property: Trim strings. 1900 * 1901 * <p> 1902 * Shortcut for calling <code>trimStrings(<jk>true</jk>)</code>. 1903 * 1904 * <ul class='seealso'> 1905 * <li class='jf'>{@link Serializer#SERIALIZER_trimStrings} 1906 * </ul> 1907 * 1908 * @return This object (for method chaining). 1909 */ 1910 public RestClientBuilder trimStringsS() { 1911 return set(SERIALIZER_trimStrings, true); 1912 } 1913 1914 /** 1915 * Configuration property: URI context bean. 1916 * 1917 * <p> 1918 * Bean used for resolution of URIs to absolute or root-relative form. 1919 * 1920 * <ul class='seealso'> 1921 * <li class='jf'>{@link Serializer#SERIALIZER_uriContext} 1922 * </ul> 1923 * 1924 * @param value The new value for this property. 1925 * @return This object (for method chaining). 1926 */ 1927 public RestClientBuilder uriContext(UriContext value) { 1928 return set(SERIALIZER_uriContext, value); 1929 } 1930 1931 /** 1932 * Configuration property: URI relativity. 1933 * 1934 * <p> 1935 * Defines what relative URIs are relative to when serializing URI/URL objects. 1936 * 1937 * <ul class='seealso'> 1938 * <li class='jf'>{@link Serializer#SERIALIZER_uriRelativity} 1939 * </ul> 1940 * 1941 * @param value 1942 * The new value for this property. 1943 * <br>The default is {@link UriRelativity#RESOURCE} 1944 * @return This object (for method chaining). 1945 */ 1946 public RestClientBuilder uriRelativity(UriRelativity value) { 1947 return set(SERIALIZER_uriRelativity, value); 1948 } 1949 1950 /** 1951 * Configuration property: URI resolution. 1952 * 1953 * <p> 1954 * Defines the resolution level for URIs when serializing URI/URL objects. 1955 * 1956 * <ul class='seealso'> 1957 * <li class='jf'>{@link Serializer#SERIALIZER_uriResolution} 1958 * </ul> 1959 * 1960 * @param value 1961 * The new value for this property. 1962 * <br>The default is {@link UriResolution#NONE} 1963 * @return This object (for method chaining). 1964 */ 1965 public RestClientBuilder uriResolution(UriResolution value) { 1966 return set(SERIALIZER_uriResolution, value); 1967 } 1968 1969 /** 1970 * Configuration property: Maximum indentation. 1971 * 1972 * <p> 1973 * Specifies the maximum indentation level in the serialized document. 1974 * 1975 * <ul class='seealso'> 1976 * <li class='jf'>{@link WriterSerializer#WSERIALIZER_maxIndent} 1977 * </ul> 1978 * 1979 * @param value 1980 * The new value for this property. 1981 * <br>The default is <c>100</c>. 1982 * @return This object (for method chaining). 1983 */ 1984 public RestClientBuilder maxIndent(int value) { 1985 return set(WSERIALIZER_maxIndent, value); 1986 } 1987 1988 /** 1989 * Configuration property: Quote character. 1990 * 1991 * <p> 1992 * This is the character used for quoting attributes and values. 1993 * 1994 * <ul class='seealso'> 1995 * <li class='jf'>{@link WriterSerializer#WSERIALIZER_quoteChar} 1996 * </ul> 1997 * 1998 * @param value 1999 * The new value for this property. 2000 * <br>The default is <js>'"'</js>. 2001 * @return This object (for method chaining). 2002 */ 2003 public RestClientBuilder quoteChar(char value) { 2004 return set(WSERIALIZER_quoteChar, value); 2005 } 2006 2007 /** 2008 * Configuration property: Quote character. 2009 * 2010 * <p> 2011 * Shortcut for calling <code>quoteChar(<js>'\''</js>)</code>. 2012 * 2013 * <ul class='seealso'> 2014 * <li class='jf'>{@link WriterSerializer#WSERIALIZER_quoteChar} 2015 * </ul> 2016 * 2017 * @return This object (for method chaining). 2018 */ 2019 public RestClientBuilder sq() { 2020 return set(WSERIALIZER_quoteChar, '\''); 2021 } 2022 2023 /** 2024 * Configuration property: Use whitespace. 2025 * 2026 * <p> 2027 * If <jk>true</jk>, newlines and indentation and spaces are added to the output to improve readability. 2028 * 2029 * <ul class='seealso'> 2030 * <li class='jf'>{@link WriterSerializer#WSERIALIZER_useWhitespace} 2031 * </ul> 2032 * 2033 * @param value 2034 * The new value for this property. 2035 * <br>The default is <jk>false</jk>. 2036 * @return This object (for method chaining). 2037 */ 2038 public RestClientBuilder useWhitespace(boolean value) { 2039 return set(WSERIALIZER_useWhitespace, value); 2040 } 2041 2042 /** 2043 * Configuration property: Use whitespace. 2044 * 2045 * <p> 2046 * Shortcut for calling <code>useWhitespace(<jk>true</jk>)</code>. 2047 * 2048 * <ul class='seealso'> 2049 * <li class='jf'>{@link WriterSerializer#WSERIALIZER_useWhitespace} 2050 * </ul> 2051 * @return This object (for method chaining). 2052 */ 2053 public RestClientBuilder useWhitespace() { 2054 return set(WSERIALIZER_useWhitespace, true); 2055 } 2056 2057 /** 2058 * Configuration property: Use whitespace. 2059 * 2060 * <p> 2061 * Shortcut for calling <code>useWhitespace(<jk>true</jk>)</code>. 2062 * 2063 * <ul class='seealso'> 2064 * <li class='jf'>{@link WriterSerializer#WSERIALIZER_useWhitespace} 2065 * </ul> 2066 * 2067 * @return This object (for method chaining). 2068 */ 2069 public RestClientBuilder ws() { 2070 return set(WSERIALIZER_useWhitespace, true); 2071 } 2072 2073 /** 2074 * Configuration property: Binary string format. 2075 * 2076 * <p> 2077 * When using the {@link Serializer#serializeToString(Object)} method on stream-based serializers, this defines the format to use 2078 * when converting the resulting byte array to a string. 2079 * 2080 * <ul class='javatree'> 2081 * <li class='jf'>{@link OutputStreamSerializer#OSSERIALIZER_binaryFormat} 2082 * </ul> 2083 * 2084 * @param value 2085 * The new value for this property. 2086 * <br>The default is {@link BinaryFormat#HEX}. 2087 * @return This object (for method chaining). 2088 */ 2089 public RestClientBuilder binaryOutputFormat(BinaryFormat value) { 2090 return set(OSSERIALIZER_binaryFormat, value); 2091 } 2092 2093 /** 2094 * Configuration property: Auto-close streams. 2095 * 2096 * If <jk>true</jk>, <l>InputStreams</l> and <l>Readers</l> passed into parsers will be closed 2097 * after parsing is complete. 2098 * 2099 * <ul class='seealso'> 2100 * <li class='jf'>{@link Parser#PARSER_autoCloseStreams} 2101 * </ul> 2102 * 2103 * @param value 2104 * The new value for this property. 2105 * <br>The default value is <jk>false</jk>. 2106 * @return This object (for method chaining). 2107 */ 2108 public RestClientBuilder autoCloseStreams(boolean value) { 2109 return set(PARSER_autoCloseStreams, value); 2110 } 2111 2112 /** 2113 * Configuration property: Auto-close streams. 2114 * 2115 * <p> 2116 * Shortcut for calling <code>autoCloseStreams(<jk>true</jk>)</code>. 2117 * 2118 * <ul class='seealso'> 2119 * <li class='jf'>{@link Parser#PARSER_autoCloseStreams} 2120 * </ul> 2121 * 2122 * @return This object (for method chaining). 2123 */ 2124 public RestClientBuilder autoCloseStreams() { 2125 return set(PARSER_autoCloseStreams, true); 2126 } 2127 2128 /** 2129 * Configuration property: Debug output lines. 2130 * 2131 * When parse errors occur, this specifies the number of lines of input before and after the 2132 * error location to be printed as part of the exception message. 2133 * 2134 * <ul class='seealso'> 2135 * <li class='jf'>{@link Parser#PARSER_debugOutputLines} 2136 * </ul> 2137 * 2138 * @param value 2139 * The new value for this property. 2140 * <br>The default value is <c>5</c>. 2141 * @return This object (for method chaining). 2142 */ 2143 public RestClientBuilder debugOutputLines(int value) { 2144 set(PARSER_debugOutputLines, value); 2145 return this; 2146 } 2147 2148 /** 2149 * Configuration property: Parser listener. 2150 * 2151 * <p> 2152 * Class used to listen for errors and warnings that occur during parsing. 2153 * 2154 * <ul class='seealso'> 2155 * <li class='jf'>{@link Parser#PARSER_listener} 2156 * </ul> 2157 * 2158 * @param value The new value for this property. 2159 * @return This object (for method chaining). 2160 */ 2161 public RestClientBuilder listenerP(Class<? extends ParserListener> value) { 2162 return set(PARSER_listener, value); 2163 } 2164 2165 /** 2166 * Configuration property: Strict mode. 2167 * 2168 * <p> 2169 * If <jk>true</jk>, strict mode for the parser is enabled. 2170 * 2171 * <ul class='seealso'> 2172 * <li class='jf'>{@link Parser#PARSER_strict} 2173 * </ul> 2174 * 2175 * @param value 2176 * The new value for this property. 2177 * <br>The default value is <jk>false</jk>. 2178 * @return This object (for method chaining). 2179 */ 2180 public RestClientBuilder strict(boolean value) { 2181 return set(PARSER_strict, value); 2182 } 2183 2184 /** 2185 * Configuration property: Strict mode. 2186 * 2187 * <p> 2188 * Shortcut for calling <code>strict(<jk>true</jk>)</code>. 2189 * 2190 * <ul class='seealso'> 2191 * <li class='jf'>{@link Parser#PARSER_strict} 2192 * </ul> 2193 * 2194 * @return This object (for method chaining). 2195 */ 2196 public RestClientBuilder strict() { 2197 return set(PARSER_strict, true); 2198 } 2199 2200 /** 2201 * Configuration property: Trim parsed strings. 2202 * 2203 * <p> 2204 * If <jk>true</jk>, string values will be trimmed of whitespace using {@link String#trim()} before being added to 2205 * the POJO. 2206 * 2207 * <ul class='seealso'> 2208 * <li class='jf'>{@link Parser#PARSER_trimStrings} 2209 * </ul> 2210 * 2211 * @param value 2212 * The new value for this property. 2213 * <br>The default value is <jk>false</jk>. 2214 * @return This object (for method chaining). 2215 */ 2216 public RestClientBuilder trimStringsP(boolean value) { 2217 return set(PARSER_trimStrings, value); 2218 } 2219 2220 /** 2221 * Configuration property: Trim parsed strings. 2222 * 2223 * <p> 2224 * Shortcut for calling <code>trimStrings(<jk>true</jk>)</code>. 2225 * 2226 * <ul class='seealso'> 2227 * <li class='jf'>{@link Parser#PARSER_trimStrings} 2228 * </ul> 2229 * 2230 * @return This object (for method chaining). 2231 */ 2232 public RestClientBuilder trimStringsP() { 2233 return set(PARSER_trimStrings, true); 2234 } 2235 2236 /** 2237 * Configuration property: Unbuffered. 2238 * 2239 * If <jk>true</jk>, don't use internal buffering during parsing. 2240 * 2241 * <ul class='seealso'> 2242 * <li class='jf'>{@link Parser#PARSER_unbuffered} 2243 * </ul> 2244 * 2245 * @param value 2246 * The new value for this property. 2247 * <br>The default value is <jk>false</jk>. 2248 * @return This object (for method chaining). 2249 */ 2250 public RestClientBuilder unbuffered(boolean value) { 2251 return set(PARSER_unbuffered, value); 2252 } 2253 2254 /** 2255 * Configuration property: Unbuffered. 2256 * 2257 * <p> 2258 * Shortcut for calling <code>unbuffered(<jk>true</jk>)</code>. 2259 * 2260 * <ul class='seealso'> 2261 * <li class='jf'>{@link Parser#PARSER_unbuffered} 2262 * </ul> 2263 * 2264 * @return This object (for method chaining). 2265 */ 2266 public RestClientBuilder unbuffered() { 2267 return set(PARSER_unbuffered, true); 2268 } 2269 2270 /** 2271 * Configuration property: File charset. 2272 * 2273 * <p> 2274 * The character set to use for reading <c>Files</c> from the file system. 2275 * 2276 * <ul class='seealso'> 2277 * <li class='jf'>{@link ReaderParser#RPARSER_fileCharset} 2278 * </ul> 2279 * 2280 * @param value 2281 * The new value for this property. 2282 * <br>The default value is <js>"DEFAULT"</js> which causes the system default to be used. 2283 * @return This object (for method chaining). 2284 */ 2285 public RestClientBuilder fileCharset(String value) { 2286 return set(RPARSER_fileCharset, value); 2287 } 2288 2289 /** 2290 * Configuration property: Input stream charset. 2291 * 2292 * <p> 2293 * The character set to use for converting <c>InputStreams</c> and byte arrays to readers. 2294 * 2295 * <ul class='seealso'> 2296 * <li class='jf'>{@link ReaderParser#RPARSER_streamCharset} 2297 * </ul> 2298 * 2299 * @param value 2300 * The new value for this property. 2301 * <br>The default value is <js>"UTF-8"</js>. 2302 * @return This object (for method chaining). 2303 */ 2304 public RestClientBuilder inputStreamCharset(String value) { 2305 return set(RPARSER_streamCharset, value); 2306 } 2307 2308 /** 2309 * Configuration property: Binary input format. 2310 * 2311 * <p> 2312 * When using the {@link Parser#parse(Object,Class)} method on stream-based parsers and the input is a string, this defines the format to use 2313 * when converting the string into a byte array. 2314 * 2315 * <ul class='seealso'> 2316 * <li class='jf'>{@link InputStreamParser#ISPARSER_binaryFormat} 2317 * </ul> 2318 * 2319 * @param value 2320 * The new value for this property. 2321 * <br>The default value is {@link BinaryFormat#HEX}. 2322 * @return This object (for method chaining). 2323 */ 2324 public RestClientBuilder binaryInputFormat(BinaryFormat value) { 2325 return set(ISPARSER_binaryFormat, value); 2326 } 2327 2328 /** 2329 * Configuration property: Parameter format. 2330 * 2331 * <ul class='seealso'> 2332 * <li class='jf'>{@link UonSerializer#UON_paramFormat} 2333 * </ul> 2334 * 2335 * @param value The new value for this property. 2336 * @return This object (for method chaining). 2337 */ 2338 public RestClientBuilder paramFormat(String value) { 2339 return set(UON_paramFormat, value); 2340 } 2341 2342 /** 2343 * Configuration property: Parameter format. 2344 * 2345 * <ul class='seealso'> 2346 * <li class='jf'>{@link UonSerializer#UON_paramFormat} 2347 * </ul> 2348 * 2349 * @return This object (for method chaining). 2350 */ 2351 public RestClientBuilder paramFormatPlain() { 2352 return set(UON_paramFormat, "PLAINTEXT"); 2353 } 2354 2355 // <FluentSetters> 2356 2357 @Override /* BeanContextBuilder */ 2358 public RestClientBuilder beanClassVisibility(Visibility value) { 2359 super.beanClassVisibility(value); 2360 return this; 2361 } 2362 2363 @Override /* BeanContextBuilder */ 2364 public RestClientBuilder beanConstructorVisibility(Visibility value) { 2365 super.beanConstructorVisibility(value); 2366 return this; 2367 } 2368 2369 @Override /* BeanContextBuilder */ 2370 @Deprecated 2371 public RestClientBuilder beanDictionary(Class<?>...values) { 2372 super.beanDictionary(values); 2373 return this; 2374 } 2375 2376 @Override /* BeanContextBuilder */ 2377 @Deprecated 2378 public RestClientBuilder beanDictionary(Object...values) { 2379 super.beanDictionary(values); 2380 return this; 2381 } 2382 2383 @Override /* BeanContextBuilder */ 2384 @Deprecated 2385 public RestClientBuilder beanDictionaryReplace(Class<?>...values) { 2386 super.beanDictionaryReplace(values); 2387 return this; 2388 } 2389 2390 @Override /* BeanContextBuilder */ 2391 @Deprecated 2392 public RestClientBuilder beanDictionaryReplace(Object...values) { 2393 super.beanDictionaryReplace(values); 2394 return this; 2395 } 2396 2397 @Override /* BeanContextBuilder */ 2398 @Deprecated 2399 public RestClientBuilder beanDictionaryRemove(Class<?>...values) { 2400 super.beanDictionaryRemove(values); 2401 return this; 2402 } 2403 2404 @Override /* BeanContextBuilder */ 2405 @Deprecated 2406 public RestClientBuilder beanDictionaryRemove(Object...values) { 2407 super.beanDictionaryRemove(values); 2408 return this; 2409 } 2410 2411 @Override /* BeanContextBuilder */ 2412 public RestClientBuilder beanFieldVisibility(Visibility value) { 2413 super.beanFieldVisibility(value); 2414 return this; 2415 } 2416 2417 @Override /* BeanContextBuilder */ 2418 public RestClientBuilder beanFilters(Object...values) { 2419 super.beanFilters(values); 2420 return this; 2421 } 2422 2423 @Override /* BeanContextBuilder */ 2424 public RestClientBuilder beanFiltersReplace(Object...values) { 2425 super.beanFiltersReplace(values); 2426 return this; 2427 } 2428 2429 @Override /* BeanContextBuilder */ 2430 public RestClientBuilder beanFiltersRemove(Object...values) { 2431 super.beanFiltersRemove(values); 2432 return this; 2433 } 2434 2435 @Override /* BeanContextBuilder */ 2436 public RestClientBuilder beanMapPutReturnsOldValue(boolean value) { 2437 super.beanMapPutReturnsOldValue(value); 2438 return this; 2439 } 2440 2441 @Override /* BeanContextBuilder */ 2442 public RestClientBuilder beanMapPutReturnsOldValue() { 2443 super.beanMapPutReturnsOldValue(); 2444 return this; 2445 } 2446 2447 @Override /* BeanContextBuilder */ 2448 public RestClientBuilder beanMethodVisibility(Visibility value) { 2449 super.beanMethodVisibility(value); 2450 return this; 2451 } 2452 2453 @Override /* BeanContextBuilder */ 2454 public RestClientBuilder beansRequireDefaultConstructor(boolean value) { 2455 super.beansRequireDefaultConstructor(value); 2456 return this; 2457 } 2458 2459 @Override /* BeanContextBuilder */ 2460 public RestClientBuilder beansRequireDefaultConstructor() { 2461 super.beansRequireDefaultConstructor(); 2462 return this; 2463 } 2464 2465 @Override /* BeanContextBuilder */ 2466 public RestClientBuilder beansRequireSerializable(boolean value) { 2467 super.beansRequireSerializable(value); 2468 return this; 2469 } 2470 2471 @Override /* BeanContextBuilder */ 2472 public RestClientBuilder beansRequireSerializable() { 2473 super.beansRequireSerializable(); 2474 return this; 2475 } 2476 2477 @Override /* BeanContextBuilder */ 2478 public RestClientBuilder beansRequireSettersForGetters(boolean value) { 2479 super.beansRequireSettersForGetters(value); 2480 return this; 2481 } 2482 2483 @Override /* BeanContextBuilder */ 2484 public RestClientBuilder beansRequireSettersForGetters() { 2485 super.beansRequireSettersForGetters(); 2486 return this; 2487 } 2488 2489 @Override /* BeanContextBuilder */ 2490 public RestClientBuilder beansRequireSomeProperties(boolean value) { 2491 super.beansRequireSomeProperties(value); 2492 return this; 2493 } 2494 2495 @Override /* BeanContextBuilder */ 2496 public RestClientBuilder bpi(Class<?> beanClass, String value) { 2497 super.bpi(beanClass, value); 2498 return this; 2499 } 2500 2501 @Override /* BeanContextBuilder */ 2502 public RestClientBuilder bpi(Map<String,Object> values) { 2503 super.bpi(values); 2504 return this; 2505 } 2506 2507 @Override /* BeanContextBuilder */ 2508 public RestClientBuilder bpi(String beanClassName, String value) { 2509 super.bpi(beanClassName, value); 2510 return this; 2511 } 2512 2513 @Override /* BeanContextBuilder */ 2514 public RestClientBuilder bpx(Class<?> beanClass, String properties) { 2515 super.bpx(beanClass, properties); 2516 return this; 2517 } 2518 2519 @Override /* BeanContextBuilder */ 2520 public RestClientBuilder bpx(Map<String,Object> values) { 2521 super.bpx(values); 2522 return this; 2523 } 2524 2525 @Override /* BeanContextBuilder */ 2526 public RestClientBuilder bpx(String beanClassName, String value) { 2527 super.bpx(beanClassName, value); 2528 return this; 2529 } 2530 2531 @Override /* BeanContextBuilder */ 2532 public RestClientBuilder bpro(Class<?> beanClass, String value) { 2533 super.bpro(beanClass, value); 2534 return this; 2535 } 2536 2537 @Override /* BeanContextBuilder */ 2538 public RestClientBuilder bpro(Map<String,Object> values) { 2539 super.bpro(values); 2540 return this; 2541 } 2542 2543 @Override /* BeanContextBuilder */ 2544 public RestClientBuilder bpro(String beanClassName, String value) { 2545 super.bpro(beanClassName, value); 2546 return this; 2547 } 2548 2549 @Override /* BeanContextBuilder */ 2550 public RestClientBuilder bpwo(Class<?> beanClass, String properties) { 2551 super.bpwo(beanClass, properties); 2552 return this; 2553 } 2554 2555 @Override /* BeanContextBuilder */ 2556 public RestClientBuilder bpwo(Map<String,Object> values) { 2557 super.bpwo(values); 2558 return this; 2559 } 2560 2561 @Override /* BeanContextBuilder */ 2562 public RestClientBuilder bpwo(String beanClassName, String value) { 2563 super.bpwo(beanClassName, value); 2564 return this; 2565 } 2566 2567 @Override /* BeanContextBuilder */ 2568 public RestClientBuilder debug() { 2569 super.debug(); 2570 interceptors(RestCallLogger.DEFAULT); 2571 return this; 2572 } 2573 2574 @Override /* BeanContextBuilder */ 2575 public RestClientBuilder debug(boolean value) { 2576 super.debug(value); 2577 if (value) 2578 interceptors(RestCallLogger.DEFAULT); 2579 return this; 2580 } 2581 2582 @Override /* BeanContextBuilder */ 2583 public RestClientBuilder dictionary(Object...values) { 2584 super.dictionary(values); 2585 return this; 2586 } 2587 2588 @Override /* BeanContextBuilder */ 2589 public <T> RestClientBuilder example(Class<T> c, T o) { 2590 super.example(c, o); 2591 return this; 2592 } 2593 2594 @Override /* BeanContextBuilder */ 2595 public <T> RestClientBuilder exampleJson(Class<T> c, String value) { 2596 super.exampleJson(c, value); 2597 return this; 2598 } 2599 2600 @Override /* BeanContextBuilder */ 2601 public RestClientBuilder ignoreInvocationExceptionsOnGetters(boolean value) { 2602 super.ignoreInvocationExceptionsOnGetters(value); 2603 return this; 2604 } 2605 2606 @Override /* BeanContextBuilder */ 2607 public RestClientBuilder ignoreInvocationExceptionsOnGetters() { 2608 super.ignoreInvocationExceptionsOnGetters(); 2609 return this; 2610 } 2611 2612 @Override /* BeanContextBuilder */ 2613 public RestClientBuilder ignoreInvocationExceptionsOnSetters(boolean value) { 2614 super.ignoreInvocationExceptionsOnSetters(value); 2615 return this; 2616 } 2617 2618 @Override /* BeanContextBuilder */ 2619 public RestClientBuilder ignoreInvocationExceptionsOnSetters() { 2620 super.ignoreInvocationExceptionsOnSetters(); 2621 return this; 2622 } 2623 2624 @Override /* BeanContextBuilder */ 2625 public RestClientBuilder ignorePropertiesWithoutSetters(boolean value) { 2626 super.ignorePropertiesWithoutSetters(value); 2627 return this; 2628 } 2629 2630 @Override 2631 public RestClientBuilder ignoreUnknownBeanProperties(boolean value) { 2632 super.ignoreUnknownBeanProperties(value); 2633 return this; 2634 } 2635 2636 @Override /* BeanContextBuilder */ 2637 public RestClientBuilder ignoreUnknownBeanProperties() { 2638 super.ignoreUnknownBeanProperties(); 2639 return this; 2640 } 2641 2642 @Override /* BeanContextBuilder */ 2643 public RestClientBuilder ignoreUnknownNullBeanProperties(boolean value) { 2644 super.ignoreUnknownNullBeanProperties(value); 2645 return this; 2646 } 2647 2648 @Override /* BeanContextBuilder */ 2649 public RestClientBuilder implClass(Class<?> interfaceClass, Class<?> implClass) { 2650 super.implClass(interfaceClass, implClass); 2651 return this; 2652 } 2653 2654 @Override /* BeanContextBuilder */ 2655 public RestClientBuilder implClasses(Map<Class<?>,Class<?>> values) { 2656 super.implClasses(values); 2657 return this; 2658 } 2659 2660 @Override /* BeanContextBuilder */ 2661 public RestClientBuilder locale(Locale value) { 2662 super.locale(value); 2663 return this; 2664 } 2665 2666 @Override /* BeanContextBuilder */ 2667 public RestClientBuilder mediaType(MediaType value) { 2668 super.mediaType(value); 2669 return this; 2670 } 2671 2672 @Override /* BeanContextBuilder */ 2673 public RestClientBuilder notBeanClasses(Object...values) { 2674 super.notBeanClasses(values); 2675 return this; 2676 } 2677 2678 @Override /* BeanContextBuilder */ 2679 public RestClientBuilder notBeanPackages(Object...values) { 2680 super.notBeanPackages(values); 2681 return this; 2682 } 2683 2684 @Override /* BeanContextBuilder */ 2685 public RestClientBuilder sortProperties(boolean value) { 2686 super.sortProperties(value); 2687 return this; 2688 } 2689 2690 @Override /* BeanContextBuilder */ 2691 public RestClientBuilder sortProperties() { 2692 super.sortProperties(); 2693 return this; 2694 } 2695 2696 @Override /* BeanContextBuilder */ 2697 public RestClientBuilder timeZone(TimeZone value) { 2698 super.timeZone(value); 2699 return this; 2700 } 2701 2702 @Override /* BeanContextBuilder */ 2703 public RestClientBuilder useEnumNames(boolean value) { 2704 super.useEnumNames(value); 2705 return this; 2706 } 2707 2708 @Override /* BeanContextBuilder */ 2709 public RestClientBuilder useEnumNames() { 2710 super.useEnumNames(); 2711 return this; 2712 } 2713 2714 @Override /* BeanContextBuilder */ 2715 public RestClientBuilder useInterfaceProxies(boolean value) { 2716 super.useInterfaceProxies(value); 2717 return this; 2718 } 2719 2720 @Override /* BeanContextBuilder */ 2721 public RestClientBuilder useJavaBeanIntrospector(boolean value) { 2722 super.useJavaBeanIntrospector(value); 2723 return this; 2724 } 2725 2726 @Override /* BeanContextBuilder */ 2727 public RestClientBuilder useJavaBeanIntrospector() { 2728 super.useJavaBeanIntrospector(); 2729 return this; 2730 } 2731 2732 @Override /* ContextBuilder */ 2733 public RestClientBuilder annotations(Annotation...values) { 2734 super.annotations(values); 2735 return this; 2736 } 2737 2738 @Override /* ContextBuilder */ 2739 public RestClientBuilder set(String name, Object value) { 2740 super.set(name, value); 2741 return this; 2742 } 2743 2744 @Override /* ContextBuilder */ 2745 public RestClientBuilder set(Map<String,Object> properties) { 2746 super.set(properties); 2747 return this; 2748 } 2749 2750 @Override /* ContextBuilder */ 2751 public RestClientBuilder add(Map<String,Object> properties) { 2752 super.add(properties); 2753 return this; 2754 } 2755 2756 @Override /* ContextBuilder */ 2757 public RestClientBuilder addTo(String name, Object value) { 2758 super.addTo(name, value); 2759 return this; 2760 } 2761 2762 @Override /* ContextBuilder */ 2763 public RestClientBuilder prependTo(String name, Object value) { 2764 super.prependTo(name, value); 2765 return this; 2766 } 2767 2768 @Override /* ContextBuilder */ 2769 public RestClientBuilder putTo(String name, String key, Object value) { 2770 super.putTo(name, key, value); 2771 return this; 2772 } 2773 2774 @Override /* ContextBuilder */ 2775 public RestClientBuilder removeFrom(String name, Object value) { 2776 super.removeFrom(name, value); 2777 return this; 2778 } 2779 2780 @Override /* ContextBuilder */ 2781 public RestClientBuilder apply(PropertyStore copyFrom) { 2782 super.apply(copyFrom); 2783 return this; 2784 } 2785 2786 @Override /* ContextBuilder */ 2787 public RestClientBuilder applyAnnotations(AnnotationList al, VarResolverSession vrs) { 2788 super.applyAnnotations(al, vrs); 2789 return this; 2790 } 2791 2792 @Override /* ContextBuilder */ 2793 public RestClientBuilder applyAnnotations(Class<?>...fromClasses) { 2794 super.applyAnnotations(fromClasses); 2795 return this; 2796 } 2797 2798 @Override /* ContextBuilder */ 2799 public RestClientBuilder applyAnnotations(Method...fromMethods) { 2800 super.applyAnnotations(fromMethods); 2801 return this; 2802 } 2803 2804 // </FluentSetters> 2805 2806 //------------------------------------------------------------------------------------------------ 2807 // Passthrough methods for HttpClientBuilder. 2808 //------------------------------------------------------------------------------------------------ 2809 2810 /** 2811 * @return This object (for method chaining). 2812 * @see HttpClientBuilder#disableRedirectHandling() 2813 */ 2814 public RestClientBuilder disableRedirectHandling() { 2815 httpClientBuilder.disableRedirectHandling(); 2816 return this; 2817 } 2818 2819 /** 2820 * @param redirectStrategy New property value. 2821 * @return This object (for method chaining). 2822 * @see HttpClientBuilder#setRedirectStrategy(RedirectStrategy) 2823 */ 2824 public RestClientBuilder redirectStrategy(RedirectStrategy redirectStrategy) { 2825 httpClientBuilder.setRedirectStrategy(redirectStrategy); 2826 return this; 2827 } 2828 2829 /** 2830 * @param cookieSpecRegistry New property value. 2831 * @return This object (for method chaining). 2832 * @see HttpClientBuilder#setDefaultCookieSpecRegistry(Lookup) 2833 */ 2834 public RestClientBuilder defaultCookieSpecRegistry(Lookup<CookieSpecProvider> cookieSpecRegistry) { 2835 httpClientBuilder.setDefaultCookieSpecRegistry(cookieSpecRegistry); 2836 return this; 2837 } 2838 2839 /** 2840 * @param requestExec New property value. 2841 * @return This object (for method chaining). 2842 * @see HttpClientBuilder#setRequestExecutor(HttpRequestExecutor) 2843 */ 2844 public RestClientBuilder requestExecutor(HttpRequestExecutor requestExec) { 2845 httpClientBuilder.setRequestExecutor(requestExec); 2846 return this; 2847 } 2848 2849 /** 2850 * @param hostnameVerifier New property value. 2851 * @return This object (for method chaining). 2852 * @see HttpClientBuilder#setSSLHostnameVerifier(HostnameVerifier) 2853 */ 2854 public RestClientBuilder sslHostnameVerifier(HostnameVerifier hostnameVerifier) { 2855 httpClientBuilder.setSSLHostnameVerifier(hostnameVerifier); 2856 return this; 2857 } 2858 2859 /** 2860 * @param publicSuffixMatcher New property value. 2861 * @return This object (for method chaining). 2862 * @see HttpClientBuilder#setPublicSuffixMatcher(PublicSuffixMatcher) 2863 */ 2864 public RestClientBuilder publicSuffixMatcher(PublicSuffixMatcher publicSuffixMatcher) { 2865 httpClientBuilder.setPublicSuffixMatcher(publicSuffixMatcher); 2866 return this; 2867 } 2868 2869 /** 2870 * @param sslContext New property value. 2871 * @return This object (for method chaining). 2872 * @see HttpClientBuilder#setSSLContext(SSLContext) 2873 */ 2874 public RestClientBuilder sslContext(SSLContext sslContext) { 2875 httpClientBuilder.setSSLContext(sslContext); 2876 return this; 2877 } 2878 2879 /** 2880 * @param sslSocketFactory New property value. 2881 * @return This object (for method chaining). 2882 * @see HttpClientBuilder#setSSLSocketFactory(LayeredConnectionSocketFactory) 2883 */ 2884 public RestClientBuilder sslSocketFactory(LayeredConnectionSocketFactory sslSocketFactory) { 2885 httpClientBuilder.setSSLSocketFactory(sslSocketFactory); 2886 return this; 2887 } 2888 2889 /** 2890 * @param maxConnTotal New property value. 2891 * @return This object (for method chaining). 2892 * @see HttpClientBuilder#setMaxConnTotal(int) 2893 */ 2894 public RestClientBuilder maxConnTotal(int maxConnTotal) { 2895 httpClientBuilder.setMaxConnTotal(maxConnTotal); 2896 return this; 2897 } 2898 2899 /** 2900 * @param maxConnPerRoute New property value. 2901 * @return This object (for method chaining). 2902 * @see HttpClientBuilder#setMaxConnPerRoute(int) 2903 */ 2904 public RestClientBuilder maxConnPerRoute(int maxConnPerRoute) { 2905 httpClientBuilder.setMaxConnPerRoute(maxConnPerRoute); 2906 return this; 2907 } 2908 2909 /** 2910 * @param config New property value. 2911 * @return This object (for method chaining). 2912 * @see HttpClientBuilder#setDefaultSocketConfig(SocketConfig) 2913 */ 2914 public RestClientBuilder defaultSocketConfig(SocketConfig config) { 2915 httpClientBuilder.setDefaultSocketConfig(config); 2916 return this; 2917 } 2918 2919 /** 2920 * @param config New property value. 2921 * @return This object (for method chaining). 2922 * @see HttpClientBuilder#setDefaultConnectionConfig(ConnectionConfig) 2923 */ 2924 public RestClientBuilder defaultConnectionConfig(ConnectionConfig config) { 2925 httpClientBuilder.setDefaultConnectionConfig(config); 2926 return this; 2927 } 2928 2929 /** 2930 * @param connTimeToLive New property value. 2931 * @param connTimeToLiveTimeUnit New property value. 2932 * @return This object (for method chaining). 2933 * @see HttpClientBuilder#setConnectionTimeToLive(long,TimeUnit) 2934 */ 2935 public RestClientBuilder connectionTimeToLive(long connTimeToLive, TimeUnit connTimeToLiveTimeUnit) { 2936 httpClientBuilder.setConnectionTimeToLive(connTimeToLive, connTimeToLiveTimeUnit); 2937 return this; 2938 } 2939 2940 /** 2941 * @param connManager New property value. 2942 * @return This object (for method chaining). 2943 * @see HttpClientBuilder#setConnectionManager(HttpClientConnectionManager) 2944 */ 2945 public RestClientBuilder connectionManager(HttpClientConnectionManager connManager) { 2946 this.httpClientConnectionManager = connManager; 2947 httpClientBuilder.setConnectionManager(connManager); 2948 return this; 2949 } 2950 2951 /** 2952 * @param shared New property value. 2953 * @return This object (for method chaining). 2954 * @see HttpClientBuilder#setConnectionManagerShared(boolean) 2955 */ 2956 public RestClientBuilder connectionManagerShared(boolean shared) { 2957 httpClientBuilder.setConnectionManagerShared(shared); 2958 return this; 2959 } 2960 2961 /** 2962 * @param reuseStrategy New property value. 2963 * @return This object (for method chaining). 2964 * @see HttpClientBuilder#setConnectionReuseStrategy(ConnectionReuseStrategy) 2965 */ 2966 public RestClientBuilder connectionReuseStrategy(ConnectionReuseStrategy reuseStrategy) { 2967 httpClientBuilder.setConnectionReuseStrategy(reuseStrategy); 2968 return this; 2969 } 2970 2971 /** 2972 * @param keepAliveStrategy New property value. 2973 * @return This object (for method chaining). 2974 * @see HttpClientBuilder#setKeepAliveStrategy(ConnectionKeepAliveStrategy) 2975 */ 2976 public RestClientBuilder keepAliveStrategy(ConnectionKeepAliveStrategy keepAliveStrategy) { 2977 httpClientBuilder.setKeepAliveStrategy(keepAliveStrategy); 2978 return this; 2979 } 2980 2981 /** 2982 * @param targetAuthStrategy New property value. 2983 * @return This object (for method chaining). 2984 * @see HttpClientBuilder#setTargetAuthenticationStrategy(AuthenticationStrategy) 2985 */ 2986 public RestClientBuilder targetAuthenticationStrategy(AuthenticationStrategy targetAuthStrategy) { 2987 httpClientBuilder.setTargetAuthenticationStrategy(targetAuthStrategy); 2988 return this; 2989 } 2990 2991 /** 2992 * @param proxyAuthStrategy New property value. 2993 * @return This object (for method chaining). 2994 * @see HttpClientBuilder#setProxyAuthenticationStrategy(AuthenticationStrategy) 2995 */ 2996 public RestClientBuilder proxyAuthenticationStrategy(AuthenticationStrategy proxyAuthStrategy) { 2997 httpClientBuilder.setProxyAuthenticationStrategy(proxyAuthStrategy); 2998 return this; 2999 } 3000 3001 /** 3002 * @param userTokenHandler New property value. 3003 * @return This object (for method chaining). 3004 * @see HttpClientBuilder#setUserTokenHandler(UserTokenHandler) 3005 */ 3006 public RestClientBuilder userTokenHandler(UserTokenHandler userTokenHandler) { 3007 httpClientBuilder.setUserTokenHandler(userTokenHandler); 3008 return this; 3009 } 3010 3011 /** 3012 * @return This object (for method chaining). 3013 * @see HttpClientBuilder#disableConnectionState() 3014 */ 3015 public RestClientBuilder disableConnectionState() { 3016 httpClientBuilder.disableConnectionState(); 3017 return this; 3018 } 3019 3020 /** 3021 * @param schemePortResolver New property value. 3022 * @return This object (for method chaining). 3023 * @see HttpClientBuilder#setSchemePortResolver(SchemePortResolver) 3024 */ 3025 public RestClientBuilder schemePortResolver(SchemePortResolver schemePortResolver) { 3026 httpClientBuilder.setSchemePortResolver(schemePortResolver); 3027 return this; 3028 } 3029 3030 /** 3031 * @param userAgent New property value. 3032 * @return This object (for method chaining). 3033 * @see HttpClientBuilder#setUserAgent(String) 3034 */ 3035 public RestClientBuilder userAgent(String userAgent) { 3036 httpClientBuilder.setUserAgent(userAgent); 3037 return this; 3038 } 3039 3040 /** 3041 * @param defaultHeaders New property value. 3042 * @return This object (for method chaining). 3043 * @see HttpClientBuilder#setDefaultHeaders(Collection) 3044 */ 3045 public RestClientBuilder defaultHeaders(Collection<? extends Header> defaultHeaders) { 3046 httpClientBuilder.setDefaultHeaders(defaultHeaders); 3047 return this; 3048 } 3049 3050 /** 3051 * @param itcp New property value. 3052 * @return This object (for method chaining). 3053 * @see HttpClientBuilder#addInterceptorFirst(HttpResponseInterceptor) 3054 */ 3055 public RestClientBuilder addInterceptorFirst(HttpResponseInterceptor itcp) { 3056 httpClientBuilder.addInterceptorFirst(itcp); 3057 return this; 3058 } 3059 3060 /** 3061 * @param itcp New property value. 3062 * @return This object (for method chaining). 3063 * @see HttpClientBuilder#addInterceptorLast(HttpResponseInterceptor) 3064 */ 3065 public RestClientBuilder addInterceptorLast(HttpResponseInterceptor itcp) { 3066 httpClientBuilder.addInterceptorLast(itcp); 3067 return this; 3068 } 3069 3070 /** 3071 * @param itcp New property value. 3072 * @return This object (for method chaining). 3073 * @see HttpClientBuilder#addInterceptorFirst(HttpRequestInterceptor) 3074 */ 3075 public RestClientBuilder addInterceptorFirst(HttpRequestInterceptor itcp) { 3076 httpClientBuilder.addInterceptorFirst(itcp); 3077 return this; 3078 } 3079 3080 /** 3081 * @param itcp New property value. 3082 * @return This object (for method chaining). 3083 * @see HttpClientBuilder#addInterceptorLast(HttpRequestInterceptor) 3084 */ 3085 public RestClientBuilder addInterceptorLast(HttpRequestInterceptor itcp) { 3086 httpClientBuilder.addInterceptorLast(itcp); 3087 return this; 3088 } 3089 3090 /** 3091 * @return This object (for method chaining). 3092 * @see HttpClientBuilder#disableCookieManagement() 3093 */ 3094 public RestClientBuilder disableCookieManagement() { 3095 httpClientBuilder.disableCookieManagement(); 3096 return this; 3097 } 3098 3099 /** 3100 * @return This object (for method chaining). 3101 * @see HttpClientBuilder#disableContentCompression() 3102 */ 3103 public RestClientBuilder disableContentCompression() { 3104 httpClientBuilder.disableContentCompression(); 3105 return this; 3106 } 3107 3108 /** 3109 * @return This object (for method chaining). 3110 * @see HttpClientBuilder#disableAuthCaching() 3111 */ 3112 public RestClientBuilder disableAuthCaching() { 3113 httpClientBuilder.disableAuthCaching(); 3114 return this; 3115 } 3116 3117 /** 3118 * @param httpprocessor New property value. 3119 * @return This object (for method chaining). 3120 * @see HttpClientBuilder#setHttpProcessor(HttpProcessor) 3121 */ 3122 public RestClientBuilder httpProcessor(HttpProcessor httpprocessor) { 3123 httpClientBuilder.setHttpProcessor(httpprocessor); 3124 return this; 3125 } 3126 3127 /** 3128 * @param retryHandler New property value. 3129 * @return This object (for method chaining). 3130 * @see HttpClientBuilder#setRetryHandler(HttpRequestRetryHandler) 3131 */ 3132 public RestClientBuilder retryHandler(HttpRequestRetryHandler retryHandler) { 3133 httpClientBuilder.setRetryHandler(retryHandler); 3134 return this; 3135 } 3136 3137 /** 3138 * @return This object (for method chaining). 3139 * @see HttpClientBuilder#disableAutomaticRetries() 3140 */ 3141 public RestClientBuilder disableAutomaticRetries() { 3142 httpClientBuilder.disableAutomaticRetries(); 3143 return this; 3144 } 3145 3146 /** 3147 * @param proxy New property value. 3148 * @return This object (for method chaining). 3149 * @see HttpClientBuilder#setProxy(HttpHost) 3150 */ 3151 public RestClientBuilder proxy(HttpHost proxy) { 3152 httpClientBuilder.setProxy(proxy); 3153 return this; 3154 } 3155 3156 /** 3157 * @param routePlanner New property value. 3158 * @return This object (for method chaining). 3159 * @see HttpClientBuilder#setRoutePlanner(HttpRoutePlanner) 3160 */ 3161 public RestClientBuilder routePlanner(HttpRoutePlanner routePlanner) { 3162 httpClientBuilder.setRoutePlanner(routePlanner); 3163 return this; 3164 } 3165 3166 /** 3167 * @param connectionBackoffStrategy New property value. 3168 * @return This object (for method chaining). 3169 * @see HttpClientBuilder#setConnectionBackoffStrategy(ConnectionBackoffStrategy) 3170 */ 3171 public RestClientBuilder connectionBackoffStrategy(ConnectionBackoffStrategy connectionBackoffStrategy) { 3172 httpClientBuilder.setConnectionBackoffStrategy(connectionBackoffStrategy); 3173 return this; 3174 } 3175 3176 /** 3177 * @param backoffManager New property value. 3178 * @return This object (for method chaining). 3179 * @see HttpClientBuilder#setBackoffManager(BackoffManager) 3180 */ 3181 public RestClientBuilder backoffManager(BackoffManager backoffManager) { 3182 httpClientBuilder.setBackoffManager(backoffManager); 3183 return this; 3184 } 3185 3186 /** 3187 * @param serviceUnavailStrategy New property value. 3188 * @return This object (for method chaining). 3189 * @see HttpClientBuilder#setServiceUnavailableRetryStrategy(ServiceUnavailableRetryStrategy) 3190 */ 3191 public RestClientBuilder serviceUnavailableRetryStrategy(ServiceUnavailableRetryStrategy serviceUnavailStrategy) { 3192 httpClientBuilder.setServiceUnavailableRetryStrategy(serviceUnavailStrategy); 3193 return this; 3194 } 3195 3196 /** 3197 * @param cookieStore New property value. 3198 * @return This object (for method chaining). 3199 * @see HttpClientBuilder#setDefaultCookieStore(CookieStore) 3200 */ 3201 public RestClientBuilder defaultCookieStore(CookieStore cookieStore) { 3202 httpClientBuilder.setDefaultCookieStore(cookieStore); 3203 return this; 3204 } 3205 3206 /** 3207 * @param credentialsProvider New property value. 3208 * @return This object (for method chaining). 3209 * @see HttpClientBuilder#setDefaultCredentialsProvider(CredentialsProvider) 3210 */ 3211 public RestClientBuilder defaultCredentialsProvider(CredentialsProvider credentialsProvider) { 3212 httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider); 3213 return this; 3214 } 3215 3216 /** 3217 * @param authSchemeRegistry New property value. 3218 * @return This object (for method chaining). 3219 * @see HttpClientBuilder#setDefaultAuthSchemeRegistry(Lookup) 3220 */ 3221 public RestClientBuilder defaultAuthSchemeRegistry(Lookup<AuthSchemeProvider> authSchemeRegistry) { 3222 httpClientBuilder.setDefaultAuthSchemeRegistry(authSchemeRegistry); 3223 return this; 3224 } 3225 3226 /** 3227 * @param contentDecoderMap New property value. 3228 * @return This object (for method chaining). 3229 * @see HttpClientBuilder#setContentDecoderRegistry(Map) 3230 */ 3231 public RestClientBuilder contentDecoderRegistry(Map<String,InputStreamFactory> contentDecoderMap) { 3232 httpClientBuilder.setContentDecoderRegistry(contentDecoderMap); 3233 return this; 3234 } 3235 3236 /** 3237 * @param config New property value. 3238 * @return This object (for method chaining). 3239 * @see HttpClientBuilder#setDefaultRequestConfig(RequestConfig) 3240 */ 3241 public RestClientBuilder defaultRequestConfig(RequestConfig config) { 3242 httpClientBuilder.setDefaultRequestConfig(config); 3243 return this; 3244 } 3245 3246 /** 3247 * @return This object (for method chaining). 3248 * @see HttpClientBuilder#useSystemProperties() 3249 */ 3250 public RestClientBuilder useSystemProperties() { 3251 httpClientBuilder.useSystemProperties(); 3252 return this; 3253 } 3254 3255 /** 3256 * @return This object (for method chaining). 3257 * @see HttpClientBuilder#evictExpiredConnections() 3258 */ 3259 public RestClientBuilder evictExpiredConnections() { 3260 httpClientBuilder.evictExpiredConnections(); 3261 return this; 3262 } 3263 3264 /** 3265 * @param maxIdleTime New property value. 3266 * @param maxIdleTimeUnit New property value. 3267 * @return This object (for method chaining). 3268 * @see HttpClientBuilder#evictIdleConnections(long,TimeUnit) 3269 */ 3270 public RestClientBuilder evictIdleConnections(long maxIdleTime, TimeUnit maxIdleTimeUnit) { 3271 httpClientBuilder.evictIdleConnections(maxIdleTime, maxIdleTimeUnit); 3272 return this; 3273 } 3274}