本文整理汇总了Java中org.springframework.scheduling.quartz.JobDetailFactoryBean类的典型用法代码示例。如果您正苦于以下问题:Java JobDetailFactoryBean类的具体用法?Java JobDetailFactoryBean怎么用?Java JobDetailFactoryBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JobDetailFactoryBean类属于org.springframework.scheduling.quartz包,在下文中一共展示了JobDetailFactoryBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import org.springframework.scheduling.quartz.JobDetailFactoryBean; //导入依赖的package包/类
public SchedulerFactoryBean build() throws Exception {
SchedulerFactoryBean bean = new SchedulerFactoryBean();
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(new ClassPathResource(config));
propertiesFactoryBean.afterPropertiesSet();
Properties props = propertiesFactoryBean.getObject();
List<Trigger> triggers = Lists.newArrayList();
List<JobModel> jobList = getJobs(props);
for (JobModel job : jobList) {
if (!job.isEnable()) {
continue;
}
JobDetailFactoryBean detail = createJobDetail(job.getName(), Class.forName(job.getJob()));
CronTriggerFactoryBean trigger = createCronTrigger(job.getName(), detail.getObject(), job.getCorn());
CronTrigger t = trigger.getObject();
triggers.add(t);
}
bean.setTriggers(triggers.toArray(new Trigger[0]));
//bean.afterPropertiesSet();
return bean;
}
示例2: createJob
import org.springframework.scheduling.quartz.JobDetailFactoryBean; //导入依赖的package包/类
/**
* Create Quartz Job.
*
* @param jobClass Class whose executeInternal() method needs to be called.
* @param isDurable Job needs to be persisted even after completion. if true, job will be persisted, not otherwise.
* @param context Spring application context.
* @param jobName Job name.
* @param jobGroup Job group.
*
* @return JobDetail object
*/
protected static JobDetail createJob(Class<? extends QuartzJobBean> jobClass, boolean isDurable,
ApplicationContext context, String jobName, String jobGroup){
JobDetailFactoryBean factoryBean = new JobDetailFactoryBean();
factoryBean.setJobClass(jobClass);
factoryBean.setDurability(isDurable);
factoryBean.setApplicationContext(context);
factoryBean.setName(jobName);
factoryBean.setGroup(jobGroup);
// set job data map
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put("myKey", "myValue");
factoryBean.setJobDataMap(jobDataMap);
factoryBean.afterPropertiesSet();
return factoryBean.getObject();
}
示例3: autowireJobTest
import org.springframework.scheduling.quartz.JobDetailFactoryBean; //导入依赖的package包/类
/**
* Test if Job instances are autowired with the required beans and the
* method ingest is called at least once (the job has been executed).
*
* @throws SchedulerException
* if there is any problem launching the job.
* @throws InterruptedException
* if test is interrupted while waiting for the job to start.
*/
@Test
@DatabaseSetup("schedulerData.xml")
public void autowireJobTest() throws SchedulerException,
InterruptedException {
JobDetailFactoryBean jdFactory = new JobDetailFactoryBean();
jdFactory.setName("jdFactory");
jdFactory.setJobClass(IngestJob.class);
Map<String, Object> jobDataMap = Maps.newHashMap();
jobDataMap.put(IngestJob.INGEST_ID, Long.toString(10L));
jdFactory.setJobDataAsMap(jobDataMap);
jdFactory.afterPropertiesSet();
JobDetail jobDetail = jdFactory.getObject();
SimpleTrigger trigger = (SimpleTrigger) newTrigger()
.withIdentity("jdFactory", "DEFAULT").forJob(jobDetail).build();
schedulerFactoryBean.getScheduler().scheduleJob(jobDetail, trigger);
Thread.sleep(5000L);
// verify(metadataIngester, atLeastOnce()).ingest(any(Metadata.class));
}
示例4: jobDetailFactoryBean
import org.springframework.scheduling.quartz.JobDetailFactoryBean; //导入依赖的package包/类
@Bean(name = "cleanUpJobDetail")
public JobDetailFactoryBean jobDetailFactoryBean() {
JobDetailFactoryBean factory = new JobDetailFactoryBean();
factory.setJobClass(CleanUpJob.class);
factory.setDurability(true);
return factory;
}
示例5: getMonitorJob
import org.springframework.scheduling.quartz.JobDetailFactoryBean; //导入依赖的package包/类
@Bean
@Scope(value = "prototype")
public JobDetailFactoryBean getMonitorJob(){
JobDetailFactoryBean bean = new JobDetailFactoryBean();
bean.setJobClass(NodeMonitorJob.class);
return bean;
}
示例6: getEventJob
import org.springframework.scheduling.quartz.JobDetailFactoryBean; //导入依赖的package包/类
@Bean
@Scope(value = "prototype")
public JobDetailFactoryBean getEventJob(){
JobDetailFactoryBean bean = new JobDetailFactoryBean();
bean.setJobClass(EventJob.class);
return bean;
}
示例7: createJobDetail
import org.springframework.scheduling.quartz.JobDetailFactoryBean; //导入依赖的package包/类
private JobDetailFactoryBean createJobDetail(String name, Class<?> jobClass) {
JobDetailFactoryBean factoryBean = new JobDetailFactoryBean();
factoryBean.setName(name);
factoryBean.setJobClass(jobClass);
factoryBean.setApplicationContext(context);
factoryBean.setApplicationContextJobDataKey(AbstractJob.KEY_APPLICATION_CONTEXT);
// job has to be durable to be stored in DB:
factoryBean.setDurability(true);
factoryBean.afterPropertiesSet();
return factoryBean;
}
示例8: gravatarJob
import org.springframework.scheduling.quartz.JobDetailFactoryBean; //导入依赖的package包/类
@Bean
public JobDetailFactoryBean gravatarJob() {
JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
jobDetailFactory.setJobClass(GravatarJob.class);
jobDetailFactory.setGroup("lemonaid-quartz");
jobDetailFactory.setDurability(true);
return jobDetailFactory;
}
示例9: locationJob
import org.springframework.scheduling.quartz.JobDetailFactoryBean; //导入依赖的package包/类
@Bean
public JobDetailFactoryBean locationJob() {
JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
jobDetailFactory.setJobClass(LocationJob.class);
jobDetailFactory.setGroup("lemonaid-quartz");
jobDetailFactory.setDurability(true);
return jobDetailFactory;
}
示例10: insideTrackJob
import org.springframework.scheduling.quartz.JobDetailFactoryBean; //导入依赖的package包/类
@Bean
public JobDetailFactoryBean insideTrackJob() {
JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
jobDetailFactory.setJobClass(InsideTrackJob.class);
jobDetailFactory.setGroup("lemonaid-quartz");
jobDetailFactory.setDurability(true);
return jobDetailFactory;
}
示例11: createJobDetail
import org.springframework.scheduling.quartz.JobDetailFactoryBean; //导入依赖的package包/类
private JobDetail createJobDetail(final PiSchedule piSchedule) {
final JobDetailFactoryBean jobDetailFactoryBean = new JobDetailFactoryBean();
jobDetailFactoryBean.setApplicationContext(context);
jobDetailFactoryBean.setName(piSchedule.getScheduleName());
jobDetailFactoryBean.setJobClass(PiJob.class);
jobDetailFactoryBean.getJobDataMap().put("piSchedule", piSchedule);
jobDetailFactoryBean.afterPropertiesSet();
return jobDetailFactoryBean.getObject();
}
示例12: createJobDetail
import org.springframework.scheduling.quartz.JobDetailFactoryBean; //导入依赖的package包/类
/**
* Create a {@link JobDetail} based on the ingest passed as parameter.
*
* @param ingest the ingest to be scheduled.
* @return a JobDetail base on the ingest passed.
*/
private JobDetail createJobDetail(Ingest ingest) {
JobDetailFactoryBean jdFactory = new JobDetailFactoryBean();
jdFactory.setName(generateJobName(ingest));
jdFactory.setJobClass(IngestJob.class);
jdFactory.getJobDataMap().put(IngestJob.INGEST_ID,
ingest.getId().toString());
jdFactory.afterPropertiesSet();
return jdFactory.getObject();
}
示例13: QuartzJobBuilder
import org.springframework.scheduling.quartz.JobDetailFactoryBean; //导入依赖的package包/类
public QuartzJobBuilder() {
jobDetailFactoryBean = new JobDetailFactoryBean();
}
示例14: simpleJobDetail
import org.springframework.scheduling.quartz.JobDetailFactoryBean; //导入依赖的package包/类
@Bean(name="simpleJobDetail")
public JobDetailFactoryBean simpleJobDetail() {
return QuartzUtils.createJobDetail(SimpleJob.class, SIMPLE_JOB_NAME, SIMPLE_JOB_GROUP, "Just a Simple Job", null);
}
示例15: cronJobDetail
import org.springframework.scheduling.quartz.JobDetailFactoryBean; //导入依赖的package包/类
@Bean(name="cronJobDetail")
public JobDetailFactoryBean cronJobDetail() {
return QuartzUtils.createJobDetail(SimpleCronJob.class, CRON_JOB_NAME, CRON_JOB_GROUP, "Just a Cron Job", null);
}