Class HttpClientFactory
java.lang.Object
cloud.opencode.base.oauth2.http.HttpClientFactory
HTTP Client Factory
HTTP 客户端工厂
Factory for creating OAuth2 HTTP clients.
用于创建 OAuth2 HTTP 客户端的工厂。
Features | 主要功能:
- Create HTTP clients with default settings - 使用默认设置创建 HTTP 客户端
- Create HTTP clients with custom timeouts - 使用自定义超时创建 HTTP 客户端
- Create HTTP clients from config - 从配置创建 HTTP 客户端
- Shared client instance support - 共享客户端实例支持
Usage Examples | 使用示例:
// Create with defaults
OAuth2HttpClient client = HttpClientFactory.create();
// Create with custom timeouts
OAuth2HttpClient client = HttpClientFactory.create(
Duration.ofSeconds(5), // connect timeout
Duration.ofSeconds(30) // read timeout
);
// Create from config
OAuth2HttpClient client = HttpClientFactory.create(config);
// Get shared instance
OAuth2HttpClient shared = HttpClientFactory.shared();
Thread Safety | 线程安全:
This class is thread-safe.
此类是线程安全的。
- Since:
- JDK 25, opencode-base-oauth2 V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHTTP Client Builder HTTP 客户端构建器 -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic HttpClientFactory.Builderbuilder()Create a builder for customizing the HTTP client 创建用于自定义 HTTP 客户端的构建器static OAuth2HttpClientcreate()Create an HTTP client with default settings 使用默认设置创建 HTTP 客户端static OAuth2HttpClientcreate(OAuth2Config config) Create an HTTP client from OAuth2 configuration 从 OAuth2 配置创建 HTTP 客户端static OAuth2HttpClientCreate an HTTP client with custom timeouts 使用自定义超时创建 HTTP 客户端static OAuth2HttpClientshared()Get the shared HTTP client instance 获取共享的 HTTP 客户端实例
-
Field Details
-
DEFAULT_CONNECT_TIMEOUT
Default connect timeout 默认连接超时 -
DEFAULT_READ_TIMEOUT
Default read timeout 默认读取超时
-
-
Method Details
-
create
Create an HTTP client with default settings 使用默认设置创建 HTTP 客户端- Returns:
- the HTTP client | HTTP 客户端
-
create
Create an HTTP client with custom timeouts 使用自定义超时创建 HTTP 客户端- Parameters:
connectTimeout- the connection timeout | 连接超时readTimeout- the read timeout | 读取超时- Returns:
- the HTTP client | HTTP 客户端
-
create
Create an HTTP client from OAuth2 configuration 从 OAuth2 配置创建 HTTP 客户端- Parameters:
config- the OAuth2 configuration | OAuth2 配置- Returns:
- the HTTP client | HTTP 客户端
-
builder
Create a builder for customizing the HTTP client 创建用于自定义 HTTP 客户端的构建器- Returns:
- the builder | 构建器
-