Spring: Using "Lookup method injection" for my ThreadFactory looks not scalable.
Posted
by Michael Bavin
on Stack Overflow
See other posts from Stack Overflow
or by Michael Bavin
Published on 2010-03-18T14:59:21Z
Indexed on
2010/03/18
15:01 UTC
Read the original article
Hit count: 417
Hi,
We're building a ThreadFactory
so everytime a singleton controller needs a new thread, i get a new instance everytime.
Looking at Lookup method injection looks good but what if we have multiple threads.
like:
public abstract class ThreadManager {
public abstract Thread createThreadDoA();
public abstract Thread createThreadDoB();
}
and config:
<bean id="threadManager" class="bla.ThreadManager" singleton="true">
<lookup-method name="createThreadA" bean="threadA" />
<lookup-method name="createThreadB" bean="threadB"/>
</bean>
<bean id="threadA" class="bla.ThreadA">
<bean id="threadB" class="bla.ThreadB">
and usage:
threadManager.createThreadA();
I don't want to create an abstract "create" method for every new threadclass.
Is it possible to make this generich like:
threadManager.createThread(ThreadA.class);
Thank you
© Stack Overflow or respective owner