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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoiddestroy()Return the configuredExecutor.voidsetExecutor(Executor executor) Configure theExecutorto use forHttpClientexchanges.voidsetThreadPrefix(String threadPrefix) Configure the thread prefix to initialize the executor with.
-
Constructor Details
-
JdkHttpClientResourceFactory
public JdkHttpClientResourceFactory()
-
-
Method Details
-
setExecutor
Configure theExecutorto use forHttpClientexchanges. The given executor is started and stopped viaInitializingBeanandDisposableBean.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 aExecutorinstance isn'tprovided.By default set to "jdk-http".
- Parameters:
threadPrefix- the thread prefix to use
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
destroy
- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Throws:
Exception
-