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:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
destroy()
Return the configuredExecutor
.void
setExecutor
(Executor executor) Configure theExecutor
to use forHttpClient
exchanges.void
setThreadPrefix
(String threadPrefix) Configure the thread prefix to initialize the executor with.
-
Constructor Details
-
JdkHttpClientResourceFactory
public JdkHttpClientResourceFactory()
-
-
Method Details
-
setExecutor
Configure theExecutor
to use forHttpClient
exchanges. The given executor is started and stopped viaInitializingBean
andDisposableBean
.By default, this is set to
Executors.newCachedThreadPool(ThreadFactory)
, which mirrorsHttpClient.Builder.executor(Executor)
.- Parameters:
executor
- the executor to use
-
getExecutor
Return the configuredExecutor
. -
setThreadPrefix
Configure the thread prefix to initialize the executor with. This is used only when aExecutor
instance isn'tprovided
.By default set to "jdk-http".
- Parameters:
threadPrefix
- the thread prefix to use
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
destroy
- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
- Throws:
Exception
-