本文整理匯總了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();
}
示例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;
}
示例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;
}
示例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));
}
示例5: scheduleOneTimeJob
import org.springframework.scheduling.quartz.QuartzJobBean; //導入依賴的package包/類
boolean scheduleOneTimeJob(String jobName, Class<? extends QuartzJobBean> jobClass, Date date);
示例6: scheduleCronJob
import org.springframework.scheduling.quartz.QuartzJobBean; //導入依賴的package包/類
boolean scheduleCronJob(String jobName, Class<? extends QuartzJobBean> jobClass, Date date, String cronExpression);