org.springframework.scheduling.quartz.JobDetailFactoryBean Java Examples

The following examples show how to use org.springframework.scheduling.quartz.JobDetailFactoryBean. 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: JobUtil.java    From spring-boot-quartz-demo with MIT License 7 votes vote down vote up
/**
 * 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();
}
 
Example #2
Source File: ScheduleModule.java    From bulbasaur with Apache License 2.0 6 votes vote down vote up
private void registerJobDetail(
    String ownSign,
    String targetObject,
    String targetMethod,
    String jobDetailBeanName

) {
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
        JobDetailFactoryBean.class);
    builder.addPropertyValue("jobClass", MyDetailQuartzJobBean.class);
    builder.addPropertyValue("group", ownSign);
    //durability 表示任务完成之后是否依然保留到数据库,默认false
    builder.addPropertyValue("durability", "true");

    Map<String, String> jobDataAsMap = Maps.newHashMap();
    jobDataAsMap.put("targetObject", targetObject);
    jobDataAsMap.put("targetMethod", targetMethod);

    builder.addPropertyValue("jobDataAsMap", jobDataAsMap);
    registry.registerBeanDefinition(jobDetailBeanName, builder.getRawBeanDefinition());

}
 
Example #3
Source File: SpringQrtzScheduler.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public JobDetailFactoryBean jobDetail() {

    JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
    jobDetailFactory.setJobClass(SampleJob.class);
    jobDetailFactory.setName("Qrtz_Job_Detail");
    jobDetailFactory.setDescription("Invoke Sample Job service...");
    jobDetailFactory.setDurability(true);
    return jobDetailFactory;
}
 
Example #4
Source File: QuartzConfig.java    From lemonaid with MIT License 5 votes vote down vote up
@Bean
public JobDetailFactoryBean gravatarJob() {
	JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
	jobDetailFactory.setJobClass(GravatarJob.class);
	jobDetailFactory.setGroup("lemonaid-quartz");
	jobDetailFactory.setDurability(true);
	return jobDetailFactory;
}
 
Example #5
Source File: QuartzConfig.java    From lemonaid with MIT License 5 votes vote down vote up
@Bean
public JobDetailFactoryBean locationJob() {
	JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
	jobDetailFactory.setJobClass(LocationJob.class);
	jobDetailFactory.setGroup("lemonaid-quartz");
	jobDetailFactory.setDurability(true);
	return jobDetailFactory;
}
 
Example #6
Source File: QuartzConfig.java    From lemonaid with MIT License 5 votes vote down vote up
@Bean
public JobDetailFactoryBean insideTrackJob() {
	JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
	jobDetailFactory.setJobClass(InsideTrackJob.class);
	jobDetailFactory.setGroup("lemonaid-quartz");
	jobDetailFactory.setDurability(true);
	return jobDetailFactory;
}
 
Example #7
Source File: BlobStorageConfiguration.java    From mojito with Apache License 2.0 5 votes vote down vote up
@Bean(name = "jobDetailDatabaseBlobStorageCleanupJob")
public JobDetailFactoryBean jobDetailExpiringBlobCleanup() {
    JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
    jobDetailFactory.setJobClass(DatabaseBlobStorageCleanupJob.class);
    jobDetailFactory.setDescription("Cleanup expired blobs");
    jobDetailFactory.setDurability(true);
    return jobDetailFactory;
}
 
Example #8
Source File: RepositoryStatisticsCronJob.java    From mojito with Apache License 2.0 5 votes vote down vote up
@Bean(name = "repositoryStatisticsCron")
public JobDetailFactoryBean jobDetailRepositoryStatisticsCron() {
    JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
    jobDetailFactory.setJobClass(RepositoryStatisticsCronJob.class);
    jobDetailFactory.setDescription("Mark repository as out of data to later recompute stats");
    jobDetailFactory.setDurability(true);
    return jobDetailFactory;
}
 
Example #9
Source File: SchedulerConfig.java    From ehousechina with Apache License 2.0 5 votes vote down vote up
@Bean(name = "sampleJobDetail")
public JobDetailFactoryBean sampleJobDetail() {
	JobDetailFactoryBean factoryBean = new JobDetailFactoryBean();
	factoryBean.setJobClass(ProcessJob.class);
	factoryBean.setDurability(true);
	return factoryBean;
}
 
Example #10
Source File: QuartzConfiguration.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
@Bean
public JobDetailFactoryBean cleanUpJobDetail() {
    JobDetailFactoryBean factory = new JobDetailFactoryBean();
    factory.setJobClass(CleanUpJob.class);
    factory.setDurability(true);
    return factory;
}
 
Example #11
Source File: AssetExtractionCleanupJob.java    From mojito with Apache License 2.0 5 votes vote down vote up
@Bean(name = "jobDetailAssetExtractionCleanup")
public JobDetailFactoryBean jobDetailAssetExtractionCleanup() {
    JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
    jobDetailFactory.setJobClass(AssetExtractionCleanupJob.class);
    jobDetailFactory.setDescription("Cleanup old asset extraction");
    jobDetailFactory.setDurability(true);
    return jobDetailFactory;
}
 
Example #12
Source File: SchedulerConfig.java    From zkdoctor with Apache License 2.0 5 votes vote down vote up
/**
 * 创建jboDetail信息
 *
 * @param jobClass job类
 * @return
 */
