org.quartz.Scheduler.setJobFactory()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(144)

本文整理了Java中org.quartz.Scheduler.setJobFactory()方法的一些代码示例,展示了Scheduler.setJobFactory()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scheduler.setJobFactory()方法的具体详情如下:
包路径:org.quartz.Scheduler
类名称:Scheduler
方法名:setJobFactory

Scheduler.setJobFactory介绍

[英]Set the JobFactory that will be responsible for producing instances of Job classes.

JobFactories may be of use to those wishing to have their application produce Job instances via some special mechanism, such as to give the opportunity for dependency injection.
[中]设置负责生成Job类实例的JobFactory
JobFactory可能对那些希望应用程序通过某种特殊机制生成Job实例的人有用,比如提供依赖注入的机会。

代码示例

代码示例来源:origin: Netflix/Priam

@Inject
public PriamScheduler(SchedulerFactory factory, GuiceJobFactory jobFactory, Sleeper sleeper) {
  try {
    this.scheduler = factory.getScheduler();
    this.scheduler.setJobFactory(jobFactory);
    this.jobFactory = jobFactory;
  } catch (SchedulerException e) {
    throw new RuntimeException(e);
  }
  this.sleeper = sleeper;
}

代码示例来源:origin: kairosdb/kairosdb

@Inject
public KairosDBSchedulerImpl(Injector guice) throws SchedulerException
{
  this.guice = guice;
  Properties props = new Properties();
  props.setProperty("org.quartz.threadPool.threadCount", "4");
  props.setProperty(StdSchedulerFactory.PROP_SCHED_SKIP_UPDATE_CHECK, "true");
  StdSchedulerFactory factory = new StdSchedulerFactory(props);
  scheduler = factory.getScheduler();
  scheduler.setJobFactory(new KairosDBJobFactory(guice));
}

代码示例来源:origin: spring-projects/spring-framework

((SchedulerContextAware) this.jobFactory).setSchedulerContext(scheduler.getContext());
scheduler.setJobFactory(this.jobFactory);

代码示例来源:origin: jooby-project/jooby

@Inject
public QuartzProvider(final Injector injector, final Config config,
  @Named("org.quartz.jobs") final Map<JobDetail, Trigger> triggers) throws Exception {
 requireNonNull(injector, "An injector is required.");
 this.scheduler = new StdSchedulerFactory(properties(config)).getScheduler();
 this.jobs = triggers.entrySet();
 // override job factory
 scheduler.setJobFactory((bundle, sch) -> {
  JobDetail jobDetail = bundle.getJobDetail();
  Class<?> jobClass = jobDetail.getJobClass();
  return (Job) injector.getInstance(jobClass);
 });
 // hacky way of setting DS? quartz API sucks (it does too much or too little)
 if (config.hasPath(DS)) {
  String name = config.getString(DS);
  // get a provider, bc ds wont be ready yet.
  Provider<DataSource> ds = injector.getInstance(Key.get(DS_TYPE, Names.named(name)));
  DBConnectionManager.getInstance()
    .addConnectionProvider(name, new QuartzConnectionProvider(ds));
 }
}

代码示例来源:origin: azkaban/azkaban

@Inject
public QuartzScheduler(final Props azProps) throws SchedulerException {
 if (!azProps.getBoolean(ConfigurationKeys.ENABLE_QUARTZ, false)) {
  return;
 }
 // TODO kunkun-tang: Many quartz properties should be defaulted such that not necessarily being
 // checked into azkaban.properties. Also, we need to only assemble Quartz related properties
 // here, which should be done in Azkaban WebServer Guice Module.
 final StdSchedulerFactory schedulerFactory =
   new StdSchedulerFactory(azProps.toAllProperties());
 this.scheduler = schedulerFactory.getScheduler();
 // Currently Quartz only support internal job schedules. When we migrate to User Production
 // flows, we need to construct a Guice-Free JobFactory for use.
 this.scheduler.setJobFactory(SERVICE_PROVIDER.getInstance(SchedulerJobFactory.class));
}

代码示例来源:origin: org.springframework/spring-context-support

((SchedulerContextAware) this.jobFactory).setSchedulerContext(scheduler.getContext());
scheduler.setJobFactory(this.jobFactory);

代码示例来源:origin: com.gitblit.fathom/fathom-quartz

/**
 * Sets the {@code JobFactory} instance (it will be a {@link InjectorJobFactory} instance).
 *
 * @param jobFactory The {@code JobFactory} instance.
 * @throws SchedulerException If any error occurs
 */
@Inject
public void setJobFactory(JobFactory jobFactory) throws SchedulerException {
  scheduler.setJobFactory(jobFactory);
}

代码示例来源:origin: com.atlassian.scheduler/atlassian-scheduler-quartz1

static void configureScheduler(final Scheduler quartz,
                final AbstractSchedulerService schedulerService,
                final RunMode runMode) throws SchedulerException {
  quartz.setJobFactory(new Quartz1JobFactory(schedulerService, runMode));
}

代码示例来源:origin: myschedule/myschedule-quartz-extra

