[英]Get fixedDelay value inside @Scheduled
是否可以在正在执行的方法中获取fixedDelay
的值?
是否存在这样的事情:
@Scheduled(fixedDelay = 86400000) //one day
public void sendEmails() {
System.out.println(TaskExecutor.getCurrentFixedDelay()); // (would print 86400000)
}
public class AnnotationParameter {
@Scheduled(fixedDelay = 86400000) //one day
public void sendEmails() throws NoSuchMethodException
{
Method method = AnnotationParameter.class.getDeclaredMethod
("sendEmails");
Scheduled annotation = method.getAnnotation(Scheduled.class);
long fixedDelay = annotation.fixedDelay();
System.out.println(fixedDelay); // (would print 86400000)
}
public static void main(String[] args) throws NoSuchMethodException
{
new AnnotationParameter().sendEmails();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.