use of org.apache.karaf.scheduler.command.support.ScriptJob 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;
}
Aggregations