Package org.quartz

Examples of org.quartz.Scheduler


        if (jobPaused.get()) {
            return;
        }
        jobPaused.set(true);

        Scheduler scheduler = getComponent().getScheduler();
        if (scheduler != null && !scheduler.isShutdown()) {
            LOG.info("Pausing trigger {}", triggerKey);
            scheduler.pauseTrigger(triggerKey);
        }
    }
View Full Code Here


        if (!jobPaused.get()) {
            return;
        }
        jobPaused.set(false);

        Scheduler scheduler = getComponent().getScheduler();
        if (scheduler != null) {
            LOG.info("Resuming trigger {}", triggerKey);
            scheduler.resumeTrigger(triggerKey);
        }
    }
View Full Code Here

        }
        return answer;
    }

    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
        scheduler.getContext().put(QuartzConstants.QUARTZ_CAMEL_CONTEXT + "-" + getCamelContext().getManagementName(), 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;
    }
View Full Code Here

   * @throws SchedulerException
   **************************************************************************/
  @SuppressWarnings("deprecation")
  private static void startTimedJobs() throws SchedulerException {
    SchedulerFactory schedFact = new org.quartz.impl.StdSchedulerFactory();
    Scheduler sched = schedFact.getScheduler();
    sched.start();
   
    initializeJob(new HistoryAnalyserJob(), "dailyHistoryAnalyser", sched);
    initializeJobNonConfigured(new HotfolderJob(), 5, sched);
  }
View Full Code Here

            return new StdSchedulerFactory();
        }
    }

    protected Scheduler createScheduler() throws SchedulerException {
        Scheduler scheduler = getFactory().getScheduler();
        scheduler.getContext().put(QuartzConstants.QUARTZ_CAMEL_CONTEXT, getCamelContext());
        return scheduler;
    }
View Full Code Here

            defaultProperties.put(THREAD_NAME, name) ;
            if (!defaultProperties.containsKey(THREAD_COUNT))
            {
                defaultProperties.put(THREAD_COUNT, "1") ;
            }
            final Scheduler scheduler ;
            try
            {
                scheduler = new StdSchedulerFactory(defaultProperties).getScheduler();
                scheduler.start() ;
            }
            catch (final SchedulerException se)
            {
                throw new SchedulingException("Failed to initialise the scheduler", se) ;
            }
View Full Code Here

        properties.put(THREAD_NAME, name) ;
        if (!properties.containsKey(THREAD_COUNT))
        {
            properties.put(THREAD_COUNT, "1") ;
        }
        final Scheduler scheduler ;
        try
        {
            scheduler = new StdSchedulerFactory(properties).getScheduler();
            scheduler.start() ;
        }
        catch (final SchedulerException se)
        {
            throw new JbpmException("Failed to initialise the scheduler", se) ;
        }
View Full Code Here

    @Override
    public Date createJob() throws Exception {

        final QuartzResourceAdapter ra = (QuartzResourceAdapter) new InitialContext().lookup("java:openejb/Resource/QuartzResourceAdapter");
        final Scheduler s = ra.getScheduler();

        //Add a job type
        final JobDetail jd = new JobDetail("job1", "group1", JobBean.MyTestJob.class);
        jd.getJobDataMap().put("MyJobKey", "MyJobValue");

        //Schedule my 'test' job to run now
        final SimpleTrigger trigger = new SimpleTrigger("trigger1", "group1", new Date());
        return s.scheduleJob(jd, trigger);
    }
View Full Code Here

        this.transacted = transactionType == TransactionType.Required || transactionType == TransactionType.RequiresNew;
        this.retryAttempts = retryAttempts;
    }

    public static synchronized Scheduler getDefaultScheduler() {
        Scheduler scheduler = SystemInstance.get().getComponent(Scheduler.class);
        if (scheduler == null) {
            Properties properties = new Properties();
            properties.put(StdSchedulerFactory.PROP_THREAD_POOL_CLASS, SystemInstance.get().hasProperty(QUARTZ_THREAD_POOL_ADAPTER) ? SystemInstance.get().getProperty(QUARTZ_THREAD_POOL_ADAPTER)
                    : DefaultTimerThreadPoolAdapter.class.getName());
            properties.put(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, "OpenEJB-TimerService-Scheduler");
            try {
                scheduler = new StdSchedulerFactory(properties).getScheduler();
                scheduler.start();
                //durability is configured with true, which means that the job will be kept in the store even if no trigger is attached to it.
                //Currently, all the EJB beans share with the same job instance
                scheduler.addJob(new JobDetail(OPENEJB_TIMEOUT_JOB_NAME, OPENEJB_TIMEOUT_JOB_GROUP_NAME, EjbTimeoutJob.class, false, true, false), true);
            } catch (SchedulerException e) {
                throw new RuntimeException("Fail to initialize the default scheduler", e);
            }
            SystemInstance.get().setComponent(Scheduler.class, scheduler);
        }
View Full Code Here

        return scheduler;
    }

    public static void shutdown() {

        Scheduler scheduler = SystemInstance.get().getComponent(Scheduler.class);
        if (scheduler != null) try {
            scheduler.shutdown();
        } catch (SchedulerException e) {
            throw new RuntimeException("Unable to shutdown scheduler", e);
        }

    }
View Full Code Here

TOP

Related Classes of org.quartz.Scheduler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.