public void setJobFactory(JobFactory jobFactory) {
  try {
    scheduler.setJobFactory(jobFactory);
  } catch (SchedulerException e) {
    throw new QuartzRuntimeException(e);
  }
}

代码示例来源:origin: org.lwapp/lwapp-dropwizard-core

@Override
public void init() throws Exception {
  final SchedulerFactory sf = new StdSchedulerFactory();
  final Scheduler sched = sf.getScheduler();
  sched.setJobFactory(jobFactory);
  final JobDetail job = JobBuilder.newJob(getJobClass())
      .withIdentity(getClass().getName())
      .build();
  final Trigger trigger = createTrigger();
  sched.scheduleJob(job, trigger);
  sched.start();
}

代码示例来源:origin: info.magnolia.scheduler/magnolia-module-scheduler

/**
 * Start the scheduler. No special configuration done yet.
 *
 * @throws SchedulerException
 */
protected void initScheduler() throws SchedulerException {
  SchedulerFactory sf = new StdSchedulerFactory();
  scheduler = sf.getScheduler();
  scheduler.setJobFactory(jobFactory);
  scheduler.start();
}

代码示例来源:origin: cdapio/cdap

void init() throws SchedulerException {
 try {
  taskExecutorService = MoreExecutors.listeningDecorator(
   Executors.newCachedThreadPool(Threads.createDaemonThreadFactory("time-schedule-task")));
  scheduler = schedulerSupplier.get();
  scheduler.setJobFactory(createJobFactory());
 } catch (org.quartz.SchedulerException e) {
  throw new SchedulerException(e);
 }
}

代码示例来源:origin: co.cask.cdap/cdap-app-fabric

void init() throws SchedulerException {
 try {
  taskExecutorService = MoreExecutors.listeningDecorator(
   Executors.newCachedThreadPool(Threads.createDaemonThreadFactory("time-schedule-task")));
  scheduler = schedulerSupplier.get();
  scheduler.setJobFactory(createJobFactory());
 } catch (org.quartz.SchedulerException e) {
  throw new SchedulerException(e);
 }
}

代码示例来源:origin: com.threewks.thundr/thundr-quartz

@Override
public void setJobFactory(JobFactory factory) throws QuartzException {
  try {
    delegate.setJobFactory(factory);
  } catch (SchedulerException e) {
    Logger.error(e.getMessage());
    throw new QuartzException(e);
  }
}

代码示例来源:origin: com.threewks.thundr/thundr-contrib-quartz

@Override
public void setJobFactory(JobFactory factory) throws QuartzException {
  try {
    delegate.setJobFactory(factory);
  } catch (SchedulerException e) {
    Logger.error(e.getMessage());
    throw new QuartzException(e);
  }
}

代码示例来源:origin: dropwizard-jobs/dropwizard-jobs

@Override
public void start() throws Exception {
  createScheduler();
  scheduler.setJobFactory(getJobFactory());
  scheduler.start();
  scheduleAllJobs();
  logAllOnApplicationStopJobs();
}

代码示例来源:origin: ch.exense.step/core

public Executor(GlobalContext globalContext) {
  super();
  
  try {
    Properties props = getProperties();
    executionRunnableFactory = new ExecutionRunnableFactory(globalContext);
    schedulerFactory = new StdSchedulerFactory(props);
    scheduler = schedulerFactory.getScheduler();
    scheduler.setJobFactory(new ExecutionJobFactory(globalContext, executionRunnableFactory));
  } catch (SchedulerException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.easybatch/easybatch-quartz

JobScheduler() throws JobSchedulerException {
  org.quartz.spi.JobFactory jobFactory = new JobFactory();
  SchedulerFactory schedulerFactory = new StdSchedulerFactory();
  try {
    scheduler = schedulerFactory.getScheduler();
    scheduler.setJobFactory(jobFactory);
  } catch (SchedulerException e) {
    throw new JobSchedulerException("An exception occurred during scheduler setup", e);
  }
}

代码示例来源:origin: io.github.benas.cb4j/cb4j-quartz

public BatchScheduler(BatchConfiguration batchConfiguration, Class<? extends BatchEngine> clazz) throws BatchSchedulerException {
  JobFactory jobFactory = new BatchJobFactory(batchConfiguration,clazz);
  SchedulerFactory schedulerFactory = new StdSchedulerFactory();
  try {
    scheduler = schedulerFactory.getScheduler();
    scheduler.setJobFactory(jobFactory);
  } catch (SchedulerException e) {
    throw new BatchSchedulerException("An exception occurred during scheduler setup, root error = ", e);
  }
}

代码示例来源:origin: io.github.benas/easybatch-quartz

public EasyBatchScheduler(EasyBatchEngine easyBatchEngine) throws EasyBatchSchedulerException {
  JobFactory jobFactory = new EasyBatchJobFactory(easyBatchEngine);
  SchedulerFactory schedulerFactory = new StdSchedulerFactory();
  try {
    scheduler = schedulerFactory.getScheduler();
    scheduler.setJobFactory(jobFactory);
  } catch (SchedulerException e) {
    throw new EasyBatchSchedulerException("An exception occurred during scheduler setup", e);
  }
}

相关文章