Search in sources :

Example 41 with Scheduler

use of org.quartz.Scheduler in project head by mifos.

the class BatchjobsServiceFacadeWebTier method suspend.

@Override
public void suspend(ServletContext context, String doSuspend) throws SchedulerException {
    MifosScheduler mifosScheduler = (MifosScheduler) context.getAttribute(MifosScheduler.class.getName());
    Scheduler scheduler = mifosScheduler.getScheduler();
    if (doSuspend.equals(ApplicationContextProvider.getBean(MessageLookup.class).lookup("systemAdministration.batchjobs.suspend")) && !scheduler.isInStandbyMode()) {
        scheduler.standby();
    }
    if (doSuspend.equals(ApplicationContextProvider.getBean(MessageLookup.class).lookup("systemAdministration.batchjobs.activate")) && scheduler.isInStandbyMode()) {
        scheduler.start();
    }
}
Also used : Scheduler(org.quartz.Scheduler) MifosScheduler(org.mifos.framework.components.batchjobs.MifosScheduler) MessageLookup(org.mifos.application.master.MessageLookup) MifosScheduler(org.mifos.framework.components.batchjobs.MifosScheduler)

Example 42 with Scheduler

use of org.quartz.Scheduler in project elastic-job by dangdangdotcom.

the class JobScheduler method createScheduler.

private Scheduler createScheduler(final boolean isMisfire) {
    Scheduler result;
    try {
        StdSchedulerFactory factory = new StdSchedulerFactory();
        factory.initialize(getBaseQuartzProperties(isMisfire));
        result = factory.getScheduler();
        result.getListenerManager().addTriggerListener(jobExecutor.getSchedulerFacade().newJobTriggerListener());
    } catch (final SchedulerException ex) {
        throw new JobSystemException(ex);
    }
    return result;
}
Also used : StdSchedulerFactory(org.quartz.impl.StdSchedulerFactory) SchedulerException(org.quartz.SchedulerException) Scheduler(org.quartz.Scheduler) JobSystemException(com.dangdang.ddframe.job.exception.JobSystemException)

Example 43 with Scheduler

use of org.quartz.Scheduler in project elastic-job by dangdangdotcom.

the class JobSchedulerTest method assertInit.

private void assertInit() throws NoSuchFieldException, SchedulerException {
    verify(jobExecutor).init();
    Scheduler scheduler = ReflectionUtils.getFieldValue(JobRegistry.getInstance().getJobScheduleController("test_job"), JobScheduleController.class.getDeclaredField("scheduler"));
    assertThat(scheduler.getListenerManager().getTriggerListeners().size(), is(1));
    assertThat(scheduler.getListenerManager().getTriggerListeners().get(0), instanceOf(JobTriggerListener.class));
    assertTrue(scheduler.isStarted());
    verify(schedulerFacade).newJobTriggerListener();
}
Also used : Scheduler(org.quartz.Scheduler) JobScheduleController(com.dangdang.ddframe.job.lite.internal.schedule.JobScheduleController) JobTriggerListener(com.dangdang.ddframe.job.lite.internal.schedule.JobTriggerListener)

Example 44 with Scheduler

use of org.quartz.Scheduler in project spring-framework by spring-projects.

the class SchedulerAccessorBean method findScheduler.

protected Scheduler findScheduler(String schedulerName) throws SchedulerException {
    if (this.beanFactory instanceof ListableBeanFactory) {
        ListableBeanFactory lbf = (ListableBeanFactory) this.beanFactory;
        String[] beanNames = lbf.getBeanNamesForType(Scheduler.class);
        for (String beanName : beanNames) {
            Scheduler schedulerBean = (Scheduler) lbf.getBean(beanName);
            if (schedulerName.equals(schedulerBean.getSchedulerName())) {
                return schedulerBean;
            }
        }
    }
    Scheduler schedulerInRepo = SchedulerRepository.getInstance().lookup(schedulerName);
    if (schedulerInRepo == null) {
        throw new IllegalStateException("No Scheduler named '" + schedulerName + "' found");
    }
    return schedulerInRepo;
}
Also used : Scheduler(org.quartz.Scheduler) ListableBeanFactory(org.springframework.beans.factory.ListableBeanFactory)

Example 45 with Scheduler

use of org.quartz.Scheduler in project openhab1-addons by openhab.

the class MpdBinding method scheduleReconnect.

private void scheduleReconnect() {
    Scheduler sched;
    try {
        sched = StdSchedulerFactory.getDefaultScheduler();
        JobDetail job = newJob(ReconnectJob.class).withIdentity("Reconnect", MPD_SCHEDULER_GROUP).build();
        CronTrigger trigger = newTrigger().withIdentity("Reconnect", MPD_SCHEDULER_GROUP).withSchedule(CronScheduleBuilder.cronSchedule("0 0 0 * * ?")).build();
        sched.scheduleJob(job, trigger);
        logger.debug("Scheduled a daily reconnect of all MPDs");
    } catch (SchedulerException se) {
        logger.warn("Scheduling MPD reconnect failed", se);
    }
}
Also used : JobDetail(org.quartz.JobDetail) CronTrigger(org.quartz.CronTrigger) SchedulerException(org.quartz.SchedulerException) Scheduler(org.quartz.Scheduler)

Aggregations

Scheduler (org.quartz.Scheduler)74 SchedulerException (org.quartz.SchedulerException)38 JobDetail (org.quartz.JobDetail)34 Trigger (org.quartz.Trigger)23 Test (org.junit.Test)19 JobKey (org.quartz.JobKey)17 SimpleTrigger (org.quartz.SimpleTrigger)16 CronTrigger (org.quartz.CronTrigger)15 JobDataMap (org.quartz.JobDataMap)10 TriggerKey (org.quartz.TriggerKey)10 TriggerBuilder.newTrigger (org.quartz.TriggerBuilder.newTrigger)9 ArrayList (java.util.ArrayList)7 Date (java.util.Date)6 Command (org.openhab.core.types.Command)5 InetSocketAddress (java.net.InetSocketAddress)4 SocketChannel (java.nio.channels.SocketChannel)4 IOException (java.io.IOException)3 RouteBuilder (org.apache.camel.builder.RouteBuilder)3 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)3 StdSchedulerFactory (org.quartz.impl.StdSchedulerFactory)3