當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。