Java Code Examples for org.quartz.SchedulerContext#put()

The following examples show how to use org.quartz.SchedulerContext#put() . 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 File: JobDataMapManager.java    From niubi-job with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化自动的调度器数据
 *
 * @param scheduler 调度器
 * @param jobBeanFactory JobBean工厂
 */
static void initAutomaticScheduler(Scheduler scheduler, JobBeanFactory jobBeanFactory) {
    try {
        SchedulerContext schedulerContext = scheduler.getContext();
        schedulerContext.put(JOB_BEAN_FACTORY_KEY, jobBeanFactory);
        schedulerContext.put(SCHEDULE_MODE_KEY, ScheduleMode.AUTOMATIC);
    } catch (SchedulerException e) {
        LoggerHelper.error("get schedule context failed.", e);
        throw new NiubiException(e);
    }
}
 
Example 2
Source File: JobDataMapManager.java    From niubi-job with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化手动的调度器数据
 *
 * @param scheduler 调度器
 */
static void initManualScheduler(Scheduler scheduler) {
    try {
        SchedulerContext schedulerContext = scheduler.getContext();
        schedulerContext.put(SCHEDULE_MODE_KEY, ScheduleMode.MANUAL);
    } catch (SchedulerException e) {
        LoggerHelper.error("get schedule context failed.", e);
        throw new NiubiException(e);
    }
}
 
Example 3
Source File: SchedulerTest.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
  try {
    SchedulerContext schedulerContext = context.getScheduler().getContext();
    schedulerContext.put(JOB_THREAD, Thread.currentThread());
    CyclicBarrier barrier = (CyclicBarrier) schedulerContext.get(BARRIER);
    barrier.await(TEST_TIMEOUT_SECONDS, TimeUnit.SECONDS);
  }
  catch (Throwable e) {
    e.printStackTrace();
    throw new AssertionError("Await on barrier was interrupted: " + e.toString());
  }
}