在GlassFish和Spring 3中使用CommonJ实现 [英] Using a CommonJ implementation with GlassFish and Spring 3

查看:350
本文介绍了在GlassFish和Spring 3中使用CommonJ实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我寻求在Websphere 7和GlassFish 3环境中统一部署时,我决定尝试在GlassFish中实现CommonJ WorkManager和TimerManager。但它没有像预期的那样工作。我已经完成了以下工作:使用myFOO CommonJ实现: http://commonj.myfoo.de/ ,并将这些库包含到我的domain / lib文件夹(包括Spring库)中。

将以下内容添加到

     < custom-resource>< / custom-resource>< custom-resource>< custom-resource>< 
< custom-resource res-type =commonj.timers.TimerManagerjndi-name =tm / defaultfactory-class =de.myfoo.commonj.timers.FooTimerManagerFactory>< / custom -resource>

将引用包含在< servers> / < server> 部分domain.xml:

  < resource-ref ref =wm / default>< / resource-ref> 
< resource-ref ref =tm / default>< / resource-ref>

在我的测试应用程序的web.xml中添加适当的资源引用:

 < resource-ref> 
< description> WorkManager< / description>
< res-ref-name> wm / default< / res-ref-name>
< res-type> commonj.work.WorkManager< / res-type>
< res-auth>容器< / res-auth>
< res-sharing-scope>可分享< / 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>容器< / res-auth>
< res-sharing-scope>不可共享< / res-sharing-scope>
< / resource-ref>

将以下bean添加到我的applicationContext.xml中:

 < bean id =threadTestTaskExecutorclass =org.springframework.scheduling.commonj.WorkManagerTaskExecutor> 
< property name =workManagerNamevalue =wm / default/>
< property name =resourceRefvalue =true/>
< / bean>

< bean id =threadTestTimerExecutorclass =org.springframework.scheduling.commonj.TimerManagerTaskScheduler>
< property name =timerManagerNamevalue =tm / default/>
< property name =resourceRefvalue =true/>
< property name =sharedvalue =false/>
< / bean>

< bean id =threadTestclass =test.ThreadTester>< / bean>

< task:scheduled ref =threadTestmethod =executefixed-delay =30000/> <! - 30秒 - >

完成所有这些设置后,所有内容都会查找并运行Web应用程序;但是,ThreadTester类不会在Timer上运行。



我已经遍历myFOO代码并且TimerManager(FooTimerManager.java)主循环正在运行,它永远不会运行似乎认识到每30秒就应该推出这个课程。



我的问题:

有没有人有使用GlassFish 3和Spring实现JSR 236/237(CommonJ)的经验? p是否有另一个除myFOO以外的实现可以使用,试用?
有没有人试图做我所做的事情?如果你成功了,你愿意分享你的结果吗?



谢谢!

编辑1:



我忘了提及使用GlassFish 的myFOO CommonJ实现,就WorkManager而言。什么是不是工作是TimerManager。这意味着我可以按要求启动线程,但触发时间安排不起作用。



编辑2:



自更新到GlassFish 3.1.1以来,TimerManager的myFOO CommonJ实现工作正常。很好!这个问题现在更像是一个HOWTO指南。

解决方案

好吧,从GlassFish 3.1.1更新版本开始,I不再存在TimerManager的myFOO实现的问题。我的 @Scheduled bean现在工作得很好。


In my quest to unify deployment among Websphere 7 and GlassFish 3 environments, I decided to try implementing a CommonJ WorkManager and TimerManager in GlassFish. But it isn't quite working as expected. I have done the following:

Use the myFOO CommonJ implementation found at: http://commonj.myfoo.de/ and include the libraries into my domain/lib folder (including the Spring libs)

Added the following to the <resources> section of the 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>

Include the references in the <servers>/<server> section of the domain.xml:

  <resource-ref ref="wm/default"></resource-ref>
  <resource-ref ref="tm/default"></resource-ref>

Add the appropriate resource references in the web.xml of my test application:

<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>

Add the following beans to my 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>

After all of this set-up, everything loads find and the web application runs; however, the ThreadTester class does not run on the Timer.

I have stepped through the myFOO code and the TimerManager (FooTimerManager.java) main loop is running, it just never seems to recognize that every 30 seconds it's supposed to launch the class.

My questions:

Has anyone had experience implementing JSR 236/237 (CommonJ) with GlassFish 3 and Spring?

Is there another implementation somewhere other than myFOO that I could use and try out? Has anyone attempted to do what I've done? Would you be willing to share your results if you succeeded?

Thanks!

Edit 1:

I forgot to mention that using myFOO CommonJ implementation with GlassFish does work as far as the WorkManager is concerned. What does not work is the TimerManager. This means that I can launch threads on demand just fine but triggered scheduling doesn't work.

Edit 2:

Since updating to GlassFish 3.1.1, the myFOO CommonJ implementation of the TimerManager is working fine. So... great! This question is now more like a HOWTO Guide.

解决方案

Well, it looks like that since updating to GlassFish 3.1.1, I no longer have the problem with the myFOO implementation of the TimerManager. My @Scheduled beans are working just fine now.

这篇关于在GlassFish和Spring 3中使用CommonJ实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