本文整理汇总了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);