Hello all,
I'm currently creating a plugin that would need to perform an action every
N seconds.
I would like the user to set the N seconds interval in the Configure System
page; so I added a field to get this value.
The action is launched from an AsyncPeriodicWork subclass, and I wrote the
following, to re launch the action every N seconds :
@Override
public long getRecurrencePeriod() {
//TODO : this method is not called regularly, need to find another
scheduling mechanism
if(DESCRIPTOR.interval != 0){
return 1000 * DESCRIPTOR.interval;
} else {
return 60 * 1000;
}
}
in the javadoc, it is written (and this is accurate) that
getRecurrencePeriod is only called once :
" *
* Hudson calls this method once to set up a recurring timer, instead of
* calling this each time after the previous execution completed. So
this class cannot be
* used to implement a non-regular recurring timer.
*
* IOW, the method should always return the same value.
"
so what I'm doing is not working.(since the I would like the user to change
this value whenever he wants)
Could you please tell me if there is a preferred way to achieve what I'm
doing (a non regular timer)? or do I need to go implementing my custom
Timer/TimerTask ?
Thanks,
Anthony