use of org.apache.karaf.scheduler.ScheduleOptions in project karaf by apache.
the class Schedule method execute.
@Override
public Object execute() throws Exception {
if (cron != null && (at != null || times != -1 || period != 0)) {
throw new IllegalArgumentException("Both cron expression and explicit execution time can not be specified");
}
ScheduleOptions options;
if (cron != null) {
options = scheduler.EXPR(cron);
} else {
Date date;
if (at != null) {
date = DatatypeConverter.parseDateTime(at).getTime();
} else {
date = new Date();
}
if (period > 0) {
options = scheduler.AT(date, times, period);
} else {
options = scheduler.AT(date);
}
}
if (name != null) {
options.name(name);
}
if (concurrent) {
options.canRunConcurrently(concurrent);
}
scheduler.schedule(new ScriptJob(session, script), options);
return null;
}
use of org.apache.karaf.scheduler.ScheduleOptions in project karaf by apache.
the class List method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column("Name");
table.column("Schedule");
Map<Object, ScheduleOptions> jobs = scheduler.getJobs();
for (Map.Entry<Object, ScheduleOptions> entry : jobs.entrySet()) {
table.addRow().addContent(entry.getValue().name(), entry.getValue().schedule());
}
table.print(System.out);
return null;
}
use of org.apache.karaf.scheduler.ScheduleOptions in project karaf by apache.
the class QuartzScheduler method getJobs.
@Override
public Map<Object, ScheduleOptions> getJobs() throws SchedulerException {
Map<Object, ScheduleOptions> jobs = new HashMap<>();
org.quartz.Scheduler s = this.scheduler;
if (s != null) {
for (String group : s.getJobGroupNames()) {
for (JobKey key : s.getJobKeys(GroupMatcher.jobGroupEquals(group))) {
JobDetail detail = s.getJobDetail(key);
ScheduleOptions options = (ScheduleOptions) detail.getJobDataMap().get(DATA_MAP_OPTIONS);
Object job = detail.getJobDataMap().get(DATA_MAP_OBJECT);
jobs.put(job, options);
}
}
}
return jobs;
}
Aggregations