use of org.springframework.scheduling.support.CronTrigger in project hub-alert by blackducksoftware.
the class ScheduledTask method scheduleExecution.
public void scheduleExecution(String cron) {
if (StringUtils.isNotBlank(cron)) {
try {
CronTrigger cronTrigger = new CronTrigger(cron, TimeZone.getTimeZone("UTC"));
unscheduleTask();
logger.info("Scheduling {} with cron : {}", getTaskName(), cron);
future = taskScheduler.schedule(this, cronTrigger);
} catch (IllegalArgumentException e) {
logger.error(e.getMessage(), e);
}
} else {
if (future != null) {
logger.info("Un-Scheduling {}", getTaskName());
unscheduleTask();
}
}
}
use of org.springframework.scheduling.support.CronTrigger in project benchmark by seelunzi.
the class DynamicScheduledTask method configureTasks.
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
// taskRegistrar.addTriggerTask(new Runnable() {
// @Override
// public void run() {
// if (!cron.equals(DEFAULT_CRON)) {
//
// }
// // 定时任务的业务逻辑
// System.out.println("动态修改定时任务cron参数,当前时间:" + dateFormat.format(new Date()));
// }
// }, new Trigger() {
// @Override
// public Date nextExecutionTime(TriggerContext triggerContext) {
// // 定时任务触发,可修改定时任务的执行周期
// CronTrigger trigger = new CronTrigger(cron);
// Date nextExecDate = trigger.nextExecutionTime(triggerContext);
// return nextExecDate;
// }
// });
taskRegistrar.addTriggerTask(() -> {
if (!cron.equals(DEFAULT_CRON)) {
}
// 定时任务的业务逻辑
System.out.println("动态修改定时任务cron参数,当前时间:" + dateFormat.format(new Date()));
}, (triggerContext) -> {
CronTrigger trigger = new CronTrigger(cron);
Date nextExecDate = trigger.nextExecutionTime(triggerContext);
return nextExecDate;
});
}
use of org.springframework.scheduling.support.CronTrigger in project camel by apache.
the class SpringScheduledPollConsumerScheduler method doStart.
@Override
protected void doStart() throws Exception {
ObjectHelper.notEmpty(cron, "cron", this);
trigger = new CronTrigger(getCron(), getTimeZone());
if (taskScheduler == null) {
taskScheduler = new CamelThreadPoolTaskScheduler(getCamelContext(), consumer, consumer.getEndpoint().getEndpointUri());
taskScheduler.afterPropertiesSet();
destroyTaskScheduler = true;
}
LOG.debug("Scheduling cron trigger {}", getCron());
future = taskScheduler.schedule(runnable, trigger);
}
use of org.springframework.scheduling.support.CronTrigger in project gravitee-management-rest-api by gravitee-io.
the class ScheduledSubscriptionsService method doStart.
@Override
protected void doStart() throws Exception {
if (enabled) {
super.doStart();
logger.info("Subscriptions Refresher service has been initialized with cron [{}]", cronTrigger);
scheduler.schedule(this, new CronTrigger(cronTrigger));
} else {
logger.warn("Subscriptions Refresher service has been disabled");
}
}
use of org.springframework.scheduling.support.CronTrigger in project gravitee-management-rest-api by gravitee-io.
the class ScheduledSyncService method doStart.
@Override
protected void doStart() throws Exception {
if (!localRegistryEnabled) {
if (enabled) {
super.doStart();
logger.info("Sync service has been initialized with cron [{}]", cronTrigger);
// Sync must start only when doStart() is invoked, that's the reason why we are not
// using @Scheduled annotation on doSync() method.
scheduler.schedule(this, new CronTrigger(cronTrigger));
} else {
logger.warn("Sync service has been disabled");
}
} else {
logger.warn("Sync service is disabled because local registry mode is enabled");
}
}
Aggregations