spring中配置了quartz定时任务,怎么在后台用java代码获取定时任务的运行状态? 20
如图,这些定时任务都能正常运行,但有时某些定时任务没起来,日志也不太好查,我需要一个界面显示这些任务的运行状态参数什么,一眼就知道。怎么实现?...
如图,这些定时任务都能正常运行,但有时某些定时任务没起来,日志也不太好查,我需要一个界面显示这些任务的运行状态参数什么,一眼就知道。怎么实现?
展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏20(财富值+成长值)
1个回答
展开全部
public class SpringWiredBean implements ApplicationContextAware {
private ApplicationContext context;
public void setApplicationContext(
org.springframework.context.ApplicationContext context)
throws BeansException {
this.context = context;
}
public void quartz() {
Map<String, Trigger> beans = context
.getBeansOfType(org.quartz.Trigger.class);
Set<String> set = beans.keySet();
for (String key : set) {
Trigger cronTrigger = beans.get(key);
if (cronTrigger instanceof CronTrigger) {
CronTrigger _cronTrigger = (CronTrigger) cronTrigger;
} else if (cronTrigger instanceof SimpleTrigger) {
SimpleTrigger _cronTrigger = (SimpleTrigger) cronTrigger;
} else if (cronTrigger instanceof NthIncludedDayTrigger) {
NthIncludedDayTrigger _cronTrigger = (NthIncludedDayTrigger) cronTrigger;
}
}
}
}
private ApplicationContext context;
public void setApplicationContext(
org.springframework.context.ApplicationContext context)
throws BeansException {
this.context = context;
}
public void quartz() {
Map<String, Trigger> beans = context
.getBeansOfType(org.quartz.Trigger.class);
Set<String> set = beans.keySet();
for (String key : set) {
Trigger cronTrigger = beans.get(key);
if (cronTrigger instanceof CronTrigger) {
CronTrigger _cronTrigger = (CronTrigger) cronTrigger;
} else if (cronTrigger instanceof SimpleTrigger) {
SimpleTrigger _cronTrigger = (SimpleTrigger) cronTrigger;
} else if (cronTrigger instanceof NthIncludedDayTrigger) {
NthIncludedDayTrigger _cronTrigger = (NthIncludedDayTrigger) cronTrigger;
}
}
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询