use of org.quartz.CronTrigger in project camel by apache.
the class QuartzEndpointConfigureTest method testConfigureAnotherCronExpression.
@Test
public void testConfigureAnotherCronExpression() throws Exception {
QuartzEndpoint endpoint = resolveMandatoryEndpoint("quartz2://myGroup/myTimerName?cron=0+0+*+*+*+?");
Scheduler scheduler = endpoint.getComponent().getScheduler();
TriggerKey triggerKey = endpoint.getTriggerKey();
Trigger trigger = scheduler.getTrigger(triggerKey);
JobDetail jobDetail = scheduler.getJobDetail(JobKey.jobKey(triggerKey.getName(), triggerKey.getGroup()));
assertEquals("getName()", "myTimerName", triggerKey.getName());
assertEquals("getGroup()", "myGroup", triggerKey.getGroup());
assertEquals("getJobName", "myTimerName", jobDetail.getKey().getName());
assertEquals("getJobGroup", "myGroup", jobDetail.getKey().getGroup());
assertIsInstanceOf(CronTrigger.class, trigger);
CronTrigger cronTrigger = (CronTrigger) trigger;
assertEquals("cron expression", "0 0 * * * ?", cronTrigger.getCronExpression());
}
use of org.quartz.CronTrigger in project camel by apache.
the class QuartzEndpointConfigureTest method testConfigureNoDoubleSlashQuestionCron.
@Test
public void testConfigureNoDoubleSlashQuestionCron() throws Exception {
QuartzEndpoint endpoint = resolveMandatoryEndpoint("quartz2:myGroup/myTimerName?cron=0+0+*+*+*+?");
Scheduler scheduler = endpoint.getComponent().getScheduler();
TriggerKey triggerKey = endpoint.getTriggerKey();
Trigger trigger = scheduler.getTrigger(triggerKey);
JobDetail jobDetail = scheduler.getJobDetail(JobKey.jobKey(triggerKey.getName(), triggerKey.getGroup()));
assertEquals("getName()", "myTimerName", triggerKey.getName());
assertEquals("getGroup()", "myGroup", triggerKey.getGroup());
assertEquals("getJobName", "myTimerName", jobDetail.getKey().getName());
assertEquals("getJobGroup", "myGroup", jobDetail.getKey().getGroup());
assertIsInstanceOf(CronTrigger.class, trigger);
CronTrigger cronTrigger = (CronTrigger) trigger;
assertEquals("cron expression", "0 0 * * * ?", cronTrigger.getCronExpression());
}
use of org.quartz.CronTrigger in project camel by apache.
the class QuartzStatefulJobRouteTest method testQuartzCronRoute.
@Test
public void testQuartzCronRoute() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(3);
assertMockEndpointsSatisfied();
Trigger trigger = mock.getReceivedExchanges().get(0).getIn().getHeader("trigger", Trigger.class);
Assert.assertThat(trigger instanceof CronTrigger, CoreMatchers.is(true));
JobDetail detail = mock.getReceivedExchanges().get(0).getIn().getHeader("jobDetail", JobDetail.class);
Assert.assertThat(detail.getJobClass().equals(StatefulCamelJob.class), CoreMatchers.is(true));
}
use of org.quartz.CronTrigger 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.CronTrigger in project iaf by ibissource.
the class SchedulerAdapter method triggerToXmlBuilder.
public XmlBuilder triggerToXmlBuilder(Scheduler theScheduler, String triggerName, String groupName) {
XmlBuilder xbRoot = new XmlBuilder("triggerDetail");
try {
Trigger trigger = theScheduler.getTrigger(triggerName, groupName);
xbRoot.addAttribute("fullName", trigger.getFullName());
xbRoot.addAttribute("triggerName", trigger.getName());
xbRoot.addAttribute("triggerGroup", trigger.getGroup());
String cn = trigger.getCalendarName();
xbRoot.addAttribute("calendarName", (cn == null ? "none" : cn));
Date date;
try {
date = trigger.getEndTime();
xbRoot.addAttribute("endTime", (null == date ? "" : DateUtils.format(date, DateUtils.FORMAT_GENERICDATETIME)));
} catch (Exception e) {
log.debug(e);
}
;
try {
date = trigger.getFinalFireTime();
xbRoot.addAttribute("finalFireTime", (null == date ? "" : DateUtils.format(date, DateUtils.FORMAT_GENERICDATETIME)));
} catch (Exception e) {
log.debug(e);
}
;
try {
date = trigger.getPreviousFireTime();
xbRoot.addAttribute("previousFireTime", (null == date ? "" : DateUtils.format(date, DateUtils.FORMAT_GENERICDATETIME)));
} catch (Exception e) {
log.debug(e);
}
;
try {
date = trigger.getNextFireTime();
xbRoot.addAttribute("nextFireTime", (null == date ? "" : DateUtils.format(date, DateUtils.FORMAT_GENERICDATETIME)));
} catch (Exception e) {
log.debug(e);
}
;
try {
date = trigger.getStartTime();
xbRoot.addAttribute("startTime", (null == date ? "" : DateUtils.format(date, DateUtils.FORMAT_GENERICDATETIME)));
} catch (Exception e) {
log.debug(e);
}
;
xbRoot.addAttribute("misfireInstruction", Integer.toString(trigger.getMisfireInstruction()));
if (trigger instanceof CronTrigger) {
xbRoot.addAttribute("triggerType", "cron");
xbRoot.addAttribute("cronExpression", ((CronTrigger) trigger).getCronExpression());
} else if (trigger instanceof SimpleTrigger) {
xbRoot.addAttribute("triggerType", "simple");
xbRoot.addAttribute("repeatInterval", ((SimpleTrigger) trigger).getRepeatInterval());
} else {
xbRoot.addAttribute("triggerType", "unknown");
}
xbRoot.addAttribute("jobGroup", trigger.getJobGroup());
xbRoot.addAttribute("jobName", trigger.getJobName());
xbRoot.addAttribute("isVolatile", (trigger.isVolatile() ? "True" : "False"));
} catch (SchedulerException se) {
log.error(se);
}
return xbRoot;
}
Aggregations