RestClient.Builder クラス

  • java.lang.Object
    • com.microsoft.bot.restclient.RestClient.Builder

public static class RestClient.Builder

REST クライアントを構築するためのビルダー クラス。

コンストラクターの概要

コンストラクター 説明
Builder()

サービスのベース URL を使用してビルダーのインスタンスを作成します。

Builder(OkHttpClient.Builder httpClientBuilder, Retrofit.Builder retrofitBuilder)

ベース URL と 2 つのカスタム ビルダーを使用して、ビルダーのインスタンスを作成します。

メソッドの概要

修飾子と型 メソッドと説明
RestClient build()

現在のすべての構成で RestClient を構築します。

Builder useHttpClientThreadPool(boolean useHttpClientThreadPool)

OkHttp クライアントまたは RxJava スケジューラでスレッド プールを使用するかどうかを設定します。

Builder withBaseUrl(Environment environment, Environment.Endpoint endpoint)

環境の既定値を使用してベース URL を設定します。

Builder withBaseUrl(String baseUrl)

動的ベース URL を設定します。

Builder withCallbackExecutor(Executor executor)

実行する非同期コールバックの Executor を設定します。

Builder withConnectionPool(ConnectionPool connectionPool)

Http クライアントの接続プールを設定します。

Builder withConnectionTimeout(long timeout, TimeUnit unit)

HTTP クライアントで接続タイムアウトを設定します。

Builder withCredentials(ServiceClientCredentials credentials)

資格情報を設定します。

Builder withDispatcher(Dispatcher dispatcher)

OkHttp クライアントで使用されるディスパッチャーを設定します。

Builder withInterceptor(Interceptor interceptor)

インターセプターを Http クライアント パイプラインに追加します。

Builder withLogLevel(LogLevel logLevel)

HTTP ログ レベルを設定します。

Builder withMaxIdleConnections(int maxIdleConnections)

非推奨

HTTP クライアントの最大アイドル接続数を設定します。

Builder withNetworkInterceptor(Interceptor networkInterceptor)

Http クライアント パイプラインのネットワーク レイヤーにインターセプターを追加します。

Builder withProxy(Proxy proxy)

HTTP クライアントのプロキシを設定します。

Builder withProxyAuthenticator(Authenticator proxyAuthenticator)

HTTP クライアントのプロキシ認証子を設定します。

Builder withReadTimeout(long timeout, TimeUnit unit)

HTTP クライアントで読み取りタイムアウトを設定します。

Builder withResponseBuilderFactory(ResponseBuilder.Factory responseBuilderFactory)

応答ビルダー ファクトリを設定します。

Builder withRetryStrategy(RetryStrategy strategy)

再試行戦略をクライアントに追加します。

Builder withSerializerAdapter(SerializerAdapter<?> serializerAdapter)

シリアル化アダプターを設定します。

Builder withUserAgent(String userAgent)

ユーザー エージェント ヘッダーを設定します。

メソッドの継承元: java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

コンストラクターの詳細

Builder

public Builder()

サービスのベース URL を使用してビルダーのインスタンスを作成します。

Builder

public Builder(OkHttpClient.Builder httpClientBuilder, Retrofit.Builder retrofitBuilder)

ベース URL と 2 つのカスタム ビルダーを使用して、ビルダーのインスタンスを作成します。

パラメーター:

httpClientBuilder - OkHttpClientをビルドするビルダー。
retrofitBuilder - ビルダーを使用して Retrofitをビルドします。

メソッドの詳細

build

public RestClient build()

現在のすべての構成を使用して RestClient をビルドします。

戻り値:

useHttpClientThreadPool

public RestClient.Builder useHttpClientThreadPool(boolean useHttpClientThreadPool)

OkHttp クライアントまたは RxJava スケジューラでスレッド プールを使用するかどうかを設定します。 true に設定すると、OkHttp クライアントのスレッド プールが使用されます。 既定値は false です。

パラメーター:

useHttpClientThreadPool - Okhttp クライアントでスレッド プールを使用するかどうか。 既定値は false です。

戻り値:

チェーンのためのビルダー自体

withBaseUrl

public RestClient.Builder withBaseUrl(Environment environment, Environment.Endpoint endpoint)

環境の既定値を使用してベース URL を設定します。

パラメーター:

environment - 使用する環境
endpoint - アプリケーションがアクセスしている環境エンドポイント

戻り値:

チェーンのためのビルダー自体

withBaseUrl

public RestClient.Builder withBaseUrl(String baseUrl)

動的ベース URL を設定します。

パラメーター:

baseUrl - 使用するベース URL。

