Top Description Fields Constructors Methods
org.springframework.http.client.reactive

public Class JdkHttpClientResourceFactory

extends Object
implements InitializingBean, DisposableBean
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean
Imports
java.net.http.HttpClient, java.util.concurrent.Executor, .ExecutorService, .Executors, .ThreadFactory, org.springframework.beans.factory.DisposableBean, .InitializingBean, org.springframework.lang.Nullable, org.springframework.scheduling.concurrent.CustomizableThreadFactory, org.springframework.util.Assert

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.

Author
Rossen Stoyanchev
Since
6.0
See Also
JdkClientHttpConnector#JdkClientHttpConnector(HttpClient.Builder, JdkHttpClientResourceFactory)

Field Summary

Modifier and TypeField and Description
private Executor
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.

This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

public void
destroy()

Implements org.springframework.beans.factory.DisposableBean.destroy.

Invoked by the containing BeanFactory on destruction of a bean.

public Executor
getExecutor()

Return the configured Executor.

public void
setExecutor(Executor
the executor to use
executor
)

Configure the Executor to use for HttpClient exchanges.

public void
setThreadPrefix(String
the thread prefix to use
threadPrefix
)

Configure the thread prefix to initialize the executor with.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

executorback to summary
private Executor executor
Annotations
@Nullable
threadPrefixback to summary
private String threadPrefix

Constructor Detail

JdkHttpClientResourceFactoryback to summary
public JdkHttpClientResourceFactory()

Method Detail

afterPropertiesSetback to summary
public void afterPropertiesSet() throws Exception

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Doc from org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.

This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.

Annotations
@Override
Exceptions
Exception:
in the event of misconfiguration (such as failure to set an essential property) or if initialization fails for any other reason
destroyback to summary
public void destroy() throws Exception

Implements org.springframework.beans.factory.DisposableBean.destroy.

Doc from org.springframework.beans.factory.DisposableBean.destroy.

Invoked by the containing BeanFactory on destruction of a bean.

Annotations
@Override
Exceptions
Exception:
in case of shutdown errors. Exceptions will get logged but not rethrown to allow other beans to release their resources as well.
getExecutorback to summary
public Executor getExecutor()

Return the configured Executor.

Annotations
@Nullable
setExecutorback to summary
public void setExecutor(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:Executor

the executor to use

setThreadPrefixback to summary
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:String

the thread prefix to use