当前位置: 首页>>代码示例>>Java>>正文


Java QuartzJobBean类代码示例

本文整理汇总了Java中org.springframework.scheduling.quartz.QuartzJobBean的典型用法代码示例。如果您正苦于以下问题:Java QuartzJobBean类的具体用法?Java QuartzJobBean怎么用?Java QuartzJobBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


QuartzJobBean类属于org.springframework.scheduling.quartz包,在下文中一共展示了QuartzJobBean类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createJob

import org.springframework.scheduling.quartz.QuartzJobBean; //导入依赖的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();
}
 
开发者ID:javabypatel,项目名称:spring-boot-quartz-demo,代码行数:30,代码来源:JobUtil.java

示例2: scheduleOneTimeJob

import org.springframework.scheduling.quartz.QuartzJobBean; //导入依赖的package包/类
/**
 * Schedule a job by jobName at given date.
 */
@Override
public boolean scheduleOneTimeJob(String jobName, Class<? extends QuartzJobBean> jobClass, Date date) {
	System.out.println("Request received to scheduleJob");

	String jobKey = jobName;
	String groupKey = "SampleGroup";	
	String triggerKey = jobName;		

	JobDetail jobDetail = JobUtil.createJob(jobClass, false, context, jobKey, groupKey);

	System.out.println("creating trigger for key :"+jobKey + " at date :"+date);
	Trigger cronTriggerBean = JobUtil.createSingleTrigger(triggerKey, date, SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW);
	//Trigger cronTriggerBean = JobUtil.createSingleTrigger(triggerKey, date, SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT);

	try {
		Scheduler scheduler = schedulerFactoryBean.getScheduler();
		Date dt = scheduler.scheduleJob(jobDetail, cronTriggerBean);
		System.out.println("Job with key jobKey :"+jobKey+ " and group :"+groupKey+ " scheduled successfully for date :"+dt);
		return true;
	} catch (SchedulerException e) {
		System.out.println("SchedulerException while scheduling job with key :"+jobKey + " message :"+e.getMessage());
		e.printStackTrace();
	}

	return false;
}
 
开发者ID:javabypatel,项目名称:spring-boot-quartz-demo,代码行数:30,代码来源:JobServiceImpl.java

示例3: scheduleCronJob

import org.springframework.scheduling.quartz.QuartzJobBean; //导入依赖的package包/类
/**
 * Schedule a job by jobName at given date.
 */
@Override
public boolean scheduleCronJob(String jobName, Class<? extends QuartzJobBean> jobClass, Date date, String cronExpression) {
	System.out.println("Request received to scheduleJob");

	String jobKey = jobName;
	String groupKey = "SampleGroup";	
	String triggerKey = jobName;		

	JobDetail jobDetail = JobUtil.createJob(jobClass, false, context, jobKey, groupKey);

	System.out.println("creating trigger for key :"+jobKey + " at date :"+date);
	Trigger cronTriggerBean = JobUtil.createCronTrigger(triggerKey, date, cronExpression, SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW);

	try {
		Scheduler scheduler = schedulerFactoryBean.getScheduler();
		Date dt = scheduler.scheduleJob(jobDetail, cronTriggerBean);
		System.out.println("Job with key jobKey :"+jobKey+ " and group :"+groupKey+ " scheduled successfully for date :"+dt);
		return true;
	} catch (SchedulerException e) {
		System.out.println("SchedulerException while scheduling job with key :"+jobKey + " message :"+e.getMessage());
		e.printStackTrace();
	}

	return false;
}
 
开发者ID:javabypatel,项目名称:spring-boot-quartz-demo,代码行数:29,代码来源:JobServiceImpl.java

示例4: isEligibleForPropertyPopulation

import org.springframework.scheduling.quartz.QuartzJobBean; //导入依赖的package包/类
/**
 * Return whether the given job object is eligible for having
 * its bean properties populated.
 * <p>The default implementation ignores {@link QuartzJobBean} instances,
 * which will inject bean properties themselves.
 * @param jobObject the job object to introspect
 * @see QuartzJobBean
 */
protected boolean isEligibleForPropertyPopulation(Object jobObject) {
	return (!(jobObject instanceof QuartzJobBean));
}
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:12,代码来源:YadaQuartzJobFactory.java

示例5: scheduleOneTimeJob

import org.springframework.scheduling.quartz.QuartzJobBean; //导入依赖的package包/类
boolean scheduleOneTimeJob(String jobName, Class<? extends QuartzJobBean> jobClass, Date date); 
开发者ID:javabypatel,项目名称:spring-boot-quartz-demo,代码行数:2,代码来源:JobService.java

示例6: scheduleCronJob

import org.springframework.scheduling.quartz.QuartzJobBean; //导入依赖的package包/类
boolean scheduleCronJob(String jobName, Class<? extends QuartzJobBean> jobClass, Date date, String cronExpression); 
开发者ID:javabypatel,项目名称:spring-boot-quartz-demo,代码行数:2,代码来源:JobService.java


注:本文中的org.springframework.scheduling.quartz.QuartzJobBean类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。