Java Code Examples for org.quartz.impl.StdSchedulerFactory
The following examples show how to use
org.quartz.impl.StdSchedulerFactory. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: glowroot Source File: QuartzPluginIT.java License: Apache License 2.0 | 6 votes |
@Override public void executeApp() throws Exception { Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler(); scheduler.start(); JobDetail job; Trigger trigger; try { job = createJob2x(); trigger = createTrigger2x(); } catch (ClassNotFoundException e) { job = createJob1x(); trigger = createTrigger1x(); } scheduler.scheduleJob(job, trigger); SECONDS.sleep(1); scheduler.shutdown(); }
Example 2
Source Project: openhab1-addons Source File: FHTBinding.java License: Eclipse Public License 2.0 | 6 votes |
/** * The user may configure this binding to update the internal clock of * FHT80b devices via rf command. The method takes care of scheduling this * job. */ private JobKey scheduleJob(Class<? extends Job> jobClass, String cronExpression) { JobKey jobKey = null; try { Scheduler sched = StdSchedulerFactory.getDefaultScheduler(); JobDetail detail = JobBuilder.newJob(jobClass).withIdentity("FHT " + jobClass.getSimpleName(), "cul") .build(); detail.getJobDataMap().put(FHTBinding.class.getName(), this); CronTrigger trigger = TriggerBuilder.newTrigger().forJob(detail) .withSchedule(CronScheduleBuilder.cronSchedule(cronExpression)).build(); jobKey = detail.getKey(); sched.scheduleJob(detail, trigger); } catch (SchedulerException e) { logger.error("Can't schedule time update job", e); } return jobKey; }
Example 3
Source Project: java-technology-stack Source File: SchedulerFactoryBean.java License: MIT License | 6 votes |
/** * Create a SchedulerFactory if necessary and apply locally defined Quartz properties to it. * @return the initialized SchedulerFactory */ private SchedulerFactory prepareSchedulerFactory() throws SchedulerException, IOException { SchedulerFactory schedulerFactory = this.schedulerFactory; if (schedulerFactory == null) { // Create local SchedulerFactory instance (typically a StdSchedulerFactory) schedulerFactory = BeanUtils.instantiateClass(this.schedulerFactoryClass); if (schedulerFactory instanceof StdSchedulerFactory) { initSchedulerFactory((StdSchedulerFactory) schedulerFactory); } else if (this.configLocation != null || this.quartzProperties != null || this.taskExecutor != null || this.dataSource != null) { throw new IllegalArgumentException( "StdSchedulerFactory required for applying Quartz properties: " + schedulerFactory); } // Otherwise, no local settings to be applied via StdSchedulerFactory.initialize(Properties) } // Otherwise, assume that externally provided factory has been initialized with appropriate settings return schedulerFactory; }
Example 4
Source Project: mykit-db-sync Source File: DBSyncBuilder.java License: Apache License 2.0 | 6 votes |
/** * 启动定时任务,同步数据库的数据 */ public void start() { for (int index = 0; index < jobList.size(); index++) { JobInfo jobInfo = jobList.get(index); String logTitle = "[" + code + "]" + jobInfo.getName() + " "; try { SchedulerFactory sf = new StdSchedulerFactory(); Scheduler sched = sf.getScheduler(); JobDetail job = newJob(JobTask.class).withIdentity(MykitDbSyncConstants.JOB_PREFIX.concat(jobInfo.getName()), code).build(); job.getJobDataMap().put(MykitDbSyncConstants.SRC_DB, srcDb); job.getJobDataMap().put(MykitDbSyncConstants.DEST_DB, destDb); job.getJobDataMap().put(MykitDbSyncConstants.JOB_INFO, jobInfo); job.getJobDataMap().put(MykitDbSyncConstants.LOG_TITLE, logTitle); logger.info(jobInfo.getCron()); CronTrigger trigger = newTrigger().withIdentity(MykitDbSyncConstants.TRIGGER_PREFIX.concat(jobInfo.getName()), code).withSchedule(cronSchedule(jobInfo.getCron())).build(); sched.scheduleJob(job, trigger); sched.start(); } catch (Exception e) { e.printStackTrace(); logger.error(logTitle + e.getMessage()); logger.error(logTitle + " run failed"); continue; } } }
Example 5
Source Project: mykit-db-sync Source File: DBSyncBuilder.java License: Apache License 2.0 | 6 votes |
/** * 启动定时任务,同步数据库的数据 */ public void start() { for (int index = 0; index < jobList.size(); index++) { JobInfo jobInfo = jobList.get(index); String logTitle = "[" + code + "]" + jobInfo.getName() + " "; try { SchedulerFactory sf = new StdSchedulerFactory(); Scheduler sched = sf.getScheduler(); JobDetail job = newJob(JobTask.class).withIdentity(MykitDbSyncConstants.JOB_PREFIX.concat(jobInfo.getName()), code).build(); job.getJobDataMap().put(MykitDbSyncConstants.SRC_DB, srcDb); job.getJobDataMap().put(MykitDbSyncConstants.DEST_DB, destDb); job.getJobDataMap().put(MykitDbSyncConstants.JOB_INFO, jobInfo); job.getJobDataMap().put(MykitDbSyncConstants.LOG_TITLE, logTitle); logger.info(jobInfo.getCron()); CronTrigger trigger = newTrigger().withIdentity(MykitDbSyncConstants.TRIGGER_PREFIX.concat(jobInfo.getName()), code).withSchedule(cronSchedule(jobInfo.getCron())).build(); sched.scheduleJob(job, trigger); sched.start(); } catch (Exception e) { e.printStackTrace(); logger.error(logTitle + e.getMessage()); logger.error(logTitle + " run failed"); continue; } } }
Example 6
Source Project: dapeng-soa Source File: TaskSchedulePlugin.java License: Apache License 2.0 | 6 votes |
public TaskSchedulePlugin(Container container) { this.container = container; container.registerAppListener(this); if (scheduler == null) { try { scheduler = StdSchedulerFactory.getDefaultScheduler(); //添加监听器 scheduler.getListenerManager().addJobListener(new SchedulerJobListener()); scheduler.getListenerManager().addTriggerListener(new SchedulerTriggerListener()); } catch (SchedulerException e) { LOGGER.error("TaskSchedulePlugin 初始化出错", e); } } }
Example 7
Source Project: wechatGroupRobot Source File: MainClass.java License: GNU General Public License v3.0 | 6 votes |
private static void cronTrigger() { JobDetail job = JobBuilder.newJob(WechatRobotJob.class).withIdentity("job1", "group1").build(); CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule("0 0 6 ? * *"); Trigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger1", "group1").withSchedule(cronScheduleBuilder).build(); JobDetail job2 = JobBuilder.newJob(WechatRobotJob2.class).withIdentity("job2", "group2").build(); CronScheduleBuilder cronScheduleBuilder2 = CronScheduleBuilder.cronSchedule("0 10 10,15,18,21 * * ?"); Trigger trigger2 = TriggerBuilder.newTrigger().withIdentity("trigger2", "group2").withSchedule(cronScheduleBuilder2).build(); SchedulerFactory schedulerFactory = new StdSchedulerFactory(); Scheduler scheduler = null; try { scheduler = schedulerFactory.getScheduler(); scheduler.scheduleJob(job, trigger); scheduler.scheduleJob(job2, trigger2); scheduler.start(); } catch (SchedulerException e) { e.printStackTrace(); } }
Example 8
Source Project: Mykit Source File: DBSyncBuilder.java License: Apache License 2.0 | 6 votes |
/** * 启动定时任务,同步数据库的数据 */ public void start() { for (int index = 0; index < jobList.size(); index++) { JobInfo jobInfo = jobList.get(index); String logTitle = "[" + code + "]" + jobInfo.getName() + " "; try { SchedulerFactory sf = new StdSchedulerFactory(); Scheduler sched = sf.getScheduler(); JobDetail job = newJob(JobTask.class).withIdentity("job-" + jobInfo.getName(), code).build(); job.getJobDataMap().put("srcDb", srcDb); job.getJobDataMap().put("destDb", destDb); job.getJobDataMap().put("jobInfo", jobInfo); job.getJobDataMap().put("logTitle", logTitle); logger.info(jobInfo.getCron()); CronTrigger trigger = newTrigger().withIdentity("trigger-" + jobInfo.getName(), code).withSchedule(cronSchedule(jobInfo.getCron())).build(); sched.scheduleJob(job, trigger); sched.start(); } catch (Exception e) { logger.info(logTitle + e.getMessage()); logger.info(logTitle + " run failed"); continue; } } }
Example 9
Source Project: aion-germany Source File: CronService.java License: GNU General Public License v3.0 | 6 votes |
public synchronized void init(Class<? extends RunnableRunner> runnableRunner) { if (scheduler != null) { return; } if (runnableRunner == null) { throw new CronServiceException("RunnableRunner class must be defined"); } this.runnableRunner = runnableRunner; Properties properties = new Properties(); properties.setProperty("org.quartz.threadPool.threadCount", "1"); try { scheduler = new StdSchedulerFactory(properties).getScheduler(); scheduler.start(); } catch (SchedulerException e) { throw new CronServiceException("Failed to initialize CronService", e); } }
Example 10
Source Project: jweb-cms Source File: SchedulerService.java License: GNU Affero General Public License v3.0 | 6 votes |
public void start() { try { SchedulerFactory sf = new StdSchedulerFactory(); scheduler = sf.getScheduler(); scheduler.start(); for (Map.Entry<String, Task> entry : tasks.entrySet()) { Task task = entry.getValue(); JobDetail job = newJob(SchedulerJob.class) .withIdentity(task.id) .build(); CronTrigger trigger = newTrigger() .withIdentity(task.id) .withSchedule(cronSchedule(task.cron)) .build(); scheduler.scheduleJob(job, trigger); } } catch (SchedulerException e) { throw new ApplicationException(e); } }
Example 11
Source Project: attic-aurora Source File: CronModule.java License: Apache License 2.0 | 6 votes |
@Provides @Singleton Scheduler provideScheduler(AuroraCronJobFactory jobFactory) throws SchedulerException { // There are several ways to create a quartz Scheduler instance. This path was chosen as the // simplest to create a Scheduler that uses a *daemon* QuartzSchedulerThread instance. Properties props = new Properties(); String name = "aurora-cron-" + ID_GENERATOR.incrementAndGet(); props.setProperty(PROP_SCHED_NAME, name); props.setProperty(PROP_SCHED_INSTANCE_ID, name); props.setProperty(PROP_THREAD_POOL_CLASS, SimpleThreadPool.class.getCanonicalName()); props.setProperty( PROP_THREAD_POOL_PREFIX + ".threadCount", String.valueOf(options.cronSchedulerNumThreads)); props.setProperty(PROP_THREAD_POOL_PREFIX + ".makeThreadsDaemons", Boolean.TRUE.toString()); props.setProperty(PROP_SCHED_MAKE_SCHEDULER_THREAD_DAEMON, Boolean.TRUE.toString()); Scheduler scheduler = new StdSchedulerFactory(props).getScheduler(); scheduler.setJobFactory(jobFactory); return scheduler; }
Example 12
Source Project: thoth Source File: Scheduler.java License: BSD 3-Clause Clear License | 6 votes |
public void init() throws SchedulerException { if (isEnabled){ // Only shrink if specified JobDetail workerJob = JobBuilder.newJob(ShrinkerJob.class) .withIdentity("shrinkingJob", "group1").build(); Trigger workerTrigger = TriggerBuilder .newTrigger() .withIdentity("shrinkingTrigger", "group1") .withSchedule( CronScheduleBuilder.cronSchedule(schedule)) // execute this every day at midnight .build(); //Schedule it org.quartz.Scheduler scheduler = new StdSchedulerFactory().getScheduler(); scheduler.start(); scheduler.getContext().put("period", shrinkPeriod); scheduler.getContext().put("thothIndexUrl", thothIndexURL); scheduler.getContext().put("threadPoolSize", threadPoolSize); scheduler.scheduleJob(workerJob, workerTrigger); } }
Example 13
Source Project: openhab1-addons Source File: GCalPersistenceService.java License: Eclipse Public License 2.0 | 6 votes |
/** * Schedules new quartz scheduler job for uploading calendar entries to Google */ private void scheduleUploadJob() { try { scheduler = StdSchedulerFactory.getDefaultScheduler(); JobDetail job = newJob(SynchronizationJob.class).withIdentity("Upload_GCal-Entries", GCAL_SCHEDULER_GROUP) .build(); SimpleTrigger trigger = newTrigger().withIdentity("Upload_GCal-Entries", GCAL_SCHEDULER_GROUP) .withSchedule(repeatSecondlyForever(uploadInterval)).build(); scheduler.scheduleJob(job, trigger); logger.debug("Scheduled Google Calendar Upload-Job with interval '{}'", uploadInterval); } catch (SchedulerException e) { logger.warn("Could not create Google Calendar Upload-Job: {}", e.getMessage()); } }
Example 14
Source Project: chronix.server Source File: ChronixRetentionHandler.java License: Apache License 2.0 | 6 votes |
/** * This method sets up a scheduled deletion job. */ private void scheduledDeletion() { System.setProperty("org.quartz.threadPool.threadCount", "3"); SchedulerFactory sf = new StdSchedulerFactory(); try { scheduler = sf.getScheduler(); Trigger trigger = newTrigger() .withIdentity("Data_Retention_Trigger") .startNow() .withSchedule(dailyAtHourAndMinute(removeDailyAt, 0)) .build(); JobDetail deletionJob = newJob(RetentionJob.class) .withIdentity("Data_Retention_Job") .usingJobData(RetentionConstants.RETENTION_URL, retentionURL) .build(); scheduler.scheduleJob(deletionJob, trigger); scheduler.startDelayed(180); } catch (SchedulerException e) { LOGGER.warn("Got an scheduler exception.", e); } }
Example 15
Source Project: openhab1-addons Source File: MapDBPersistenceService.java License: Eclipse Public License 2.0 | 6 votes |
/** * Schedules new quartz scheduler jobs for committing transactions and * backing up the database */ private void scheduleJob() { try { Scheduler sched = StdSchedulerFactory.getDefaultScheduler(); // schedule commit-job JobDetail job = newJob(CommitJob.class).withIdentity("Commit_Transaction", SCHEDULER_GROUP).build(); SimpleTrigger trigger = newTrigger().withIdentity("Commit_Transaction", SCHEDULER_GROUP) .withSchedule(repeatSecondlyForever(commitInterval)).build(); sched.scheduleJob(job, trigger); logger.debug("Scheduled Commit-Job with interval {}sec.", commitInterval); } catch (SchedulerException e) { logger.warn("Could not create Job: {}", e.getMessage()); } }
Example 16
Source Project: hsweb-framework Source File: ScheduleAutoConfiguration.java License: Apache License 2.0 | 6 votes |
@Bean public SchedulerFactoryBean schedulerFactory(JobFactory jobFactory) { SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean(); schedulerFactoryBean.setApplicationContext(applicationContext); schedulerFactoryBean.setAutoStartup(schedulerProperties.isAutoStartup()); schedulerFactoryBean.setDataSource(dataSource); schedulerFactoryBean.setTransactionManager(platformTransactionManager); schedulerFactoryBean.setOverwriteExistingJobs(schedulerProperties.isOverwriteExistingJobs()); schedulerFactoryBean.setSchedulerFactoryClass(StdSchedulerFactory.class); schedulerFactoryBean.setBeanName(schedulerProperties.getBeanName()); schedulerFactoryBean.setJobFactory(jobFactory); schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(schedulerProperties.isWaitOnShutdown()); schedulerFactoryBean.setQuartzProperties(schedulerProperties.getProperties()); schedulerFactoryBean.setStartupDelay(schedulerProperties.getStartupDelay()); schedulerFactoryBean.setCalendars(calendarMap); schedulerFactoryBean.setSchedulerListeners(schedulerListeners); return schedulerFactoryBean; }
Example 17
Source Project: openhab1-addons Source File: CalDavLoaderImpl.java License: Eclipse Public License 2.0 | 6 votes |
@Override public void start() { super.start(); if (this.isProperlyConfigured()) { try { scheduler = new StdSchedulerFactory().getScheduler(); this.removeAllJobs(); } catch (SchedulerException e) { log.warn("Cannot get job scheduler", e); throw new IllegalStateException("Cannot get job scheduler", e); } this.startLoading(); } }
Example 18
Source Project: Knowage-Server Source File: QuartzInitializer.java License: GNU Affero General Public License v3.0 | 6 votes |
@Override public void init(SourceBean config) { StdSchedulerFactory stdSchedFact = new StdSchedulerFactory(); Properties properties = new Properties(); try { Thread currThread = Thread.currentThread(); ClassLoader classLoader = currThread.getContextClassLoader(); InputStream propIs = classLoader.getResourceAsStream("quartz.properties"); properties.load(propIs); String figuredOutValue = null; if (properties.containsKey(PROPERTY_DELEGATE_CLASS)) { logger.info("Quartz delegate class set to " + properties.get(PROPERTY_DELEGATE_CLASS)); } else { logger.warn("Property " + PROPERTY_DELEGATE_CLASS + " not set! Trying to figure out what delegate class needs to be used..."); determineDelegateClass(properties); } stdSchedFact.initialize(properties); Scheduler sched = stdSchedFact.getScheduler(); sched.start(); } catch (Exception e) { SpagoBITracer.major(SpagoBIConstants.NAME_MODULE, this.getClass().getName(), "init", "Error while initializing scheduler " + e); } }
Example 19
Source Project: openhab1-addons Source File: MyStromEcoPowerBinding.java License: Eclipse Public License 2.0 | 5 votes |
@Override public void activate() { try { scheduler = StdSchedulerFactory.getDefaultScheduler(); super.activate(); } catch (SchedulerException se) { logger.error("initializing scheduler throws exception", se); } }
Example 20
Source Project: FEBS-Cloud Source File: FebsJobConfigure.java License: Apache License 2.0 | 5 votes |
@Bean public SchedulerFactoryBean schedulerFactoryBean() { SchedulerFactoryBean factory = new SchedulerFactoryBean(); // 设置数据源 DataSource job = dynamicRoutingDataSource.getDataSource("job"); factory.setDataSource(job); Properties prop = new Properties(); // 任务调度实例名称,集群时多个实例名称保持一致 prop.put(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, "FebsCloudScheduler"); // 任务调度实例ID,指定为AUTO时,将自动生成ID prop.put(StdSchedulerFactory.PROP_SCHED_INSTANCE_ID, StdSchedulerFactory.AUTO_GENERATE_INSTANCE_ID); // quartz提供的简单线程池,适用于绝大部分场景 prop.put(StdSchedulerFactory.PROP_THREAD_POOL_CLASS, SimpleThreadPool.class); // 并发执行任务的线程数,取决于服务器系统资源 prop.put("org.quartz.threadPool.threadCount", "20"); // 可以是Thread.MIN_PRIORITY(1)和Thread.MAX_PRIORITY(10)之间的任何int值 。 // 默认值为Thread.NORM_PRIORITY(5) prop.put("org.quartz.threadPool.threadPriority", "5"); // 指定任务存储策略,这里使用关系型数据库 prop.put(StdSchedulerFactory.PROP_JOB_STORE_CLASS, JobStoreTX.class); // 是否开启集群 prop.put("org.quartz.jobStore.isClustered", "true"); // 集群中任务调度实例失效的检查时间间隔,单位为毫秒 prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000"); prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1"); prop.put("org.quartz.jobStore.misfireThreshold", "12000"); // 数据表前缀 prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); factory.setQuartzProperties(prop); factory.setSchedulerName("FEBS_Cloud_Scheduler"); // 延时启动 factory.setStartupDelay(1); factory.setApplicationContextSchedulerContextKey("applicationContextKey"); // 启动时更新己存在的 Job factory.setOverwriteExistingJobs(true); // 设置自动启动,默认为 true factory.setAutoStartup(true); return factory; }
Example 21
Source Project: SDA Source File: SchedulerMainService.java License: BSD 2-Clause "Simplified" License | 5 votes |
public Scheduler getScheduler() throws Exception { if (scheduler == null) { schedulFactoty = new StdSchedulerFactory(); scheduler = schedulFactoty.getScheduler(); } return scheduler; }
Example 22
Source Project: quartz-redis-jobstore Source File: BaseIntegrationTest.java License: Apache License 2.0 | 5 votes |
protected Properties schedulerConfig(String host, int port) { Properties config = new Properties(); config.setProperty(StdSchedulerFactory.PROP_JOB_STORE_CLASS, RedisJobStore.class.getName()); config.setProperty("org.quartz.jobStore.host", host); config.setProperty("org.quartz.jobStore.port", String.valueOf(port)); config.setProperty("org.quartz.threadPool.threadCount", "1"); config.setProperty("org.quartz.jobStore.misfireThreshold", "500"); config.setProperty(StdSchedulerFactory.PROP_SCHED_SKIP_UPDATE_CHECK, "true"); return config; }
Example 23
Source Project: simple-robot-core Source File: TimeTaskManager.java License: Apache License 2.0 | 5 votes |
/** 尝试加载一个疑似是定时任务的类 */ public void register(Class<? extends Job> timeTaskClass, Supplier<MsgSender> senderSupplier, StdSchedulerFactory factory){ List<Annotation> timeTaskAnnos = isTimeTask(timeTaskClass); if(timeTaskAnnos.size() > 0){ //遍历 timeTaskAnnos.forEach(a -> register(timeTaskClass, a, senderSupplier.get(), factory)); registerNum += timeTaskAnnos.size(); } }
Example 24
Source Project: ingestion Source File: RestSource.java License: Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public void start() { this.jobDetail = JobBuilder.newJob(RequestJob.class).withIdentity(DEFAULT_JOBNAME).build(); // Create an scheduled trigger with interval in seconds Trigger trigger = TriggerBuilder .newTrigger() .withIdentity(DEFAULT_JOBNAME) .withSchedule( SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(frequency) .repeatForever()).build(); // Put needed object in scheduler context and start the job. try { scheduler = new StdSchedulerFactory().getScheduler(); scheduler.getContext().put("client", client); scheduler.getContext().put("queue", queue); scheduler.getContext().put("properties", properties); scheduler.getContext().put("restSourceHandler", restSourceHandler); scheduler.getContext().put("urlHandler", urlHandler); scheduler.start(); scheduler.scheduleJob(jobDetail, trigger); } catch (SchedulerException e) { log.error("RestSource error. " + e.getMessage()); } }
Example 25
Source Project: shardingsphere-elasticjob-lite Source File: JobScheduler.java License: Apache License 2.0 | 5 votes |
private Scheduler createScheduler() { Scheduler result; try { StdSchedulerFactory factory = new StdSchedulerFactory(); factory.initialize(getQuartzProps()); result = factory.getScheduler(); result.getListenerManager().addTriggerListener(schedulerFacade.newJobTriggerListener()); } catch (final SchedulerException ex) { throw new JobSystemException(ex); } return result; }
Example 26
Source Project: simple-robot-core Source File: ScannerManager.java License: Apache License 2.0 | 5 votes |
/** * 注册定时器 */ private void registerTimeTask(Set<Class<?>> classes, Supplier<MsgSender> senderSupplier, TimeTaskManager timeTaskManager, StdSchedulerFactory factory){ //过滤出继承了Job接口的 //遍历并尝试注册 classes.stream().filter(c -> FieldUtils.isChild(c, Job.class)).forEach(c -> timeTaskManager.register((Class<? extends Job>)c, senderSupplier, factory)); //全部注册完毕后,启动定时任务 try { timeTaskManager.start(factory); } catch (SchedulerException e) { throw new TimeTaskException("startFailed", e); } }
Example 27
Source Project: roboconf-platform Source File: RoboconfScheduler.java License: Apache License 2.0 | 5 votes |
/** * Starts the scheduler. * <p> * Invoked by iPojo. * </p> */ public void start() throws Exception { this.logger.info( "Roboconf's scheduler is starting..." ); // Verify the "scheduler" directory exists File schedulerDirectory = getSchedulerDirectory(); Utils.createDirectory( schedulerDirectory ); // Disable Quartz update checks StringBuilder quartzProperties = new StringBuilder(); quartzProperties.append( "org.quartz.scheduler.instanceName: Roboconf Quartz Scheduler\n" ); quartzProperties.append( "org.quartz.threadPool.threadCount = 3\n" ); quartzProperties.append( "org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore\n" ); quartzProperties.append( "org.quartz.scheduler.skipUpdateCheck: false\n" ); StdSchedulerFactory factory = new StdSchedulerFactory(); factory.initialize( new ByteArrayInputStream( quartzProperties.toString().getBytes( StandardCharsets.UTF_8 ))); // Create a new scheduler this.scheduler = factory.getScheduler(); this.scheduler.start(); this.scheduler.getContext().put( MANAGER, this.manager ); // Add a listener to the DM this.dmListener = new ManagerListener( this ); this.manager.listenerAppears( this.dmListener ); // Reload all the jobs loadJobs(); }
Example 28
Source Project: MtgDesktopCompanion Source File: QwartzServer.java License: GNU General Public License v3.0 | 5 votes |
public QwartzServer() { try { if(!getFile(ORG_QUARTZ_PLUGIN_JOB_INITIALIZER_FILE_NAMES).exists()) { logger.debug("creating quartz config file"); FileUtils.copyURLToFile(getClass().getResource("/data/default-quartz.xml"),getFile(ORG_QUARTZ_PLUGIN_JOB_INITIALIZER_FILE_NAMES)); } scheduler = new StdSchedulerFactory(getProperties()).getScheduler(); } catch (Exception e) { logger.error(e); } }
Example 29
Source Project: SO Source File: SchedulerManager.java License: BSD 2-Clause "Simplified" License | 5 votes |
@PostConstruct public void schedulerManagerInit() { //public SchedulerManager() { try{ scheduler = new StdSchedulerFactory().getScheduler(); }catch(SchedulerException e){ e.printStackTrace(); } if(thread == null){ thread = new Thread(this); } if(!thread.isAlive()){ thread.start(); } }
Example 30
Source Project: uyuni Source File: ScheduleManager.java License: GNU General Public License v2.0 | 5 votes |
/** * Constructor * @param dbmgr allows ScheduleManager to access the database. * @param idxmgr allows the ScheduleManager to access the indexer. */ public ScheduleManager(DatabaseManager dbmgr, IndexManager idxmgr) { databaseManager = dbmgr; indexManager = idxmgr; try { scheduler = StdSchedulerFactory.getDefaultScheduler(); } catch (SchedulerException e) { throw new RuntimeException(e); } }