How to use Spring ThreadPoolExecutorFactoryBean factory bean

I would like to be able to embed an instance ExecutorServicein my Spring services, and the Spring API suggests using it ThreadPoolExecutorFactoryBeanfor this purpose. A very simple question; how the hell am i using ThreadPoolExecutorFactoryBeanto create ExecutorServicewhich i can connect to other services?

I feel like a complete idiot to ask his question, but I can’t understand what he understood.

+5
source share
3 answers

First of all, you need to know what it FactoryBeanis to read section 3.8.3 of the spring docs.

Javadoc ThreadPoolExecutorFactoryBean , .

ThreadPoolExecutorFactoryBean . ExecutorService ( FactoryBean, . ), bean.

+6

, , :

<bean id="classNeedingExecutor" class="foo.Bar">
  <property name="executor" ref="threadExecutor" />
</bean>

<bean id="threadExecutor"
  class="org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean">
  <property name="corePoolSize" value="1" />
  <property name="maxPoolSize" value="1" />
</bean>

JavaDocs , ExecutorService.

+8

All Articles