Java Code Examples for org.springframework.scheduling.quartz.JobDetailFactoryBean

The following examples show how to use org.springframework.scheduling.quartz.JobDetailFactoryBean. These examples are extracted from open source projects. 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 Project: spring-boot-quartz-demo   Source File: JobUtil.java    License: 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 Project: bulbasaur   Source File: ScheduleModule.java    License: 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 Project: MyCommunity   Source File: QuartzConfig.java    License: 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 4
Source Project: MyCommunity   Source File: QuartzConfig.java    License: 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 5
Source Project: pacbot   Source File: PacmanQuartzConfiguration.java    License: 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 6
Source Project: zkdoctor   Source File: SchedulerConfig.java    License: 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 7
Source Project: multiapps-controller   Source File: QuartzConfiguration.java    License: 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 8
Source Project: ehousechina   Source File: SchedulerConfig.java    License: 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 9
Source Project: lemonaid   Source File: QuartzConfig.java    License: 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 10
Source Project: lemonaid   Source File: QuartzConfig.java    License: 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 11
Source Project: lemonaid   Source File: QuartzConfig.java    License: 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 12
Source Project: mojito   Source File: BlobStorageConfiguration.java    License: 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 13
Source Project: mojito   Source File: RepositoryStatisticsCronJob.java    License: 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 14
Source Project: mojito   Source File: AssetExtractionCleanupJob.java    License: 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 15
Source Project: mojito   Source File: PollableTaskCleanupJob.java    License: 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 16
Source Project: mojito   Source File: PluralFormUpdaterJob.java    License: 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 17
Source Project: mojito   Source File: SlaCheckerCronJob.java    License: 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 18
Source Project: mojito   Source File: RepositoryManualScreenshotRunJob.java    License: 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 19
Source Project: tutorials   Source File: SpringQrtzScheduler.java    License: 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 20
Source Project: RCT   Source File: QuartzSchedule.java    License: Apache License 2.0 4 votes vote down vote up
@Bean(name = "slowlogScheduleJob")
public JobDetailFactoryBean slowlogScheduleJob() {
	JobDetailFactoryBean jobDetail = new JobDetailFactoryBean();
	jobDetail.setJobClass(SlowlogScheduleJob.class);
	return jobDetail;
}
 
Example 21
Source Project: RCT   Source File: QuartzSchedule.java    License: 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 22
Source Project: pacbot   Source File: PacmanQuartzConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public JobDetailFactoryBean weeklyScheduleJobDetail() {
    return createJobDetail(WeeklyScheduleJob.class);
}
 
Example 23
Source Project: zkdoctor   Source File: SchedulerConfig.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 集群信息收集Job
 *
 * @return
 */
@Bean
public JobDetailFactoryBean zkJobDetail() {
    return createJobDetail(ZKJob.class,
            SchedulerConstant.ZK_COLLECT_JOB_NAME, SchedulerConstant.ZK_COLLECT_JOB_GROUP);
}
 
Example 24
Source Project: zkdoctor   Source File: SchedulerConfig.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 历史数据清除job信息
 *
 * @return
 */
@Bean
public JobDetailFactoryBean cleanCollectDataJobDetail() {
    return createJobDetail(CleanCollectDataJob.class,
            SchedulerConstant.ZK_CLEAN_JOB_NAME, SchedulerConstant.ZK_CLEAN_JOB_GROUP);
}
 
Example 25
Source Project: zkdoctor   Source File: SchedulerConfig.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 监控报警job信息
 *
 * @return
 */
@Bean
public JobDetailFactoryBean monitorJobDetail() {
    return createJobDetail(MonitorJob.class,
            SchedulerConstant.ZK_MONITOR_JOB_NAME, SchedulerConstant.ZK_MONITOR_JOB_GROUP);
}
 
Example 26
Source Project: zkdoctor   Source File: SchedulerConfig.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 机器信息收集job信息
 *
 * @return
 */
@Bean
public JobDetailFactoryBean machineJobDetail() {
    return createJobDetail(MachineJob.class,
            SchedulerConstant.MACHINE_COLLECT_JOB_NAME, SchedulerConstant.MACHINE_COLLECT_JOB_GROUP);
}
 
Example 27
Source Project: zkdoctor   Source File: SchedulerConfig.java    License: 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);
}
 
Example 28
Source Project: redis-manager   Source File: QuartzSchedule.java    License: 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 29
Source Project: spring-boot-starter-quartz   Source File: QuartzUtils.java    License: 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 30
@Bean(name="simpleJobDetail")
public JobDetailFactoryBean simpleJobDetail() {
	return QuartzUtils.createJobDetail(SimpleJob.class, SIMPLE_JOB_NAME, SIMPLE_JOB_GROUP, "Just a Simple Job", null);
}