在Spring中访问计划任务 [英] Accessing scheduled tasks in Spring

查看:113
本文介绍了在Spring中访问计划任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Spring的任务计划程序中安排了几项任务:

I have a couple of tasks scheduled within Spring's task scheduler:

<task:scheduled-tasks>
    <task:scheduled ref="task1" method="run"
        cron="0 0 */0 * * *" />
    <task:scheduled ref="task2" method="run"
        cron="0 0 */30 * * *" />
</task:scheduled-tasks>

<task:scheduler id="scheduler" pool-size="10" />

如何访问计划任务列表并检索应用程序上下文中的元信息(例如下一个执行时间)?

How can I access a list of scheduled tasks and retrieve meta-information (e.g the next execution time) from within the application context?

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
ThreadPoolTaskScheduler scheduler = (ThreadPoolTaskScheduler)context.getBean("scheduler");
//... how to continue from here?


推荐答案

Spring中没有公共API来执行此操作。

There is no public API in Spring to do this.

相关:

  • How are Spring <task:scheduled> objects represented at runtime?

这篇关于在Spring中访问计划任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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