use of org.quartz.Scheduler in project spring-framework by spring-projects.
the class QuartzSupportTests method schedulerAutoStartsOnContextRefreshedEventByDefault.
@Test
@SuppressWarnings("resource")
public void schedulerAutoStartsOnContextRefreshedEventByDefault() throws Exception {
StaticApplicationContext context = new StaticApplicationContext();
context.registerBeanDefinition("scheduler", new RootBeanDefinition(SchedulerFactoryBean.class));
Scheduler bean = context.getBean("scheduler", Scheduler.class);
assertFalse(bean.isStarted());
context.refresh();
assertTrue(bean.isStarted());
}
use of org.quartz.Scheduler in project spring-framework by spring-projects.
the class QuartzSupportTests method multipleSchedulers.
/**
* Tests the creation of multiple schedulers (SPR-772)
*/
@Test
public void multipleSchedulers() throws Exception {
ClassPathXmlApplicationContext ctx = context("multipleSchedulers.xml");
try {
Scheduler scheduler1 = (Scheduler) ctx.getBean("scheduler1");
Scheduler scheduler2 = (Scheduler) ctx.getBean("scheduler2");
assertNotSame(scheduler1, scheduler2);
assertEquals("quartz1", scheduler1.getSchedulerName());
assertEquals("quartz2", scheduler2.getSchedulerName());
} finally {
ctx.close();
}
}
use of org.quartz.Scheduler in project spring-framework by spring-projects.
the class QuartzSupportTests method schedulerAutoStartupFalse.
@Test
@SuppressWarnings("resource")
public void schedulerAutoStartupFalse() throws Exception {
StaticApplicationContext context = new StaticApplicationContext();
BeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(SchedulerFactoryBean.class).addPropertyValue("autoStartup", false).getBeanDefinition();
context.registerBeanDefinition("scheduler", beanDefinition);
Scheduler bean = context.getBean("scheduler", Scheduler.class);
assertFalse(bean.isStarted());
context.refresh();
assertFalse(bean.isStarted());
}
use of org.quartz.Scheduler in project camel by apache.
the class QuartzComponent method createScheduler.
protected Scheduler createScheduler() throws SchedulerException {
Scheduler scheduler = getFactory().getScheduler();
if (LOG.isDebugEnabled()) {
LOG.debug("Using SchedulerFactory {} to get/create Scheduler {}({})", new Object[] { getFactory(), scheduler, ObjectHelper.getIdentityHashCode(scheduler) });
}
// register current camel context to scheduler so we can look it up when jobs is being triggered
// must use management name as it should be unique in the same JVM
String uid = QuartzHelper.getQuartzContextName(getCamelContext());
scheduler.getContext().put(QuartzConstants.QUARTZ_CAMEL_CONTEXT + "-" + uid, getCamelContext());
// store Camel job counter
AtomicInteger number = (AtomicInteger) scheduler.getContext().get("CamelJobs");
if (number == null) {
number = new AtomicInteger(0);
scheduler.getContext().put("CamelJobs", number);
}
return scheduler;
}
use of org.quartz.Scheduler in project camel by apache.
the class QuartzEndpoint method resumeTrigger.
public void resumeTrigger() throws Exception {
if (!jobPaused.get()) {
return;
}
jobPaused.set(false);
Scheduler scheduler = getComponent().getScheduler();
if (scheduler != null) {
LOG.info("Resuming trigger {}", triggerKey);
scheduler.resumeTrigger(triggerKey);
}
}
Aggregations