Using a CommonJ implementation with GlassFish and Spring 3

安稳与你 提交于 2019-12-03 08:53:33
christian

I don't think it's a good idea to use the TimerManager of myFoo CommonJ - in addition to being dormant for about 6 years, the code is just strange at some points (referring to v1.1). E.g. the isExpired method of the FooTimer class looks like this:

public boolean isExpired() {
    return scheduledExcecutionTime >= System.currentTimeMillis();
}

So, the timer will expire when its scheduled next execution time is in the future? Nonsense - that should be the other way round!

Somewhere else (TimerExecutor#run), notifyAll is called on an object (TimerManager) that the current thread has no monitor for, constantly causing java.lang.IllegalMonitorStateExceptions.

Hands off!

If you're working in Spring, why are you using another Timer implementation? Why not just use the Spring scheduling integration? Then you don't need to worry about in which server your app is running, as Spring doesn't care.

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.

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