private JobDetailFactoryBean createJobDetail(Class jobClass, String keyName, String group) {
    JobDetailFactoryBean factoryBean = new JobDetailFactoryBean();
    factoryBean.setJobClass(jobClass);
    factoryBean.setDurability(true);
    factoryBean.setName(keyName);
    factoryBean.setGroup(group);
    return factoryBean;
}
 
Example #13
Source File: PollableTaskCleanupJob.java    From mojito with Apache License 2.0 5 votes vote down vote up
@Bean(name = "jobDetailPollableTaskCleanup")
public JobDetailFactoryBean jobDetailPollableTaskCleanup() {
    JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
    jobDetailFactory.setJobClass(PollableTaskCleanupJob.class);
    jobDetailFactory.setDescription(FINISH_ZOMBIE_TASKS_WITH_ERROR);
    jobDetailFactory.setDurability(true);
    return jobDetailFactory;
}
 
Example #14
Source File: PluralFormUpdaterJob.java    From mojito with Apache License 2.0 5 votes vote down vote up
@Bean(name = "jobDetailPluralFromUpdater")
JobDetailFactoryBean jobDetailPluralFromUpdater() {
    JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
    jobDetailFactory.setJobClass(PluralFormUpdaterJob.class);
    jobDetailFactory.setDescription("Update plural forms in text units");
    jobDetailFactory.setDurability(true);
    return jobDetailFactory;
}
 
Example #15
Source File: SlaCheckerCronJob.java    From mojito with Apache License 2.0 5 votes vote down vote up
@Bean(name = "slaCheckerCron")
public JobDetailFactoryBean jobDetailSlaCheckerCronJob() {
    JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
    jobDetailFactory.setJobClass(SlaCheckerCronJob.class);
    jobDetailFactory.setDescription("Check for incident related to SLA");
    jobDetailFactory.setDurability(true);
    return jobDetailFactory;
}
 
Example #16
Source File: RepositoryManualScreenshotRunJob.java    From mojito with Apache License 2.0 5 votes vote down vote up
@Bean(name = "repositoryManualScreenshotRun")
public JobDetailFactoryBean jobDetailRepositoryManualScreenshotRunJob() {
    JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
    jobDetailFactory.setJobClass(RepositoryManualScreenshotRunJob.class);
    jobDetailFactory.setDescription("One time update of manual screenshot run on repository objects");
    jobDetailFactory.setDurability(true);
    return jobDetailFactory;
}
 
Example #17
Source File: PacmanQuartzConfiguration.java    From pacbot with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
public JobDetailFactoryBean createJobDetail(Class jobClass) {
	JobDetailFactoryBean factoryBean = new JobDetailFactoryBean();
	factoryBean.setJobClass(jobClass);
	// job has to be durable to be stored in DB:
	factoryBean.setDurability(true);
	return factoryBean;
}
 
Example #18
Source File: QuartzConfig.java    From MyCommunity with Apache License 2.0 5 votes vote down vote up
public JobDetailFactoryBean postScoreRefreshJobDetail() {
    JobDetailFactoryBean factoryBean = new JobDetailFactoryBean();
    factoryBean.setJobClass(PostScoreRefreshJob.class);
    factoryBean.setName("postScoreRefreshJob");
    factoryBean.setGroup("communityJobGroup");
    factoryBean.setDurability(true);
    factoryBean.setRequestsRecovery(true);
    return factoryBean;
}
 
Example #19
Source File: QuartzConfig.java    From MyCommunity with Apache License 2.0 5 votes vote down vote up
public JobDetailFactoryBean alphaJobDetail () {
    JobDetailFactoryBean factoryBean = new JobDetailFactoryBean();
    factoryBean.setJobClass(AlphaJob.class);  // 管理的Job
    factoryBean.setName("alphaJob");
    factoryBean.setGroup("alphaGroup");
    factoryBean.setDurability(true);  // 任务是否持久保存
    factoryBean.setRequestsRecovery(true);  // 任务发生错误时是否可恢复

    return factoryBean;
}
 
