I would like to be able to inject an ExecutorService instance into my Spring services, and the Spring API suggest using ThreadPoolExecutorFactoryBean for this purpose. Very simple question; how the hell do I use the ThreadPoolExecutorFactoryBean to create an ExecutorService that I can wire into my other services?
I feel like a complete idiot for asking his question, but I can’t seem to get this figured out.
First off, you need to learn what a
FactoryBeanis – read section 3.8.3 of the spring docs.Then, you read the Javadoc for
ThreadPoolExecutorFactoryBeanand understand what it does.Next, you configure a
ThreadPoolExecutorFactoryBeanin your context. This will create anExecutorService(since it’s aFactoryBean, see above), which you can inject into your bean.