public class ReactorResourceFactory extends java.lang.Object implements InitializingBean, DisposableBean
LoopResources
for
event loop threads, and ConnectionProvider
for the connection pool,
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.
Constructor and Description |
---|
ReactorResourceFactory() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Invoked by the containing
BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware , ApplicationContextAware etc. |
void |
destroy()
Invoked by the containing
BeanFactory on destruction of a bean. |
reactor.netty.resources.ConnectionProvider |
getConnectionProvider()
Return the configured
ConnectionProvider . |
reactor.netty.resources.LoopResources |
getLoopResources()
Return the configured
LoopResources . |
java.lang.String |
getThreadPrefix()
Return the configured prefix for event loop threads.
|
boolean |
isGlobalResources()
Whether this factory exposes the global
HttpResources holder. |
void |
setConnectionProvider(reactor.netty.resources.ConnectionProvider connectionProvider)
Configure the
ConnectionProvider to use. |
void |
setGlobalResources(boolean globalResources)
Whether to expose and manage the global Reactor Netty resources from the
HttpResources holder. |
void |
setLoopResources(reactor.netty.resources.LoopResources loopResources)
Configure the
LoopResources to use. |
void |
setThreadPrefix(java.lang.String threadPrefix)
Configure the thread prefix to initialize
LoopResources with. |
public void setGlobalResources(boolean globalResources)
HttpResources
holder.
Default is "true" in which case this factory helps to configure and
shut down the global Reactor Netty resources within the lifecycle of a
Spring ApplicationContext
.
If set to "false" then the factory creates and manages its own
LoopResources
and ConnectionProvider
, independent of the
global ones in the HttpResources
holder.
globalResources
- whether to expose and manage the global resourcespublic void setConnectionProvider(@Nullable reactor.netty.resources.ConnectionProvider connectionProvider)
ConnectionProvider
to use.
By default, initialized with ConnectionProvider.elastic(String)
.
connectionProvider
- the connection provider to usepublic void setLoopResources(@Nullable reactor.netty.resources.LoopResources loopResources)
LoopResources
to use.
By default, initialized with LoopResources.create(String)
.
loopResources
- the loop resources to usepublic void setThreadPrefix(java.lang.String threadPrefix)
LoopResources
with. This
is used only when a LoopResources
instance isn't
provided
.
By default set to "reactor-http".
threadPrefix
- the thread prefix to usepublic boolean isGlobalResources()
HttpResources
holder.@Nullable public reactor.netty.resources.ConnectionProvider getConnectionProvider()
ConnectionProvider
.@Nullable public reactor.netty.resources.LoopResources getLoopResources()
LoopResources
.public java.lang.String getThreadPrefix()
public void afterPropertiesSet() throws java.lang.Exception
InitializingBean
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.
afterPropertiesSet
in interface InitializingBean
java.lang.Exception
- in the event of misconfiguration (such as failure to set an
essential property) or if initialization fails for any other reasonpublic void destroy()
DisposableBean
BeanFactory
on destruction of a bean.destroy
in interface DisposableBean