faf*_*ffy 5 spring glassfish commonj java-ee workmanagers
为了统一Websphere 7和GlassFish 3环境中的部署,我决定尝试在GlassFish中实现CommonJ WorkManager和TimerManager.但它没有按预期工作.我做了以下事情:
使用在http://commonj.myfoo.de/上找到的myFOO CommonJ实现,并将库包含到我的domain/lib文件夹中(包括Spring库)
将以下内容添加到<resources>glassfish domain.xml 的部分:
<custom-resource res-type="commonj.work.WorkManager" jndi-name="wm/default" factory-class="de.myfoo.commonj.work.FooWorkManagerFactory"></custom-resource>
<custom-resource res-type="commonj.timers.TimerManager" jndi-name="tm/default" factory-class="de.myfoo.commonj.timers.FooTimerManagerFactory"></custom-resource>
Run Code Online (Sandbox Code Playgroud)
在domain.xml 的<servers>/ <server>section中包含引用:
<resource-ref ref="wm/default"></resource-ref>
<resource-ref ref="tm/default"></resource-ref>
Run Code Online (Sandbox Code Playgroud)
在我的测试应用程序的web.xml中添加适当的资源引用:
<resource-ref>
<description>WorkManager</description>
<res-ref-name>wm/default</res-ref-name>
<res-type>commonj.work.WorkManager</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<description>TimerManager</description>
<res-ref-name>tm/default</res-ref-name>
<res-type>commonj.timers.TimerManager</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Unshareable</res-sharing-scope>
</resource-ref>
Run Code Online (Sandbox Code Playgroud)
将以下bean添加到我的applicationContext.xml:
<bean id="threadTestTaskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
<property name="workManagerName" value="wm/default" />
<property name="resourceRef" value="true"/>
</bean>
<bean id="threadTestTimerExecutor" class="org.springframework.scheduling.commonj.TimerManagerTaskScheduler">
<property name="timerManagerName" value="tm/default" />
<property name="resourceRef" value="true" />
<property name="shared" value="false" />
</bean>
<bean id="threadTest" class="test.ThreadTester"></bean>
<task:scheduled-tasks scheduler="threadTestTimerExecutor">
<task:scheduled ref="threadTest" method="execute" fixed-delay="30000" /> <!-- 30 seconds -->
</task:scheduled-tasks>
Run Code Online (Sandbox Code Playgroud)
完成所有这些设置后,所有内容都会找到并运行Web应用程序; 但是,ThreadTester类不会在Timer上运行.
我已经逐步完成了myFOO代码并且TimerManager(FooTimerManager.java)主循环正在运行,它似乎永远不会认识到应该每30秒启动一次.
我的问题:
有没有人有使用GlassFish 3和Spring实现JSR 236/237(CommonJ)的经验?
除了myFOO之外还有其他实现我可以使用并试用吗?有没有人试图做我做过的事情?如果你成功了,你愿意分享你的结果吗?
谢谢!
编辑1:
我忘了提到使用myFOO CommonJ实现与GlassFish 就 WorkManager而言确实有用.什么是不工作是一个TimerManager.这意味着我可以按需启动线程,但触发调度不起作用.
编辑2:
自更新到GlassFish 3.1.1以来,TimerManager的myFOO CommonJ实现工作正常.很好!这个问题现在更像是HOWTO指南.
| 归档时间: |
|
| 查看次数: |
5262 次 |
| 最近记录: |