-
Mar 13th, 2012, 10:23 AM
#1
factory-method fails ??
Greetings,
Although I read http://static.springsource.org/sprin...tory-lifecycle
I fail to understand why this fails :
<bean id="foo" factory-bean="exe" factory-method="newCachedThreadPool"/>
<bean id="exe" class="java.util.concurrent.Executors"/>
I thought that Executors.newCachedThreadPool would return me a ThreadPoolExecutor that could be referenced as foo.
But STS tells me Non-static factory method 'newCachedThreadPool' not found in factory bean class.
I Use JSE 6 and knows there is s the mistake is elsewhere.
Can someone please explain to me what's wrong ?
thanks !
-
Mar 13th, 2012, 10:36 AM
#2
why don't you use directly:
<bean id="foo" class="java.util.concurrent.Executors" factory-method="newCachedThreadPool" />
In the documentation you are referring to there's in section 3.2.3.2.2 statement:
"Note that the definition does not specify the type (class) of the returned object, only the class containing the factory method"
-
Mar 13th, 2012, 10:44 AM
#3
You were right, your proposal didn't work (I had tried it before) because the setter was not respecting javabeans convention.
Now it works.
Thank you !
-
Mar 14th, 2012, 05:05 AM
#4
Use following [ only for static factory method as per doc ]
<bean id="foo" class="java.util.concurrent.Executors" factory-method="newCachedThreadPool" />
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules