Package org.springframework.http.client.reactive

# Class JdkHttpClientResourceFactory

java.lang.Object
org.springframework.http.client.reactive.JdkHttpClientResourceFactory

All Implemented Interfaces:
  `org.springframework.beans.factory.DisposableBean`, `org.springframework.beans.factory.InitializingBean`

public class JdkHttpClientResourceFactory extends Object implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
Factory to manage JDK HttpClient resources such as a shared `Executor` within the lifecycle of a Spring `ApplicationContext`.

This factory implements `InitializingBean` and `DisposableBean` and is expected typically to be declared as a Spring-managed bean.

Since:
  6.0
Author:
  Rossen Stoyanchev
See Also:
  - `JdkClientHttpConnector(HttpClient.Builder, JdkHttpClientResourceFactory)`

## Constructor Summary

Constructors
Constructor
Description
`JdkHttpClientResourceFactory()`

## Method Summary

Modifier and Type
Method
Description
`void`
`afterPropertiesSet()`
`void`
`destroy()`
`Executor`
`getExecutor()`
Return the configured `Executor`.
`void`
`setExecutor(Executor executor)`
Configure the `Executor` to use for `HttpClient` exchanges.
`void`
`setThreadPrefix(String threadPrefix)`
Configure the thread prefix to initialize the executor with.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### JdkHttpClientResourceFactory

public JdkHttpClientResourceFactory()

## Method Details

### setExecutor

public void setExecutor(@Nullable Executor executor)
Configure the `Executor` to use for `HttpClient` exchanges. The given executor is started and stopped via `InitializingBean` and `DisposableBean`.

By default, this is set to `Executors.newCachedThreadPool(ThreadFactory)`, which mirrors `HttpClient.Builder.executor(Executor)`.

Parameters:
  `executor` - the executor to use

### getExecutor

@Nullable public Executor getExecutor()
Return the configured `Executor`.

### setThreadPrefix

public void setThreadPrefix(String threadPrefix)
Configure the thread prefix to initialize the executor with. This is used only when a `Executor` instance isn't `provided`.

By default set to "jdk-http".

Parameters:
  `threadPrefix` - the thread prefix to use

### afterPropertiesSet

public void afterPropertiesSet() throws Exception

Specified by:
  `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
Throws:
  `Exception`

### destroy

public void destroy() throws Exception

Specified by:
  `destroy` in interface `org.springframework.beans.factory.DisposableBean`
Throws:
  `Exception`