use of org.quartz.SchedulerException in project opennms by OpenNMS.
the class DefaultSchedulerService method addCronTrigger.
/*
* (non-Javadoc)
* @see
* org.opennms.web.svclayer.support.SchedulerService#addCronTrigger(org
* .opennms.web.report.database.model.DatabaseReportCriteria,
* java.lang.String, java.lang.String, java.lang.String,
* org.springframework.webflow.execution.RequestContext)
*/
/**
* {@inheritDoc}
*/
@Override
public String addCronTrigger(String id, ReportParameters criteria, DeliveryOptions deliveryOptions, String cronExpression, RequestContext context) {
CronTriggerImpl cronTrigger = null;
try {
if (m_reportWrapperService.validate(criteria, id) == false) {
LOG.error(PARAMETER_ERROR);
context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(PARAMETER_ERROR).build());
return ERROR;
} else {
try {
cronTrigger = new CronTriggerImpl();
cronTrigger.setGroup(m_triggerGroup);
cronTrigger.setName(deliveryOptions.getInstanceId());
cronTrigger.setJobName(m_jobDetail.getKey().getName());
cronTrigger.setCronExpression(cronExpression);
// cronTrigger = new CronTrigger(triggerName, m_triggerGroup,
// cronExpression);
} catch (ParseException e) {
LOG.error(TRIGGER_PARSE_ERROR, e);
context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(TRIGGER_PARSE_ERROR).build());
context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(e.getMessage()).build());
return ERROR;
}
cronTrigger.setJobName(m_jobDetail.getKey().getName());
cronTrigger.getJobDataMap().put("criteria", (ReportParameters) criteria);
cronTrigger.getJobDataMap().put("reportId", id);
cronTrigger.getJobDataMap().put("mode", ReportMode.SCHEDULED);
cronTrigger.getJobDataMap().put("deliveryOptions", (DeliveryOptions) deliveryOptions);
try {
m_scheduler.scheduleJob(cronTrigger);
} catch (SchedulerException e) {
LOG.error(SCHEDULER_ERROR, e);
context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(SCHEDULER_ERROR).build());
return ERROR;
}
return SUCCESS;
}
} catch (ReportServiceLocatorException e) {
LOG.error(REPORTID_ERROR);
context.getMessageContext().addMessage(new MessageBuilder().error().defaultText(REPORTID_ERROR).build());
return ERROR;
}
}
use of org.quartz.SchedulerException in project opennms by OpenNMS.
the class DefaultSchedulerService method getTriggerDescriptions.
/**
* <p>getTriggerDescriptions</p>
*
* @return a {@link java.util.List} object.
*/
@Override
public List<TriggerDescription> getTriggerDescriptions() {
List<TriggerDescription> triggerDescriptions = new ArrayList<>();
try {
Set<TriggerKey> triggerKeys = m_scheduler.getTriggerKeys(GroupMatcher.<TriggerKey>groupEquals(m_triggerGroup));
for (TriggerKey triggerKey : triggerKeys) {
TriggerDescription description = new TriggerDescription();
Trigger trigger = m_scheduler.getTrigger(triggerKey);
description.setNextFireTime(trigger.getNextFireTime());
description.setTriggerName(triggerKey.getName());
description.setReportId((String) trigger.getJobDataMap().get("reportId"));
description.setDeliveryOptions((DeliveryOptions) trigger.getJobDataMap().get("deliveryOptions"));
description.setReportParameters(((ReportParameters) trigger.getJobDataMap().get("criteria")).getReportParms());
triggerDescriptions.add(description);
}
} catch (SchedulerException e) {
LOG.error("exception lretrieving trigger descriptions", e);
}
return triggerDescriptions;
}
use of org.quartz.SchedulerException in project Dempsy by Dempsy.
the class RelativeOutputSchedule method start.
/**
* Container will invoke this method.
*/
@Override
public void start(final Infrastructure infra) {
try {
final OutputQuartzHelper outputQuartzHelper = new OutputQuartzHelper();
final JobDetail jobDetail = outputQuartzHelper.getJobDetail(outputInvoker);
final Trigger trigger = outputQuartzHelper.getSimpleTrigger(timeUnit, (int) interval);
scheduler = StdSchedulerFactory.getDefaultScheduler();
scheduler.scheduleJob(jobDetail, trigger);
scheduler.start();
} catch (final SchedulerException se) {
LOGGER.error("Error occurred while starting the relative scheduler : " + se.getMessage(), se);
}
}
use of org.quartz.SchedulerException in project Dempsy by Dempsy.
the class CronOutputSchedule method start.
/*
* (non-Javadoc)
*
* @see com.nokia.dempsy.output.OutputExecuter#start()
*/
@Override
public void start(final Infrastructure infra) {
try {
final OutputQuartzHelper outputQuartzHelper = new OutputQuartzHelper();
final JobDetail jobDetail = outputQuartzHelper.getJobDetail(outputInvoker);
final Trigger trigger = outputQuartzHelper.getCronTrigger(cronExpression);
scheduler = StdSchedulerFactory.getDefaultScheduler();
scheduler.scheduleJob(jobDetail, trigger);
scheduler.start();
} catch (final SchedulerException se) {
LOGGER.error("Error occurred while starting the cron scheduler : " + se.getMessage(), se);
}
}
use of org.quartz.SchedulerException in project openhab1-addons by openhab.
the class PlugwiseBinding method execute.
@Override
protected void execute() {
if (isProperlyConfigured()) {
try {
Scheduler sched = StdSchedulerFactory.getDefaultScheduler();
scheduleJobs(sched);
} catch (SchedulerException e) {
logger.error("An exception occurred while getting a reference to the Quartz Scheduler ({})", e.getMessage());
}
}
}
Aggregations