Example #20
Source File: SchedulerConfig.java    From quartz-manager with Apache License 2.0 4 votes vote down vote up
private static JobDetailFactoryBean createJobDetail(Class<? extends Job> jobClass) {
	JobDetailFactoryBean factoryBean = new JobDetailFactoryBean();
	factoryBean.setJobClass(jobClass);
	factoryBean.setDurability(false);
	return factoryBean;
}
 
Example #21
Source File: SchedulerConfig.java    From quartz-manager with Apache License 2.0 4 votes vote down vote up
@Bean
@SuppressWarnings("unchecked")
public JobDetailFactoryBean jobDetail() throws ClassNotFoundException {
	Class<? extends Job> JobClass = (Class<? extends Job>) Class.forName(jobClassname);
	return createJobDetail(JobClass);
}
 
Example #22
Source File: QuartzSchedule.java    From RCT with Apache License 2.0 4 votes vote down vote up
@Bean(name = "rdbScheduleJob")
public JobDetailFactoryBean rdbScheduleJob() {
	JobDetailFactoryBean jobDetail = new JobDetailFactoryBean();
	jobDetail.setJobClass(RDBScheduleJob.class);
	return jobDetail;
}
 
Example #23
Source File: TestContextConfiguration11.java    From spring-boot-starter-quartz with Apache License 2.0 4 votes vote down vote up
@Bean(name="callbackJobDetail")
public JobDetailFactoryBean callbackJobDetail() {
	return QuartzUtils.createJobDetail(CallbackQueuedJob.class, CALLBACK_JOB_NAME, CALLBACK_JOB_GROUP, "Callback Job", null);
}
 
Example #24
Source File: TestContextConfiguration11.java    From spring-boot-starter-quartz with Apache License 2.0 4 votes vote down vote up
@Bean(name="cronJobDetail")
public JobDetailFactoryBean cronJobDetail() {
	return QuartzUtils.createJobDetail(SimpleCronJob.class, CRON_JOB_NAME, CRON_JOB_GROUP, "Just a Cron Job", null);
}
 
Example #25
Source File: TestContextConfiguration11.java    From spring-boot-starter-quartz with Apache License 2.0 4 votes vote down vote up
@Bean(name="simpleJobDetail")
public JobDetailFactoryBean simpleJobDetail() {
	return QuartzUtils.createJobDetail(SimpleJob.class, SIMPLE_JOB_NAME, SIMPLE_JOB_GROUP, "Just a Simple Job", null);
}
 
Example #26
Source File: TestContextConfiguration4.java    From spring-boot-starter-quartz with Apache License 2.0 4 votes vote down vote up
@Bean(name="cronJobDetail")
public JobDetailFactoryBean cronJobDetail() {
	return QuartzUtils.createJobDetail(SimpleCronJob.class, CRON_JOB_NAME, CRON_JOB_GROUP, "Just a Cron Job", null);
}
 
Example #27
Source File: TestContextConfiguration4.java    From spring-boot-starter-quartz with Apache License 2.0 4 votes vote down vote up
@Bean(name="simpleJobDetail")
public JobDetailFactoryBean simpleJobDetail() {
	return QuartzUtils.createJobDetail(SimpleJob.class, SIMPLE_JOB_NAME, SIMPLE_JOB_GROUP, "Just a Simple Job", null);
}
 
Example #28
Source File: QuartzUtils.java    From spring-boot-starter-quartz with Apache License 2.0 4 votes vote down vote up
/**
 * creates a job builder. you have to call {@link #build()} afterwards to get the object
 */
public QuartzJobBuilder() {
	jobDetailFactoryBean = new JobDetailFactoryBean();
}
 
Example #29
Source File: QuartzSchedule.java    From redis-manager with Apache License 2.0 4 votes vote down vote up
@Bean(name = "rdbScheduleJob")
public JobDetailFactoryBean rdbScheduleJob() {
    JobDetailFactoryBean jobDetail = new JobDetailFactoryBean();
    jobDetail.setJobClass(RDBScheduleJob.class);
    return jobDetail;
}
 
Example #30
Source File: SchedulerConfig.java    From zkdoctor with Apache License 2.0 4 votes vote down vote up
/**
 * 实例连接信息收集job信息
 *
 * @return
 */
@Bean
public JobDetailFactoryBean instanceConnCollectJobDetail() {
    return createJobDetail(InstanceConnectionCollectJob.class,
            SchedulerConstant.INSTANCE_CONN_COLLECT_JOB_NAME, SchedulerConstant.INSTANCE_CONN_COLLECT_JOB_GROUP);
}