use of org.quartz.impl.StdSchedulerFactory in project jforum2 by rafaelsteil.
the class POPJobStarter method startJob.
public static void startJob() throws SchedulerException {
boolean isEnabled = SystemGlobals.getBoolValue(ConfigKeys.MAIL_POP3_INTEGRATION_ENABLED);
if (!isStarted && isEnabled) {
String filename = SystemGlobals.getValue(ConfigKeys.QUARTZ_CONFIG);
String cronExpression = SystemGlobals.getValue("org.quartz.context.mailintegration.cron.expression");
scheduler = new StdSchedulerFactory(filename).getScheduler();
Trigger trigger = null;
try {
trigger = new CronTrigger(POPListener.class.getName(), "pop3Integration", cronExpression);
logger.info("Starting POP3 integration expression " + cronExpression);
scheduler.scheduleJob(new JobDetail(POPListener.class.getName(), "pop3Integration", POPListener.class), trigger);
scheduler.start();
} catch (ParseException e) {
e.printStackTrace();
}
}
isStarted = true;
}
use of org.quartz.impl.StdSchedulerFactory in project oxCore by GluuFederation.
the class QuartzSchedulerManager method initInternal.
protected void initInternal() {
try {
StdSchedulerFactory factory = new StdSchedulerFactory();
factory.initialize(QUARTZ_PROPERTY_FILE_NAME);
scheduler = factory.getScheduler();
// Register job listener to bound request context to every job
// execution
scheduler.getListenerManager().addJobListener(jobListener, EverythingMatcher.allJobs());
// Replace default job factory
scheduler.setJobFactory(jobFactory);
} catch (SchedulerException ex) {
throw new IllegalStateException("Failed to initialize Quartz scheduler manager", ex);
}
log.info("Quartz scheduler manager initialized");
}
use of org.quartz.impl.StdSchedulerFactory in project siddhi by wso2.
the class CronTrigger method scheduleCronJob.
private void scheduleCronJob(String cronString, String elementId) {
try {
SchedulerFactory schedulerFactory = new StdSchedulerFactory();
scheduler = schedulerFactory.getScheduler();
jobName = "TriggerJob_" + elementId;
JobKey jobKey = new JobKey(jobName, jobGroup);
if (scheduler.checkExists(jobKey)) {
scheduler.deleteJob(jobKey);
}
scheduler.start();
JobDataMap dataMap = new JobDataMap();
dataMap.put("trigger", this);
JobDetail job = org.quartz.JobBuilder.newJob(CronTrigger.class).withIdentity(jobName, jobGroup).usingJobData(dataMap).build();
org.quartz.Trigger trigger = org.quartz.TriggerBuilder.newTrigger().withIdentity("TriggerJob_" + elementId, jobGroup).withSchedule(CronScheduleBuilder.cronSchedule(cronString)).build();
scheduler.scheduleJob(job, trigger);
} catch (SchedulerException e) {
LOG.error(ExceptionUtil.getMessageWithContext(e, siddhiAppContext) + " Error while instantiating quartz scheduler for trigger '" + triggerDefinition.getId() + "'.", e);
}
}
use of org.quartz.impl.StdSchedulerFactory in project javautils by jiadongpo.
the class StartQuartzJobTest method testQuartz.
public static void testQuartz() throws Exception {
SchedulerFactory schedFact = new StdSchedulerFactory();
Scheduler sched = schedFact.getScheduler();
sched.start();
JobDetail job = JobBuilder.newJob(StartQuartzJob.class).withIdentity("myJob", "group1").usingJobData("jobSays", "hello world!").usingJobData("myFloatValue", 3.141f).build();
Trigger trigger = TriggerBuilder.newTrigger().withIdentity("myTrigger", "group1").startNow().withSchedule(CronScheduleBuilder.cronSchedule("0/2 * * * * ?")).build();
sched.scheduleJob(job, trigger);
}
use of org.quartz.impl.StdSchedulerFactory in project java-example by 1479005017.
the class QuartzTest method testModify.
@Test
public void testModify() throws Exception {
SchedulerFactory schedulerFactory = new StdSchedulerFactory();
Scheduler scheduler = schedulerFactory.getScheduler();
QuartzManager quartzManager = new QuartzManager(scheduler);
quartzManager.addJob("myJob", "test", MyJob.class, Collections.singletonMap("x", "1"), "0/5 * * * * ?");
quartzManager.startScheduler();
Thread.sleep(1500);
for (int i = 0; Thread.activeCount() > 0; i++) {
if (i % 3 == 0) {
quartzManager.modifyJob("myJob", "test", Collections.singletonMap("x", i + ""));
}
Thread.sleep(1000);
}
}
Aggregations