Need sample code explaning Workmanager in Tomcat

元气小坏坏 提交于 2021-02-10 15:16:51

问题


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.


回答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.




回答2:


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.



来源:https://stackoverflow.com/questions/14779246/need-sample-code-explaning-workmanager-in-tomcat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!