use of org.quartz.SchedulerException in project openhab1-addons by openhab.
the class Db4oPersistenceService method cancelAllJobs.
/**
* Delete all quartz scheduler jobs of the group <code>Dropbox</code>.
*/
private void cancelAllJobs() {
try {
Scheduler sched = StdSchedulerFactory.getDefaultScheduler();
Set<JobKey> jobKeys = sched.getJobKeys(jobGroupEquals(SCHEDULER_GROUP));
if (jobKeys.size() > 0) {
sched.deleteJobs(new ArrayList<JobKey>(jobKeys));
logger.debug("Found {} DB4O-Jobs to delete from DefaultScheduler (keys={})", jobKeys.size(), jobKeys);
}
} catch (SchedulerException e) {
logger.warn("Couldn't remove Commit-Job: {}", e.getMessage());
}
}
use of org.quartz.SchedulerException in project opennms by OpenNMS.
the class Main method shutdownContextAndExit.
private static void shutdownContextAndExit(AbstractApplicationContext context) {
int returnCode = 0;
// an exception. See #NMS-6966 for more details.
if (context.isActive()) {
// If there is a scheduler in the context, then shut it down
Scheduler scheduler = (Scheduler) context.getBean("scheduler");
if (scheduler != null) {
try {
LOG.info("Shutting down PollerFrontEnd scheduler");
scheduler.shutdown();
LOG.info("PollerFrontEnd scheduler shutdown complete");
} catch (SchedulerException ex) {
LOG.warn("Shutting down PollerFrontEnd scheduler failed", ex);
returnCode = 10;
}
}
// Now close the application context. This will invoke
// {@link DefaultPollerFrontEnd#destroy()} which will mark the
// remote poller as "Stopped" during shutdown instead of letting
// it remain in the "Disconnected" state.
context.close();
}
final int returnCodeValue = returnCode;
new Thread() {
public void run() {
// PropertyChangeListeners get a chance to fire
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}
// Exit
System.exit(returnCodeValue);
}
}.start();
}
use of org.quartz.SchedulerException in project OpenClinica by OpenClinica.
the class XsltTransformJob method initDependencies.
/**
* Initializes the dependencies of this job with the components from the Spring application context.
*
* @param scheduler
*/
private void initDependencies(Scheduler scheduler) {
try {
ApplicationContext ctx = (ApplicationContext) scheduler.getContext().get("applicationContext");
DataSource dataSource = ctx.getBean(DataSource.class);
mailSender = ctx.getBean(OpenClinicaMailSender.class);
auditEventDAO = ctx.getBean(AuditEventDAO.class);
datasetDao = ctx.getBean(DatasetDAO.class);
userAccountDao = ctx.getBean(UserAccountDAO.class);
studyDao = new StudyDAO(dataSource);
archivedDatasetFileDao = ctx.getBean(ArchivedDatasetFileDAO.class);
generateFileService = ctx.getBean(GenerateExtractFileService.class);
odmFileCreation = ctx.getBean(OdmFileCreation.class);
} catch (SchedulerException e) {
throw new IllegalStateException("Could not load dependencies from scheduler context", e);
}
}
use of org.quartz.SchedulerException in project OpenClinica by OpenClinica.
the class XsltTransformJob method postErrorMessage.
private void postErrorMessage(String message, JobExecutionContext context) {
String SCHEDULER = "schedulerFactoryBean";
try {
ApplicationContext appContext = (ApplicationContext) context.getScheduler().getContext().get("applicationContext");
StdScheduler scheduler = (StdScheduler) appContext.getBean(SCHEDULER);
JobDetail jobDetail = context.getJobDetail();
JobDataMap dataMap = jobDetail.getJobDataMap();
dataMap.put("failMessage", message);
jobDetail.getJobBuilder().usingJobData(dataMap);
// replace the job with the extra data
scheduler.addJob(jobDetail, true);
} catch (SchedulerException e) {
throw new IllegalStateException("Error processing post error message", e);
}
}
use of org.quartz.SchedulerException in project OpenClinica by OpenClinica.
the class XsltTriggerService method generateXsltTrigger.
public SimpleTrigger generateXsltTrigger(Scheduler scheduler, String xslFile, String xmlFile, String endFilePath, String endFile, int datasetId, ExtractPropertyBean epBean, UserAccountBean userAccountBean, String locale, int cnt, String xsltPath, String triggerGroupName) {
//Date startDateTime = new Date(System.currentTimeMillis());
String jobName = datasetId + "_" + epBean.getExportFileName()[0];
if (triggerGroupName != null)
TRIGGER_GROUP_NAME = triggerGroupName;
//WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
ApplicationContext context = null;
try {
context = (ApplicationContext) scheduler.getContext().get("applicationContext");
} catch (SchedulerException e) {
e.printStackTrace();
}
SimpleTriggerFactoryBean triggerFactoryBean = context.getBean(SimpleTriggerFactoryBean.class, xslFile, xmlFile, endFilePath, endFile, datasetId, epBean, userAccountBean, locale, cnt, xsltPath);
SimpleTrigger trigger = triggerFactoryBean.getObject();
return trigger;
}
Aggregations