I want to know how to use WorkManager in Tomcat 7. I came across the open source library Foo-CommonJ but nowhere i found a sample code explaning the usage. The input parameter for FooWorkManager's constructor is an instance of commonj.work.work class, where as no one provides the commonj.work.work class (neither tomcat nor foo-commonj). Basically i need a sample code explaining usage of WorkManager (FooCommonj jar) in tomcat. And if Foo-Commonj doesn't support workmanager properly, then some alternative.
Asked
Active
Viewed 4,539 times
1
-
1CommonJ is an implementation of the very old [JSR-237](http://jcp.org/en/jsr/detail?id=237) that in the mean time has been withdrawn, so maybe it's not the ideal base for new work. Have a look at [this SO article](http://stackoverflow.com/questions/3745905/what-is-recommended-way-for-spawning-threads-from-a-servlet-in-tomcat) that has some recommendations wrt thread creation in a servlet container. – fvu Feb 11 '13 at 10:33
2 Answers
1
JSR-237 has been withdrawn, but it has been merged with JSR-236. http://jcp.org/en/jsr/detail?id=237 Reason: JSR 237 has been merged with JSR 236, providing a single, consistent specification for Java EE concurrency.

Haritha Reddy
- 11
- 1
0
Old school way
Copy to tomcat\lib folder following jars:
- commonj-xxx.jar
- tomcat-commonj-xxx.jar
In context.xml of your app or tomcat create a new WorkManager instance:
<Resource name="wm/myWorkManager" type="commonj.work.WorkManager" auth="Container"
factory="de.myfoo.commonj.work.FooWorkManagerFactory"
maxThreads="10"
minThreads="5" />
Fetch this instance using JNDI. For example using web.xml:
<resource-ref>
<description>Work manager example</description>
<res-ref-name>wm/myWorkManager"</res-ref-name>
<res-type>commonj.work.WorkManager</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Unshareable</res-sharing-scope>
</resource-ref>
Any other way should work.

Talijanac
- 1,087
- 9
- 20