戻り値:

チェーン用のビルダー自体。

withCallbackExecutor

public RestClient.Builder withCallbackExecutor(Executor executor)

実行する非同期コールバックの Executor を設定します。

パラメーター:

executor - コールバックを実行する Executor。

戻り値:

チェーンのためのビルダー自体

withConnectionPool

public RestClient.Builder withConnectionPool(ConnectionPool connectionPool)

Http クライアントの接続プールを設定します。

パラメーター:

connectionPool - 使用する OkHttp 3 接続プール

戻り値:

チェーンのためのビルダー自体

withConnectionTimeout

public RestClient.Builder withConnectionTimeout(long timeout, TimeUnit unit)

HTTP クライアントで接続タイムアウトを設定します。 既定値は 10 秒です。

パラメーター:

timeout - タイムアウト数値
unit - 数値の時間単位

戻り値:

チェーンのためのビルダー自体

withCredentials

public RestClient.Builder withCredentials(ServiceClientCredentials credentials)

資格情報を設定します。

パラメーター:

credentials - 資格情報オブジェクト。

戻り値:

チェーン用のビルダー自体。

withDispatcher

public RestClient.Builder withDispatcher(Dispatcher dispatcher)

OkHttp クライアントで使用されるディスパッチャーを設定します。 これは、HTTP 要求を実行するためのスレッド プールを設定する場所でもあります。

パラメーター:

dispatcher - 使用するディスパッチャー

戻り値:

チェーンのためのビルダー自体

withInterceptor

public RestClient.Builder withInterceptor(Interceptor interceptor)

インターセプターを Http クライアント パイプラインに追加します。

パラメーター:

interceptor - 追加するインターセプター。

戻り値:

チェーン用のビルダー自体。

withLogLevel

public RestClient.Builder withLogLevel(LogLevel logLevel)

HTTP ログ レベルを設定します。

パラメーター:

logLevel - LogLevel 列挙型。

戻り値:

チェーン用のビルダー自体。

withMaxIdleConnections


public RestClient.Builder withMaxIdleConnections(int maxIdleConnections)

非推奨

HTTP クライアントの最大アイドル接続数を設定します。 既定値は 5 です。

パラメーター:

maxIdleConnections - 最大アイドル接続数

戻り値:

チェーンのためのビルダー自体

withNetworkInterceptor

public RestClient.Builder withNetworkInterceptor(Interceptor networkInterceptor)

Http クライアント パイプラインのネットワーク レイヤーにインターセプターを追加します。

パラメーター:

networkInterceptor - 追加するインターセプター。

戻り値:

チェーン用のビルダー自体。

withProxy

public RestClient.Builder withProxy(Proxy proxy)

HTTP クライアントのプロキシを設定します。

パラメーター:

proxy - 使用するプロキシ

戻り値:

チェーンのためのビルダー自体

withProxyAuthenticator

public RestClient.Builder withProxyAuthenticator(Authenticator proxyAuthenticator)

HTTP クライアントのプロキシ認証子を設定します。

パラメーター:

proxyAuthenticator - 使用するプロキシ認証子

戻り値:

チェーンのためのビルダー自体

withReadTimeout

public RestClient.Builder withReadTimeout(long timeout, TimeUnit unit)

HTTP クライアントで読み取りタイムアウトを設定します。 既定値は 10 秒です。

パラメーター:

timeout - タイムアウト数値
unit - 数値の時間単位

戻り値:

チェーンのためのビルダー自体

withResponseBuilderFactory

public RestClient.Builder withResponseBuilderFactory(ResponseBuilder.Factory responseBuilderFactory)

応答ビルダー ファクトリを設定します。

パラメーター:

responseBuilderFactory - 応答ビルダー ファクトリ

戻り値:

チェーンのためのビルダー自体

withRetryStrategy

public RestClient.Builder withRetryStrategy(RetryStrategy strategy)

再試行戦略をクライアントに追加します。

パラメーター:

strategy - 追加する再試行戦略

戻り値:

チェーンのためのビルダー自体

withSerializerAdapter

public RestClient.Builder withSerializerAdapter(SerializerAdapter serializerAdapter)

シリアル化アダプターを設定します。

パラメーター:

serializerAdapter - アダプターをシリアライザーに接続する

戻り値:

チェーンのためのビルダー自体

withUserAgent

public RestClient.Builder withUserAgent(String userAgent)

ユーザー エージェント ヘッダーを設定します。

パラメーター:

userAgent - ユーザー エージェント ヘッダー。

戻り値:

チェーン用のビルダー自体。

適用対象