Using a CommonJ implementation with GlassFish and Spring 3

前端 未结 3 1222
情话喂你
情话喂你 2021-02-10 04:45

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

相关标签:
3条回答
  • 2021-02-10 05:06

    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!

    0 讨论(0)
  • 2021-02-10 05:12

    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.

    0 讨论(0)
  • 2021-02-10 05:26

    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.

    0 讨论(0)
提交回复
热议问题