use of org.quartz.impl.StdSchedulerFactory in project java-example by 1479005017.
the class QuartzTest method testModify.
@Test
public void testModify() throws Exception {
SchedulerFactory schedulerFactory = new StdSchedulerFactory();
Scheduler scheduler = schedulerFactory.getScheduler();
QuartzManager quartzManager = new QuartzManager(scheduler);
quartzManager.addJob("myJob", "test", MyJob.class, Collections.singletonMap("x", "1"), "0/5 * * * * ?");
quartzManager.startScheduler();
Thread.sleep(1500);
for (int i = 0; Thread.activeCount() > 0; i++) {
if (i % 3 == 0) {
quartzManager.modifyJob("myJob", "test", Collections.singletonMap("x", i + ""));
}
Thread.sleep(1000);
}
}
use of org.quartz.impl.StdSchedulerFactory in project jforum2 by rafaelsteil.
the class SummaryScheduler method startJob.
/**
* Starts the summary Job. Conditions to start: Is not started yet and is enabled on the file
* SystemGlobasl.properties. The to enable it is "summary.enabled"
* (ConfigKeys.SUMMARY_IS_ENABLED).
*
* @throws SchedulerException
* @throws IOException
*/
public static void startJob() throws SchedulerException {
boolean isEnabled = SystemGlobals.getBoolValue(ConfigKeys.SUMMARY_IS_ENABLED);
if (!isStarted && isEnabled) {
String filename = SystemGlobals.getValue(ConfigKeys.QUARTZ_CONFIG);
String cronExpression = SystemGlobals.getValue("org.quartz.context.summary.cron.expression");
scheduler = new StdSchedulerFactory(filename).getScheduler();
Trigger trigger = null;
try {
trigger = new CronTrigger(SummaryJob.class.getName(), "summaryJob", cronExpression);
logger.info("Starting quartz summary expression " + cronExpression);
scheduler.scheduleJob(new JobDetail(SummaryJob.class.getName(), "summaryJob", SummaryJob.class), trigger);
scheduler.start();
} catch (ParseException e) {
e.printStackTrace();
}
}
isStarted = true;
}
use of org.quartz.impl.StdSchedulerFactory in project opencast by opencast.
the class CaptureNowProlongingService method activate.
/**
* Activates the component
*
* @param cc
* the component's context
*/
public void activate(ComponentContext cc) {
componentContext = cc;
try {
quartz = new StdSchedulerFactory().getScheduler();
quartz.start();
// create and set the job. To actually run it call schedule(..)
final JobDetail job = new JobDetail(JOB_NAME, JOB_GROUP, Runner.class);
job.setDurability(true);
job.setVolatility(true);
job.getJobDataMap().put(JOB_PARAM_PARENT, this);
quartz.addJob(job, true);
} catch (org.quartz.SchedulerException e) {
throw new RuntimeException(e);
}
}
use of org.quartz.impl.StdSchedulerFactory in project yyl_example by Relucent.
the class QuartzExample method main.
public static void main(String[] args) throws Exception {
// JobDetail job = new JobDetail();
// job.setName("jobName");
// job.setJobClass(HelloJob.class);
JobDetail job = //
JobBuilder.newJob(HelloJob.class).withIdentity("jobName", //
"groupName").build();
// CronTrigger trigger = new CronTrigger();
// trigger.setName("triggerName");
// trigger.setCronExpression("0/5 * * * * ?");
Trigger trigger = //
TriggerBuilder.newTrigger().withIdentity("triggerName", //
"group").withSchedule(//
CronScheduleBuilder.cronSchedule("0/5 * * * * ?")).build();
//
StdSchedulerFactory stdSchedulerFactory = new StdSchedulerFactory();
// 默认从quartz.properties文件读取配置
// stdSchedulerFactory.initialize();
// 使用Properties设置配置信息
Properties props = new Properties();
props.put("org.quartz.scheduler.instanceName", "MyScheduler");
props.put("org.quartz.threadPool.threadCount", "3");
props.put("org.quartz.jobStore.class", "org.quartz.simpl.RAMJobStore");
stdSchedulerFactory.initialize(props);
Scheduler scheduler = stdSchedulerFactory.getScheduler();
scheduler.start();
scheduler.scheduleJob(job, trigger);
// 运行30秒关闭
Thread.sleep(30 * 1000);
scheduler.shutdown();
}
use of org.quartz.impl.StdSchedulerFactory in project gocd by gocd.
the class BackupSchedulerTest method setup.
@BeforeEach
void setup() throws SchedulerException {
stdSchedulerFactory = new StdSchedulerFactory();
scheduler = stdSchedulerFactory.getScheduler();
backupScheduler = new BackupScheduler(scheduler, goConfigService, serverHealthService, backupService);
}
Aggregations