001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.rest.client; 018 019/** 020 * A builder interface for configuring and creating {@link HttpTransport} instances. 021 * 022 * <p> 023 * Transport modules (Apache HC, Java HTTP Client, OkHttp, etc.) implement this interface to expose their 024 * configuration options in a transport-agnostic way. The built transport is then passed to 025 * {@link RestClient.Builder#transport(HttpTransport)}. 026 * 027 * <p> 028 * Example usage: 029 * <p class='bjava'> 030 * <jc>// Transport-specific options (here, the underlying Apache client) are set on the concrete builder.</jc> 031 * HttpTransport <jv>transport</jv> = ApacheHc5Transport.<jsm>builder</jsm>() 032 * .httpClient(<jv>myCloseableHttpClient</jv>) 033 * .build(); 034 * 035 * RestClient <jv>client</jv> = RestClient.create() 036 * .transport(<jv>transport</jv>) 037 * .build(); 038 * </p> 039 * 040 * <h5 class='section'>See Also:</h5><ul> 041 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/NextGenRestClient">Next-Generation REST Client</a> 042 * </ul> 043 * 044 * @since 9.2.1 045 */ 046public interface HttpTransportBuilder { 047 048 /** 049 * Builds and returns a configured {@link HttpTransport} instance. 050 * 051 * @return A new transport. Never <jk>null</jk>. 052 */ 053 HttpTransport build(); 054}